Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_unicode_by_name(name):
glyph = GlyphData.by_name.get(name, None) \
or GlyphData.by_prodname.get(name, None)
if glyph is not None and glyph.unicode is not None:
return glyph.unicode
match = PURE_UNI_CHR.match(name)
if match is not None:
return int(match.groups()[0], base=16)
return None
def get_name_by_name(search_name, production_name=False):
"""
Use this if you don't know what exact type your name is. E.g. when
the names in your source are mixes friendly names and production names.
Returns None if GlyphsData.xml doesn't contain search_name.
"""
entry = (None, None)
glyph = GlyphData.by_name.get(search_name, None) \
or GlyphData.by_prodname.get(search_name, None)
if glyph is not None:
entry = (glyph.name, glyph.production_name)
return entry[1] if production_name else entry[0]
def get_unicode_by_name(name):
glyph = GlyphData.by_name.get(name, None) \
or GlyphData.by_prodname.get(name, None)
if glyph is not None and glyph.unicode is not None:
return glyph.unicode
match = PURE_UNI_CHR.match(name)
if match is not None:
return int(match.groups()[0], base=16)
return None
def get_name_by_unicode(search_codepoint, production_name=False):
"""
Returns None if GlyphsData.xml doesn't contain search_codepoint.
"""
entry = (None, None)
glyph = GlyphData.by_unicode.get(search_codepoint, None)
if glyph is not None:
entry = (glyph.name, glyph.production_name)
return entry[1] if production_name else entry[0]