mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
PDF Output: Fix error when input document contains multiple instances of a font some with vertical metric and some without. Fixes #2023041 [Private bug](https://bugs.launchpad.net/calibre/+bug/2023041)
This commit is contained in:
parent
f2b8bc9dd3
commit
2c89d50fb8
@ -50,11 +50,17 @@ def merge_truetype_fonts_for_pdf(fonts, log=None):
|
||||
log(f'Size mismatch for glyph id: {glyph_id} prev_sz: {len(prev_glyph_data)} sz: {sz}')
|
||||
if hhea is not None:
|
||||
m = hhea.metrics_for(glyph_id)
|
||||
if m != hmetrics_map[glyph_id]:
|
||||
old_val = hmetrics_map.get(glyph_id)
|
||||
if old_val is None:
|
||||
hmetrics_map[glyph_id] = m
|
||||
elif m != old_val:
|
||||
log(f'Metrics mismatch for glyph id: {glyph_id} prev: {hmetrics_map[glyph_id]} cur: {m}')
|
||||
if vhea is not None:
|
||||
m = vhea.metrics_for(glyph_id)
|
||||
if m != vmetrics_map[glyph_id]:
|
||||
old_val = vmetrics_map.get(glyph_id)
|
||||
if old_val is None:
|
||||
vmetrics_map[glyph_id] = m
|
||||
elif m != vmetrics_map[glyph_id]:
|
||||
log(f'Metrics mismatch for glyph id: {glyph_id} prev: {vmetrics_map[glyph_id]} cur: {m}')
|
||||
|
||||
glyf = ans[b'glyf']
|
||||
@ -71,9 +77,9 @@ def merge_truetype_fonts_for_pdf(fonts, log=None):
|
||||
head.update()
|
||||
maxp.num_glyphs = len(loca.offset_map) - 1
|
||||
maxp.update()
|
||||
if hmetrics_map:
|
||||
if hmetrics_map and b'hhea' in ans:
|
||||
ans[b'hhea'].update(hmetrics_map, ans[b'hmtx'])
|
||||
if vmetrics_map:
|
||||
if vmetrics_map and b'vhea' in ans:
|
||||
ans[b'vhea'].update(vmetrics_map, ans[b'vmtx'])
|
||||
|
||||
for name in 'hdmx GPOS GSUB'.split():
|
||||
|
Loading…
x
Reference in New Issue
Block a user