Skip to content

Fix actualBoundingBox metrics being clamped to the text origin - #2631

Open
florianaltendorfer wants to merge 1 commit into
Automattic:masterfrom
florianaltendorfer:bounty-2620
Open

florianaltendorfer wants to merge 1 commit into
Automattic:masterfrom
florianaltendorfer:bounty-2620

Conversation

@florianaltendorfer

Copy link
Copy Markdown

Closes #2620.

On master (4.0.0-rc3) the sign of actualBoundingBoxLeft from the report is already correct, but MeasureText started the ink box min/max at 0, so the box always included the pen origin. Ink that starts right of the origin (W, aaaa, -) gave actualBoundingBoxLeft 0 instead of a negative value, and the same clamp applied to right, ascent and descent (- reported descent 0 instead of a negative value). The box now starts from the first glyph that has ink, using the first flag that was already declared there, and glyphs without ink such as spaces are skipped so a leading space doesn't put the origin back in the box.

  • Have you updated CHANGELOG.md?

Tested with a new case in test/canvas.test.js (fails before, passes after), the existing measureText tests, and by comparing measureText against the ink scanned from fillText output for the strings in the issue with left and right alignment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

actualBoundingBoxLeft has the sign inverted relative to canvas's own rasteriser (3.2.0, 3.2.3)

1 participant