mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Detect fonts with obsolete mimetypes as well
This commit is contained in:
parent
3bc7e7d943
commit
c4d213d490
@ -43,7 +43,7 @@ exists, join, relpath = os.path.exists, os.path.join, os.path.relpath
|
||||
def guess_type(x):
|
||||
return _guess_type(x)[0] or 'application/octet-stream'
|
||||
|
||||
OEB_FONTS = {guess_type('a.ttf'), guess_type('b.otf')}
|
||||
OEB_FONTS = {guess_type('a.ttf'), guess_type('b.otf'), guess_type('a.woff'), 'application/x-font-ttf', 'application/x-font-otf'}
|
||||
OPF_NAMESPACES = {'opf':OPF2_NS, 'dc':DC11_NS}
|
||||
|
||||
class CSSPreProcessor(cssp):
|
||||
|
@ -11,7 +11,7 @@ import os, sys
|
||||
|
||||
from calibre import prints, as_unicode
|
||||
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, guess_type
|
||||
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
|
||||
@ -35,7 +35,7 @@ def subset_all_fonts(container, font_stats, report):
|
||||
remove = set()
|
||||
total_old = total_new = 0
|
||||
for name, mt in container.mime_map.iteritems():
|
||||
if mt in OEB_FONTS or name.rpartition('.')[-1].lower() in {'otf', 'ttf'}:
|
||||
if (mt in OEB_FONTS or name.rpartition('.')[-1].lower() in {'otf', 'ttf'}) and mt != guess_type('a.woff'):
|
||||
chars = font_stats.get(name, set())
|
||||
path = container.name_path_map[name]
|
||||
total_old += os.path.getsize(path)
|
||||
|
@ -17,7 +17,7 @@ from PyQt4.Qt import (
|
||||
|
||||
from calibre import human_readable, sanitize_file_name_unicode
|
||||
from calibre.ebooks.oeb.base import OEB_STYLES, OEB_DOCS
|
||||
from calibre.ebooks.oeb.polish.container import guess_type
|
||||
from calibre.ebooks.oeb.polish.container import guess_type, OEB_FONTS
|
||||
from calibre.ebooks.oeb.polish.cover import get_cover_page_name, get_raster_cover_name
|
||||
from calibre.gui2 import error_dialog, choose_files
|
||||
from calibre.gui2.tweak_book import current_container, elided_text
|
||||
@ -178,13 +178,11 @@ class FileList(QTreeWidget):
|
||||
for names in container.manifest_type_map.itervalues():
|
||||
manifested_names |= set(names)
|
||||
|
||||
font_types = {guess_type('a.'+x) for x in ('ttf', 'otf', 'woff')}
|
||||
|
||||
def get_category(name, mt):
|
||||
category = 'misc'
|
||||
if mt.startswith('image/'):
|
||||
category = 'images'
|
||||
elif mt in font_types:
|
||||
elif mt in OEB_FONTS:
|
||||
category = 'fonts'
|
||||
elif mt in OEB_STYLES:
|
||||
category = 'styles'
|
||||
|
Loading…
x
Reference in New Issue
Block a user