From 2207a86ea736d6f1d9f61a51b14e0d84e11e725f Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 7 Oct 2019 06:41:14 +0530 Subject: [PATCH] Better error message when there is a glyph mismatch --- src/calibre/utils/fonts/sfnt/merge.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/calibre/utils/fonts/sfnt/merge.py b/src/calibre/utils/fonts/sfnt/merge.py index 8c73d576ea..e36a96909f 100644 --- a/src/calibre/utils/fonts/sfnt/merge.py +++ b/src/calibre/utils/fonts/sfnt/merge.py @@ -8,6 +8,10 @@ from collections import OrderedDict from functools import partial +class GlyphSizeMismatch(ValueError): + pass + + def merge_truetype_fonts_for_pdf(*fonts): # only merges the glyf and loca tables, ignoring all other tables all_glyphs = {} @@ -24,7 +28,7 @@ def merge_truetype_fonts_for_pdf(*fonts): 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)) + raise GlyphSizeMismatch('Size mismatch for glyph id: {} prev_sz: {} sz: {}'.format(glyph_id, len(prev_glyph_data), sz)) glyf = ans[b'glyf'] head = ans[b'head']