mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Font subsetting: When font-variant: small-caps is used include the capital letters as well, in case either the font or the renderer do not support OpenType smcp. Fixes #1568555 [Subsets of fonts with CSS set to uppercase or small-caps variants](https://bugs.launchpad.net/calibre/+bug/1568555)
This commit is contained in:
parent
0dd8f53b4e
commit
b2dbb4ac01
Binary file not shown.
@ -27,6 +27,7 @@ font_dict = (style, computed=false) ->
|
|||||||
'font-style':style.getPropertyValue('font-style'),
|
'font-style':style.getPropertyValue('font-style'),
|
||||||
'font-stretch':style.getPropertyValue('font-stretch'),
|
'font-stretch':style.getPropertyValue('font-stretch'),
|
||||||
'text-transform':style.getPropertyValue('text-transform'),
|
'text-transform':style.getPropertyValue('text-transform'),
|
||||||
|
'font-variant':style.getPropertyValue('font-variant'),
|
||||||
}
|
}
|
||||||
|
|
||||||
font_usage = (node) ->
|
font_usage = (node) ->
|
||||||
|
@ -338,7 +338,7 @@ class StatsCollector(object):
|
|||||||
for font in font_usage:
|
for font in font_usage:
|
||||||
text = set()
|
text = set()
|
||||||
for t in font['text']:
|
for t in font['text']:
|
||||||
tt = font['text-transform']
|
tt = (font['text-transform'] or '').lower()
|
||||||
if tt != 'none':
|
if tt != 'none':
|
||||||
if tt == 'uppercase':
|
if tt == 'uppercase':
|
||||||
t = icu_upper(t)
|
t = icu_upper(t)
|
||||||
@ -348,6 +348,9 @@ class StatsCollector(object):
|
|||||||
m = self.capitalize_pat.search(t)
|
m = self.capitalize_pat.search(t)
|
||||||
if m is not None:
|
if m is not None:
|
||||||
t += icu_upper(m.group())
|
t += icu_upper(m.group())
|
||||||
|
fv = (font['font-variant'] or '').lower()
|
||||||
|
if fv in {'smallcaps', 'small-caps', 'all-small-caps', 'petite-caps', 'all-petite-caps', 'unicase'}:
|
||||||
|
t += icu_upper(t) # for renderers that try to fake small-caps by using small normal caps
|
||||||
text |= frozenset(t)
|
text |= frozenset(t)
|
||||||
text.difference_update(exclude)
|
text.difference_update(exclude)
|
||||||
if not text:
|
if not text:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user