Bug 249943 - Emoji character is horizontally misaligned when using COLR font
Summary: Emoji character is horizontally misaligned when using COLR font
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Text (show other bugs)
Version: Safari Technology Preview
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: BrowserCompat, InRadar
Depends on:
Blocks:
 
Reported: 2022-12-29 09:48 PST by Nolan Lawson
Modified: 2024-03-05 12:41 PST (History)
8 users (show)

See Also:


Attachments
Screenshot of Chrome, Firefox, and Safari TP (389.77 KB, image/png)
2022-12-29 09:48 PST, Nolan Lawson
no flags Details
Repro HTML and TTF file (714.38 KB, application/zip)
2022-12-29 09:49 PST, Nolan Lawson
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nolan Lawson 2022-12-29 09:48:52 PST
Created attachment 464247 [details]
Screenshot of Chrome, Firefox, and Safari TP

When using the Twemoji Mozilla COLR font [1], Safari Technology Preview Release 160 (Safari 16.4, WebKit 18615.1.14.3) renders certain emoji characters with the wrong alignment inside of a flexbox container with `align-items: center; justify-content: center;`.

Minimal repro: https://nolanlawson.github.io/webkit-emoji-font-repro/

Note that the fourth character (☺️) is not horizontally centered, whereas the other characters are.

This issue only repros in Safari. In Firefox and Chrome, all emoji characters are rendered with the correct horizontal center alignment. (See attached screenshots.)

Based on my testing, this only repros with a custom COLR font (not the built-in Apple Color Emoji font), and only certain emoji characters are misaligned: ☺️, 😐, ♥️, 👍️, etc.

[1]: https://github.com/mozilla/twemoji-colr/releases/tag/v0.7.0
Comment 1 Nolan Lawson 2022-12-29 09:49:17 PST
Created attachment 464248 [details]
Repro HTML and TTF file
Comment 2 zalan 2022-12-29 10:03:58 PST
Thank you for filing this bug report! It looks like the preferred width computation has some issues with fallback fonts. It fails with any flexing type of layout (e.g. shrink to fit) ->

.emoji {
 float: left;
 font-size: 22px;
 font-family: MozillaTwemojiColr;
 border: 1px solid black;
}
Comment 3 zalan 2022-12-29 14:07:43 PST
This is about measuring the emoji character. ComplexTextController returns 24px for Apple Color Emoji font, while 44px for MozillaTwemojiColr.
When measured using MozillaTwemojiColr, ComplexTextController sees 2 glyphs U+263A and U+FE0F (variant selection) and they advance 22px individually.
Myles, do you know what's going on here?
Comment 4 Radar WebKit Bug Importer 2022-12-29 14:08:21 PST
<rdar://problem/103764035>