advance width of missing-glyphs in canvas text does not account for DPI correctly

NEW
Unassigned

Status

()

Core
Graphics: Text
5 years ago
5 years ago

People

(Reporter: jfkthame, Unassigned)

Tracking

(Blocks: 1 bug)

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(3 attachments)

(Reporter)

Description

5 years ago
Created attachment 717656 [details]
testcase for rendering missing-glyphs in <canvas>

When there are missing glyphs (characters not supported by any font) in canvas text, the gap left for the missing glyphs is scaled incorrectly with DPI changes due to hidpi support and/or scaling of the canvas transform.

This is more obvious now that bug 808288 part 2 has been re-landed, so that ".notdef" boxes are rendered instead of just blank space, but the incorrect scaling of the missing-glyph advance existed even before this.

The attached testcase demonstrates the behavior. On a Retina display, the missing-glyph advances are twice what they should be; and the second set of three lines (where "scale(5, 5)" is applied to the canvas) the advances are multiplied to 5x the expected width.
The advance calculation was wrong even before bug 808288 part 1 is landed.
Created attachment 717733 [details]
testcase for CSS transform: scale

This bug is not even limited to canvas.
Component: Canvas: 2D → Graphics: Text
Created attachment 717758 [details]
unscaled testcase

This is not even related with scaling.
gfxFontMissingGlyphs tries to ensure the minimum width for hex micro-glyphs.
But if the font-size is too small, hexes will not be rendered anyway because there's no enough height. We should stop to ensure the minimum width (or should ensure the minimum width based on a more reasonable value).
(Reporter)

Comment 4

5 years ago
Ugh, yes, that looks pretty bad.

Also, zooming in on your testcase shows that once we start drawing the hex digits, they're way oversized for the available height of the box. So we're not handling zoom properly there. (Requires a hidpi display to reproduce with your testcase as it stands, but if you change the font size to 5px it will reproduce with non-hidpi as well.)
You need to log in before you can comment on or make changes to this bug.