Created
January 22, 2021 03:27
-
-
Save frankrolf/10cafcbfcea55ab8aed8e24c20e0532f to your computer and use it in GitHub Desktop.
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
''' | |
for https://github.com/adobe-fonts/source-code-pro/issues/247 | |
check character support requests against code points present in font | |
''' | |
import sys | |
import unicodedata | |
from fontTools import ttLib | |
def get_cmap(font_path): | |
try: | |
font = ttLib.TTFont(font_path) | |
except ttLib.TTLibError: | |
return False | |
char_map = font['cmap'].getBestCmap() | |
return char_map.keys() | |
requests = { | |
'Braille Patterns': range(0x2800, 0x28FF + 1), | |
'Geometric Shapes': range(0x25A0, 0x25FF + 1), | |
'Box Drawing and Block Elements': range(0x2500, 0x259F + 1), | |
} | |
cmap = get_cmap(sys.argv[-1]) | |
for u_range, cp_range in requests.items(): | |
print(f'## {u_range}\n') | |
print('| code point | character | name | supported |') | |
print('| --- | --- | --- | --- | ') | |
for cp in cp_range: | |
char = chr(cp) | |
print('|', end=' ') | |
print('U+{:04X}'.format(ord(char)), end=' | ') | |
print(char, end=' | ') | |
print(unicodedata.name(char), end=' | ') | |
if (ord(char) in cmap): | |
print('✔', end=' | ') | |
else: | |
print('✘', end=' | ') | |
print() | |
print() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment