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']