Re: [csswg-drafts] [css-fonts-5] Text Fitting: Scaling of things based on font-size (#12888)

> `calc()` with font-relative values would be problematic. If an element in a line box has something like `margin-left: calc(1em - 5px)`, it's difficult to compute the scaling factor of the line.

The `1em - 5px` case (when used for not font-size) is relatively simple to calculate, as this is just a static contribution that can be calculated for all elements in just one extra step (best method can vary: we can either calculate what will happen with `font-size: 0`, which will allow us to get all the static contributions, or use original font size vs, say, 200% font-size while freezing the optical sizing axis, which will allow us to see if there is anything that adds non-relative values and accommodate the available space based on them.)

The more complex cases, like with reverse relative units `5px - 1em` or when regular calculations like `1em - 5px` are used on nested elements _could_ break the calculation of the available space, but I consider these edge cases which would be ok to discard. Because if that's the price we pay for all the regular use cases to be available, that is much preferable to throwing _all_ use cases away.

I will come up with some examples that demonstrate real use cases and how not scaling font-relative units in them will make the feature not produce the expected result.

-- 
GitHub Notification of comment by kizu
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/12888#issuecomment-3375700378 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Tuesday, 7 October 2025 08:12:41 UTC