servo / webrender

A GPU-based renderer for the web
https://doc.servo.org/webrender/
Mozilla Public License 2.0
3.12k stars 277 forks source link

Font fallback should be attempted for Variation Selectors before using the base glyph #3196

Open hfhchan opened 6 years ago

hfhchan commented 6 years ago

The algorithm in CSS Fonts, 5.3. Cluster Matching is defined as follows:

For sequences containing variation selectors, which indicate the precise glyph to be used for a given character, user agents always attempt system font fallback to find the appropriate glyph before using the default glyph of the base character.

Currently, WebRender uses the default glyph of the base character without attempting fallback if the font does not support a variation sequence.

This breaks expectations for CJK users because Ideographic Variation Sequences will be increasingly used for plain-text interchange of historical and rare variants, where accurate reproduction of the glyph may be necessary to convey the full semantics of the text. Fallback when encountering unsupported variation sequences are supported correctly on Android.

Reproduction Steps:

For the sequence

齋󠄁齋 ([\xE9\xBD\x8B] [\xF3\xA0\x84\x81] [\xE9\xBD\x8B])

I have HanaMinA installed, which supports the variation selector, and SimSun, bundled with Windows, which doesn't. When I set CSS property

font-family: SimSun, HanaMinA;

It displays as SimSun instead of HanaMinA.

image

emilio commented 6 years ago

cc @lsalzman

Also, this could probably get a Firefox bug.