Bug 1097499 part 7 - Add reverse function of GetFullWidth. r=emk

MozReview-Commit-ID: HRDoZPzr1GO
This commit is contained in:
Xidorn Quan
2016-04-22 09:18:41 +10:00
parent 4912a1a884
commit f4b949c3e6
4 changed files with 57 additions and 16 deletions

View File

@@ -361,22 +361,22 @@ GetHanVariant(uint32_t aCh)
}
#endif
uint32_t
GetFullWidth(uint32_t aCh)
{
// full-width mappings only exist for BMP characters; all others are
// returned unchanged
if (aCh < UNICODE_BMP_LIMIT) {
uint32_t v =
sFullWidthValues[sFullWidthPages[aCh >> kFullWidthCharBits]]
[aCh & ((1 << kFullWidthCharBits) - 1)];
if (v) {
// return the mapped value if non-zero; else return original char
return v;
}
}
return aCh;
}
#define DEFINE_BMP_1PLANE_MAPPING_GET_FUNC(prefix_) \
uint32_t Get##prefix_(uint32_t aCh) \
{ \
if (aCh >= UNICODE_BMP_LIMIT) { \
return aCh; \
} \
auto page = s##prefix_##Pages[aCh >> k##prefix_##CharBits]; \
auto index = aCh & ((1 << k##prefix_##CharBits) - 1); \
uint32_t v = s##prefix_##Values[page][index]; \
return v ? v : aCh; \
}
// full-width mappings only exist for BMP characters; all others are
// returned unchanged
DEFINE_BMP_1PLANE_MAPPING_GET_FUNC(FullWidth)
DEFINE_BMP_1PLANE_MAPPING_GET_FUNC(FullWidthInverse)
bool
IsClusterExtender(uint32_t aCh, uint8_t aCategory)