improvement
expose alternate reuse variables
This commit is contained in:
parent
adc5ad8ea6
commit
459bf739dd
1 changed files with 9 additions and 8 deletions
|
@ -34,7 +34,6 @@ name_to_glyph_d = {
|
||||||
"space": " ",
|
"space": " ",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class FontFace:
|
class FontFace:
|
||||||
"""FontFace is a class holding glyphs
|
"""FontFace is a class holding glyphs
|
||||||
|
|
||||||
|
@ -84,7 +83,7 @@ def add_glyph(font_name, face_name, glyph_id, glyph_object):
|
||||||
fonts[font_name].faces[face_name].glyphs.get(glyph_id).append(glyph_object)
|
fonts[font_name].faces[face_name].glyphs.get(glyph_id).append(glyph_object)
|
||||||
|
|
||||||
|
|
||||||
def get_glyph(font_name, face_name, glyph_id):
|
def get_glyph(font_name, face_name, glyph_id, alternate=0):
|
||||||
""" add_glyph adds a glyph to a FontFace
|
""" add_glyph adds a glyph to a FontFace
|
||||||
it creates the :class:`Font` and :class:`FontFace` if it does not exist yet
|
it creates the :class:`Font` and :class:`FontFace` if it does not exist yet
|
||||||
|
|
||||||
|
@ -104,16 +103,18 @@ def get_glyph(font_name, face_name, glyph_id):
|
||||||
print(fonts.keys())
|
print(fonts.keys())
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if fonts[font_name].faces.get(face_name) == None:
|
face = fonts[font_name].faces.get(face_name)
|
||||||
print(f"FONT3D::get_glyph: font face({face_name}) not found")
|
if face == None:
|
||||||
|
print(f"FONT3D::get_glyph: font({font_name}) face({face_name}) not found")
|
||||||
print(fonts[font_name].faces.keys())
|
print(fonts[font_name].faces.keys())
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if fonts[font_name].faces[face_name].glyphs.get(glyph_id) == None:
|
glyphs_for_id = face.glyphs.get(glyph_id)
|
||||||
print(f"FONT3D::get_glyph: glyph id({glyph_id}) not found")
|
if glyphs_for_id == None or len(glyphs_for_id) <= alternate:
|
||||||
|
print(f"FONT3D::get_glyph: font({font_name}) face({face_name}) glyph({glyph_id})[{alternate}] not found")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
return fonts[font_name].faces[face_name].glyphs.get(glyph_id)[0]
|
return fonts[font_name].faces[face_name].glyphs.get(glyph_id)[alternate]
|
||||||
|
|
||||||
def get_loaded_fonts():
|
def get_loaded_fonts():
|
||||||
return fonts.keys()
|
return fonts.keys()
|
||||||
|
|
Loading…
Reference in a new issue