Skip to content

Should we expose line height compensation var? #229

@JayPanoz

Description

@JayPanoz

See search for context: https://github.com/search?q=repo%3Areadium/css%20--RS__lineHeightCompensation&type=code

In the base module, we are setting a line height compensation for our default line-height:

/* For square-ish fonts (CJK, Indic, etc.), we must apply some compensation in dynamic leading. Default is 1 i.e. no compensation */
--RS__lineHeightCompensation: 1;
--RS__baseLineHeight: calc(1.5 * var(--RS__lineHeightCompensation));

The comment says it all

/* For square-ish fonts (CJK, Indic, etc.), we must apply some compensation in (dynamic) leading. Default is 1 i.e. no compensation */

Although it needs to be updated to no longer refer to dynamic leading.

And this is what we do here for instance:

:lang(am) {
--RS__baseFontFamily: Kefa, Nyala, Roboto, Noto, "Noto Sans Ethiopic", serif;
--RS__lineHeightCompensation: 1.167;
}

Host apps of Readium CSS do not have access to these values, unless they keep a Map of lang – value, and we could expose them as vars, as we do for default colors or font family stacks for instance.

This would probably be helpful for a line-height user setting if you have values defined for Latin, and they do not play nicely in some languages e.g. if your max line-height is 1.75 chances are that is the publisher’s value in CJK cos it is usually 15–20% more with ideographs, so the user is only able to reduce line-height with your setting.

/* For CJK, the line-height is usually 15–20% more than for Latin */
--RS__lineHeightCompensation: 1.167;

In that case you would be able to check the compensation factor Readium CSS sets as a reference, and adjust your values accordingly if needed.

We already have this issue in Thorium Web, as our 3 settings presets are generally for Latin. So we will need to adjust anyway in an upcoming release to improve i18n, and we generally import these JSON from Readium CSS to retrieve the ref.

Another option is applying this compensation in the line-height user setting submodule: https://github.com/readium/css/blob/2982c7da924df2c4e27bf219cb80cda79836aea8/css/src/modules/user-settings-submodules/ReadiumCSS-lineHeight_pref.css

But it breaks the assumption that Readium CSS should not be opinionated and must not surprise implementers. If they do not see their given value applied, I’d argue this is surprising, especially for developers who are not dealing with Latin languages by default.

CC @danielweck @mickael-menu

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions