From e83a7ecfd739fd294e40470e9ed033195f2c5501 Mon Sep 17 00:00:00 2001 From: Derek Sollenberger Date: Mon, 28 Jul 2014 09:54:10 -0400 Subject: Remove unused code now that the android framework has move this logic elsewhere. R=tomhudson@google.com Review URL: https://codereview.chromium.org/424663005 --- include/ports/SkTypeface_android.h | 18 ---- src/ports/SkFontConfigInterface_android.cpp | 133 ---------------------------- 2 files changed, 151 deletions(-) diff --git a/include/ports/SkTypeface_android.h b/include/ports/SkTypeface_android.h index 2e04414f5a..843bf196b4 100644 --- a/include/ports/SkTypeface_android.h +++ b/include/ports/SkTypeface_android.h @@ -87,22 +87,4 @@ SkTypeface* SkGetTypefaceForGlyphID(uint16_t glyphID, const SkTypeface* origType int* lowerBounds = NULL, int* upperBounds = NULL); #endif // #ifdef SK_BUILD_FOR_ANDROID -#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK - -#include "SkPaintOptionsAndroid.h" -#include "../harfbuzz_ng/src/hb.h" - -/** - * Return a new typeface for a fallback script. If the script is - * not valid, or can not map to a font, returns null. - * @param script The harfbuzz script id. - * @param style The font style, for example bold - * @param elegant true if we want the web friendly elegant version of the font - * @return reference to the matching typeface. Caller must call - * unref() when they are done. - */ -SK_API SkTypeface* SkCreateTypefaceForScript(hb_script_t script, SkTypeface::Style style, - SkPaintOptionsAndroid::FontVariant fontVariant = SkPaintOptionsAndroid::kDefault_Variant); - -#endif // #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK #endif // #ifndef SkTypeface_android_DEFINED diff --git a/src/ports/SkFontConfigInterface_android.cpp b/src/ports/SkFontConfigInterface_android.cpp index 94662f5d59..3f169e137a 100644 --- a/src/ports/SkFontConfigInterface_android.cpp +++ b/src/ports/SkFontConfigInterface_android.cpp @@ -774,136 +774,3 @@ SkTypeface* SkGetTypefaceForGlyphID(uint16_t glyphID, const SkTypeface* origType return fontConfig->getTypefaceForGlyphID(glyphID, origTypeface, options, lowerBounds, upperBounds); } - -/////////////////////////////////////////////////////////////////////////////// - -#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK - -struct HB_UnicodeMapping { - hb_script_t script; - const SkUnichar unicode; -}; - -/* - * The following scripts are not complex fonts and we do not expect them to be parsed by this table - * HB_SCRIPT_COMMON, - * HB_SCRIPT_GREEK, - * HB_SCRIPT_CYRILLIC, - * HB_SCRIPT_HANGUL - * HB_SCRIPT_INHERITED - */ - -/* Harfbuzz (old) is missing a number of scripts in its table. For these, - * we include a value which can never happen. We won't get complex script - * shaping in these cases, but the library wouldn't know how to shape - * them anyway. */ -#define HB_Script_Unknown HB_ScriptCount - -static HB_UnicodeMapping HB_UnicodeMappingArray[] = { - {HB_SCRIPT_ARMENIAN, 0x0531}, - {HB_SCRIPT_HEBREW, 0x0591}, - {HB_SCRIPT_ARABIC, 0x0600}, - {HB_SCRIPT_SYRIAC, 0x0710}, - {HB_SCRIPT_THAANA, 0x0780}, - {HB_SCRIPT_NKO, 0x07C0}, - {HB_SCRIPT_DEVANAGARI, 0x0901}, - {HB_SCRIPT_BENGALI, 0x0981}, - {HB_SCRIPT_GURMUKHI, 0x0A10}, - {HB_SCRIPT_GUJARATI, 0x0A90}, - {HB_SCRIPT_ORIYA, 0x0B10}, - {HB_SCRIPT_TAMIL, 0x0B82}, - {HB_SCRIPT_TELUGU, 0x0C10}, - {HB_SCRIPT_KANNADA, 0x0C90}, - {HB_SCRIPT_MALAYALAM, 0x0D10}, - {HB_SCRIPT_SINHALA, 0x0D90}, - {HB_SCRIPT_THAI, 0x0E01}, - {HB_SCRIPT_LAO, 0x0E81}, - {HB_SCRIPT_TIBETAN, 0x0F00}, - {HB_SCRIPT_MYANMAR, 0x1000}, - {HB_SCRIPT_GEORGIAN, 0x10A0}, - {HB_SCRIPT_ETHIOPIC, 0x1200}, - {HB_SCRIPT_CHEROKEE, 0x13A0}, - {HB_SCRIPT_OGHAM, 0x1680}, - {HB_SCRIPT_RUNIC, 0x16A0}, - {HB_SCRIPT_KHMER, 0x1780}, - {HB_SCRIPT_TAI_LE, 0x1950}, - {HB_SCRIPT_NEW_TAI_LUE, 0x1980}, - {HB_SCRIPT_TAI_THAM, 0x1A20}, - {HB_SCRIPT_CHAM, 0xAA00}, -}; - -// returns 0 for "Not Found" -static SkUnichar getUnicodeFromHBScript(hb_script_t script) { - SkUnichar unichar = 0; - int numSupportedFonts = sizeof(HB_UnicodeMappingArray) / sizeof(HB_UnicodeMapping); - for (int i = 0; i < numSupportedFonts; i++) { - if (script == HB_UnicodeMappingArray[i].script) { - unichar = HB_UnicodeMappingArray[i].unicode; - break; - } - } - return unichar; -} - -struct TypefaceLookupStruct { - hb_script_t script; - SkTypeface::Style style; - SkPaintOptionsAndroid::FontVariant fontVariant; - SkTypeface* typeface; -}; - -SK_DECLARE_STATIC_MUTEX(gTypefaceTableMutex); // This is the mutex for gTypefaceTable -static SkTDArray gTypefaceTable; // This is protected by gTypefaceTableMutex - -static int typefaceLookupCompare(const TypefaceLookupStruct& first, - const TypefaceLookupStruct& second) { - if (first.script != second.script) { - return (first.script > second.script) ? 1 : -1; - } - if (first.style != second.style) { - return (first.style > second.style) ? 1 : -1; - } - if (first.fontVariant != second.fontVariant) { - return (first.fontVariant > second.fontVariant) ? 1 : -1; - } - return 0; -} - -SkTypeface* SkCreateTypefaceForScript(hb_script_t script, SkTypeface::Style style, - SkPaintOptionsAndroid::FontVariant fontVariant) { - SkAutoMutexAcquire ac(gTypefaceTableMutex); - - TypefaceLookupStruct key; - key.script = script; - key.style = style; - key.fontVariant = fontVariant; - - int index = SkTSearch( - (const TypefaceLookupStruct*) gTypefaceTable.begin(), - gTypefaceTable.count(), key, sizeof(TypefaceLookupStruct), - typefaceLookupCompare); - - SkTypeface* retTypeface = NULL; - if (index >= 0) { - retTypeface = gTypefaceTable[index].typeface; - } - else { - SkUnichar unichar = getUnicodeFromHBScript(script); - if (!unichar) { - return NULL; - } - - SkFontConfigInterfaceAndroid* fontConfig = getSingletonInterface(); - retTypeface = fontConfig->getTypefaceForChar(unichar, style, fontVariant); - - // add to the lookup table - key.typeface = retTypeface; - *gTypefaceTable.insert(~index) = key; - } - - // we ref(), the caller is expected to unref when they are done - return SkSafeRef(retTypeface); -} - -#endif - -- cgit v1.2.3