将 .otf 字体转换为所有字形的 .gif 图像
Convert .otf font into a .gif image of all glyphs
如何将 .otf
字体文件转换为 .gif
图像,其中字体中的每个字形在 gif 中占据一个帧?
我见过 imagemagick 用于将字形转换为 png,
convert -background none -fill black -font font.otf -pointsize 300 label:"Z" z.png
这是否可以扩展我所追求的?
或者我需要使用其他方法吗?
(另请注意,上述命令对我来说无法正常工作,我使用的字体 tangwar-annatar 有一些字形被上述命令生成的 png 的边缘切断)
我在 mac 上可以访问几乎所有内容,所以我会接受任何语言的任何解决方案,只要它对我有用。
再次更新
好的,我看到了你的字体,字符似乎超出了预期的大小。我认为您需要做的就是使用更大的 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
更新答案
在固定背景下 -annotate
您可能会相处得更好,如下所示。我还在这个例子中添加了如何处理有问题的字符——你也可以在另一个例子中做同样的事情:
#!/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
原答案
你可以这样做:
#!/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
图像,其中字体中的每个字形在 gif 中占据一个帧?
我见过 imagemagick 用于将字形转换为 png,
convert -background none -fill black -font font.otf -pointsize 300 label:"Z" z.png
这是否可以扩展我所追求的?
或者我需要使用其他方法吗?
(另请注意,上述命令对我来说无法正常工作,我使用的字体 tangwar-annatar 有一些字形被上述命令生成的 png 的边缘切断)
我在 mac 上可以访问几乎所有内容,所以我会接受任何语言的任何解决方案,只要它对我有用。
再次更新
好的,我看到了你的字体,字符似乎超出了预期的大小。我认为您需要做的就是使用更大的 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
更新答案
在固定背景下 -annotate
您可能会相处得更好,如下所示。我还在这个例子中添加了如何处理有问题的字符——你也可以在另一个例子中做同样的事情:
#!/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
原答案
你可以这样做:
#!/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