engine icon indicating copy to clipboard operation
engine copied to clipboard

[web] Use Canvas2d to measure text height

Open mdebbar opened this issue 3 years ago • 0 comments

Measure text height using canvas2d's measureText API. Height metrics are available in most major browsers (Firefox doesn't support fontBoundingBoxAscent/fontBoundingBoxDescent).

This works well when rendering text into a canvas2d. But when rendering into DOM, the text isn't aligned to the baseline correctly. This is a blocker for the PR and I haven't found a solution to it yet.

Remaining tasks:

  • [ ] Incorporate TextHeightRuler into the new CachedMeasurements class (as a fallback for browsers that don't support canvas2d height metrics).
  • [ ] Adjust measurements (and caching) for letter spacing (if it's non-zero).
  • [ ] Fix DOM rendering of some international characters.

mdebbar avatar Jun 13 '22 18:06 mdebbar