Reputation:
How can I convert a .otf
font file into a .gif
image, where each glyph within the font occupies a single frame in the gif?
I have seen imagemagick used to convert glyphs into pngs,
convert -background none -fill black -font font.otf -pointsize 300 label:"Z" z.png
Is this extendable for what I am after?
Or do I need to use a different method?
(Also note that the above command doesn't work properly for me, the font I am using, tangwar-annatar, has some glyphs that were cut off by the edges of the png generated by the above command)
I'm on a mac with access to pretty much everything, so would accept any solution in any language as long as it works for me.
Upvotes: 0
Views: 699
Reputation: 207385
Updated Again
Ok, I have seen your font and the characters seem to extend beyond the expected sizes. I think all you need to do is use a bigger canvas:
#!/bin/bash
{
for c in {a..z} {A..Z} {0..9}; do
convert xc:none[1000x1000] -background none -fill black -font tengwar.otf -pointsize 300 \
-gravity center -annotate 0 "$c" miff:-
done
# Do any problematic characters as an afterthought, e.g. semi-colon, and exclamation
convert xc:none[1000x1000] -background none -fill black -font tengwar.otf -pointsize 300 \
-gravity center -annotate 0 ";" miff:-
convert xc:none[1000x1000] -background none -fill black -font tengwar.otf -pointsize 300 \
-gravity center -annotate 0 "!" miff:-
} | convert -dispose background -delay 20 miff:- anim.gif
Updated Answer
You may get on better with -annotate
on a fixed background as below. I have also added how to deal with problematic characters in this example - you can do the same in the other example too:
#!/bin/bash
{
for c in {a..z} {A..Z} {0..9}; do
convert xc:none[350x350] -background none -fill black -font arial -pointsize 300 \
-gravity center -annotate 0 "$c" miff:-
done
# Do any problematic characters as an afterthought, e.g. semi-colon, and exclamation
convert xc:none[350x350] -background none -fill black -font arial -pointsize 300 \
-gravity center -annotate 0 ";" miff:-
convert xc:none[350x350] -background none -fill black -font arial -pointsize 300 \
-gravity center -annotate 0 "!" miff:-
} | convert -dispose background -delay 20 miff:- anim.gif
Original Answer
You can do something like this:
#!/bin/bash
for c in {a..z} {A..Z} {0..9}; do
convert -background none -fill black -font arial -pointsize 300 \
label:"$c" -gravity center -extent 350x350 miff:-
done | convert -dispose background -delay 80 miff:- anim.gif
Upvotes: 2