Skip to content

fix(engine-render): include italic overhang in measured text width - #7782

Open
ceedot-rock wants to merge 2 commits into
dream-num:devfrom
ceedot-rock:fix/italic-overhang-clipping
Open

ceedot-rock wants to merge 2 commits into
dream-num:devfrom
ceedot-rock:fix/italic-overhang-clipping

Conversation

@ceedot-rock

@ceedot-rock ceedot-rock commented Sep 29, 2026 •

Copy link
Copy Markdown

Summary

Right-aligned (or centered) italic cell text had its rightmost glyphs clipped by the cell boundary (e.g. Tahoma italic).

Root cause

Canvas measureText().width returns the advance width, which doesn't include the italic overhang — slanted glyphs extend past it on the right. The document layout positioned lines by the advance width, so the overhang ink spilled past the clip edge.

Changes

  • FontCache.getMeasureText now captures actualBoundingBoxLeft/actualBoundingBoxRight in the measure cache (IMeasureTextCache extended).
  • For italic fonts, the measured width is extended to the ink's right edge (max(width, actualBoundingBoxRight)), so alignment accounts for the overhang. Non-italic measurement is unchanged.
  • Existing measure-cache test mocks updated for the new fields; regression test added.

Testing

  • New regression test in font-cache.spec.ts: italic width extends to the ink edge, upright width unchanged.
  • 737 tests across the 9 affected doc-layout/sheet suites: all pass.
  • tsc --noEmit on engine-render: clean.

Fixes #7658


Slid Phi Labs accepts donations to keep the lab independent.

@codecov

codecov Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.15%. Comparing base (14bb44a) to head (751ffc0).
⚠️ Report is 13 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #7782      +/-   ##
==========================================
+ Coverage   81.08%   81.15%   +0.06%     
==========================================
  Files        3059     3059              
  Lines      198216   198342     +126     
  Branches    50799    51091     +292     
==========================================
+ Hits       160719   160955     +236     
+ Misses      37437    37327     -110     
  Partials       60       60              

☔ 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.

@ceedot-rock

Copy link
Copy Markdown
Author

Bump — one-line fix: italic overhang was missing from measured text width. Happy to add a test if you'd like one.

Italic glyphs slant past their advance width, so the ink extends
beyond measureText().width on the right. Right-aligned (or centered)
text positioned by the advance width had its overhang clipped by the
cell boundary, hiding part of the value.

FontCache.getMeasureText now captures actualBoundingBoxLeft/Right and
extends the measured width to the ink's right edge for italic fonts,
so alignment accounts for the overhang. Existing measure-cache tests
updated for the new fields; regression test added.

Fixes dream-num#7658
… cache

The italic-overhang fix added actualBoundingBoxLeft/Right to
IMeasureTextCache; the docs package's font-loader spec mock was still
building the old shape and failed typecheck. Adds the two fields to the
mock (right edge = advance width, matching the test's upright glyph).
@ceedot-rock
ceedot-rock force-pushed the fix/italic-overhang-clipping branch from 1dd96b7 to 751ffc0 Compare October 4, 2026 15:24

This branch has not been deployed

No deployments
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.

[Bug] Part of the value within a cell is hidden when Tahoma font, italics, and right alignment are applied

1 participant