google / google/fonts

Subsetter causes issues regarding grapheme clusters in Firefox

Open
#7,163 1 comment 0 reactions 0 assignees View on GitHub
-- Needs Eng team opinion I API / Website / Platform I Request I Tools / workflow / repo
Dominant language
HTML
Stars
20.5k
Forks
2.9k
Avg merge
1d 21h
Merged PRs (30d)
95

Description

Currently, due to implementation limitations, Firefox matches fonts codepoint-by-codepoint, not by grapheme cluster. (Safari also seems to have the same behavior, though I don't have a mac to test that). This causes problems with Google Fonts's subsetter, which sometimes puts different grapheme clusters that start with the same codepoint into different fonts. I specifically noticed this with Noto Color Emoji (I'm not sure how exactly the subsetter works as it doesn't seem to be public so I can't tell if this could happen with other fonts too), in . For example, the Bird emoji (U+1F426) is in font file [10], while Black Bird (U+1F426 U+200D U+2B1B) is in file [7]. When matching the black bird emoji sequence, Firefox will look through the font files in reverse order (as specified by the CSS Fonts spec), and find the bird in file [10]. It will thus never consider the grapheme cluster in file [7] as an option and fail to render the black bird properly, falling back to a regular bird and black square.

My proposed fix would be to make sure that the subsetter always puts all grapheme clusters that start with the same codepoint into the same subset. This would mean that font-matching by the first codepoint, which Firefox and apparently also Safari do, will always find the font file with the correct glyph.

See also: the [Firefox bug](https://bugzilla.mozilla.org/show_bug.cgi?id=1874405) I made regarding this issue (but since this is blocked on a 14-year-old open issue, and also appears in Safari, it seems easier to fix in Google Fonts).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.