Get Supported Unicode Ranges from Font *.ttf file on Ubuntu
I have some fonts in 'ttf' format on my Ubuntu machine.
I want to know some metadata of those fonts, about which unicode ranges and which non-unicode codepages those font files are supporte.
How I can do it?
Added 1: Forgot to mention, that i want to get those information for several hundreds of fonts, so I need some kind of terminal utility, that can be automized
Solution 1:
fc-query
can show supported unicode character sets. I don't know of other codepages though.
For example, fc-query /usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf
on my Debian shows this:
…
charset:
0000: 00000000 ffffffff ffffffff 7fffffff 00000000 ffffffff ffffffff ffffffff
0001: ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff
0002: ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff 008873ff
…
It shows the supported character ranges, although it doesn't which block it belongs to (you have to know which range belongs to which block).
For example, the fourth column of 0000, which corresponds to U+0060 - U+007F, has a hex value of 7fffffff
. This has a bit value of 0111 1111 1111 1111 1111 1111 1111 1111
, where the right most bit is U+0060, and the left most is U+007F. This means that U+007F is not supported in this font.
You'd probably need to write a script that makes bitwise operations on the information provided by fc-query
.
P/S: My favorite go-to site for unicode information is FileFormat.Info
Solution 2:
I'd recommend FontForge. It is available in Ubuntu's package manager simply as fontforge
.
Solution 3:
Note for anyone finding this ..
fc-query isn't 100% reliable on the charset output.
For example Yogafont on dafont.com this shows an empty character set, though it definitely does have characters in it.
$ fc-query yogafont.TTF
Pattern has 20 elts (size 32)
family: "Yogafont"(s)
familylang: "en"(s)
style: "Regular"(s)
stylelang: "en"(s)
fullname: "Yogafont"(s)
fullnamelang: "en"(s)
slant: 0(i)(s)
weight: 80(i)(s)
width: 100(i)(s)
spacing: 100(i)(s)
foundry: "unknown"(s)
file: "yogafont.TTF"(s)
index: 0(i)(s)
outline: FcTrue(s)
scalable: FcTrue(s)
charset:
(s)
lang: (s)
fontversion: 0(i)(s)
fontformat: "TrueType"(s)
decorative: FcFalse(s)
Other fonts with drawings in them such as WW1 show a limited character set.
$ fc-query WW1-A___.TTF
Pattern has 19 elts (size 32)
family: "WW1 A"(s)
familylang: "en"(s)
style: "Regular"(s)
stylelang: "en"(s)
fullname: "WW1 A"(s)
fullnamelang: "en"(s)
slant: 0(i)(s)
weight: 80(i)(s)
width: 100(i)(s)
foundry: "unknown"(s)
file: "WW1-A___.TTF"(s)
index: 0(i)(s)
outline: FcTrue(s)
scalable: FcTrue(s)
charset:
0000: 00000000 00000001 00000000 0001fffe 00000000 00000000 00000000 00000000
(s)
lang: (s)
fontversion: 65536(i)(s)
fontformat: "TrueType"(s)
decorative: FcFalse(s)