[quartz] Adjust x_extents metric.

CoreText uses different advances depending on the font size, with very
small point sizes sometimes getting advances that are smaller than the
glyph's width. This is manifested in the Apple Color Emoji font with the
Emoji glyphs having a width of 1.25 and an advance width of 1.0. That
results in overlapping emoji when they're in a string.

The small spacing difference also affects 3 tests so updated reference
images are included in this commit.

 # Please enter the commit message for your changes. Lines starting
This commit is contained in:
John Ralls 2022-04-23 14:36:15 -07:00
parent c755e48c2e
commit 2784159d0e
4 changed files with 6 additions and 1 deletions

View file

@ -412,7 +412,12 @@ _cairo_quartz_init_glyph_metrics (cairo_quartz_scaled_font_t *font,
extents.y_bearing = - ymax;
extents.width = xmax - xmin;
extents.height = ymax - ymin;
extents.x_advance = advance.width;
/* At the necessary 1.0pt ctFont size some glyphs get a reduced
* advance that causes overlaps when scaled up. We can avoid that by
* using the width instead if it's wider. Since cairo doesn't support
* vertical font layout we don't do the same for y_advance.
*/
extents.x_advance = MAX(extents.width, advance.width);
extents.y_advance = advance.height;
#ifdef DEBUG

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB