Add U+202F NARROW NO-BREAK SPACE to the sticky white list

Mongolian fonts need to shape across U+202F NARROW NO-BREAK SPACE
(NNBSP). But if the first font in the fallback chain supports NNBSP,
it would break Mongolian shaping since the text would be broken into
three font runs. By making NNBSP sticky, we make sure Mongolian text
is kept in one font run and is shaped properly.

See http://www.unicode.org/L2/L2017/17036-mongolian-suffix.pdf for
background. The proposed character in the proposal was not accepted
for encoding by the Unicode Techincal Committee, but the document
explains in more detail why this change in needed.

Bug: 34344220
Test: manual
Change-Id: I344a63f383fa5485875603570025eac3c4eb2574
This commit is contained in:
Roozbeh Pournader
2017-02-13 15:33:47 -08:00
parent 44c14c81d1
commit 30b9f327d3

View File

@@ -325,19 +325,21 @@ FontFamily* FontCollection::getFamilyForChar(uint32_t ch, uint32_t vs,
return bestFamily;
}
const uint32_t NBSP = 0xa0;
const uint32_t ZWJ = 0x200c;
const uint32_t ZWNJ = 0x200d;
const uint32_t NBSP = 0xA0;
const uint32_t ZWJ = 0x200C;
const uint32_t ZWNJ = 0x200D;
const uint32_t HYPHEN = 0x2010;
const uint32_t NB_HYPHEN = 0x2011;
const uint32_t NNBSP = 0x202F;
const uint32_t FEMALE_SIGN = 0x2640;
const uint32_t MALE_SIGN = 0x2642;
const uint32_t STAFF_OF_AESCULAPIUS = 0x2695;
// Characters where we want to continue using existing font run instead of
// recomputing the best match in the fallback list.
static const uint32_t stickyWhitelist[] = { '!', ',', '-', '.', ':', ';', '?', NBSP, ZWJ, ZWNJ,
HYPHEN, NB_HYPHEN, FEMALE_SIGN, MALE_SIGN, STAFF_OF_AESCULAPIUS };
static const uint32_t stickyWhitelist[] = {
'!', ',', '-', '.', ':', ';', '?', NBSP, ZWJ, ZWNJ,
HYPHEN, NB_HYPHEN, NNBSP, FEMALE_SIGN, MALE_SIGN, STAFF_OF_AESCULAPIUS };
static bool isStickyWhitelisted(uint32_t c) {
for (size_t i = 0; i < sizeof(stickyWhitelist) / sizeof(stickyWhitelist[0]); i++) {