Skip to content

Instantly share code, notes, and snippets.

@amake
Created September 15, 2016 08:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amake/97b9ecff3fbaaa1dd855e6de80ce4f92 to your computer and use it in GitHub Desktop.
Save amake/97b9ecff3fbaaa1dd855e6de80ce4f92 to your computer and use it in GitHub Desktop.
Dump Android supported glyphs
'''
Call this with TrueType font filename arguments to output a list of
all Unicode characters covered by all fonts, e.g.
list_ttf_chars.py $ANDROID_HOME/platforms/android-XY/data/fonts/*.ttf
Requires FontTools: https://pypi.python.org/pypi/FontTools
'''
import sys
from fontTools.ttLib import TTFont
from fontTools.unicode import Unicode
chars = {}
for f in sys.argv[1:]:
for table in TTFont(f)['cmap'].tables:
chars.update(table.cmap)
print('\n'.join(['U+%06x %s' % (c, desc)
for c, desc in sorted(chars.items())]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment