Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Unicode hex value checks in cmap tables (fonts)
tt = TTFont(fontpath)
cmap = tt.getBestCmap()
# now the integers are keys in the cmap object and can be used to compare against hexadecimal values for presence in a font
test_list = (hex1, hex2, hex3,...)
# how to split hex ranges to individual hex codes
# e.g., 0x0020-0x0028
for x in range(0x0020,0x0028):
print(hex(x))
for codepoint in test_list:
if int(codepoint) in cmap:
print(True)
else:
print(False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.