From b2dbb4ac0133a8e4aac37b5fc91c129bd855d6ce Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 11 Apr 2016 16:42:49 +0530 Subject: [PATCH] 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) --- resources/compiled_coffeescript.zip | Bin 107364 -> 107426 bytes .../ebooks/oeb/polish/font_stats.coffee | 1 + src/calibre/ebooks/oeb/polish/stats.py | 5 ++++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/resources/compiled_coffeescript.zip b/resources/compiled_coffeescript.zip index 10e6f498b3d6ea63288ac4f08d7ccaa1c1666b03..18908ea0bbce9032ef4f43718ee4bd594832c988 100644 GIT binary patch delta 222 zcmaEIjBU|zwuUW?${xH|Te>}T?k$=(S%QIK@^%9c#xE=)I$R21pq`eWSE5^%Sd^KV zH{H>PQIQ?OF4?Z+%eXiQRqymm^BLn9Ursk%z^Ko-WP0KPMycu37BMIXxJpPJTX6ObH~bw3tys!`##$F~uY; z#Vje&z{0}PBGJG&)xa{v*w`$|z{1Gb5D3x?jZ=-M*DqoepMGWmqu=y@3mMHBYXJ 'font-style':style.getPropertyValue('font-style'), 'font-stretch':style.getPropertyValue('font-stretch'), 'text-transform':style.getPropertyValue('text-transform'), + 'font-variant':style.getPropertyValue('font-variant'), } font_usage = (node) -> diff --git a/src/calibre/ebooks/oeb/polish/stats.py b/src/calibre/ebooks/oeb/polish/stats.py index 023f1b2b44..afa60b3dbd 100644 --- a/src/calibre/ebooks/oeb/polish/stats.py +++ b/src/calibre/ebooks/oeb/polish/stats.py @@ -338,7 +338,7 @@ class StatsCollector(object): for font in font_usage: text = set() for t in font['text']: - tt = font['text-transform'] + tt = (font['text-transform'] or '').lower() if tt != 'none': if tt == 'uppercase': t = icu_upper(t) @@ -348,6 +348,9 @@ class StatsCollector(object): m = self.capitalize_pat.search(t) if m is not None: 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.difference_update(exclude) if not text: