Created
November 7, 2019 19:01
-
-
Save chrissimpkins/157762f6bed4fe728e538b8e1eb0aefd to your computer and use it in GitHub Desktop.
Unicode hex value checks in cmap tables (fonts)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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