check for None
This commit is contained in:
parent
4113343e79
commit
7b4e65cbb7
2 changed files with 12 additions and 12 deletions
|
@ -163,7 +163,7 @@ class Font:
|
|||
def register_font(font_name, face_name, glyphs_in_fontfile, filepath):
|
||||
if not fonts.keys().__contains__(font_name):
|
||||
fonts[font_name] = Font({})
|
||||
if fonts[font_name].faces.get(face_name) == None:
|
||||
if fonts[font_name].faces.get(face_name) is None:
|
||||
fonts[font_name].faces[face_name] = FontFace({})
|
||||
fonts[font_name].faces[face_name].glyphs_in_fontfile = glyphs_in_fontfile
|
||||
else:
|
||||
|
@ -193,9 +193,9 @@ def add_glyph(font_name, face_name, glyph_id, glyph_object):
|
|||
|
||||
if not fonts.keys().__contains__(font_name):
|
||||
fonts[font_name] = Font({})
|
||||
if fonts[font_name].faces.get(face_name) == None:
|
||||
if fonts[font_name].faces.get(face_name) is None:
|
||||
fonts[font_name].faces[face_name] = FontFace({})
|
||||
if fonts[font_name].faces[face_name].glyphs.get(glyph_id) == None:
|
||||
if fonts[font_name].faces[face_name].glyphs.get(glyph_id) is None:
|
||||
fonts[font_name].faces[face_name].glyphs[glyph_id] = []
|
||||
fonts[font_name].faces[face_name].glyphs.get(glyph_id).append(glyph_object)
|
||||
|
||||
|
@ -224,13 +224,13 @@ def get_glyph(font_name, face_name, glyph_id, alternate=0):
|
|||
return None
|
||||
|
||||
face = fonts[font_name].faces.get(face_name)
|
||||
if face == None:
|
||||
if face is None:
|
||||
# print(f"ABC3D::get_glyph: font({font_name}) face({face_name}) not found")
|
||||
# print(fonts[font_name].faces.keys())
|
||||
return None
|
||||
|
||||
glyphs_for_id = face.glyphs.get(glyph_id)
|
||||
if glyphs_for_id == None or len(glyphs_for_id) <= alternate:
|
||||
if glyphs_for_id is None or len(glyphs_for_id) <= alternate:
|
||||
# print(f"ABC3D::get_glyph: font({font_name}) face({face_name}) glyph({glyph_id})[{alternate}] not found")
|
||||
if glyph_id not in fonts[font_name].faces[face_name].missing_glyphs:
|
||||
fonts[font_name].faces[face_name].missing_glyphs.append(glyph_id)
|
||||
|
@ -243,7 +243,7 @@ def test_glyphs_availability(font_name, face_name, text):
|
|||
# maybe there is NOTHING yet
|
||||
if (
|
||||
not fonts.keys().__contains__(font_name)
|
||||
or fonts[font_name].faces.get(face_name) == None
|
||||
or fonts[font_name].faces.get(face_name) is None
|
||||
):
|
||||
return "", "", text # <loaded>, <missing>, <maybe>
|
||||
|
||||
|
@ -286,7 +286,7 @@ MISSING_FACE = 1
|
|||
def test_availability(font_name, face_name, text):
|
||||
if not fonts.keys().__contains__(font_name):
|
||||
return MISSING_FONT
|
||||
if fonts[font_name].faces.get(face_name) == None:
|
||||
if fonts[font_name].faces.get(face_name) is None:
|
||||
return MISSING_FACE
|
||||
loaded, missing, maybe, filepaths = test_glyphs_availability(
|
||||
font_name, face_name, text
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue