blob: 9c188d90c63efa803810fc7b30d7bce1c06df49a [file] [log] [blame]
djsollen@google.combfae9d32013-05-21 16:53:50 +00001
2/*
3 * Copyright 2013 The Android Open Source Project
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
9#include "SkFontConfigInterface.h"
10#include "SkTypeface_android.h"
11
12#include "SkFontConfigParser_android.h"
13#include "SkFontConfigTypeface.h"
14#include "SkFontMgr.h"
15#include "SkGlyphCache.h"
16#include "SkPaint.h"
djsollen@google.combfae9d32013-05-21 16:53:50 +000017#include "SkString.h"
18#include "SkStream.h"
19#include "SkThread.h"
20#include "SkTypefaceCache.h"
21#include "SkTArray.h"
22#include "SkTDict.h"
23#include "SkTSearch.h"
24
25#include <stdio.h>
26#include <string.h>
27
28#ifndef SK_DEBUG_FONTS
29 #define SK_DEBUG_FONTS 0
30#endif
31
32#if SK_DEBUG_FONTS
33 #define DEBUG_FONT(args) SkDebugf args
34#else
35 #define DEBUG_FONT(args)
36#endif
37
38///////////////////////////////////////////////////////////////////////////////
39
40// For test only.
41static const char* gTestMainConfigFile = NULL;
42static const char* gTestFallbackConfigFile = NULL;
43static const char* gTestFontFilePrefix = NULL;
44
45///////////////////////////////////////////////////////////////////////////////
46
djsollen@google.com40078cb2013-05-24 20:31:57 +000047typedef int32_t FontRecID;
48#define INVALID_FONT_REC_ID -1
49
50typedef int32_t FamilyRecID;
51#define INVALID_FAMILY_REC_ID -1
52
djsollen@google.combfae9d32013-05-21 16:53:50 +000053// used to record our notion of the pre-existing fonts
54struct FontRec {
55 SkRefPtr<SkTypeface> fTypeface;
56 SkString fFileName;
57 SkTypeface::Style fStyle;
djsollen@google.combfae9d32013-05-21 16:53:50 +000058 bool fIsValid;
djsollen@google.com40078cb2013-05-24 20:31:57 +000059 FamilyRecID fFamilyRecID;
djsollen@google.combfae9d32013-05-21 16:53:50 +000060};
61
djsollen@google.combfae9d32013-05-21 16:53:50 +000062struct FamilyRec {
63 FamilyRec() {
64 memset(fFontRecID, INVALID_FONT_REC_ID, sizeof(fFontRecID));
65 }
66
67 static const int FONT_STYLE_COUNT = 4;
68 FontRecID fFontRecID[FONT_STYLE_COUNT];
djsollen@google.comb27eba72013-09-06 12:59:50 +000069 bool fIsFallbackFont;
djsollen@google.com39a7c702013-09-24 20:08:47 +000070 SkString fFallbackName;
djsollen@google.comb27eba72013-09-06 12:59:50 +000071 SkPaintOptionsAndroid fPaintOptions;
djsollen@google.combfae9d32013-05-21 16:53:50 +000072};
73
djsollen@google.combfae9d32013-05-21 16:53:50 +000074
djsollen@google.comb27eba72013-09-06 12:59:50 +000075typedef SkTDArray<FamilyRecID> FallbackFontList;
djsollen@google.combfae9d32013-05-21 16:53:50 +000076
77class SkFontConfigInterfaceAndroid : public SkFontConfigInterface {
78public:
79 SkFontConfigInterfaceAndroid(SkTDArray<FontFamily*>& fontFamilies);
80 virtual ~SkFontConfigInterfaceAndroid();
81
82 virtual bool matchFamilyName(const char familyName[],
83 SkTypeface::Style requested,
84 FontIdentity* outFontIdentifier,
85 SkString* outFamilyName,
86 SkTypeface::Style* outStyle) SK_OVERRIDE;
87 virtual SkStream* openStream(const FontIdentity&) SK_OVERRIDE;
88
89 // new APIs
90 virtual SkDataTable* getFamilyNames() SK_OVERRIDE;
91 virtual bool matchFamilySet(const char inFamilyName[],
92 SkString* outFamilyName,
93 SkTArray<FontIdentity>*) SK_OVERRIDE;
94
95 /**
96 * Get the family name of the font in the default fallback font list that
97 * contains the specified chararacter. if no font is found, returns false.
98 */
djsollen@google.com9902c382013-09-19 18:22:30 +000099 bool getFallbackFamilyNameForChar(SkUnichar uni, const char* lang, SkString* name);
djsollen@google.combfae9d32013-05-21 16:53:50 +0000100 /**
101 *
102 */
103 SkTypeface* getTypefaceForChar(SkUnichar uni, SkTypeface::Style style,
104 SkPaintOptionsAndroid::FontVariant fontVariant);
105 SkTypeface* nextLogicalTypeface(SkFontID currFontID, SkFontID origFontID,
106 const SkPaintOptionsAndroid& options);
djsollen@google.com5df5e612013-10-03 14:42:24 +0000107 SkTypeface* getTypefaceForGlyphID(uint16_t glyphID, const SkTypeface* origTypeface,
108 const SkPaintOptionsAndroid& options,
109 int* lowerBounds, int* upperBounds);
djsollen@google.combfae9d32013-05-21 16:53:50 +0000110
111private:
djsollen@google.comb27eba72013-09-06 12:59:50 +0000112 void addFallbackFamily(FamilyRecID fontRecID);
djsollen@google.com40078cb2013-05-24 20:31:57 +0000113 SkTypeface* getTypefaceForFontRec(FontRecID fontRecID);
djsollen@google.com9a70f342013-06-25 18:07:45 +0000114 FallbackFontList* getCurrentLocaleFallbackFontList();
djsollen@google.com40078cb2013-05-24 20:31:57 +0000115 FallbackFontList* findFallbackFontList(const SkLanguage& lang, bool isOriginal = true);
djsollen@google.combfae9d32013-05-21 16:53:50 +0000116
117 SkTArray<FontRec> fFonts;
118 SkTArray<FamilyRec> fFontFamilies;
119 SkTDict<FamilyRecID> fFamilyNameDict;
120 FamilyRecID fDefaultFamilyRecID;
121
122 // (SkLanguage)<->(fallback chain index) translation
123 SkTDict<FallbackFontList*> fFallbackFontDict;
djsollen@google.com40078cb2013-05-24 20:31:57 +0000124 SkTDict<FallbackFontList*> fFallbackFontAliasDict;
djsollen@google.combfae9d32013-05-21 16:53:50 +0000125 FallbackFontList fDefaultFallbackList;
djsollen@google.com9a70f342013-06-25 18:07:45 +0000126
127 // fallback info for current locale
128 SkString fCachedLocale;
129 FallbackFontList* fLocaleFallbackFontList;
djsollen@google.combfae9d32013-05-21 16:53:50 +0000130};
131
132///////////////////////////////////////////////////////////////////////////////
133
134static SkFontConfigInterfaceAndroid* getSingletonInterface() {
135 SK_DECLARE_STATIC_MUTEX(gMutex);
136 static SkFontConfigInterfaceAndroid* gFontConfigInterface;
137
138 SkAutoMutexAcquire ac(gMutex);
139 if (NULL == gFontConfigInterface) {
140 // load info from a configuration file that we can use to populate the
141 // system/fallback font structures
142 SkTDArray<FontFamily*> fontFamilies;
143 if (!gTestMainConfigFile) {
144 SkFontConfigParser::GetFontFamilies(fontFamilies);
145 } else {
146 SkFontConfigParser::GetTestFontFamilies(fontFamilies, gTestMainConfigFile,
147 gTestFallbackConfigFile);
148 }
149
150 gFontConfigInterface = new SkFontConfigInterfaceAndroid(fontFamilies);
151
152 // cleanup the data we received from the parser
153 fontFamilies.deleteAll();
154 }
155 return gFontConfigInterface;
156}
157
158SkFontConfigInterface* SkFontConfigInterface::GetSingletonDirectInterface() {
159 return getSingletonInterface();
160}
161
162///////////////////////////////////////////////////////////////////////////////
163
164static bool has_font(const SkTArray<FontRec>& array, const SkString& filename) {
165 for (int i = 0; i < array.count(); i++) {
166 if (array[i].fFileName == filename) {
167 return true;
168 }
169 }
170 return false;
171}
172
173#ifndef SK_FONT_FILE_PREFIX
174 #define SK_FONT_FILE_PREFIX "/fonts/"
175#endif
176
177static void get_path_for_sys_fonts(SkString* full, const char name[]) {
178 if (gTestFontFilePrefix) {
179 full->set(gTestFontFilePrefix);
180 } else {
181 full->set(getenv("ANDROID_ROOT"));
182 full->append(SK_FONT_FILE_PREFIX);
183 }
184 full->append(name);
185}
186
187static void insert_into_name_dict(SkTDict<FamilyRecID>& familyNameDict,
188 const char* name, FamilyRecID familyRecID) {
189 SkAutoAsciiToLC tolc(name);
djsollen@google.com92e3f082013-08-27 17:40:03 +0000190 if (familyNameDict.find(tolc.lc())) {
191 SkDebugf("---- system font attempting to use a the same name [%s] for"
192 "multiple families. skipping subsequent occurrences", tolc.lc());
193 } else {
194 familyNameDict.set(tolc.lc(), familyRecID);
195 }
djsollen@google.combfae9d32013-05-21 16:53:50 +0000196}
197
198// Defined in SkFontHost_FreeType.cpp
199bool find_name_and_attributes(SkStream* stream, SkString* name,
200 SkTypeface::Style* style, bool* isFixedWidth);
201
202///////////////////////////////////////////////////////////////////////////////
203
204SkFontConfigInterfaceAndroid::SkFontConfigInterfaceAndroid(SkTDArray<FontFamily*>& fontFamilies) :
205 fFonts(fontFamilies.count()),
206 fFontFamilies(fontFamilies.count() / FamilyRec::FONT_STYLE_COUNT),
207 fFamilyNameDict(1024),
208 fDefaultFamilyRecID(INVALID_FAMILY_REC_ID),
djsollen@google.com40078cb2013-05-24 20:31:57 +0000209 fFallbackFontDict(128),
djsollen@google.com9a70f342013-06-25 18:07:45 +0000210 fFallbackFontAliasDict(128),
211 fLocaleFallbackFontList(NULL) {
djsollen@google.combfae9d32013-05-21 16:53:50 +0000212
213 for (int i = 0; i < fontFamilies.count(); ++i) {
214 FontFamily* family = fontFamilies[i];
215
216 // defer initializing the familyRec until we can be sure that at least
217 // one of it's children contains a valid font file
218 FamilyRec* familyRec = NULL;
219 FamilyRecID familyRecID = INVALID_FAMILY_REC_ID;
220
221 for (int j = 0; j < family->fFontFiles.count(); ++j) {
222 SkString filename;
223 get_path_for_sys_fonts(&filename, family->fFontFiles[j]->fFileName);
224
225 if (has_font(fFonts, filename)) {
226 SkDebugf("---- system font and fallback font files specify a duplicate "
227 "font %s, skipping the second occurrence", filename.c_str());
228 continue;
229 }
230
231 FontRec& fontRec = fFonts.push_back();
232 fontRec.fFileName = filename;
233 fontRec.fStyle = SkTypeface::kNormal;
djsollen@google.combfae9d32013-05-21 16:53:50 +0000234 fontRec.fIsValid = false;
djsollen@google.com40078cb2013-05-24 20:31:57 +0000235 fontRec.fFamilyRecID = familyRecID;
djsollen@google.combfae9d32013-05-21 16:53:50 +0000236
237 const FontRecID fontRecID = fFonts.count() - 1;
238
239 SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(filename.c_str()));
240 if (stream.get() != NULL) {
241 bool isFixedWidth;
242 SkString name;
243 fontRec.fIsValid = find_name_and_attributes(stream.get(), &name,
244 &fontRec.fStyle, &isFixedWidth);
245 } else {
djsollen@google.comb27eba72013-09-06 12:59:50 +0000246 if (!family->fIsFallbackFont) {
djsollen@google.combfae9d32013-05-21 16:53:50 +0000247 SkDebugf("---- failed to open <%s> as a font\n", filename.c_str());
248 }
249 }
250
251 if (fontRec.fIsValid) {
252 DEBUG_FONT(("---- SystemFonts[%d][%d] fallback=%d file=%s",
djsollen@google.com9902c382013-09-19 18:22:30 +0000253 i, fFonts.count() - 1, family->fIsFallbackFont, filename.c_str()));
djsollen@google.combfae9d32013-05-21 16:53:50 +0000254 } else {
255 DEBUG_FONT(("---- SystemFonts[%d][%d] fallback=%d file=%s (INVALID)",
djsollen@google.com9902c382013-09-19 18:22:30 +0000256 i, fFonts.count() - 1, family->fIsFallbackFont, filename.c_str()));
djsollen@google.combfae9d32013-05-21 16:53:50 +0000257 continue;
258 }
259
260 // create a familyRec now that we know that at least one font in
261 // the family is valid
262 if (familyRec == NULL) {
263 familyRec = &fFontFamilies.push_back();
264 familyRecID = fFontFamilies.count() - 1;
djsollen@google.com40078cb2013-05-24 20:31:57 +0000265 fontRec.fFamilyRecID = familyRecID;
djsollen@google.comb27eba72013-09-06 12:59:50 +0000266
267 familyRec->fIsFallbackFont = family->fIsFallbackFont;
268 familyRec->fPaintOptions = family->fFontFiles[j]->fPaintOptions;
269
djsollen@google.comb27eba72013-09-06 12:59:50 +0000270 } else if (familyRec->fPaintOptions != family->fFontFiles[j]->fPaintOptions) {
271 SkDebugf("Every font file within a family must have identical"
272 "language and variant attributes");
273 sk_throw();
djsollen@google.combfae9d32013-05-21 16:53:50 +0000274 }
275
276 // add this font to the current familyRec
277 if (INVALID_FONT_REC_ID != familyRec->fFontRecID[fontRec.fStyle]) {
278 DEBUG_FONT(("Overwriting familyRec for style[%d] old,new:(%d,%d)",
279 fontRec.fStyle, familyRec->fFontRecID[fontRec.fStyle],
280 fontRecID));
281 }
282 familyRec->fFontRecID[fontRec.fStyle] = fontRecID;
djsollen@google.combfae9d32013-05-21 16:53:50 +0000283 }
284
djsollen@google.com39a7c702013-09-24 20:08:47 +0000285 if (familyRec) {
286 if (familyRec->fIsFallbackFont) {
287 // add the font to the appropriate fallback chains and also insert a
288 // unique name into the familyNameDict for internal usage
289 addFallbackFamily(familyRecID);
290 } else {
291 // add the names that map to this family to the dictionary for easy lookup
292 const SkTDArray<const char*>& names = family->fNames;
293 if (names.isEmpty()) {
294 SkDEBUGFAIL("ERROR: non-fallback font with no name");
295 continue;
296 }
djsollen@google.combfae9d32013-05-21 16:53:50 +0000297
djsollen@google.com39a7c702013-09-24 20:08:47 +0000298 for (int i = 0; i < names.count(); i++) {
299 insert_into_name_dict(fFamilyNameDict, names[i], familyRecID);
300 }
djsollen@google.combfae9d32013-05-21 16:53:50 +0000301 }
302 }
djsollen@google.combfae9d32013-05-21 16:53:50 +0000303 }
304
305 DEBUG_FONT(("---- We have %d system fonts", fFonts.count()));
306
307 if (fFontFamilies.count() > 0) {
308 fDefaultFamilyRecID = 0;
309 }
310
311 // scans the default fallback font chain, adding every entry to every other
312 // fallback font chain to which it does not belong. this results in every
313 // language-specific fallback font chain having all of its fallback fonts at
314 // the front of the chain, and everything else at the end.
315 FallbackFontList* fallbackList;
316 SkTDict<FallbackFontList*>::Iter iter(fFallbackFontDict);
317 const char* fallbackLang = iter.next(&fallbackList);
318 while(fallbackLang != NULL) {
319 for (int i = 0; i < fDefaultFallbackList.count(); i++) {
djsollen@google.comb27eba72013-09-06 12:59:50 +0000320 FamilyRecID familyRecID = fDefaultFallbackList[i];
321 const SkString& fontLang = fFontFamilies[familyRecID].fPaintOptions.getLanguage().getTag();
djsollen@google.combfae9d32013-05-21 16:53:50 +0000322 if (strcmp(fallbackLang, fontLang.c_str()) != 0) {
djsollen@google.comb27eba72013-09-06 12:59:50 +0000323 fallbackList->push(familyRecID);
djsollen@google.combfae9d32013-05-21 16:53:50 +0000324 }
325 }
326 // move to the next fallback list in the dictionary
327 fallbackLang = iter.next(&fallbackList);
328 }
329}
330
331SkFontConfigInterfaceAndroid::~SkFontConfigInterfaceAndroid() {
332 // iterate through and cleanup fFallbackFontDict
333 SkTDict<FallbackFontList*>::Iter iter(fFallbackFontDict);
334 FallbackFontList* fallbackList;
335 while(iter.next(&fallbackList) != NULL) {
336 SkDELETE(fallbackList);
337 }
338}
339
djsollen@google.comb27eba72013-09-06 12:59:50 +0000340void SkFontConfigInterfaceAndroid::addFallbackFamily(FamilyRecID familyRecID) {
341 SkASSERT(familyRecID < fFontFamilies.count());
djsollen@google.com39a7c702013-09-24 20:08:47 +0000342 FamilyRec& familyRec = fFontFamilies[familyRecID];
djsollen@google.comb27eba72013-09-06 12:59:50 +0000343 SkASSERT(familyRec.fIsFallbackFont);
djsollen@google.combfae9d32013-05-21 16:53:50 +0000344
djsollen@google.com39a7c702013-09-24 20:08:47 +0000345 // add the fallback family to the name dictionary. This is
346 // needed by getFallbackFamilyNameForChar() so that fallback
347 // families can be identified by a unique name. The unique
348 // identifier that we've chosen is the familyID in hex (e.g. '0F##fallback').
349 familyRec.fFallbackName.printf("%.2x##fallback", familyRecID);
350 insert_into_name_dict(fFamilyNameDict, familyRec.fFallbackName.c_str(), familyRecID);
351
djsollen@google.combfae9d32013-05-21 16:53:50 +0000352 // add to the default fallback list
djsollen@google.comb27eba72013-09-06 12:59:50 +0000353 fDefaultFallbackList.push(familyRecID);
djsollen@google.combfae9d32013-05-21 16:53:50 +0000354
355 // stop here if it is the default language tag
djsollen@google.comb27eba72013-09-06 12:59:50 +0000356 const SkString& languageTag = familyRec.fPaintOptions.getLanguage().getTag();
djsollen@google.combfae9d32013-05-21 16:53:50 +0000357 if (languageTag.isEmpty()) {
358 return;
359 }
360
361 // add to the appropriate language's custom fallback list
362 FallbackFontList* customList = NULL;
363 if (!fFallbackFontDict.find(languageTag.c_str(), &customList)) {
364 DEBUG_FONT(("---- Created fallback list for \"%s\"", languageTag.c_str()));
365 customList = SkNEW(FallbackFontList);
366 fFallbackFontDict.set(languageTag.c_str(), customList);
367 }
368 SkASSERT(customList != NULL);
djsollen@google.comb27eba72013-09-06 12:59:50 +0000369 customList->push(familyRecID);
djsollen@google.combfae9d32013-05-21 16:53:50 +0000370}
371
372
373static FontRecID find_best_style(const FamilyRec& family, SkTypeface::Style style) {
374
375 const FontRecID* fontRecIDs = family.fFontRecID;
376
377 if (fontRecIDs[style] != INVALID_FONT_REC_ID) { // exact match
378 return fontRecIDs[style];
379 }
380 // look for a matching bold
381 style = (SkTypeface::Style)(style ^ SkTypeface::kItalic);
382 if (fontRecIDs[style] != INVALID_FONT_REC_ID) {
383 return fontRecIDs[style];
384 }
385 // look for the plain
386 if (fontRecIDs[SkTypeface::kNormal] != INVALID_FONT_REC_ID) {
387 return fontRecIDs[SkTypeface::kNormal];
388 }
389 // look for anything
390 for (int i = 0; i < FamilyRec::FONT_STYLE_COUNT; i++) {
391 if (fontRecIDs[i] != INVALID_FONT_REC_ID) {
392 return fontRecIDs[i];
393 }
394 }
395 // should never get here, since the fontRecID list should not be empty
396 SkDEBUGFAIL("No valid fonts exist for this family");
397 return -1;
398}
399
400bool SkFontConfigInterfaceAndroid::matchFamilyName(const char familyName[],
401 SkTypeface::Style style,
402 FontIdentity* outFontIdentifier,
403 SkString* outFamilyName,
robertphillips@google.comb7457d02013-05-22 00:12:43 +0000404 SkTypeface::Style* outStyle) {
djsollen@google.combfae9d32013-05-21 16:53:50 +0000405 // clip to legal style bits
406 style = (SkTypeface::Style)(style & SkTypeface::kBoldItalic);
407
408 bool exactNameMatch = false;
409
410 FamilyRecID familyRecID = INVALID_FAMILY_REC_ID;
411 if (NULL != familyName) {
djsollen@google.com2e08f192013-05-21 20:08:10 +0000412 SkAutoAsciiToLC tolc(familyName);
413 if (fFamilyNameDict.find(tolc.lc(), &familyRecID)) {
djsollen@google.combfae9d32013-05-21 16:53:50 +0000414 exactNameMatch = true;
415 }
416 } else {
417 familyRecID = fDefaultFamilyRecID;
418
419 }
420
djsollen@google.com1f584ed2013-09-19 12:08:40 +0000421 // If no matching family name is found then return false. This allows clients
422 // to be able to search for other fonts instead of forcing them to use the
423 // default font.
djsollen@google.combfae9d32013-05-21 16:53:50 +0000424 if (INVALID_FAMILY_REC_ID == familyRecID) {
djsollen@google.com1f584ed2013-09-19 12:08:40 +0000425 return false;
djsollen@google.combfae9d32013-05-21 16:53:50 +0000426 }
427
428 FontRecID fontRecID = find_best_style(fFontFamilies[familyRecID], style);
429 FontRec& fontRec = fFonts[fontRecID];
430
431 if (NULL != outFontIdentifier) {
432 outFontIdentifier->fID = fontRecID;
433 outFontIdentifier->fTTCIndex = 0;
434 outFontIdentifier->fString.set(fontRec.fFileName);
435// outFontIdentifier->fStyle = fontRec.fStyle;
436 }
437
438 if (NULL != outFamilyName) {
439 if (exactNameMatch) {
440 outFamilyName->set(familyName);
441 } else {
442 // find familyName from list of names
443 const char* familyName = NULL;
djsollen@google.comab6eeb92013-05-21 17:15:27 +0000444 SkAssertResult(fFamilyNameDict.findKey(familyRecID, &familyName));
445 SkASSERT(familyName);
djsollen@google.combfae9d32013-05-21 16:53:50 +0000446 outFamilyName->set(familyName);
447 }
448 }
449
450 if (NULL != outStyle) {
451 *outStyle = fontRec.fStyle;
452 }
453
454 return true;
455}
456
robertphillips@google.comb7457d02013-05-22 00:12:43 +0000457SkStream* SkFontConfigInterfaceAndroid::openStream(const FontIdentity& identity) {
djsollen@google.combfae9d32013-05-21 16:53:50 +0000458 return SkStream::NewFromFile(identity.fString.c_str());
459}
460
robertphillips@google.comb7457d02013-05-22 00:12:43 +0000461SkDataTable* SkFontConfigInterfaceAndroid::getFamilyNames() {
djsollen@google.combfae9d32013-05-21 16:53:50 +0000462 SkTDArray<const char*> names;
463 SkTDArray<size_t> sizes;
464
465 SkTDict<FamilyRecID>::Iter iter(fFamilyNameDict);
466 const char* familyName = iter.next(NULL);
467 while(familyName != NULL) {
468 *names.append() = familyName;
469 *sizes.append() = strlen(familyName) + 1;
470
471 // move to the next familyName in the dictionary
472 familyName = iter.next(NULL);
473 }
474
475 return SkDataTable::NewCopyArrays((const void*const*)names.begin(),
476 sizes.begin(), names.count());
477}
478
479bool SkFontConfigInterfaceAndroid::matchFamilySet(const char inFamilyName[],
480 SkString* outFamilyName,
robertphillips@google.comb7457d02013-05-22 00:12:43 +0000481 SkTArray<FontIdentity>*) {
djsollen@google.combfae9d32013-05-21 16:53:50 +0000482 return false;
483}
484
djsollen@google.com40078cb2013-05-24 20:31:57 +0000485static bool find_proc(SkTypeface* face, SkTypeface::Style style, void* ctx) {
486 const FontRecID* fontRecID = (const FontRecID*)ctx;
487 FontRecID currFontRecID = ((FontConfigTypeface*)face)->getIdentity().fID;
488 return currFontRecID == *fontRecID;
489}
490
491SkTypeface* SkFontConfigInterfaceAndroid::getTypefaceForFontRec(FontRecID fontRecID) {
492 FontRec& fontRec = fFonts[fontRecID];
djsollen@google.combfae9d32013-05-21 16:53:50 +0000493 SkTypeface* face = fontRec.fTypeface.get();
494 if (!face) {
djsollen@google.com40078cb2013-05-24 20:31:57 +0000495 // look for it in the typeface cache
496 face = SkTypefaceCache::FindByProcAndRef(find_proc, &fontRecID);
djsollen@google.combfae9d32013-05-21 16:53:50 +0000497
498 // if it is not in the cache then create it
djsollen@google.com40078cb2013-05-24 20:31:57 +0000499 if (!face) {
500 const char* familyName = NULL;
501 SkAssertResult(fFamilyNameDict.findKey(fontRec.fFamilyRecID, &familyName));
502 SkASSERT(familyName);
503 face = SkTypeface::CreateFromName(familyName, fontRec.fStyle);
504 }
djsollen@google.combfae9d32013-05-21 16:53:50 +0000505
506 // store the result for subsequent lookups
507 fontRec.fTypeface = face;
508 }
509 SkASSERT(face);
510 return face;
511}
512
djsollen@google.com9902c382013-09-19 18:22:30 +0000513bool SkFontConfigInterfaceAndroid::getFallbackFamilyNameForChar(SkUnichar uni,
514 const char* lang,
515 SkString* name) {
516 FallbackFontList* fallbackFontList = this->findFallbackFontList(lang);
djsollen@google.com9a70f342013-06-25 18:07:45 +0000517 for (int i = 0; i < fallbackFontList->count(); i++) {
djsollen@google.comb27eba72013-09-06 12:59:50 +0000518 FamilyRecID familyRecID = fallbackFontList->getAt(i);
djsollen@google.com9902c382013-09-19 18:22:30 +0000519
520 // if it is not one of the accepted variants then move to the next family
521 int32_t acceptedVariants = SkPaintOptionsAndroid::kDefault_Variant |
522 SkPaintOptionsAndroid::kElegant_Variant;
523 if (!(fFontFamilies[familyRecID].fPaintOptions.getFontVariant() & acceptedVariants)) {
524 continue;
525 }
526
djsollen@google.comb27eba72013-09-06 12:59:50 +0000527 FontRecID fontRecID = find_best_style(fFontFamilies[familyRecID], SkTypeface::kNormal);
djsollen@google.com40078cb2013-05-24 20:31:57 +0000528 SkTypeface* face = this->getTypefaceForFontRec(fontRecID);
djsollen@google.combfae9d32013-05-21 16:53:50 +0000529
530 SkPaint paint;
531 paint.setTypeface(face);
532 paint.setTextEncoding(SkPaint::kUTF32_TextEncoding);
533
534 uint16_t glyphID;
535 paint.textToGlyphs(&uni, sizeof(uni), &glyphID);
536 if (glyphID != 0) {
djsollen@google.com39a7c702013-09-24 20:08:47 +0000537 name->set(fFontFamilies[familyRecID].fFallbackName);
djsollen@google.combfae9d32013-05-21 16:53:50 +0000538 return true;
539 }
540 }
541 return false;
542}
543
544SkTypeface* SkFontConfigInterfaceAndroid::getTypefaceForChar(SkUnichar uni,
545 SkTypeface::Style style,
546 SkPaintOptionsAndroid::FontVariant fontVariant) {
547 FontRecID fontRecID = find_best_style(fFontFamilies[fDefaultFamilyRecID], style);
djsollen@google.com40078cb2013-05-24 20:31:57 +0000548 SkTypeface* face = this->getTypefaceForFontRec(fontRecID);
djsollen@google.combfae9d32013-05-21 16:53:50 +0000549
550 SkPaintOptionsAndroid paintOptions;
551 paintOptions.setFontVariant(fontVariant);
552 paintOptions.setUseFontFallbacks(true);
553
554 SkPaint paint;
555 paint.setTypeface(face);
556 paint.setTextEncoding(SkPaint::kUTF16_TextEncoding);
557 paint.setPaintOptionsAndroid(paintOptions);
558
559 SkAutoGlyphCache autoCache(paint, NULL, NULL);
560 SkGlyphCache* cache = autoCache.getCache();
561
562 SkScalerContext* ctx = cache->getScalerContext();
563 if (ctx) {
564 SkFontID fontID = ctx->findTypefaceIdForChar(uni);
565 return SkTypefaceCache::FindByID(fontID);
566 }
567 return NULL;
568}
569
djsollen@google.com9a70f342013-06-25 18:07:45 +0000570FallbackFontList* SkFontConfigInterfaceAndroid::getCurrentLocaleFallbackFontList() {
571 SkString locale = SkFontConfigParser::GetLocale();
572 if (NULL == fLocaleFallbackFontList || locale != fCachedLocale) {
573 fCachedLocale = locale;
574 fLocaleFallbackFontList = this->findFallbackFontList(locale);
575 }
576 return fLocaleFallbackFontList;
577}
578
djsollen@google.com40078cb2013-05-24 20:31:57 +0000579FallbackFontList* SkFontConfigInterfaceAndroid::findFallbackFontList(const SkLanguage& lang,
580 bool isOriginal) {
djsollen@google.combfae9d32013-05-21 16:53:50 +0000581 const SkString& langTag = lang.getTag();
582 if (langTag.isEmpty()) {
583 return &fDefaultFallbackList;
584 }
585
586 FallbackFontList* fallbackFontList;
djsollen@google.com40078cb2013-05-24 20:31:57 +0000587 if (fFallbackFontDict.find(langTag.c_str(), langTag.size(), &fallbackFontList) ||
588 fFallbackFontAliasDict.find(langTag.c_str(), langTag.size(), &fallbackFontList)) {
djsollen@google.combfae9d32013-05-21 16:53:50 +0000589 return fallbackFontList;
590 }
591
592 // attempt a recursive fuzzy match
djsollen@google.combfae9d32013-05-21 16:53:50 +0000593 SkLanguage parent = lang.getParent();
djsollen@google.com40078cb2013-05-24 20:31:57 +0000594 fallbackFontList = findFallbackFontList(parent, false);
595
596 // cache the original lang so we don't have to do the recursion again.
597 if (isOriginal) {
598 DEBUG_FONT(("---- Created fallback list alias for \"%s\"", langTag.c_str()));
599 fFallbackFontAliasDict.set(langTag.c_str(), fallbackFontList);
600 }
601 return fallbackFontList;
djsollen@google.combfae9d32013-05-21 16:53:50 +0000602}
603
604SkTypeface* SkFontConfigInterfaceAndroid::nextLogicalTypeface(SkFontID currFontID,
605 SkFontID origFontID,
606 const SkPaintOptionsAndroid& opts) {
607 // Skia does not support font fallback by default. This enables clients such
608 // as WebKit to customize their font selection. In any case, clients can use
609 // GetFallbackFamilyNameForChar() to get the fallback font for individual
610 // characters.
611 if (!opts.isUsingFontFallbacks()) {
612 return NULL;
613 }
614
djsollen@google.combfae9d32013-05-21 16:53:50 +0000615 FallbackFontList* currentFallbackList = findFallbackFontList(opts.getLanguage());
616 SkASSERT(currentFallbackList);
617
djsollen@google.comb27eba72013-09-06 12:59:50 +0000618 SkTypeface::Style origStyle = SkTypeface::kNormal;
619 const SkTypeface* origTypeface = SkTypefaceCache::FindByID(origFontID);
620 if (NULL != origTypeface) {
621 origStyle = origTypeface->style();
622 }
623
djsollen@google.combfae9d32013-05-21 16:53:50 +0000624 // we must convert currTypeface into a FontRecID
djsollen@google.come47e7d12013-06-06 21:25:09 +0000625 FontRecID currFontRecID = INVALID_FONT_REC_ID;
626 const SkTypeface* currTypeface = SkTypefaceCache::FindByID(currFontID);
627 // non-system fonts are not in the font cache so if we are asked to fallback
628 // for a non-system font we will start at the front of the chain.
djsollen@google.com29bf8622013-07-31 15:48:10 +0000629 if (NULL != currTypeface && currFontID != origFontID) {
djsollen@google.come47e7d12013-06-06 21:25:09 +0000630 currFontRecID = ((FontConfigTypeface*)currTypeface)->getIdentity().fID;
631 SkASSERT(INVALID_FONT_REC_ID != currFontRecID);
632 }
djsollen@google.combfae9d32013-05-21 16:53:50 +0000633
djsollen@google.comb27eba72013-09-06 12:59:50 +0000634 FamilyRecID currFamilyRecID = INVALID_FAMILY_REC_ID;
635 if (INVALID_FONT_REC_ID != currFontRecID) {
636 currFamilyRecID = fFonts[currFontRecID].fFamilyRecID;
637 }
638
djsollen@google.come47e7d12013-06-06 21:25:09 +0000639 // lookup the index next font in the chain
djsollen@google.comb27eba72013-09-06 12:59:50 +0000640 int currFallbackFontIndex = currentFallbackList->find(currFamilyRecID);
djsollen@google.come47e7d12013-06-06 21:25:09 +0000641 // We add 1 to the returned index for 2 reasons: (1) if find succeeds it moves
642 // our index to the next entry in the list; (2) if find() fails it returns
643 // -1 and incrementing it will set our starting index to 0 (the head of the list)
djsollen@google.combfae9d32013-05-21 16:53:50 +0000644 int nextFallbackFontIndex = currFallbackFontIndex + 1;
djsollen@google.combfae9d32013-05-21 16:53:50 +0000645
djsollen@google.com40078cb2013-05-24 20:31:57 +0000646 if(nextFallbackFontIndex >= currentFallbackList->count()) {
djsollen@google.combfae9d32013-05-21 16:53:50 +0000647 return NULL;
648 }
649
650 // If a rec object is set to prefer "kDefault_Variant" it means they have no preference
651 // In this case, we set the value to "kCompact_Variant"
652 SkPaintOptionsAndroid::FontVariant variant = opts.getFontVariant();
653 if (variant == SkPaintOptionsAndroid::kDefault_Variant) {
654 variant = SkPaintOptionsAndroid::kCompact_Variant;
655 }
656
657 int32_t acceptedVariants = SkPaintOptionsAndroid::kDefault_Variant | variant;
658
659 SkTypeface* nextLogicalTypeface = 0;
660 while (nextFallbackFontIndex < currentFallbackList->count()) {
djsollen@google.comb27eba72013-09-06 12:59:50 +0000661 FamilyRecID familyRecID = currentFallbackList->getAt(nextFallbackFontIndex);
662 if ((fFontFamilies[familyRecID].fPaintOptions.getFontVariant() & acceptedVariants) != 0) {
663 FontRecID matchedFont = find_best_style(fFontFamilies[familyRecID], origStyle);
664 nextLogicalTypeface = this->getTypefaceForFontRec(matchedFont);
djsollen@google.combfae9d32013-05-21 16:53:50 +0000665 break;
666 }
667 nextFallbackFontIndex++;
668 }
669
670 DEBUG_FONT(("---- nextLogicalFont: currFontID=%d, origFontID=%d, currRecID=%d, "
djsollen@google.com40078cb2013-05-24 20:31:57 +0000671 "lang=%s, variant=%d, nextFallbackIndex[%d,%d] => nextLogicalTypeface=%d",
djsollen@google.combfae9d32013-05-21 16:53:50 +0000672 currFontID, origFontID, currFontRecID, opts.getLanguage().getTag().c_str(),
djsollen@google.com40078cb2013-05-24 20:31:57 +0000673 variant, nextFallbackFontIndex, currentFallbackList->getAt(nextFallbackFontIndex),
djsollen@google.combfae9d32013-05-21 16:53:50 +0000674 (nextLogicalTypeface) ? nextLogicalTypeface->uniqueID() : 0));
675 return SkSafeRef(nextLogicalTypeface);
676}
677
djsollen@google.com5df5e612013-10-03 14:42:24 +0000678SkTypeface* SkFontConfigInterfaceAndroid::getTypefaceForGlyphID(uint16_t glyphID,
679 const SkTypeface* origTypeface,
680 const SkPaintOptionsAndroid& opts,
681 int* lBounds, int* uBounds) {
682 // If we aren't using fallbacks then we shouldn't be calling this
683 SkASSERT(opts.isUsingFontFallbacks());
684 SkASSERT(origTypeface);
685
686 SkTypeface* currentTypeface = NULL;
687 int lowerBounds = 0; //inclusive
688 int upperBounds = origTypeface->countGlyphs(); //exclusive
689
690 // check to see if the glyph is in the bounds of the origTypeface
691 if (glyphID < upperBounds) {
692 currentTypeface = const_cast<SkTypeface*>(origTypeface);
693 } else {
694 FallbackFontList* currentFallbackList = findFallbackFontList(opts.getLanguage());
695 SkASSERT(currentFallbackList);
696
697 // If an object is set to prefer "kDefault_Variant" it means they have no preference
698 // In this case, we set the value to "kCompact_Variant"
699 SkPaintOptionsAndroid::FontVariant variant = opts.getFontVariant();
700 if (variant == SkPaintOptionsAndroid::kDefault_Variant) {
701 variant = SkPaintOptionsAndroid::kCompact_Variant;
702 }
703
704 int32_t acceptedVariants = SkPaintOptionsAndroid::kDefault_Variant | variant;
705 SkTypeface::Style origStyle = origTypeface->style();
706
707 for (int x = 0; x < currentFallbackList->count(); ++x) {
708 const FamilyRecID familyRecID = currentFallbackList->getAt(x);
709 const SkPaintOptionsAndroid& familyOptions = fFontFamilies[familyRecID].fPaintOptions;
710 if ((familyOptions.getFontVariant() & acceptedVariants) != 0) {
711 FontRecID matchedFont = find_best_style(fFontFamilies[familyRecID], origStyle);
712 currentTypeface = this->getTypefaceForFontRec(matchedFont);
713 lowerBounds = upperBounds;
714 upperBounds += currentTypeface->countGlyphs();
715 if (glyphID < upperBounds) {
716 break;
717 }
718 }
719 }
720 }
721
722 if (NULL != currentTypeface) {
723 if (lBounds) {
724 *lBounds = lowerBounds;
725 }
726 if (uBounds) {
727 *uBounds = upperBounds;
728 }
729 }
730 return currentTypeface;
731}
732
djsollen@google.combfae9d32013-05-21 16:53:50 +0000733///////////////////////////////////////////////////////////////////////////////
734
735bool SkGetFallbackFamilyNameForChar(SkUnichar uni, SkString* name) {
djsollen@google.com9902c382013-09-19 18:22:30 +0000736 SkString locale = SkFontConfigParser::GetLocale();
djsollen@google.combfae9d32013-05-21 16:53:50 +0000737 SkFontConfigInterfaceAndroid* fontConfig = getSingletonInterface();
djsollen@google.com9902c382013-09-19 18:22:30 +0000738 return fontConfig->getFallbackFamilyNameForChar(uni, locale.c_str(), name);
739}
740
741bool SkGetFallbackFamilyNameForChar(SkUnichar uni, const char* lang, SkString* name) {
742 SkFontConfigInterfaceAndroid* fontConfig = getSingletonInterface();
743 return fontConfig->getFallbackFamilyNameForChar(uni, lang, name);
djsollen@google.combfae9d32013-05-21 16:53:50 +0000744}
745
746void SkUseTestFontConfigFile(const char* mainconf, const char* fallbackconf,
747 const char* fontsdir) {
748 gTestMainConfigFile = mainconf;
749 gTestFallbackConfigFile = fallbackconf;
750 gTestFontFilePrefix = fontsdir;
751 SkASSERT(gTestMainConfigFile);
752 SkASSERT(gTestFallbackConfigFile);
753 SkASSERT(gTestFontFilePrefix);
754 SkDEBUGF(("Use Test Config File Main %s, Fallback %s, Font Dir %s",
755 gTestMainConfigFile, gTestFallbackConfigFile, gTestFontFilePrefix));
756}
757
758SkTypeface* SkAndroidNextLogicalTypeface(SkFontID currFontID, SkFontID origFontID,
759 const SkPaintOptionsAndroid& options) {
760 SkFontConfigInterfaceAndroid* fontConfig = getSingletonInterface();
761 return fontConfig->nextLogicalTypeface(currFontID, origFontID, options);
762
763}
764
djsollen@google.com5df5e612013-10-03 14:42:24 +0000765SkTypeface* SkGetTypefaceForGlyphID(uint16_t glyphID, const SkTypeface* origTypeface,
766 const SkPaintOptionsAndroid& options,
767 int* lowerBounds, int* upperBounds) {
768 SkFontConfigInterfaceAndroid* fontConfig = getSingletonInterface();
769 return fontConfig->getTypefaceForGlyphID(glyphID, origTypeface, options,
770 lowerBounds, upperBounds);
771}
772
djsollen@google.combfae9d32013-05-21 16:53:50 +0000773///////////////////////////////////////////////////////////////////////////////
774
djsollen@google.com40078cb2013-05-24 20:31:57 +0000775#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
776
777struct HB_UnicodeMapping {
778 // TODO: when the WebView no longer needs harfbuzz_old, remove
779 HB_Script script_old;
780 hb_script_t script;
781 const SkUnichar unicode;
782};
783
784/*
785 * The following scripts are not complex fonts and we do not expect them to be parsed by this table
786 * HB_SCRIPT_COMMON,
787 * HB_SCRIPT_GREEK,
788 * HB_SCRIPT_CYRILLIC,
789 * HB_SCRIPT_HANGUL
790 * HB_SCRIPT_INHERITED
791 */
792
793/* Harfbuzz (old) is missing a number of scripts in its table. For these,
794 * we include a value which can never happen. We won't get complex script
795 * shaping in these cases, but the library wouldn't know how to shape
796 * them anyway. */
797#define HB_Script_Unknown HB_ScriptCount
798
799static HB_UnicodeMapping HB_UnicodeMappingArray[] = {
800 {HB_Script_Armenian, HB_SCRIPT_ARMENIAN, 0x0531},
801 {HB_Script_Hebrew, HB_SCRIPT_HEBREW, 0x0591},
802 {HB_Script_Arabic, HB_SCRIPT_ARABIC, 0x0600},
803 {HB_Script_Syriac, HB_SCRIPT_SYRIAC, 0x0710},
804 {HB_Script_Thaana, HB_SCRIPT_THAANA, 0x0780},
805 {HB_Script_Nko, HB_SCRIPT_NKO, 0x07C0},
806 {HB_Script_Devanagari, HB_SCRIPT_DEVANAGARI, 0x0901},
807 {HB_Script_Bengali, HB_SCRIPT_BENGALI, 0x0981},
808 {HB_Script_Gurmukhi, HB_SCRIPT_GURMUKHI, 0x0A10},
809 {HB_Script_Gujarati, HB_SCRIPT_GUJARATI, 0x0A90},
810 {HB_Script_Oriya, HB_SCRIPT_ORIYA, 0x0B10},
811 {HB_Script_Tamil, HB_SCRIPT_TAMIL, 0x0B82},
812 {HB_Script_Telugu, HB_SCRIPT_TELUGU, 0x0C10},
813 {HB_Script_Kannada, HB_SCRIPT_KANNADA, 0x0C90},
814 {HB_Script_Malayalam, HB_SCRIPT_MALAYALAM, 0x0D10},
815 {HB_Script_Sinhala, HB_SCRIPT_SINHALA, 0x0D90},
816 {HB_Script_Thai, HB_SCRIPT_THAI, 0x0E01},
817 {HB_Script_Lao, HB_SCRIPT_LAO, 0x0E81},
818 {HB_Script_Tibetan, HB_SCRIPT_TIBETAN, 0x0F00},
819 {HB_Script_Myanmar, HB_SCRIPT_MYANMAR, 0x1000},
820 {HB_Script_Georgian, HB_SCRIPT_GEORGIAN, 0x10A0},
821 {HB_Script_Unknown, HB_SCRIPT_ETHIOPIC, 0x1200},
822 {HB_Script_Unknown, HB_SCRIPT_CHEROKEE, 0x13A0},
823 {HB_Script_Ogham, HB_SCRIPT_OGHAM, 0x1680},
824 {HB_Script_Runic, HB_SCRIPT_RUNIC, 0x16A0},
825 {HB_Script_Khmer, HB_SCRIPT_KHMER, 0x1780},
826 {HB_Script_Unknown, HB_SCRIPT_TAI_LE, 0x1950},
827 {HB_Script_Unknown, HB_SCRIPT_NEW_TAI_LUE, 0x1980},
828 {HB_Script_Unknown, HB_SCRIPT_TAI_THAM, 0x1A20},
829 {HB_Script_Unknown, HB_SCRIPT_CHAM, 0xAA00},
830};
831
832static hb_script_t getHBScriptFromHBScriptOld(HB_Script script_old) {
833 hb_script_t script = HB_SCRIPT_INVALID;
834 int numSupportedFonts = sizeof(HB_UnicodeMappingArray) / sizeof(HB_UnicodeMapping);
835 for (int i = 0; i < numSupportedFonts; i++) {
836 if (script_old == HB_UnicodeMappingArray[i].script_old) {
837 script = HB_UnicodeMappingArray[i].script;
838 break;
839 }
840 }
841 return script;
842}
843
844// returns 0 for "Not Found"
845static SkUnichar getUnicodeFromHBScript(hb_script_t script) {
846 SkUnichar unichar = 0;
847 int numSupportedFonts = sizeof(HB_UnicodeMappingArray) / sizeof(HB_UnicodeMapping);
848 for (int i = 0; i < numSupportedFonts; i++) {
849 if (script == HB_UnicodeMappingArray[i].script) {
850 unichar = HB_UnicodeMappingArray[i].unicode;
851 break;
852 }
853 }
854 return unichar;
855}
856
857struct TypefaceLookupStruct {
858 hb_script_t script;
859 SkTypeface::Style style;
860 SkPaintOptionsAndroid::FontVariant fontVariant;
861 SkTypeface* typeface;
862};
863
864SK_DECLARE_STATIC_MUTEX(gTypefaceTableMutex); // This is the mutex for gTypefaceTable
865static SkTDArray<TypefaceLookupStruct> gTypefaceTable; // This is protected by gTypefaceTableMutex
866
867static int typefaceLookupCompare(const TypefaceLookupStruct& first,
868 const TypefaceLookupStruct& second) {
869 if (first.script != second.script) {
870 return (first.script > second.script) ? 1 : -1;
871 }
872 if (first.style != second.style) {
873 return (first.style > second.style) ? 1 : -1;
874 }
875 if (first.fontVariant != second.fontVariant) {
876 return (first.fontVariant > second.fontVariant) ? 1 : -1;
877 }
878 return 0;
879}
880
881SkTypeface* SkCreateTypefaceForScriptNG(hb_script_t script, SkTypeface::Style style,
882 SkPaintOptionsAndroid::FontVariant fontVariant) {
883 SkAutoMutexAcquire ac(gTypefaceTableMutex);
884
885 TypefaceLookupStruct key;
886 key.script = script;
887 key.style = style;
888 key.fontVariant = fontVariant;
889
890 int index = SkTSearch<TypefaceLookupStruct>(
891 (const TypefaceLookupStruct*) gTypefaceTable.begin(),
892 gTypefaceTable.count(), key, sizeof(TypefaceLookupStruct),
893 typefaceLookupCompare);
894
895 SkTypeface* retTypeface = NULL;
896 if (index >= 0) {
897 retTypeface = gTypefaceTable[index].typeface;
898 }
899 else {
900 SkUnichar unichar = getUnicodeFromHBScript(script);
901 if (!unichar) {
902 return NULL;
903 }
904
905 SkFontConfigInterfaceAndroid* fontConfig = getSingletonInterface();
906 retTypeface = fontConfig->getTypefaceForChar(unichar, style, fontVariant);
907
908 // add to the lookup table
909 key.typeface = retTypeface;
910 *gTypefaceTable.insert(~index) = key;
911 }
912
913 // we ref(), the caller is expected to unref when they are done
914 return SkSafeRef(retTypeface);
915}
916
917SkTypeface* SkCreateTypefaceForScript(HB_Script script, SkTypeface::Style style,
918 SkPaintOptionsAndroid::FontVariant fontVariant) {
919 return SkCreateTypefaceForScriptNG(getHBScriptFromHBScriptOld(script), style, fontVariant);
920}
921
922#endif
923
924///////////////////////////////////////////////////////////////////////////////
925
djsollen@google.combfae9d32013-05-21 16:53:50 +0000926SkFontMgr* SkFontMgr::Factory() {
927 return NULL;
928}