findUnicodeFont
py
Python
#copy form https://superuser.com/questions/876572/how-do-i-find-out-which-font-contains-a-certain-special-character
import unicodedata
import os
fonts = []
for root,dirs,files in os.walk("/usr/share/fonts/"):
for file in files:
if file.endswith(".ttf"): fonts.append(os.path.join(root,file))
if file.endswith(".otf"): fonts.append(os.path.join(root,file))
for root,dirs,files in os.walk("/home/charles/.local/share/fonts/"):
for file in files:
if file.endswith(".ttf"): fonts.append(os.path.join(root,file))
if file.endswith(".otf"): fonts.append(os.path.join(root,file))
from fontTools.ttLib import TTFont
def char_in_font(unicode_char, font):
for cmap in font['cmap'].tables:
if cmap.isUnicode():
if ord(unicode_char) in cmap.cmap:
return True
return False
def test(char):
for fontpath in fonts:
font = TTFont(fontpath) # specify the path to the font in question
if char_in_font(char, font):
try:
print(char + " " + unicodedata.name(char) + " in " + fontpath)
except ValueError as ve:
print(char + " in " + fontpath)
test(u"●")
test(u"\u1F63A")
test(u"\u1F408")
test(u"")
test(u"")