Skip to content

[css-text-decor] Please implement text-strikethrough-position key #9027

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

Open
ryanbugden opened this issue Jul 4, 2023 · 7 comments
Open

Comments

@ryanbugden
Copy link

In submitting bug reports to various browsers, and how they are inaccurately rendering from-font values for text decoration (with this test page by @nicksherman), it started to become clear, that within the dichotomy of underline and strikethroughs (the two linear decorations that font files contain metadata for), there seems to be no way to invoke the font metadata which covers the strikethrough’s y-position.

On the CSS level, how we invoke the values from the font:

Underline thickness: Taken care of by text-decoration-thickness: from-font;
Strikethrough thickness: Also taken care of by text-decoration-thickness: from-font;
Underline position: Taken care of by text-underline-position: from-font;
Strikethrough position

On the font level, these are the values in the font:

Underline: post table

  • underlineThickness
  • underlinePosition

Strikethrough: OS2 table

  • yStrikeoutSize
  • yStrikeoutPosition

Suggestion:

  • Implement a text-strikethrough-position key, for which there is a possible (and hopefully default) from-font value.
  • For this position, look at OS2 > yStrikeoutPosition, and interpret it as the y-position of the top of the stroke.

The position of the top of the strikeout stroke relative to the baseline in font design units.

Thanks for your consideration!

@cdoublev
Copy link
Collaborator

cdoublev commented Jul 4, 2023

I wonder why text-decoration-position and text-decoration-offset do not exist to apply for any value of text-decoration-line.

@ryanbugden
Copy link
Author

See issues filed with browsers below, which may or may not be able to addressed without this CSS key:

@fantasai
Copy link
Collaborator

fantasai commented Aug 11, 2023

If the main idea is to get UAs to use font information, well, they should just do it! The spec encourages that explicitly, e.g. https://www.w3.org/TR/css-text-decor-4/#line-auto-offset

The only problem I'm concerned about here is if the fonts contain bogus information. If we're unable to detect those cases and they end up creating widespread problems, then we might need an explicit opt-in.

So I think the right thing to do is file issues against the UAs, as you've done here, and if they push back and say they can't do it without an opt-in switch, then we can revisit and do something about that.

@ryanbugden
Copy link
Author

Good points @fantasai . It looks like the Mozilla team is able to do on-the-fly testing for bogus values. If browsers can see whether a strikethrough is outside of the font bounds, maybe they can just (default to honoring the font but) choose their own hard-coded value if so.

@ryanbugden
Copy link
Author

cc @drott

@schenney-chromium
Copy link
Contributor

Repeating @drott's question from the bug report ...

Is there an opentype field for strike-through position?

@jfkthame
Copy link
Contributor

https://learn.microsoft.com/en-gb/typography/opentype/spec/os2#ystrikeoutposition

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants