mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix some warnings from the font subset process not making it into the final report
This commit is contained in:
parent
2f6cd98741
commit
6cf5501674
@ -47,7 +47,7 @@ def subset_all_fonts(container, font_stats, report):
|
|||||||
chars = font_stats.get(name, set())
|
chars = font_stats.get(name, set())
|
||||||
with container.open(name, 'rb') as f:
|
with container.open(name, 'rb') as f:
|
||||||
f.seek(0, os.SEEK_END)
|
f.seek(0, os.SEEK_END)
|
||||||
total_old += f.tell()
|
font_size = f.tell()
|
||||||
if not chars:
|
if not chars:
|
||||||
remove.add(name)
|
remove.add(name)
|
||||||
report(_('Removed unused font: %s')%name)
|
report(_('Removed unused font: %s')%name)
|
||||||
@ -57,23 +57,24 @@ def subset_all_fonts(container, font_stats, report):
|
|||||||
try:
|
try:
|
||||||
font_name = get_font_names(raw)[-1]
|
font_name = get_font_names(raw)[-1]
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
container.log.warning(
|
report(
|
||||||
'Corrupted font: %s, ignoring. Error: %s'%(
|
'Corrupted font: %s, ignoring. Error: %s'%(
|
||||||
name, as_unicode(e)))
|
name, as_unicode(e)))
|
||||||
continue
|
continue
|
||||||
warnings = []
|
warnings = []
|
||||||
container.log('Subsetting font: %s'%(font_name or name))
|
report('Subsetting font: %s'%(font_name or name))
|
||||||
try:
|
try:
|
||||||
nraw, old_sizes, new_sizes = subset(raw, chars,
|
nraw, old_sizes, new_sizes = subset(raw, chars,
|
||||||
warnings=warnings)
|
warnings=warnings)
|
||||||
except UnsupportedFont as e:
|
except UnsupportedFont as e:
|
||||||
container.log.warning(
|
report(
|
||||||
'Unsupported font: %s, ignoring. Error: %s'%(
|
'Unsupported font: %s, ignoring. Error: %s'%(
|
||||||
name, as_unicode(e)))
|
name, as_unicode(e)))
|
||||||
continue
|
continue
|
||||||
|
total_old += font_size
|
||||||
|
|
||||||
for w in warnings:
|
for w in warnings:
|
||||||
container.log.warn(w)
|
report(w)
|
||||||
olen = sum(itervalues(old_sizes))
|
olen = sum(itervalues(old_sizes))
|
||||||
nlen = sum(itervalues(new_sizes))
|
nlen = sum(itervalues(new_sizes))
|
||||||
total_new += len(nraw)
|
total_new += len(nraw)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user