Merge pull request #3300 from jepler/count-missing-chars

gen_display_resources: report missing character count, if any
This commit is contained in:
Scott Shawcroft 2020-08-19 10:19:46 -07:00 committed by GitHub
commit 837abd6da0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -58,15 +58,20 @@ filtered_characters = all_characters
# Try to pre-load all of the glyphs. Misses will still be slow later.
f.load_glyphs(set(ord(c) for c in all_characters))
missing = 0
# Get each glyph.
for c in set(all_characters):
if ord(c) not in f._glyphs:
missing += 1
filtered_characters = filtered_characters.replace(c, "")
continue
g = f.get_glyph(ord(c))
if g["shift"][1] != 0:
raise RuntimeError("y shift")
if missing > 0:
print("Font missing", missing, "characters", file=sys.stderr)
x, y, dx, dy = f.get_bounding_box()
tile_x, tile_y = x - dx, y - dy
total_bits = tile_x * len(all_characters)