[feature] unload glyphs
This commit is contained in:
parent
9423659153
commit
2dcd4e7a2c
3 changed files with 552 additions and 280 deletions
|
@ -1,6 +1,5 @@
|
|||
from typing import Dict
|
||||
from pathlib import Path
|
||||
from typing import NamedTuple
|
||||
from typing import Dict, NamedTuple
|
||||
|
||||
# convenience dictionary for translating names to glyph ids
|
||||
# note: overwritten/extended by the content of "glypNamesToUnicode.txt"
|
||||
|
@ -161,7 +160,6 @@ class Font:
|
|||
self.faces = faces
|
||||
|
||||
|
||||
|
||||
def register_font(font_name, face_name, glyphs_in_fontfile, filepath):
|
||||
if not fonts.keys().__contains__(font_name):
|
||||
fonts[font_name] = Font({})
|
||||
|
@ -250,7 +248,10 @@ def get_glyphs(font_name, face_name, glyph_id):
|
|||
face = get_font_face(font_name, face_name)
|
||||
if face is None:
|
||||
print(f"ABC3D::get_glyph: font({font_name}) face({face_name}) not found")
|
||||
print(fonts[font_name].faces.keys())
|
||||
try:
|
||||
print(fonts[font_name].faces.keys())
|
||||
except:
|
||||
print(fonts.keys())
|
||||
return []
|
||||
|
||||
glyphs_for_id = face.glyphs.get(glyph_id)
|
||||
|
@ -291,6 +292,19 @@ def get_glyph(font_name, face_name, glyph_id, alternate=0):
|
|||
return glyphs[alternate]
|
||||
|
||||
|
||||
def unloaded_glyph(font_name, face_name, glyph_id):
|
||||
face = get_font_face(font_name, face_name)
|
||||
if face is None:
|
||||
print(f"ABC3D::get_glyph: font({font_name}) face({face_name}) not found")
|
||||
return
|
||||
while True:
|
||||
try:
|
||||
fonts[font_name].faces[face_name].loaded_glyphs.remove(glyph_id)
|
||||
del fonts[font_name].faces[face_name].glyphs[glyph_id]
|
||||
except ValueError:
|
||||
break
|
||||
|
||||
|
||||
class GlyphsAvailability(NamedTuple):
|
||||
loaded: str
|
||||
missing: str
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue