am 543c65c8: Try Unicode decomposition for selecting fallback font

* commit '543c65c80b71e3111314bf429004a10d004e861b':
  Try Unicode decomposition for selecting fallback font
This commit is contained in:
Raph Levien 2014-08-27 17:07:48 +00:00 committed by Android Git Automerger
commit 604053e564

View File

@ -19,6 +19,9 @@
#define LOG_TAG "Minikin"
#include <cutils/log.h>
#include "unicode/unistr.h"
#include "unicode/unorm2.h"
#include "MinikinInternal.h"
#include <minikin/CmapCoverage.h>
#include <minikin/FontCollection.h>
@ -143,7 +146,18 @@ const FontCollection::FontInstance* FontCollection::getInstanceForChar(uint32_t
}
}
}
if (bestInstance == NULL) {
if (bestInstance == NULL && !mInstanceVec.empty()) {
UErrorCode errorCode = U_ZERO_ERROR;
const UNormalizer2* normalizer = unorm2_getNFDInstance(&errorCode);
if (U_SUCCESS(errorCode)) {
UChar decomposed[4];
int len = unorm2_getRawDecomposition(normalizer, ch, decomposed, 4, &errorCode);
if (U_SUCCESS(errorCode) && len > 0) {
int off = 0;
U16_NEXT_UNSAFE(decomposed, off, ch);
return getInstanceForChar(ch, lang, variant);
}
}
bestInstance = &mInstances[0];
}
return bestInstance;