gfx: Derive line-through metrics for fonts on MacOS (#31756)

There is now platform-specific way to get metrics for `line-through` on
MacOS and currently striking through simply does not work. The correct
approach here is likely to first search for these metrics in font tables
and then falling back to deriving them. Searching the font tables is a
larger change, so this change adds the fallback mechanism first. This at
least makes sure that strike through renders at all on Mac.

In a followup change we can add support for getting metrics via HarfBuzz
in a platform-independent way, which is what Gecko does.

Fixes #942.
This commit is contained in:
Martin Robinson 2024-03-19 14:55:12 +01:00 committed by GitHub
parent d3b03a20b5
commit f175679434
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 5 deletions

View file

@ -428,7 +428,6 @@ impl Fragment {
{
let mut rect = rect;
rect.origin.y += Length::from(font_metrics.ascent - font_metrics.strikeout_offset);
// XXX(ferjm) This does not work on MacOS #942
rect.size.height = Length::new(font_metrics.strikeout_size.to_nearest_pixel(dppx));
self.build_display_list_for_text_decoration(fragment, builder, &rect, &color);
}