Skip to content

Instantly share code, notes, and snippets.

@delagreen-v2
Last active May 28, 2024 13:22
Show Gist options
  • Select an option

  • Save delagreen-v2/3214855b9246f8878360e6e7b0215f72 to your computer and use it in GitHub Desktop.

Select an option

Save delagreen-v2/3214855b9246f8878360e6e7b0215f72 to your computer and use it in GitHub Desktop.
is_empty_unicode
from fontTools.ttLib import TTFont
def is_empty_unicode(path_to_ttf, symbol):
font = TTFont(path_to_ttf)
cmap = font['cmap'].getBestCmap()
unicodes = [chr(k) for k in cmap.keys()]
if symbol in unicodes:
return True
else:
return False
print(is_empty_unicode(
'/home/astraadmin/Desktop/rep/drawing_text_recognition/new/tesseract-tutorial/fonts/gost_2.304_italic.ttf', '`'
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment