Last active
August 1, 2024 12:23
-
-
Save bendmorris/7170209 to your computer and use it in GitHub Desktop.
Potrace script designed for making FontForge pixel fonts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# To use, move the potrace binary to potrace-bin, then place this script | |
# somewhere on the path so that it'll be found by fontforge. | |
# After autotracing, you'll need to apply the following transformation: | |
# scale uniform 10%, using glyph origin as the origin | |
# get the last parameter passed by fontforge - the name of the temp img file | |
for last; do true; done | |
# get all of the other parameters | |
length=$(($#-1)) | |
array=${@:1:$length} | |
# get the size of the passed image | |
size=$(identify $last | grep -Po "[0-9]+x[0-9]+" | head -1) | |
# multiply that size by 10 | |
newsize=$(python -c "x = '$size'; print('x'.join([str(int(i)*10) for i in x.split('x')]))") | |
# scale up 10x and then use potrace to trace the pixelated outline | |
cat $last | mkbitmap -s 1 | convert -scale $newsize - - | potrace-bin -a 0 $array |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I just tried it again with a fresh installation and now it just works.. my god that have been 4 hours now...Thanks a lot for your reply :)
For anyone who is (after all this time) still interested in getting this to work, just follow these simple steps for a fresh installed Ubuntu 20.04:
Python 3 is already preinstalled, so nothing to be done there.
Then, create a file called
potrace
in your /usr/local/bin (leave the original potrace binary as it is)(or any other editor of your choice)
paste the following shell script there (its the same as above just with python3 and with an explicite call of the potrace binary in the /usr/bin folder) and save it
make the file executable
Then start FontForge, import your bdf as background and use the autotrace on the elements you like :)