From 7489f1a7930cbc6c86164e303d2dbf257502f90e Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 22 Nov 2015 17:21:16 +0530 Subject: [PATCH] PDF Output: Handle input documents with fonts that do not have either postscript or full name information. Fixes #1518678 [ebook-convert failing on file with embedded font](https://bugs.launchpad.net/calibre/+bug/1518678) --- src/calibre/utils/fonts/sfnt/metrics.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/calibre/utils/fonts/sfnt/metrics.py b/src/calibre/utils/fonts/sfnt/metrics.py index b5774102e3..088ec262fd 100644 --- a/src/calibre/utils/fonts/sfnt/metrics.py +++ b/src/calibre/utils/fonts/sfnt/metrics.py @@ -61,7 +61,10 @@ class FontMetrics(object): def postscript_name(self): if 'postscript_name' in self.names: return self.names['postscript_name'].replace(' ', '-') - return self.names['full_name'].replace(' ', '-') + try: + return self.names['full_name'].replace(' ', '-') + except KeyError: + return self.names['family_name'].replace(' ', '-') def underline_thickness(self, pixel_size=12.0): 'Thickness for lines (in pixels) at the specified size'