![如何从字体文件中获取字体名称?](https://linux22.com/image/131113/%E5%A6%82%E4%BD%95%E4%BB%8E%E5%AD%97%E4%BD%93%E6%96%87%E4%BB%B6%E4%B8%AD%E8%8E%B7%E5%8F%96%E5%AD%97%E4%BD%93%E5%90%8D%E7%A7%B0%EF%BC%9F%20.png)
假设我有一个文件“foo_whatever.ttf”是否有命令行工具可以从文件中获取实际的字体名称?
下面的链接确实包含答案,但我没有在搜索结果中找到它,特别是“/fonts name”。回想起来,我本可以使用更一般的搜索。 mod对此有何政策?
事实上,这是我找到的链接,它引导我找到了正确的答案(我在那里了解到了其余的fc-
命令:
答案1
您可以fc-scan
从 fontconfig 包中使用:
[root@centos7 ~]# fc-scan /usr/share/fonts/liberation/LiberationSerif-Regular.ttf
Pattern has 22 elts (size 32)
family: "Liberation Serif"(s)
familylang: "en"(s)
style: "Regular"(s)
stylelang: "en"(s)
fullname: "Liberation Serif"(s)
fullnamelang: "en"(s)
slant: 0(i)(s)
weight: 80(i)(s)
width: 100(i)(s)
foundry: "unknown"(s)
file: "/usr/share/fonts/liberation/LiberationSerif-Regular.ttf"(s)
index: 0(i)(s)
outline: True(s)
scalable: True(s)
charset:
0000: 00000000 ffffffff ffffffff 7fffffff 00000000 ffffffff ffffffff ffffffff
0001: ffffffff ffffffff ffffffff ffffffff 00040000 00000000 00000000 fc000000
0002: 0f000000 00000000 00000000 00000000 00000000 00000000 3f0002c0 00000000
0003: 00000000 00000000 00000000 40000000 ffffd7f0 fffffffb 00007fff 00000000
0004: ffffffff ffffffff ffffffff 00000000 00030000 00000000 00000000 00000000
001e: 00000000 00000000 00000000 00000000 0000003f 00000000 00000000 000c0000
0020: 7fbb0000 560d0047 00000010 80000000 00000000 00001098 00000000 00000000
0021: 00480020 00004044 78000000 00000000 003f0000 00000100 00000000 00000000
0022: c6268044 00000a00 00000100 00000033 00000000 00000000 00000000 00000000
0023: 00010004 00000003 00000000 00000000 00000000 00000000 00000000 00000000
0025: 11111005 10101010 ffff0000 00001fff 000f1111 14041c03 03008c10 00000040
0026: 00000000 1c000000 00000005 00000c69 00000000 00000000 00000000 00000000
00f0: 00000036 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00fb: 00000006 00000000 00000000 00000000 00000000 00000000 00000000 00000000
(s)
lang: aa|af|av|ay|be|bg|bi|br|bs|ca|ce|ch|co|cs|cy|da|de|el|en|eo|es|et|eu|fi|fj|fo|fr|fur|fy|gd|gl|gv|ho|hr|hu|ia|id|ie|ik|io|is|it|ki|kl|kum|la|lb|lez|lt|lv|mg|mh|mk|mo|mt|nb|nds|nl|nn|no|nr|nso|ny|oc|om|os|pl|pt|rm|ro|ru|se|sel|sk|sl|sma|smj|smn|so|sq|sr|ss|st|sv|sw|tk|tl|tn|tr|ts|uk|uz|vo|vot|wa|wen|wo|xh|yap|zu|an|crh|csb|fil|hsb|ht|jv|kj|ku-tr|kwm|lg|li|ms|na|ng|pap-an|pap-aw|rn|rw|sc|sg|sn|su|za(s)
fontversion: 70123(i)(s)
capability: "otlayout:DFLT otlayout:cyrl otlayout:grek otlayout:latn"(s)
fontformat: "TrueType"(s)
decorative: False(s)
hash: "sha256:2829b7333ab4697f7b2d68855fca83f1be92121db16dd0bfcf3ae2b416839b05"(s)
postscriptname: "LiberationSerif"(s)
之后,您可以从其输出中 grep forfullname
或postscriptname
:
fc-scan <font-name> | grep fullname