mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Fallback from script-specific hyphens to normal hyphen first
The previous code fell back directly from a script-specific hyphen to the ASCII hyphen-minus if the font didn't support the script-specific hyphen. Now we try the Unicode hyphen (U+2010) first before trying the ASCII hyphen-minus. Bug: 36201363 Test: Not needed Change-Id: I374234fd73fab7edd990ea86f8937c38761c90bf
This commit is contained in:
parent
f698f16c1e
commit
829f28371c
@ -736,12 +736,22 @@ static void addFeatures(const string &str, vector<hb_feature_t>* features) {
|
||||
}
|
||||
}
|
||||
|
||||
static const hb_codepoint_t CHAR_HYPHEN = 0x2010; /* HYPHEN */
|
||||
|
||||
static inline hb_codepoint_t determineHyphenChar(hb_codepoint_t preferredHyphen, hb_font_t* font) {
|
||||
if (preferredHyphen == 0x2010 /* HYPHEN */
|
||||
|| preferredHyphen == 0x058A /* ARMENIAN_HYPHEN */
|
||||
hb_codepoint_t glyph;
|
||||
if (preferredHyphen == 0x058A /* ARMENIAN_HYPHEN */
|
||||
|| preferredHyphen == 0x05BE /* HEBREW PUNCTUATION MAQAF */
|
||||
|| preferredHyphen == 0x1400 /* CANADIAN SYLLABIC HYPHEN */) {
|
||||
hb_codepoint_t glyph;
|
||||
if (hb_font_get_nominal_glyph(font, preferredHyphen, &glyph)) {
|
||||
return preferredHyphen;
|
||||
} else {
|
||||
// The original hyphen requested was not supported. Let's try and see if the
|
||||
// Unicode hyphen is supported.
|
||||
preferredHyphen = CHAR_HYPHEN;
|
||||
}
|
||||
}
|
||||
if (preferredHyphen == CHAR_HYPHEN) { /* HYPHEN */
|
||||
// Fallback to ASCII HYPHEN-MINUS if the font didn't have a glyph for the preferred hyphen.
|
||||
// Note that we intentionally don't do anything special if the font doesn't have a
|
||||
// HYPHEN-MINUS either, so a tofu could be shown, hinting towards something missing.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user