engine
engine copied to clipboard
[web] Use Canvas2d to measure text height
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
TextHeightRulerinto the newCachedMeasurementsclass (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.