am c89eaf91: Merge "Fix for Typeface.create(Typeface, style) semantics changed in KK" into klp-dev
* commit 'c89eaf916ad7e88565d2a15991432b22cd9099ff': Fix for Typeface.create(Typeface, style) semantics changed in KK
This commit is contained in:
@@ -34,6 +34,13 @@ static SkTypeface* Typeface_create(JNIEnv* env, jobject, jstring name,
|
|||||||
if (NULL != name) {
|
if (NULL != name) {
|
||||||
AutoJavaStringToUTF8 str(env, name);
|
AutoJavaStringToUTF8 str(env, name);
|
||||||
face = SkTypeface::CreateFromName(str.c_str(), style);
|
face = SkTypeface::CreateFromName(str.c_str(), style);
|
||||||
|
// Try to find the closest matching font, using the standard heuristic
|
||||||
|
if (NULL == face) {
|
||||||
|
face = SkTypeface::CreateFromName(str.c_str(), (SkTypeface::Style)(style ^ SkTypeface::kItalic));
|
||||||
|
}
|
||||||
|
for (int i = 0; NULL == face && i < 4; i++) {
|
||||||
|
face = SkTypeface::CreateFromName(str.c_str(), (SkTypeface::Style)i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// return the default font at the best style if no exact match exists
|
// return the default font at the best style if no exact match exists
|
||||||
@@ -45,8 +52,13 @@ static SkTypeface* Typeface_create(JNIEnv* env, jobject, jstring name,
|
|||||||
|
|
||||||
static SkTypeface* Typeface_createFromTypeface(JNIEnv* env, jobject, SkTypeface* family, int style) {
|
static SkTypeface* Typeface_createFromTypeface(JNIEnv* env, jobject, SkTypeface* family, int style) {
|
||||||
SkTypeface* face = SkTypeface::CreateFromTypeface(family, (SkTypeface::Style)style);
|
SkTypeface* face = SkTypeface::CreateFromTypeface(family, (SkTypeface::Style)style);
|
||||||
// return the default font at the best style if the requested style does not
|
// Try to find the closest matching font, using the standard heuristic
|
||||||
// exist in the provided family
|
if (NULL == face) {
|
||||||
|
face = SkTypeface::CreateFromTypeface(family, (SkTypeface::Style)(style ^ SkTypeface::kItalic));
|
||||||
|
}
|
||||||
|
for (int i = 0; NULL == face && i < 4; i++) {
|
||||||
|
face = SkTypeface::CreateFromTypeface(family, (SkTypeface::Style)i);
|
||||||
|
}
|
||||||
if (NULL == face) {
|
if (NULL == face) {
|
||||||
face = SkTypeface::CreateFromName(NULL, (SkTypeface::Style)style);
|
face = SkTypeface::CreateFromName(NULL, (SkTypeface::Style)style);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user