csswg-drafts icon indicating copy to clipboard operation
csswg-drafts copied to clipboard

[css-text-decor-4] Definition of `from-font` value for `text-decoration-thickness`

Open jfkthame opened this issue 1 month ago • 2 comments

https://drafts.csswg.org/css-text-decor-4/#valdef-text-decoration-thickness-from-font says that the from-font value means:

If the first available font has metrics indicating a preferred underline width, use that width, otherwise behaves as auto.

However, this seems wrong for line-through decorations, as OpenType fonts provide a separate yStrikeoutSize value in the OS/2 table which specifies the font's desired thickness for the strikeout stroke.

This may often match the font's underlineThickness (found in the post table), but there are some common fonts where the two metrics are different, including for example the Arial and Times fonts on macOS.

To more properly respect the metrics provided by the font designer, I suggest from-font should be defined to use the font's preferred underline width for underline and overline decorations (OpenType does not provide a separate overline-thickness metric), but to use the strikeout size for line-through decorations.

jfkthame avatar Dec 13 '25 17:12 jfkthame

For example, in the Arial.ttf font on macOS, I find:

  <post>
    ...
    <underlinePosition value="-217"/>
    <underlineThickness value="150"/>
    ...

but

  <OS_2>
    ...
    <yStrikeoutSize value="102"/>
    <yStrikeoutPosition value="530"/>
    ...

so the from-font value of line-through thickness should be only 68% of the from-font underline thickness.

jfkthame avatar Dec 13 '25 17:12 jfkthame

This reminds me of #838 wherein I proposed length units, e.g. bs and hs, for the glyph stroke width of the currently used font. That means, perhaps the font-specified thicknesses of over-/underlines and strikethroughs would better be accessed through units (which would probably hardly be used for anything else, though).

Crissov avatar Dec 15 '25 21:12 Crissov