问题描述
如何将 .otf
字体文件转换为 .gif
图像,其中字体中的每个字形在gif中占据一个单帧?
我已经看过imagemagick用来将字形转换成png,
convert -background none -fill black -font font.otf -pointsize 300 label:Zz.png
这是可以扩展的吗?
还是需要使用不同的方法?
(另外请注意,上面的命令对我来说工作不正常,我使用的字体tangwar-annatar有一些字形,它们是由上面的命令)
我在一个mac上可以访问几乎所有的东西,只要它适合我,就可以接受任何语言的解决方案。
再次更新看到你的字体和人物似乎超出了预期的大小。我想所有你需要做的就是使用一个更大的画布:
#!/ bin / bash
{
为{a..z} {A..Z} {0..9}中的c;
convert xc:none [1000x1000] -background none -fill black -font tengwar.otf -pointsize 300 \
-gravity center -annotate 0$ cmiff: -
done
#做任何有问题的角色作为事后考虑,例如分号和感叹号
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
更新后的答案
code> -annotate ,如下所示。在这个例子中,我还添加了如何处理有问题的字符 - 你也可以在另一个例子中做同样的事情:
# !/ bin / bash
{
for {a..z} {A..Z} {0..9};
转换xc:none [350x350] -background none -fill black -font arial -pointsize 300 \
-gravity center -annotate 0$ cmiff: -
done
#做任何有问题的字符作为事后的想法,例如分号和感叹号
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
原始回答
您可以这样做:
#!/ bin / bash
for {a..z} {A..Z} { 0..9};做
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
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.
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
这篇关于将.otf字体转换为所有字形的.gif图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!