mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Polishing books: Ignore unsupported fonts instead of erroring out on them. Fixes #1132085 (Private bug)
This commit is contained in:
parent
67cbdb9ad1
commit
626993f6bc
@ -9,10 +9,11 @@ __docformat__ = 'restructuredtext en'
|
|||||||
|
|
||||||
import os, sys
|
import os, sys
|
||||||
|
|
||||||
from calibre import prints
|
from calibre import prints, as_unicode
|
||||||
from calibre.ebooks.oeb.base import OEB_STYLES, OEB_DOCS, XPath
|
from calibre.ebooks.oeb.base import OEB_STYLES, OEB_DOCS, XPath
|
||||||
from calibre.ebooks.oeb.polish.container import OEB_FONTS
|
from calibre.ebooks.oeb.polish.container import OEB_FONTS
|
||||||
from calibre.utils.fonts.sfnt.subset import subset
|
from calibre.utils.fonts.sfnt.subset import subset
|
||||||
|
from calibre.utils.fonts.sfnt.errors import UnsupportedFont
|
||||||
from calibre.utils.fonts.utils import get_font_names
|
from calibre.utils.fonts.utils import get_font_names
|
||||||
|
|
||||||
def remove_font_face_rules(container, sheet, remove_names, base):
|
def remove_font_face_rules(container, sheet, remove_names, base):
|
||||||
@ -46,9 +47,16 @@ def subset_all_fonts(container, font_stats, report):
|
|||||||
raw = f.read()
|
raw = f.read()
|
||||||
font_name = get_font_names(raw)[-1]
|
font_name = get_font_names(raw)[-1]
|
||||||
warnings = []
|
warnings = []
|
||||||
container.log('Subsetting font: %s'%font_name)
|
container.log('Subsetting font: %s'%(font_name or name))
|
||||||
nraw, old_sizes, new_sizes = subset(raw, chars,
|
try:
|
||||||
|
nraw, old_sizes, new_sizes = subset(raw, chars,
|
||||||
warnings=warnings)
|
warnings=warnings)
|
||||||
|
except UnsupportedFont as e:
|
||||||
|
container.log.warning(
|
||||||
|
'Unsupported font: %s, ignoring. Error: %s'%(
|
||||||
|
name, as_unicode(e)))
|
||||||
|
continue
|
||||||
|
|
||||||
for w in warnings:
|
for w in warnings:
|
||||||
container.log.warn(w)
|
container.log.warn(w)
|
||||||
olen = sum(old_sizes.itervalues())
|
olen = sum(old_sizes.itervalues())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user