Make the use of fallback fonts in Android a runtime decision.
R=reed@google.com Review URL: https://codereview.chromium.org/14972022 git-svn-id: http://skia.googlecode.com/svn/trunk@9168 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
8371e704b7
commit
9401deeb10
@ -61,16 +61,20 @@ class SkPaintOptionsAndroid {
|
||||
public:
|
||||
SkPaintOptionsAndroid() {
|
||||
fFontVariant = kDefault_Variant;
|
||||
fUseFontFallbacks = false;
|
||||
}
|
||||
|
||||
SkPaintOptionsAndroid& operator=(const SkPaintOptionsAndroid& b) {
|
||||
fLanguage = b.fLanguage;
|
||||
fFontVariant = b.fFontVariant;
|
||||
fUseFontFallbacks = b.fUseFontFallbacks;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool operator!=(const SkPaintOptionsAndroid& b) const {
|
||||
return fLanguage != b.fLanguage || fFontVariant != b.fFontVariant;
|
||||
return fLanguage != b.fLanguage ||
|
||||
fFontVariant != b.fFontVariant ||
|
||||
fUseFontFallbacks != b.fUseFontFallbacks;
|
||||
}
|
||||
|
||||
void flatten(SkFlattenableWriteBuffer&) const;
|
||||
@ -108,9 +112,16 @@ public:
|
||||
fFontVariant = fontVariant;
|
||||
}
|
||||
|
||||
bool isUsingFontFallbacks() const { return fUseFontFallbacks; }
|
||||
|
||||
void setUseFontFallbacks(bool useFontFallbacks) {
|
||||
fUseFontFallbacks = useFontFallbacks;
|
||||
}
|
||||
|
||||
private:
|
||||
SkLanguage fLanguage;
|
||||
FontVariant fFontVariant;
|
||||
bool fUseFontFallbacks;
|
||||
};
|
||||
|
||||
#endif // #ifdef SK_BUILD_FOR_ANDROID
|
||||
|
@ -30,6 +30,7 @@ SkLanguage SkLanguage::getParent() const {
|
||||
void SkPaintOptionsAndroid::flatten(SkFlattenableWriteBuffer& buffer) const {
|
||||
buffer.writeUInt(fFontVariant);
|
||||
buffer.writeString(fLanguage.getTag().c_str());
|
||||
buffer.writeBool(fUseFontFallbacks);
|
||||
}
|
||||
|
||||
void SkPaintOptionsAndroid::unflatten(SkFlattenableReadBuffer& buffer) {
|
||||
@ -37,6 +38,7 @@ void SkPaintOptionsAndroid::unflatten(SkFlattenableReadBuffer& buffer) {
|
||||
char* tag = buffer.readString();
|
||||
fLanguage = SkLanguage(tag);
|
||||
sk_free(tag);
|
||||
fUseFontFallbacks = buffer.readBool();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -803,13 +803,14 @@ SkTypeface* SkFontHost::CreateTypeface(const SkTypeface* familyFace,
|
||||
|
||||
SkTypeface* SkAndroidNextLogicalTypeface(SkFontID currFontID, SkFontID origFontID,
|
||||
const SkPaintOptionsAndroid& options) {
|
||||
#if !defined(SK_BUILD_FOR_ANDROID_FRAMEWORK)
|
||||
// Skia does not support font fallback for ndk applications in order to
|
||||
// enable clients such as WebKit to customize their font selection.
|
||||
// Clients can use GetFallbackFamilyNameForChar() to get the fallback
|
||||
// Skia does not support font fallback by default for ndk applications. This
|
||||
// enables clients such as WebKit to customize their font selection. In any
|
||||
// case clients can use GetFallbackFamilyNameForChar() to get the fallback
|
||||
// font for individual characters.
|
||||
if (!options.isUsingFontFallbacks()) {
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
SkAutoMutexAcquire ac(gFamilyHeadAndNameListMutex);
|
||||
|
||||
load_system_fonts();
|
||||
|
Loading…
Reference in New Issue
Block a user