1 /* 2 * Copyright 2012 Google Inc. 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 9 #ifndef SkTypeface_android_DEFINED 10 #define SkTypeface_android_DEFINED 11 12 #include "SkTypeface.h" 13 14 #ifdef SK_BUILD_FOR_ANDROID 15 16 class SkPaintOptionsAndroid; 17 18 /** 19 * Get the family name of the font in the fallback font list containing 20 * the specified character. if no font is found, returns false. 21 */ 22 SK_API bool SkGetFallbackFamilyNameForChar(SkUnichar uni, SkString* name); 23 24 /** 25 * For test only. 26 * Load font config from given xml files, instead of those from Android system. 27 */ 28 SK_API void SkUseTestFontConfigFile(const char* mainconf, const char* fallbackconf, 29 const char* fontsdir); 30 31 /** 32 * Given a "current" fontID, return a ref to the next logical typeface 33 * when searching fonts for a given unicode value. Typically the caller 34 * will query a given font, and if a unicode value is not supported, they 35 * will call this, and if 0 is not returned, will search that font, and so 36 * on. This process must be finite, and when the fonthost sees a 37 * font with no logical successor, it must return NULL. 38 * 39 * The original fontID is also provided. This is the initial font that was 40 * stored in the typeface of the caller. It is provided as an aid to choose 41 * the best next logical font. e.g. If the original font was bold or serif, 42 * but the 2nd in the logical chain was plain, then a subsequent call to 43 * get the 3rd can still inspect the original, and try to match its 44 * stylistic attributes. 45 */ 46 SkTypeface* SkAndroidNextLogicalTypeface(SkFontID currFontID, SkFontID origFontID, 47 const SkPaintOptionsAndroid& options); 48 49 #endif // #ifdef SK_BUILD_FOR_ANDROID 50 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK 51 52 #include "SkPaintOptionsAndroid.h" 53 #include "../harfbuzz/src/harfbuzz-shaper.h" 54 #include "../harfbuzz_ng/src/hb.h" 55 56 /** 57 * Return a new typeface for a fallback script. If the script is 58 * not valid, or can not map to a font, returns null. 59 * @param script The harfbuzz script id. 60 * @param style The font style, for example bold 61 * @param elegant true if we want the web friendly elegant version of the font 62 * @return reference to the matching typeface. Caller must call 63 * unref() when they are done. 64 */ 65 SK_API SkTypeface* SkCreateTypefaceForScriptNG(hb_script_t script, SkTypeface::Style style, 66 SkPaintOptionsAndroid::FontVariant fontVariant = SkPaintOptionsAndroid::kDefault_Variant); 67 68 SK_API SkTypeface* SkCreateTypefaceForScript(HB_Script script, SkTypeface::Style style, 69 SkPaintOptionsAndroid::FontVariant fontVariant = SkPaintOptionsAndroid::kDefault_Variant); 70 71 #endif // #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK 72 #endif // #ifndef SkTypeface_android_DEFINED 73