blob: 1ee17e6eaa5ce7007d33eb7403c23566d0a31f5f [file] [log] [blame]
djsollen@google.comff029602012-03-15 15:49:51 +00001/*
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
14enum FallbackScripts {
15 kArabic_FallbackScript,
djsollen@google.com15eeca02012-06-01 12:52:26 +000016 kArmenian_FallbackScript,
17 kBengali_FallbackScript,
18 kDevanagari_FallbackScript,
djsollen@google.comff029602012-03-15 15:49:51 +000019 kEthiopic_FallbackScript,
djsollen@google.com15eeca02012-06-01 12:52:26 +000020 kGeorgian_FallbackScript,
djsollen@google.comff029602012-03-15 15:49:51 +000021 kHebrewRegular_FallbackScript,
22 kHebrewBold_FallbackScript,
djsollen@google.com15eeca02012-06-01 12:52:26 +000023 kKannada_FallbackScript,
24 kMalayalam_FallbackScript,
25 kTamilRegular_FallbackScript,
26 kTamilBold_FallbackScript,
djsollen@google.comff029602012-03-15 15:49:51 +000027 kThai_FallbackScript,
djsollen@google.com15eeca02012-06-01 12:52:26 +000028 kTelugu_FallbackScript,
djsollen@google.comff029602012-03-15 15:49:51 +000029 kFallbackScriptNumber
30};
31
djsollen@google.comc6ff3e72012-06-04 13:39:47 +000032// 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.comda309992012-06-04 14:13:06 +000035#define kTamil_FallbackScript kTamilRegular_FallbackScript
djsollen@google.comc6ff3e72012-06-04 13:39:47 +000036
djsollen@google.comff029602012-03-15 15:49:51 +000037#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 */
46SK_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 */
52SK_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 */
59SK_API FallbackScripts SkGetFallbackScriptFromID(const char* id);
60
djsollen@google.com5df2a992012-06-25 13:58:22 +000061/**
djsollen@google.combae17122012-10-09 19:26:59 +000062 * 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 */
65SK_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 */
72SK_API bool SkGetFallbackFamilyNameForChar(SkUnichar uni, SkString* name);
73
74/**
djsollen@google.com5df2a992012-06-25 13:58:22 +000075 * For test only.
76 * Load font config from given xml files, instead of those from Android system.
77 */
78SK_API void SkUseTestFontConfigFile(const char* mainconf, const char* fallbackconf,
79 const char* fontsdir);
80
djsollen@google.comff029602012-03-15 15:49:51 +000081#endif