Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checklist for Readium CSS integration #1

Open
mickael-menu opened this issue May 22, 2020 · 8 comments
Open

Checklist for Readium CSS integration #1

mickael-menu opened this issue May 22, 2020 · 8 comments
Labels
enhancement New feature or request

Comments

@mickael-menu
Copy link
Member

mickael-menu commented May 22, 2020

Here are a few points regarding the Readium CSS integration which should be double-checked or fixed in the mobile toolkits.

@mickael-menu
Copy link
Member Author

When choosing a specific font, as a rule of thumb we should fall back on one of the known font stacks, e.g.

--USER__fontFamily: "SF Mono" var(--RS__monospaceTf);

@JayPanoz
Copy link

JayPanoz commented May 27, 2020

Should we manipulate the typeScale property when changing the font size?

We discussed about this in private so for the benefit of everyone, here is a recap on the concept of type scale, its purpose and use cases.

Definition

Type scale, also known as modular scale, is a sequence of numbers that relate to one another in a meaningful way. As typographer Robert Bringhurst put it:

A modular scale, like a musical scale, is a prearranged set of harmonious proportions.

So in ReadiumCSS we have this typeScale ratio in the font-size normalise module, and then you’ll find a calc() function using it to compute a font-size e.g.

font-size: calc(1rem * var(--USER__typeScale))

An interactive web app such as this one will illustrate what happens when you change the type scale.

For more details, you can also check this 2011 article.

Purpose

It was initially implemented in ReadiumCSS as a way to get relatively foolproof typography in many circumstances – it’s also implemented in the default stylesheet for instance.

And we also had this issue of the font-size setting which doesn’t have anything standard in CSS (or a JS API) so we parsed lots of stylesheets to find a reasonable default ratio (1.2) working for most authors’ stylesheets.

It became clear it was a good idea to expose this variable to reading system developers so that they could change this ratio as they see fit.

Use cases

  • if you want to compute the ratio used by the author (by checking headings and paragraphs and doing some Math) and adjust the type scale of the font-size normalisation accordingly;
  • anything responsive typography:
    • you might want to use different type scales for different devices/screen sizes so that you don’t have these awkward large headings on a smartphone;
    • if the user sets a large font-size, you might want to decrease the type scale so that headings are not super large.
  • it could probably also be exposed as a setting for custom themes given the dramatic effect it has on typography.

Admittedly all of these use cases are kinda going the extra mile, but it could also be a “design differentiator” if you’re willing to take great care of typography in your app – we’ve done our best to provide a sound and better-than-average basis in ReadiumCSS so handling this typeScale could probably be considered a bonus. It’s not necessary but may show a clear commitment to the Reading Experience if you wish to differentiate on that.

[Edit] I guess we could add this comment AS-IS in the Readium CSS docs if it can be helpful (after all we already have a glossary for i18n).

@JayPanoz
Copy link

Some parts of the UX must follow the publication's direction, including search and highlights.

Although the vast majority of the UX can be ltr, I’m noticing that vertical writing + the toc panel is an open question BTW.

In Requirements for Japanese Text Layout:

For example, the table of contents may contain small modifications. Furthermore, there are many examples of indexes with a different page format than the basic page format, and vertically set books often have indexes in horizontal writing mode and sometimes multiple columns.

They just mention indexes for ltr layout in vertical-rtl so I’m assuming Apple Books does the right thing by having the toc panel the same as the reading progression of the publication.

@JayPanoz
Copy link

On a related note, would you like this warning about Mongolian directly in the docs?

It only exists in this ReadMe at the moment.

@JayPanoz
Copy link

Should we use Readium CSS highlight colors? There's an on-going discussion.

So yeah there’s this issue in Readium CSS for that.

If we deem it’s in ReadiumCSS’ scope (although it hasn’t necessarily been clarified it would be trivial to handle it in a efficient and compatible way with the Highlights API we discussed months ago), then it would have to go through a major “code change.”

There’s also this issue in r2-navigator-js which should be relevant to this discussion.

