Fonts

如何從字型檔中獲取字型名稱?

  • April 9, 2018

假設我有一個文件“foo_whatever.ttf”是否有命令行工具可以從文件中獲取實際的字型名稱?


下面的連結確實包含答案,但我沒有在我的搜尋結果中找到它,特別是“/fonts name”。回想起來,我本可以使用更一般的搜尋。什麼是mod政策?

是否有可以分析字型檔的 unix 命令行工具?

這實際上是我發現的連結,它引導我找到了正確的答案(在那裡我了解到了其餘的fc-命令:

如何獲取字型的真實名稱?

您可以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)

之後,您可以從其輸出中 grepfullnamepostscriptname

引用自:https://unix.stackexchange.com/questions/436541