-
-
Save bendmorris/7170209 to your computer and use it in GitHub Desktop.
#!/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 |
for whom it may concern...
newsize=$(python -c "x = '$size'; print('x'.join([str(int(i)*10) for i in x.split('x')]))")
use python3 instead of python up there
I also tried to make this work on Ubuntu 20.04 but without success so far. On my 18.04 Ubuntu with FontForge from 2017 it works without any problems. Btw using python3 instead did not have any effect for me.
I tried to use an older potrace version --> no difference
Currently Im trying to compile the fontforge version from 2017 since I cant find a release from that time
If anyone finds a solution please post it here, thx!
I might have a lead on whats happening here. if it doesn't work even if you switched to python3, the whole sequence probably didn't happen at all, because if you have been using python 2, the program would fail on the print() statement since it's illegal syntax
did you see any outputs on the console?
I might have a lead on whats happening here. if it doesn't work even if you switched to python3, the whole sequence probably didn't happen at all, because if you have been using python 2, the program would fail on the print() statement since it's illegal syntax
did you see any outputs on the console?
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:
sudo apt-get update
sudo apt-get install potrace imagemagick fontforge
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)
sudo nano /usr/local/bin/potrace
(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
#!/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=$(python3 -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 - - | /usr/bin/potrace -a 0 $array
make the file executable
sudo chmod 0755 /usr/local/bin/potrace
Then start FontForge, import your bdf as background and use the autotrace on the elements you like :)
I've only spent a week or so in Python.. I wonder why it's saying the
i
being passed intoint(i)
is empty?