@mickael-menu
Copy link
Member Author

@JayPanoz

We discussed about this in private so for the benefit of everyone, here is a recap on the concept of type scale, its purpose and use cases.

Thanks for the explanation, the use cases are particularly useful 👍

So for mobile test apps, I think it's fine to ignore this property for now to keep it simple.

I actually think that we need a native wrapper/module around Readium CSS for mobile toolkits. Something similar to what we have with UserSettings but simpler to use, type-safe and more complete. This module could implement all the recommendations from Readium CSS documentation and handle:

  • Injection of:
    • Readium CSS stylesheets (including default when there's not author styles)
    • dir=, lang=
    • USER/RS variables in <html>
  • Generation of the JavaScript used to update the USER/RS variables
  • A complete type-safe settings API which would expose all the Readium CSS variables (so including typeScale). The test app would only use a subset of them.

Except for the effective reading progression and the primary language, which should probably be in the shared models + EPUB parsers and not particularly tied to Readium CSS. (I'm not sure about dir= and lang=, is it specific to Readium CSS?)

This wouldn't be the upcoming "Rendering/User Settings" API, which should be format-agnostic. But this would be a lower-level API that the User Settings API would use when rendering EPUBs.

On a related note, would you like this warning about Mongolian directly in the docs?

I think it would make sense, I actually didn't read the README in dist/, assuming it was a condensed version of the documentation.

If we deem it’s in ReadiumCSS’ scope (although it hasn’t necessarily been clarified it would be trivial to handle it in a efficient and compatible way with the Highlights API we discussed months ago), then it would have to go through a major “code change.”

After thinking more about this, I believe that highlights should not be in the scope of Readium CSS. If we have some default highlight colors in Readium, they should maybe be documented in architecture, and declared in the test apps. There's just too many different ways to implement highlighting, and also we couldn't reuse the colors declared in Readium CSS for other formats such as PDF.

@JayPanoz
Copy link

JayPanoz commented May 27, 2020

Some quick answers for the stuff that doesn’t need much thought.

(I'm not sure about dir= and lang=, is it specific to Readium CSS?)

So dir is tied to CSS multicol for pagination/fragmentation (which is applied on :root a.k.a. html element). If it weren’t present, the columns progression would go the opposite way. We didn’t have enough samples in RTL to check whether authors add it themselves or not so we resolved to this rule.

Then lang is not particularly tied to ReadiumCSS in the sense the rendering engine will use it to hyphenate properly for instance, or for some very specific CSS styles (including browsers’ UA styles).

But yeah in the end ReadiumCSS is relying on this as a web browsers actually do (default font-stacks, word breaking rules, etc.).

I think it would make sense, I actually didn't read the README in dist/, assuming it was a condensed version of the documentation.

Just noticed this morning, sorry. I can see I should also mention the fact only Windows has a typeface for traditional Mongolian – Android you have to install a downloadable font if I’m not mistaken, iOS and web you’re pretty much out of luck. I tried contacting the type designer of a popular Mongolian font in 2018 so that Readium projects could use it – through a contact form in Chinese – but never got an answer, unfortunately.

I believe that highlights should not be in the scope of Readium CSS.

Yeah me neither given how limiting a ReadiumCSS module would be. And we shouldn’t forget other formats – I’m assuming web publications could have TTS with sync/overlaid highlights, notes, etc. as differentiating features from web browsers.

So we should probably open a vote in the ReadiumCSS issue tracker on dropping this highlights module.

@mickael-menu
Copy link
Member Author

mickael-menu commented Jul 1, 2020

An issue related to Readium CSS, but to be fixed on the native side: Some books won't change their font size unless publisher's styles are disabled (note to self: 9782081418011.epub).

This occurs when a book uses absolute font units, which Readium CSS can only handle when the fsNormalize module is enabled through --USER__advancedSettings: readium-advanced-on.

Here are two potential solutions which require to provide a native wrapper for Readium CSS, to handle this seamlessly for reading apps:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants