dominant-baseline middle is inconsistent at small font-sizes, probably due to nscoord precision
Categories
(Core :: SVG, defect)
Tracking
()
People
(Reporter: samdinner, Unassigned)
References
(Blocks 1 open bug)
Details
(Keywords: webcompat:platform-bug)
User Story
user-impact-score:3
Attachments
(7 files)
User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:93.0) Gecko/20100101 Firefox/93.0
Steps to reproduce:
I set dominant-baseline to "middle" on a SVG <text> element. Then I copied the <svg> element and scaled all the dimensions by factors of 10 so that each <svg> should render the same thing just with a different size.
Actual results:
I expected the same SVG every time since everything was scaled consistently.
Expected results:
Each scale aligns the text in a different place.
Comment 1•4 years ago
|
||
The Bugbug bot thinks this bug should belong to the 'Core::SVG' component, and is moving the bug to that component. Please revert this change in case you think the bot is wrong.
| Reporter | ||
Comment 2•4 years ago
|
||
A screenshot of what test.html looks like on Ubuntu 21.10.
| Reporter | ||
Comment 3•4 years ago
|
||
I tried testing this on Windows and noticed the issue was still there but the offset was more subtle. I also experienced the issue on Nightly (20211030103646).
Comment 4•4 years ago
|
||
Only the really tiny font doesn't work on my Mac. The other 3 are OK.
Comment 5•4 years ago
|
||
The severity field is not set for this bug.
:boris, could you have a look please?
For more information, please visit auto_nag documentation.
Comment 6•4 years ago
•
|
||
This is my screenshot. The 0-0.01 and 0-0.1 are different.
Updated•4 years ago
|
Comment 7•1 year ago
|
||
This is particularly a problem for small font-sizes, I think -- updating the bug title to mention that. I'll attach a testcase I came up with while investigating a case of this at bug 1918604, too.
Comment 8•1 year ago
|
||
Comment 9•1 year ago
•
|
||
Here's a reference case for testcase 2, where I've just scaled up all of the sizes inside the SVG content by 10 (which shouldn't actually impact the rendering, since the SVG content is still squished into the same size container).
The expectation is that testcase 2 should exactly match this reference case. But in Firefox, the first "E" is lower down in testcase 2 as compared to this reference case.
(This offset gets even worse if you zoom out with Ctrl -, too. Depending on your screen resolution, you might have to do that in order to see this bug in the first place.)
Comment 10•1 year ago
|
||
Updated•1 year ago
|
Comment 11•1 year ago
•
|
||
(This offset gets even worse if you zoom out with
Ctrl -, too. Depending on your screen resolution, you might have to do that in order to see this bug in the first place.)
Here's a screenshot to demonstrate this^. In the top left of this screenshot (showing the top half of testcase 2, viewed at 50% full-page-zoom), the "E" is protruding quite a ways outside of the orange area.
Comment 12•1 year ago
|
||
I think because we're working with the nscoord type so small values are simply rounded to 0.
nsIFrame::GetLogicalBaseline returns nscoord
nsfontMetrics->XHeight() returns nscoord (https://searchfox.org/mozilla-central/source/gfx/src/nsFontMetrics.cpp#179)
So you simply lose precision with small values.
Comment 13•1 year ago
•
|
||
(In reply to Robert Longson [:longsonr] from comment #12)
I think because we're working with the nscoord type so small values are simply rounded to 0.
That makes sense, yup.
nscoord units really aren't well-suited to this scenario where things have been scaled up by this much... They're fractions of a CSS pixel and are implicitly meant to be fractions-of-the-smallest-distance-a-user-can-perceive, but in cases where the scale-factor is such that they end up being larger than (or around the same magnitude as) a display pixel, things break down like this.
I wonder if we could hack around this in some cases (at least for viewBox scales) by adding another internal scale factor of some sort, so that we could be working with units that are in the right ballpark in terms of sub-pixel positioning... That wouldn't be especially robust in the face of scales from per-element transform-scales, but maybe it'd still be worth exploring for this viewBox-scaling scenario at least.
Updated•1 year ago
|
Updated•5 months ago
|
Description
•