diff options
author | Billy Hewlett <billyh@google.com> | 2012-06-04 15:56:42 -0700 |
---|---|---|
committer | Billy Hewlett <billyh@google.com> | 2012-06-04 17:18:33 -0700 |
commit | ca140956b75684db0cb9609af79b8e8956ae770a (patch) | |
tree | 09f5b1d77175f691c7d46bff6c9e8996c7310219 /Source | |
parent | be480525e35fed411698c2a58200b5d010f5ecde (diff) | |
download | external_webkit-ca140956b75684db0cb9609af79b8e8956ae770a.zip external_webkit-ca140956b75684db0cb9609af79b8e8956ae770a.tar.gz external_webkit-ca140956b75684db0cb9609af79b8e8956ae770a.tar.bz2 |
Fix hardcoded font path. Allow adding new font path thru Skia changes.
Bug: 6609231
Change-Id: I3ecaf2bc8c560588f38f4c3a49ede7fadd1ee81c
Diffstat (limited to 'Source')
-rw-r--r-- | Source/WebCore/platform/graphics/android/fonts/FontAndroid.cpp | 62 |
1 files changed, 15 insertions, 47 deletions
diff --git a/Source/WebCore/platform/graphics/android/fonts/FontAndroid.cpp b/Source/WebCore/platform/graphics/android/fonts/FontAndroid.cpp index e26fa9e..3350788 100644 --- a/Source/WebCore/platform/graphics/android/fonts/FontAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/fonts/FontAndroid.cpp @@ -45,6 +45,7 @@ #include "SkTypeface.h" #include "SkUtils.h" #include "TextRun.h" +#include "SkTypeface_android.h" #ifdef SUPPORT_COMPLEX_SCRIPTS #include "HarfbuzzSkia.h" @@ -460,25 +461,8 @@ public: } private: - enum CustomScript { - Bengali, - Devanagari, - Hebrew, - HebrewBold, - Kannada, - Malayalam, - Naskh, - Tamil, - TamilBold, - Telugu, - Thai, - NUM_SCRIPTS - }; - - static const char* paths[NUM_SCRIPTS]; - void setupFontForScriptRun(); - const FontPlatformData* setupComplexFont(CustomScript script, + const FontPlatformData* setupComplexFont(FallbackScripts script, const FontPlatformData& platformData); HB_FontRec* allocHarfbuzzFont(); void deleteGlyphArrays(); @@ -521,22 +505,6 @@ private: unsigned m_letterSpacing; // pixels to be added after each glyph. }; - -// Indexed using enum CustomScript -const char* TextRunWalker::paths[] = { - "/system/fonts/Lohit-Bengali.ttf", - "/system/fonts/DroidSansDevanagari-Regular.ttf", - "/system/fonts/DroidSansHebrew-Regular.ttf", - "/system/fonts/DroidSansHebrew-Bold.ttf", - "/system/fonts/Lohit-Kannada.ttf", - "/system/fonts/AnjaliNewLipi-light.ttf", - "/system/fonts/DroidNaskh-Regular.ttf", - "/system/fonts/DroidSansTamil-Regular.ttf", - "/system/fonts/DroidSansTamil-Bold.ttf", - "/system/fonts/Lohit-Telugu.ttf", - "/system/fonts/DroidSansThai.ttf" -}; - TextRunWalker::TextRunWalker(const TextRun& run, int startingX, int startingY, const Font* font) : m_font(font) , m_startingX(startingX) @@ -691,7 +659,7 @@ void TextRunWalker::setWordAndLetterSpacing(int wordSpacingAdjustment, } const FontPlatformData* TextRunWalker::setupComplexFont( - CustomScript script, + FallbackScripts script, const FontPlatformData& platformData) { static FallbackHash fallbackPlatformData; @@ -700,7 +668,7 @@ const FontPlatformData* TextRunWalker::setupComplexFont( FontPlatformData* newPlatformData = 0; if (!fallbackPlatformData.contains(key)) { - SkTypeface* typeface = SkTypeface::CreateFromFile(paths[script]); + SkTypeface* typeface = SkCreateTypefaceForScript(script); newPlatformData = new FontPlatformData(platformData, typeface); SkSafeUnref(typeface); fallbackPlatformData.set(key, newPlatformData); @@ -722,51 +690,51 @@ void TextRunWalker::setupFontForScriptRun() switch (m_item.item.script) { case HB_Script_Bengali: - complexPlatformData = setupComplexFont(Bengali, platformData); + complexPlatformData = setupComplexFont(kBengali_FallbackScript, platformData); break; case HB_Script_Devanagari: - complexPlatformData = setupComplexFont(Devanagari, platformData); + complexPlatformData = setupComplexFont(kDevanagari_FallbackScript, platformData); break; case HB_Script_Hebrew: switch (platformData.typeface()->style()) { case SkTypeface::kBold: case SkTypeface::kBoldItalic: - complexPlatformData = setupComplexFont(HebrewBold, platformData); + complexPlatformData = setupComplexFont(kHebrewBold_FallbackScript, platformData); break; case SkTypeface::kNormal: case SkTypeface::kItalic: default: - complexPlatformData = setupComplexFont(Hebrew, platformData); + complexPlatformData = setupComplexFont(kHebrewRegular_FallbackScript, platformData); break; } break; case HB_Script_Kannada: - complexPlatformData = setupComplexFont(Kannada, platformData); + complexPlatformData = setupComplexFont(kKannada_FallbackScript, platformData); break; case HB_Script_Malayalam: - complexPlatformData = setupComplexFont(Malayalam, platformData); + complexPlatformData = setupComplexFont(kMalayalam_FallbackScript, platformData); break; case HB_Script_Arabic: - complexPlatformData = setupComplexFont(Naskh, platformData); + complexPlatformData = setupComplexFont(kArabic_FallbackScript, platformData); break; case HB_Script_Tamil: switch (platformData.typeface()->style()) { case SkTypeface::kBold: case SkTypeface::kBoldItalic: - complexPlatformData = setupComplexFont(TamilBold, platformData); + complexPlatformData = setupComplexFont(kTamilBold_FallbackScript, platformData); break; case SkTypeface::kNormal: case SkTypeface::kItalic: default: - complexPlatformData = setupComplexFont(Tamil, platformData); + complexPlatformData = setupComplexFont(kTamilRegular_FallbackScript, platformData); break; } break; case HB_Script_Telugu: - complexPlatformData = setupComplexFont(Telugu, platformData); + complexPlatformData = setupComplexFont(kTelugu_FallbackScript, platformData); break; case HB_Script_Thai: - complexPlatformData = setupComplexFont(Thai, platformData); + complexPlatformData = setupComplexFont(kThai_FallbackScript, platformData); break; default: // HB_Script_Common; includes Ethiopic |