readium / readium-css

🌈 A set of reference stylesheets for EPUB Reading Systems, starting with Readium Mobile
https://readium.org/readium-css/
BSD 3-Clause "New" or "Revised" License
89 stars 20 forks source link

letter-spacing forces font-variant to none #102

Closed danielweck closed 2 years ago

danielweck commented 3 years ago

Issue first reported in Thorium by @ThomasR128

https://github.com/edrlab/thorium-reader/issues/1387

Reproducible with https://standardebooks.org/ebooks/john-muir/my-first-summer-in-the-sierra

The screenshot below is with the "Georgia" typeface in both Thorium and Books.app on MacOS (note the missing small-caps font-variant:

Screenshot 2021-02-22 at 15 37 05

And here's the culprit: font-variant: none; in ReadiumCSS triggered by letter-spacing.

https://github.com/readium/readium-css/blob/583011453612e6f695056ab6c086a2c4f4cac9c0/css/src/modules/user-settings-submodules/ReadiumCSS-letterSpacing_pref.css#L19

Screenshot 2021-02-22 at 15 40 31
JayPanoz commented 3 years ago

That is to be expected with advanced settings given letter- and word-spacing are strongly tied to dyslexia, where you don’t want small caps nor all caps, etc.

And these advanced settings were designed as either “on” or “off” – if the CSS variable is inlined on :root it’s considered “on” (even if the value is 0). If it isn’t then it is “off” and doesn’t apply – and override author styles.

That said, it may be possible to filter value 0 with something like :not([style*=--USER__wordSpacing:0]):not([style*=--USER__wordSpacing: 0]) – note the extra space because this is something to account for – appended to all these selectors, although I can’t tell what the performance impact could be – we’ve hit quite a significant number of performance regressions so I prefer to mention that point.

danielweck commented 2 years ago

Fixed in Thorium via https://github.com/readium/r2-navigator-js/commit/c547705c5000687914ba2fad97ab027a0c094611 and https://github.com/edrlab/thorium-reader/commit/5c0c392751c7df8d0008a9104e2fcf34bfd3b65c (in a nutshell: we weren't handling the "zero" values correctly, now we do :)