djsollen@google.com | ff02960 | 2012-03-15 15:49:51 +0000 | [diff] [blame] | 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 | enum FallbackScripts { |
| 15 | kArabic_FallbackScript, |
djsollen@google.com | 15eeca0 | 2012-06-01 12:52:26 +0000 | [diff] [blame] | 16 | kArmenian_FallbackScript, |
| 17 | kBengali_FallbackScript, |
| 18 | kDevanagari_FallbackScript, |
djsollen@google.com | ff02960 | 2012-03-15 15:49:51 +0000 | [diff] [blame] | 19 | kEthiopic_FallbackScript, |
djsollen@google.com | 15eeca0 | 2012-06-01 12:52:26 +0000 | [diff] [blame] | 20 | kGeorgian_FallbackScript, |
djsollen@google.com | ff02960 | 2012-03-15 15:49:51 +0000 | [diff] [blame] | 21 | kHebrewRegular_FallbackScript, |
| 22 | kHebrewBold_FallbackScript, |
djsollen@google.com | 15eeca0 | 2012-06-01 12:52:26 +0000 | [diff] [blame] | 23 | kKannada_FallbackScript, |
| 24 | kMalayalam_FallbackScript, |
| 25 | kTamilRegular_FallbackScript, |
| 26 | kTamilBold_FallbackScript, |
djsollen@google.com | ff02960 | 2012-03-15 15:49:51 +0000 | [diff] [blame] | 27 | kThai_FallbackScript, |
djsollen@google.com | 15eeca0 | 2012-06-01 12:52:26 +0000 | [diff] [blame] | 28 | kTelugu_FallbackScript, |
djsollen@google.com | ff02960 | 2012-03-15 15:49:51 +0000 | [diff] [blame] | 29 | kFallbackScriptNumber |
| 30 | }; |
| 31 | |
djsollen@google.com | c6ff3e7 | 2012-06-04 13:39:47 +0000 | [diff] [blame] | 32 | // This particular mapping will be removed after WebKit is updated to use the |
| 33 | // new mappings. No new caller should use the kTamil_FallbackScript but rather |
| 34 | // the more specific Tamil scripts in the standard enum. |
djsollen@google.com | da30999 | 2012-06-04 14:13:06 +0000 | [diff] [blame] | 35 | #define kTamil_FallbackScript kTamilRegular_FallbackScript |
djsollen@google.com | c6ff3e7 | 2012-06-04 13:39:47 +0000 | [diff] [blame] | 36 | |
djsollen@google.com | ff02960 | 2012-03-15 15:49:51 +0000 | [diff] [blame] | 37 | #define SkTypeface_ValidScript(s) (s >= 0 && s < kFallbackScriptNumber) |
| 38 | |
| 39 | /** |
| 40 | * Return a new typeface for a fallback script. If the script is |
| 41 | * not valid, or can not map to a font, returns null. |
| 42 | * @param script The script id. |
| 43 | * @return reference to the matching typeface. Caller must call |
| 44 | * unref() when they are done. |
| 45 | */ |
| 46 | SK_API SkTypeface* SkCreateTypefaceForScript(FallbackScripts script); |
| 47 | |
| 48 | /** |
| 49 | * Return the string representation for the fallback script on Android. |
| 50 | * If the script is not valid, returns null. |
| 51 | */ |
| 52 | SK_API const char* SkGetFallbackScriptID(FallbackScripts script); |
| 53 | |
| 54 | /** |
| 55 | * Return the fallback script enum for the ID on Android. |
| 56 | * If the ID is not valid, or can not map to a fallback |
| 57 | * script, returns kFallbackScriptNumber. |
| 58 | */ |
| 59 | SK_API FallbackScripts SkGetFallbackScriptFromID(const char* id); |
| 60 | |
djsollen@google.com | 5df2a99 | 2012-06-25 13:58:22 +0000 | [diff] [blame] | 61 | /** |
djsollen@google.com | bae1712 | 2012-10-09 19:26:59 +0000 | [diff] [blame^] | 62 | * Return a new typeface of the font in the fallback font list containing |
| 63 | * the specified chararacter. If no typeface is found, returns null. |
| 64 | */ |
| 65 | SK_API SkTypeface* SkCreateFallbackTypefaceForChar(SkUnichar uni, |
| 66 | SkTypeface::Style style); |
| 67 | |
| 68 | /** |
| 69 | * Get the family name of the font in the fallback font list containing |
| 70 | * the specified chararacter. if no font is found, returns false. |
| 71 | */ |
| 72 | SK_API bool SkGetFallbackFamilyNameForChar(SkUnichar uni, SkString* name); |
| 73 | |
| 74 | /** |
djsollen@google.com | 5df2a99 | 2012-06-25 13:58:22 +0000 | [diff] [blame] | 75 | * For test only. |
| 76 | * Load font config from given xml files, instead of those from Android system. |
| 77 | */ |
| 78 | SK_API void SkUseTestFontConfigFile(const char* mainconf, const char* fallbackconf, |
| 79 | const char* fontsdir); |
| 80 | |
djsollen@google.com | ff02960 | 2012-03-15 15:49:51 +0000 | [diff] [blame] | 81 | #endif |