From 960511848ade732f7dab838a1625729698c7c952 Mon Sep 17 00:00:00 2001 From: Billy Hewlett Date: Thu, 21 Jun 2012 09:58:42 -0700 Subject: [PATCH] Revert "Revert "Use Elegant fonts for Webkit, Compact fonts for Textview"" This reverts commit 6fadccd2484233ed570218b3f97c085ef1a1ec28 --- core/jni/android/graphics/TextLayoutCache.cpp | 35 ++++++++++++------- core/jni/android/graphics/TextLayoutCache.h | 2 +- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/core/jni/android/graphics/TextLayoutCache.cpp b/core/jni/android/graphics/TextLayoutCache.cpp index 023e6d127c4d4..5da4a0998be50 100644 --- a/core/jni/android/graphics/TextLayoutCache.cpp +++ b/core/jni/android/graphics/TextLayoutCache.cpp @@ -755,7 +755,8 @@ SkTypeface* TextLayoutShaper::typefaceForUnichar(const SkPaint* paint, SkTypefac // Set the correct Typeface depending on the script switch (script) { case HB_Script_Arabic: - typeface = getCachedTypeface(&mArabicTypeface, kArabic_FallbackScript); + typeface = getCachedTypeface(&mArabicTypeface, HB_Script_Arabic, + SkTypeface::kNormal); #if DEBUG_GLYPHS ALOGD("Using Arabic Typeface"); #endif @@ -766,7 +767,8 @@ SkTypeface* TextLayoutShaper::typefaceForUnichar(const SkPaint* paint, SkTypefac switch (typeface->style()) { case SkTypeface::kBold: case SkTypeface::kBoldItalic: - typeface = getCachedTypeface(&mHebrewBoldTypeface, kHebrewBold_FallbackScript); + typeface = getCachedTypeface(&mHebrewBoldTypeface, HB_Script_Hebrew, + SkTypeface::kBold); #if DEBUG_GLYPHS ALOGD("Using Hebrew Bold/BoldItalic Typeface"); #endif @@ -775,14 +777,16 @@ SkTypeface* TextLayoutShaper::typefaceForUnichar(const SkPaint* paint, SkTypefac case SkTypeface::kNormal: case SkTypeface::kItalic: default: - typeface = getCachedTypeface(&mHebrewRegularTypeface, kHebrewRegular_FallbackScript); + typeface = getCachedTypeface(&mHebrewRegularTypeface, HB_Script_Hebrew, + SkTypeface::kNormal); #if DEBUG_GLYPHS ALOGD("Using Hebrew Regular/Italic Typeface"); #endif break; } } else { - typeface = getCachedTypeface(&mHebrewRegularTypeface, kHebrewRegular_FallbackScript); + typeface = getCachedTypeface(&mHebrewRegularTypeface, HB_Script_Hebrew, + SkTypeface::kNormal); #if DEBUG_GLYPHS ALOGD("Using Hebrew Regular Typeface"); #endif @@ -790,21 +794,24 @@ SkTypeface* TextLayoutShaper::typefaceForUnichar(const SkPaint* paint, SkTypefac break; case HB_Script_Bengali: - typeface = getCachedTypeface(&mBengaliTypeface, kBengali_FallbackScript); + typeface = getCachedTypeface(&mBengaliTypeface, HB_Script_Bengali, + SkTypeface::kNormal); #if DEBUG_GLYPHS ALOGD("Using Bengali Typeface"); #endif break; case HB_Script_Thai: - typeface = getCachedTypeface(&mThaiTypeface, kThai_FallbackScript); + typeface = getCachedTypeface(&mThaiTypeface, HB_Script_Thai, + SkTypeface::kNormal); #if DEBUG_GLYPHS ALOGD("Using Thai Typeface"); #endif break; case HB_Script_Devanagari: - typeface = getCachedTypeface(&mDevanagariRegularTypeface, kDevanagari_FallbackScript); + typeface = getCachedTypeface(&mDevanagariRegularTypeface, HB_Script_Devanagari, + SkTypeface::kNormal); #if DEBUG_GLYPHS ALOGD("Using Devanagari Regular Typeface"); #endif @@ -815,7 +822,8 @@ SkTypeface* TextLayoutShaper::typefaceForUnichar(const SkPaint* paint, SkTypefac switch (typeface->style()) { case SkTypeface::kBold: case SkTypeface::kBoldItalic: - typeface = getCachedTypeface(&mTamilBoldTypeface, kTamilBold_FallbackScript); + typeface = getCachedTypeface(&mTamilBoldTypeface, HB_Script_Tamil, + SkTypeface::kBold); #if DEBUG_GLYPHS ALOGD("Using Tamil Bold Typeface"); #endif @@ -824,14 +832,16 @@ SkTypeface* TextLayoutShaper::typefaceForUnichar(const SkPaint* paint, SkTypefac case SkTypeface::kNormal: case SkTypeface::kItalic: default: - typeface = getCachedTypeface(&mTamilRegularTypeface, kTamilRegular_FallbackScript); + typeface = getCachedTypeface(&mTamilRegularTypeface, HB_Script_Tamil, + SkTypeface::kNormal); #if DEBUG_GLYPHS ALOGD("Using Tamil Regular Typeface"); #endif break; } } else { - typeface = getCachedTypeface(&mTamilRegularTypeface, kTamilRegular_FallbackScript); + typeface = getCachedTypeface(&mTamilRegularTypeface, HB_Script_Tamil, + SkTypeface::kNormal); #if DEBUG_GLYPHS ALOGD("Using Tamil Regular Typeface"); #endif @@ -949,9 +959,10 @@ void TextLayoutShaper::deleteShaperItemGlyphArrays() { delete[] mShaperItem.log_clusters; } -SkTypeface* TextLayoutShaper::getCachedTypeface(SkTypeface** typeface, FallbackScripts fallbackEnum) { +SkTypeface* TextLayoutShaper::getCachedTypeface(SkTypeface** typeface, HB_Script script, + SkTypeface::Style style) { if (!*typeface) { - *typeface = SkCreateTypefaceForScript(fallbackEnum); + *typeface = SkCreateTypefaceForScript(script, style); // CreateFromFile(path) can return NULL if the path is non existing if (!*typeface) { #if DEBUG_GLYPHS diff --git a/core/jni/android/graphics/TextLayoutCache.h b/core/jni/android/graphics/TextLayoutCache.h index 4f7ecdf97aeb4..3cac0746fe0a7 100644 --- a/core/jni/android/graphics/TextLayoutCache.h +++ b/core/jni/android/graphics/TextLayoutCache.h @@ -239,7 +239,7 @@ private: Vector* const outAdvances, jfloat* outTotalAdvance, Vector* const outGlyphs); - SkTypeface* getCachedTypeface(SkTypeface** typeface, FallbackScripts fallbackEnum); + SkTypeface* getCachedTypeface(SkTypeface** typeface, HB_Script script, SkTypeface::Style style); HB_Face getCachedHBFace(SkTypeface* typeface); void ensureShaperItemGlyphArrays(size_t size);