OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 The Android Open Source Project | 2 * Copyright 2011 The Android Open Source Project |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SKFONTCONFIGPARSER_ANDROID_H_ | 8 #ifndef SkFontMgr_android_parser_DEFINED |
9 #define SKFONTCONFIGPARSER_ANDROID_H_ | 9 #define SkFontMgr_android_parser_DEFINED |
10 | 10 |
11 #include "SkFontMgr_android.h" | |
12 #include "SkString.h" | 11 #include "SkString.h" |
13 #include "SkTDArray.h" | 12 #include "SkTDArray.h" |
14 | 13 |
15 #include <climits> | 14 #include <climits> |
16 #include <limits> | 15 #include <limits> |
17 | 16 |
18 /** \class SkLanguage | 17 /** \class SkLanguage |
19 | 18 |
20 The SkLanguage class represents a human written language, and is used by | 19 The SkLanguage class represents a human written language, and is used by |
21 text draw operations to determine which glyph to draw when drawing | 20 text draw operations to determine which glyph to draw when drawing |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 : fVariant(kDefault_FontVariant) | 90 : fVariant(kDefault_FontVariant) |
92 , fOrder(-1) | 91 , fOrder(-1) |
93 , fIsFallbackFont(isFallbackFont) | 92 , fIsFallbackFont(isFallbackFont) |
94 , fBasePath(basePath) | 93 , fBasePath(basePath) |
95 { } | 94 { } |
96 | 95 |
97 SkTArray<SkString, true> fNames; | 96 SkTArray<SkString, true> fNames; |
98 SkTArray<FontFileInfo, true> fFonts; | 97 SkTArray<FontFileInfo, true> fFonts; |
99 SkLanguage fLanguage; | 98 SkLanguage fLanguage; |
100 FontVariant fVariant; | 99 FontVariant fVariant; |
101 int fOrder; // internal to SkFontConfigParser | 100 int fOrder; // internal to the parser, not useful to users. |
102 bool fIsFallbackFont; | 101 bool fIsFallbackFont; |
103 const SkString fBasePath; | 102 const SkString fBasePath; |
104 }; | 103 }; |
105 | 104 |
106 namespace SkFontConfigParser { | 105 namespace SkFontMgr_Android_Parser { |
107 | 106 |
108 /** Parses system font configuration files and appends result to fontFamilies. *
/ | 107 /** Parses system font configuration files and appends result to fontFamilies. *
/ |
109 void GetSystemFontFamilies(SkTDArray<FontFamily*>& fontFamilies); | 108 void GetSystemFontFamilies(SkTDArray<FontFamily*>& fontFamilies); |
110 | 109 |
111 /** Parses font configuration files and appends result to fontFamilies. */ | 110 /** Parses font configuration files and appends result to fontFamilies. */ |
112 void GetCustomFontFamilies(SkTDArray<FontFamily*>& fontFamilies, | 111 void GetCustomFontFamilies(SkTDArray<FontFamily*>& fontFamilies, |
113 const SkString& basePath, | 112 const SkString& basePath, |
114 const char* fontsXml, | 113 const char* fontsXml, |
115 const char* fallbackFontsXml, | 114 const char* fallbackFontsXml, |
116 const char* langFallbackFontsDir = NULL); | 115 const char* langFallbackFontsDir = NULL); |
117 | 116 |
118 } // SkFontConfigParser namespace | 117 } // SkFontMgr_Android_Parser namespace |
119 | 118 |
120 | 119 |
121 /** Parses a null terminated string into an integer type, checking for overflow. | 120 /** Parses a null terminated string into an integer type, checking for overflow. |
122 * http://www.w3.org/TR/html-markup/datatypes.html#common.data.integer.non-nega
tive-def | 121 * http://www.w3.org/TR/html-markup/datatypes.html#common.data.integer.non-nega
tive-def |
123 * | 122 * |
124 * If the string cannot be parsed into 'value', returns false and does not chan
ge 'value'. | 123 * If the string cannot be parsed into 'value', returns false and does not chan
ge 'value'. |
125 */ | 124 */ |
126 template <typename T> static bool parse_non_negative_integer(const char* s, T* v
alue) { | 125 template <typename T> static bool parse_non_negative_integer(const char* s, T* v
alue) { |
127 SK_COMPILE_ASSERT(std::numeric_limits<T>::is_integer, T_must_be_integer); | 126 SK_COMPILE_ASSERT(std::numeric_limits<T>::is_integer, T_must_be_integer); |
128 | 127 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 n = (n * 10) + d; | 205 n = (n * 10) + d; |
207 } | 206 } |
208 if (negate) { | 207 if (negate) { |
209 n = -n; | 208 n = -n; |
210 frac = -frac; | 209 frac = -frac; |
211 } | 210 } |
212 *value = (n << N) + frac; | 211 *value = (n << N) + frac; |
213 return true; | 212 return true; |
214 } | 213 } |
215 | 214 |
216 #endif /* SKFONTCONFIGPARSER_ANDROID_H_ */ | 215 #endif /* SkFontMgr_android_parser_DEFINED */ |
OLD | NEW |