зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1719544 - part 2 - Convert gfxHarfBuzzShaper normalization callbacks from direct ICU access to mozilla::intl::String APIs. r=platform-i18n-reviewers,dminor
Depends on D126259 Differential Revision: https://phabricator.services.mozilla.com/D126260
This commit is contained in:
Родитель
2cfc8b9513
Коммит
71ac7ba474
|
@ -10,17 +10,13 @@
|
||||||
#include "gfxFontUtils.h"
|
#include "gfxFontUtils.h"
|
||||||
#include "gfxTextRun.h"
|
#include "gfxTextRun.h"
|
||||||
#include "mozilla/Sprintf.h"
|
#include "mozilla/Sprintf.h"
|
||||||
|
#include "mozilla/intl/String.h"
|
||||||
#include "nsUnicodeProperties.h"
|
#include "nsUnicodeProperties.h"
|
||||||
#include "nsUnicodeScriptCodes.h"
|
#include "nsUnicodeScriptCodes.h"
|
||||||
|
|
||||||
#include "harfbuzz/hb.h"
|
#include "harfbuzz/hb.h"
|
||||||
#include "harfbuzz/hb-ot.h"
|
#include "harfbuzz/hb-ot.h"
|
||||||
|
|
||||||
#include "unicode/unorm.h"
|
|
||||||
#include "unicode/utext.h"
|
|
||||||
|
|
||||||
static const UNormalizer2* sNormalizer = nullptr;
|
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#define FloatToFixed(f) (65536 * (f))
|
#define FloatToFixed(f) (65536 * (f))
|
||||||
|
@ -1038,12 +1034,10 @@ static const char16_t sDageshForms[0x05EA - 0x05D0 + 1] = {
|
||||||
static hb_bool_t HBUnicodeCompose(hb_unicode_funcs_t* ufuncs, hb_codepoint_t a,
|
static hb_bool_t HBUnicodeCompose(hb_unicode_funcs_t* ufuncs, hb_codepoint_t a,
|
||||||
hb_codepoint_t b, hb_codepoint_t* ab,
|
hb_codepoint_t b, hb_codepoint_t* ab,
|
||||||
void* user_data) {
|
void* user_data) {
|
||||||
if (sNormalizer) {
|
char32_t ch = mozilla::intl::String::ComposePairNFC(a, b);
|
||||||
UChar32 ch = unorm2_composePair(sNormalizer, a, b);
|
if (ch > 0) {
|
||||||
if (ch >= 0) {
|
*ab = ch;
|
||||||
*ab = ch;
|
return true;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -1062,37 +1056,16 @@ static hb_bool_t HBUnicodeDecompose(hb_unicode_funcs_t* ufuncs,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!sNormalizer) {
|
char32_t decomp[2] = {0};
|
||||||
return false;
|
if (mozilla::intl::String::DecomposeRawNFD(ab, decomp)) {
|
||||||
|
if (decomp[1] || decomp[0] != ab) {
|
||||||
|
*a = decomp[0];
|
||||||
|
*b = decomp[1];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Canonical decompositions are never more than two characters,
|
return false;
|
||||||
// or a maximum of 4 utf-16 code units.
|
|
||||||
const unsigned MAX_DECOMP_LENGTH = 4;
|
|
||||||
|
|
||||||
UErrorCode error = U_ZERO_ERROR;
|
|
||||||
UChar decomp[MAX_DECOMP_LENGTH];
|
|
||||||
int32_t len = unorm2_getRawDecomposition(sNormalizer, ab, decomp,
|
|
||||||
MAX_DECOMP_LENGTH, &error);
|
|
||||||
if (U_FAILURE(error) || len < 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
UText text = UTEXT_INITIALIZER;
|
|
||||||
utext_openUChars(&text, decomp, len, &error);
|
|
||||||
NS_ASSERTION(U_SUCCESS(error), "UText failure?");
|
|
||||||
|
|
||||||
UChar32 ch = UTEXT_NEXT32(&text);
|
|
||||||
if (ch != U_SENTINEL) {
|
|
||||||
*a = ch;
|
|
||||||
}
|
|
||||||
ch = UTEXT_NEXT32(&text);
|
|
||||||
if (ch != U_SENTINEL) {
|
|
||||||
*b = ch;
|
|
||||||
}
|
|
||||||
utext_close(&text);
|
|
||||||
|
|
||||||
return *b != 0 || *a != ab;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void AddOpenTypeFeature(const uint32_t& aTag, uint32_t& aValue,
|
static void AddOpenTypeFeature(const uint32_t& aTag, uint32_t& aValue,
|
||||||
|
@ -1164,10 +1137,6 @@ bool gfxHarfBuzzShaper::Initialize() {
|
||||||
hb_unicode_funcs_set_decompose_func(sHBUnicodeFuncs, HBUnicodeDecompose,
|
hb_unicode_funcs_set_decompose_func(sHBUnicodeFuncs, HBUnicodeDecompose,
|
||||||
nullptr, nullptr);
|
nullptr, nullptr);
|
||||||
hb_unicode_funcs_make_immutable(sHBUnicodeFuncs);
|
hb_unicode_funcs_make_immutable(sHBUnicodeFuncs);
|
||||||
|
|
||||||
UErrorCode error = U_ZERO_ERROR;
|
|
||||||
sNormalizer = unorm2_getNFCInstance(&error);
|
|
||||||
MOZ_ASSERT(U_SUCCESS(error), "failed to get ICU normalizer");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gfxFontEntry* entry = mFont->GetFontEntry();
|
gfxFontEntry* entry = mFont->GetFontEntry();
|
||||||
|
|
Загрузка…
Ссылка в новой задаче