From be785b1143fd8ee6a07313b4c3da1e7c7e2589fe Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 2 Sep 2016 13:12:03 +0530 Subject: [PATCH] PDF Output: Fix OpenType fonts with CFF font data not embeddable on windows Qt now uses DirectWrite on windows, which means CFF fonts work --- .../ebooks/conversion/plugins/pdf_output.py | 23 ++----------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/src/calibre/ebooks/conversion/plugins/pdf_output.py b/src/calibre/ebooks/conversion/plugins/pdf_output.py index c59ebc9f7a..c6ead0502e 100644 --- a/src/calibre/ebooks/conversion/plugins/pdf_output.py +++ b/src/calibre/ebooks/conversion/plugins/pdf_output.py @@ -10,7 +10,7 @@ Convert OEB ebook format to PDF. import glob, os -from calibre.constants import iswindows, islinux +from calibre.constants import islinux from calibre.customize.conversion import (OutputFormatPlugin, OptionRecommendation) from calibre.ptempfile import TemporaryDirectory @@ -157,21 +157,14 @@ class PDFOutput(OutputFormatPlugin): self.cover_data = item.data def handle_embedded_fonts(self): - ''' On windows, Qt uses GDI which does not support OpenType - (CFF) fonts, so we need to nuke references to OpenType - fonts. Qt's directwrite text backend is not mature. - Also make sure all fonts are embeddable. ''' + ''' Make sure all fonts are embeddable. ''' from calibre.ebooks.oeb.base import urlnormalize from calibre.utils.fonts.utils import remove_embed_restriction - from PyQt5.Qt import QByteArray, QRawFont - font_warnings = set() processed = set() - is_cff = {} for item in list(self.oeb.manifest): if not hasattr(item.data, 'cssRules'): continue - remove = set() for i, rule in enumerate(item.data.cssRules): if rule.type == rule.FONT_FACE_RULE: try: @@ -195,18 +188,6 @@ class PDFOutput(OutputFormatPlugin): ff.data = nraw self.oeb.container.write(path, nraw) - if iswindows: - if path not in is_cff: - f = QRawFont(QByteArray(nraw), 12) - is_cff[path] = f.isValid() and len(f.fontTable('head')) == 0 - if is_cff[path]: - if path not in font_warnings: - font_warnings.add(path) - self.log.warn('CFF OpenType fonts are not supported on windows, ignoring: %s' % path) - remove.add(i) - for i in sorted(remove, reverse=True): - item.data.cssRules.pop(i) - def convert_text(self, oeb_book): from calibre.ebooks.metadata.opf2 import OPF if self.opts.old_pdf_engine: