зеркало из https://github.com/mozilla/gecko-dev.git
bug 728866 - pt 1 - expose low-level APIs for canonical composition and decomposition of a single Unicode character. r=smontagu
--HG-- rename : intl/unicharutil/src/nsUnicodeNormalizer.h => intl/unicharutil/public/nsUnicodeNormalizer.h
This commit is contained in:
Родитель
50124fe16f
Коммит
2b957702c7
|
@ -48,6 +48,7 @@ EXPORTS = \
|
|||
nsICaseConversion.h \
|
||||
nsIUGenCategory.h \
|
||||
nsUnicharUtilCIID.h \
|
||||
nsUnicodeNormalizer.h \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
|
@ -57,6 +57,10 @@ public:
|
|||
NS_IMETHOD NormalizeUnicodeNFC( const nsAString& aSrc, nsAString& aDest);
|
||||
NS_IMETHOD NormalizeUnicodeNFKD( const nsAString& aSrc, nsAString& aDest);
|
||||
NS_IMETHOD NormalizeUnicodeNFKC( const nsAString& aSrc, nsAString& aDest);
|
||||
|
||||
// low-level access to the composition data needed for HarfBuzz callbacks
|
||||
static bool Compose(PRUint32 a, PRUint32 b, PRUint32 *ab);
|
||||
static bool DecomposeNonRecursively(PRUint32 comp, PRUint32 *c1, PRUint32 *c2);
|
||||
};
|
||||
|
||||
#endif //nsUnicodeNormalizer_h__
|
|
@ -713,3 +713,30 @@ nsUnicodeNormalizer::NormalizeUnicodeNFKC( const nsAString& aSrc, nsAString& aDe
|
|||
return mdn_normalize(true, true, aSrc, aDest);
|
||||
}
|
||||
|
||||
bool
|
||||
nsUnicodeNormalizer::Compose(PRUint32 a, PRUint32 b, PRUint32 *ab)
|
||||
{
|
||||
return mdn__unicode_compose(a, b, ab) == NS_OK;
|
||||
}
|
||||
|
||||
bool
|
||||
nsUnicodeNormalizer::DecomposeNonRecursively(PRUint32 c, PRUint32 *c1, PRUint32 *c2)
|
||||
{
|
||||
// We can't use mdn__unicode_decompose here, because that does a recursive
|
||||
// decomposition that may yield more than two characters, but the harfbuzz
|
||||
// callback wants just a single-step decomp that is guaranteed to produce
|
||||
// no more than two characters. So we do a low-level lookup in the table
|
||||
// of decomp sequences.
|
||||
const PRUint32 *seq;
|
||||
PRUint32 seqidx = decompose_char(c, &seq);
|
||||
if (seqidx == 0 || ((seqidx & DECOMP_COMPAT) != 0)) {
|
||||
return false;
|
||||
}
|
||||
*c1 = *seq & ~END_BIT;
|
||||
if (*seq & END_BIT) {
|
||||
*c2 = 0;
|
||||
} else {
|
||||
*c2 = *++seq & ~END_BIT;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче