Check glyph definition sizes are identical when merging ttf fonts

This commit is contained in:
Kovid Goyal 2019-09-07 10:25:18 +05:30
parent 411cd21e82
commit 7366d8f57a
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -17,10 +17,14 @@ def merge_truetype_fonts_for_pdf(*fonts):
glyf = font[b'glyf']
loca.load_offsets(font[b'head'], font[b'maxp'])
for glyph_id in range(len(loca.offset_map) - 1):
if glyph_id not in all_glyphs:
offset, sz = loca.glyph_location(glyph_id)
if sz > 0:
offset, sz = loca.glyph_location(glyph_id)
if sz > 0:
prev_glyph_data = all_glyphs.get(glyph_id)
if prev_glyph_data is None:
all_glyphs[glyph_id] = glyf.glyph_data(offset, sz, as_raw=True)
else:
if sz != len(prev_glyph_data):
raise Exception('Size mismatch for glyph id: {}'.format(glyph_id))
glyf = ans[b'glyf']
head = ans[b'head']