Skip to content

Account for the Firefox font size quantization in the text layer - #21810

Open
calixteman wants to merge 1 commit into
mozilla:masterfrom
calixteman:quantize_measured_font_size
Open

Account for the Firefox font size quantization in the text layer#21810
calixteman wants to merge 1 commit into
mozilla:masterfrom
calixteman:quantize_measured_font_size

Conversation

@calixteman

Copy link
Copy Markdown
Contributor

Firefox rounds the font size set on a canvas 2d context, once divided by the device pixel ratio, to 7 bits of precision. Hence measureText can return a width up to ~1% off the one the spans are laid out with, which made --scale-x slightly wrong in a zoom dependent way. Measure with a size left untouched by that rounding and rescale the returned width, which is linear in the font size.

@codecov-commenter

codecov-commenter commented Aug 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.20%. Comparing base (a570239) to head (1ad823c).

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #21810   +/-   ##
=======================================
  Coverage   90.20%   90.20%           
=======================================
  Files         264      264           
  Lines       67322    67329    +7     
=======================================
+ Hits        60729    60736    +7     
  Misses       6593     6593           
Flag Coverage Δ
browsertest 66.31% <91.66%> (+<0.01%) ⬆️
fonttest 8.91% <ø> (ø)
integrationtest 69.42% <100.00%> (+<0.01%) ⬆️
unittest 58.37% <91.66%> (-0.01%) ⬇️
unittestcli 56.92% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread src/display/text_layer.js Outdated

@timvandermeij timvandermeij left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=me, with passing browser tests. Thanks!

@calixteman

Copy link
Copy Markdown
Contributor Author

/botio browsertest

@moz-tools-bot

Copy link
Copy Markdown
Collaborator

From: Bot.io (Windows)


Received

Command cmd_browsertest from @calixteman received. Current queue size: 1

Live output at: http://54.193.163.58:8877/e6305afdc9d9f99/output.txt

@moz-tools-bot

Copy link
Copy Markdown
Collaborator

From: Bot.io (Linux m4)


Received

Command cmd_browsertest from @calixteman received. Current queue size: 1

Live output at: http://54.241.84.105:8877/0112093346dfb1d/output.txt

@moz-tools-bot

Copy link
Copy Markdown
Collaborator

From: Bot.io (Linux m4)


Failed

Full output at http://54.241.84.105:8877/0112093346dfb1d/output.txt

Total script time: 18.10 mins

  • Regression tests: FAILED
  different ref/snapshot: 75

Image differences available at: http://54.241.84.105:8877/0112093346dfb1d/reftest-analyzer.html#web=eq.log

@moz-tools-bot

Copy link
Copy Markdown
Collaborator

From: Bot.io (Windows)


Failed

Full output at http://54.193.163.58:8877/e6305afdc9d9f99/output.txt

Total script time: 23.39 mins

  • Regression tests: FAILED
  different ref/snapshot: 72

Image differences available at: http://54.193.163.58:8877/e6305afdc9d9f99/reftest-analyzer.html#web=eq.log

Firefox rounds the font size set on a canvas 2d context, once divided by
the device pixel ratio, to 7 bits of precision. Hence `measureText` can
return a width up to ~1% off the one the spans are laid out with, which
made `--scale-x` slightly wrong in a zoom dependent way.
Measure with a size left untouched by that rounding and rescale the
returned width, which is linear in the font size.
@calixteman
calixteman force-pushed the quantize_measured_font_size branch from cb79d37 to 1ad823c Compare August 23, 2026 16:50
@calixteman
calixteman deployed to code-coverage August 23, 2026 16:50 — with GitHub Actions Active
@calixteman

Copy link
Copy Markdown
Contributor Author

/botio browsertest

@moz-tools-bot

Copy link
Copy Markdown
Collaborator

From: Bot.io (Linux m4)


Received

Command cmd_browsertest from @calixteman received. Current queue size: 0

Live output at: http://54.241.84.105:8877/385709e28bf0a93/output.txt

@moz-tools-bot

Copy link
Copy Markdown
Collaborator

From: Bot.io (Windows)


Received

Command cmd_browsertest from @calixteman received. Current queue size: 0

Live output at: http://54.193.163.58:8877/5fa67fe83411386/output.txt

@moz-tools-bot

Copy link
Copy Markdown
Collaborator

From: Bot.io (Linux m4)


Failed

Full output at http://54.241.84.105:8877/385709e28bf0a93/output.txt

Total script time: 18.12 mins

  • Regression tests: FAILED
  different ref/snapshot: 98

Image differences available at: http://54.241.84.105:8877/385709e28bf0a93/reftest-analyzer.html#web=eq.log

@moz-tools-bot

Copy link
Copy Markdown
Collaborator

From: Bot.io (Windows)


Failed

Full output at http://54.193.163.58:8877/5fa67fe83411386/output.txt

Total script time: 23.19 mins

  • Regression tests: FAILED
  different ref/snapshot: 98

Image differences available at: http://54.193.163.58:8877/5fa67fe83411386/reftest-analyzer.html#web=eq.log

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants