From 0b40e8a8642b84591be2021f2316dbcf71919081 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 11 Jan 2013 12:39:20 +0530 Subject: [PATCH] Conversion: When subsetting fonts, handle multiple @font-face rules referring to the same physical font --- src/calibre/ebooks/oeb/transforms/subset.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/calibre/ebooks/oeb/transforms/subset.py b/src/calibre/ebooks/oeb/transforms/subset.py index f85f786547..0cca73fcce 100644 --- a/src/calibre/ebooks/oeb/transforms/subset.py +++ b/src/calibre/ebooks/oeb/transforms/subset.py @@ -36,7 +36,15 @@ class SubsetFonts(object): self.oeb.manifest.remove(font['item']) font['rule'].parentStyleSheet.deleteRule(font['rule']) + fonts = {} for font in self.embedded_fonts: + item, chars = font['item'], font['chars'] + if item.href in fonts: + fonts[item.href]['chars'] |= chars + else: + fonts[item.href] = font + + for font in fonts.itervalues(): if not font['chars']: self.log('The font %s is unused. Removing it.'%font['src']) remove(font)