Closed Bug 1722689 Opened 3 years ago Closed 3 years ago

Canvas renders font too large

Categories

(Core :: Graphics: Canvas2D, defect)

Firefox 90
defect

Tracking

()

RESOLVED FIXED
92 Branch
Tracking Status
firefox92 --- fixed

People

(Reporter: surma, Assigned: jfkthame)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36

Steps to reproduce:

Canvas, large scaling factor (>300) and small font size (0.3px)

Repro sample: https://glitch.com/edit/#!/equatorial-caramel-coaster?path=index.html%3A4%3A1

Actual results:

The “X” are way too big and overlap.

Expected results:

They should be stacked, similar to how Chrome renders this (although Chrome has separate issues)

The Bugbug bot thinks this bug should belong to the 'Core::Canvas: 2D' component, and is moving the bug to that component. Please revert this change in case you think the bot is wrong.

Component: Untriaged → Canvas: 2D
Product: Firefox → Core

Jonathan, does this repro for you on macOS? It does not happen for me on Linux.

Severity: -- → S3
Flags: needinfo?(jfkthame)

Yes, reproduces on macOS. It looks like the font size is getting clamped to a minimum of 1px or something like that.

This looks suspiciously like it might be relevant. The clamping there dates back to bug 365236... I suspect we could revisit that.

Flags: needinfo?(jfkthame)

Allowing smaller font sizes seems fine; we just need to ensure the size is not actually zero if we're going to use it in font-size-adjust computations, but fractional sizes like 0.1px should be allowed.

I've created a simple reftest for this. It fails on Linux on tryserver, though it passes for me locally on Ubuntu, so I think there must be some dependency on system configuration (e.g. the system's hinting preferences, or maybe freetype version?). It looks like on try, the glyph advances are being snapped to whole pixels (before the transform is applied), whereas locally I get accurate (fractional) advances. Given this, I propose to just mark the test as random on Linux for now.

Assignee: nobody → jfkthame
Pushed by jkew@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/95d1d8822b62
Don't clamp minimum font size on macOS to 1 pixel; allow really tiny sizes (which may subsequently be scaled). r=lsalzman
Pushed by emilio@crisal.io:
https://hg.mozilla.org/integration/autoland/rev/0e112e92bacc
follow-up: Annotate some WPTs as no longer failing on macOS.
Pushed by malexandru@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/dc7ecea25b52
Annotate some more WPTs as no longer failing on macOS. a=wpt-fix
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: