Use HarfBuzz to retrieve font baselines and synthesize fallbacks
Categories
(Core :: Layout: Block and Inline, enhancement)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox149 | --- | fixed |
People
(Reporter: sajidanwar, Assigned: sajidanwar)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
Additional baselines are required for the new vertical-align (alignment-baseline) values as well for text-box-edge. The current vendored copy of HarfBuzz has an hb_ot_layout_get_baseline_with_fallback API that synthesizes/measures baselines according to the css-inline-3 specification. HarfBuzz is already used to retrieve some baselines without fallback synthesis by gfxFont::GetBaselines (which is only used Canvas2D). This task is to update gfxFont::GetBaselines to add additional baselines and to directly use HarfBuzz for baseline retrieval and synthesis, and to then update nsFontMetrics to expose these baselines.
Comment 1•4 months ago
|
||
Should SVG GetBaselinePosition https://searchfox.org/firefox-main/source/layout/svg/SVGTextFrame.cpp#261 also use gfxFont::GetBaselines too rather than implementing the baseline position offset itself?
| Assignee | ||
Comment 2•4 months ago
|
||
From :jfkthame in #layout:
It's possible there might be discrepancies between our existing values (for the cases already implemented) and the HB-synthetic values, in which case we'd need to look at the effect on current behavior, but I suspect any differences would be minor enough to be unimportant.
The current fallback values used in gfxFont::GetBaselines are:
- alphabetic = 0
- hanging = 0.8 * ascent
- ideographic = -0.5 * descent
The fallbacks used by hb_ot_layout_get_baseline_with_fallback and/or recommended by css-inline-3 are:
- alphabetic = 0
- hanging = 0.6em (if glyph measurement is unsuccessful; this fallback is recommended by the spec)
- ideographic = descent (this fallback is recommended by the spec for CJK fonts)
Alphabetic is the same. Hanging is probably similar enough; e.g. if the font has a 200/800 descent/ascent size, then 0.6em places hanging at 600 vs. the 640 that is currently used. Ideographic is definitely different, using the full descent vs. half the descent, but it looks like Blink does use the full descent for its fallback already so I suspect this change will be fine.
| Assignee | ||
Comment 3•4 months ago
|
||
Thanks for the pointer Robert, I'll update those baseline calculations to use this as part of bug 2010721.
| Assignee | ||
Comment 4•4 months ago
|
||
Updated•4 months ago
|
Comment 6•4 months ago
|
||
| bugherder | ||
Updated•3 months ago
|
Description
•