blob: 6f9ed3a93b46bbf1987c7265cd2fbeb6d4bd2177 [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) {
commit-bot@chromium.orgc0445fe2013-10-07 19:49:13 +0000516 FallbackFontList* fallbackFontList = NULL;
517 const SkString langTag(lang);
518 if (langTag.isEmpty()) {
519 fallbackFontList = this->getCurrentLocaleFallbackFontList();
520 } else {
521 fallbackFontList = this->findFallbackFontList(langTag);
522 }
523
djsollen@google.com9a70f342013-06-25 18:07:45 +0000524 for (int i = 0; i < fallbackFontList->count(); i++) {
djsollen@google.comb27eba72013-09-06 12:59:50 +0000525 FamilyRecID familyRecID = fallbackFontList->getAt(i);
djsollen@google.com9902c382013-09-19 18:22:30 +0000526
527 // if it is not one of the accepted variants then move to the next family
528 int32_t acceptedVariants = SkPaintOptionsAndroid::kDefault_Variant |
529 SkPaintOptionsAndroid::kElegant_Variant;
530 if (!(fFontFamilies[familyRecID].fPaintOptions.getFontVariant() & acceptedVariants)) {
531 continue;
532 }
533
djsollen@google.comb27eba72013-09-06 12:59:50 +0000534 FontRecID fontRecID = find_best_style(fFontFamilies[familyRecID], SkTypeface::kNormal);
djsollen@google.com40078cb2013-05-24 20:31:57 +0000535 SkTypeface* face = this->getTypefaceForFontRec(fontRecID);
djsollen@google.combfae9d32013-05-21 16:53:50 +0000536
537 SkPaint paint;
538 paint.setTypeface(face);
539 paint.setTextEncoding(SkPaint::kUTF32_TextEncoding);
540
541 uint16_t glyphID;
542 paint.textToGlyphs(&uni, sizeof(uni), &glyphID);
543 if (glyphID != 0) {
djsollen@google.com39a7c702013-09-24 20:08:47 +0000544 name->set(fFontFamilies[familyRecID].fFallbackName);
djsollen@google.combfae9d32013-05-21 16:53:50 +0000545 return true;
546 }
547 }
548 return false;
549}
550
551SkTypeface* SkFontConfigInterfaceAndroid::getTypefaceForChar(SkUnichar uni,
552 SkTypeface::Style style,
553 SkPaintOptionsAndroid::FontVariant fontVariant) {
554 FontRecID fontRecID = find_best_style(fFontFamilies[fDefaultFamilyRecID], style);
djsollen@google.com40078cb2013-05-24 20:31:57 +0000555 SkTypeface* face = this->getTypefaceForFontRec(fontRecID);
djsollen@google.combfae9d32013-05-21 16:53:50 +0000556
557 SkPaintOptionsAndroid paintOptions;
558 paintOptions.setFontVariant(fontVariant);
559 paintOptions.setUseFontFallbacks(true);
560
561 SkPaint paint;
562 paint.setTypeface(face);
563 paint.setTextEncoding(SkPaint::kUTF16_TextEncoding);
564 paint.setPaintOptionsAndroid(paintOptions);
565
566 SkAutoGlyphCache autoCache(paint, NULL, NULL);
567 SkGlyphCache* cache = autoCache.getCache();
568
569 SkScalerContext* ctx = cache->getScalerContext();
570 if (ctx) {
571 SkFontID fontID = ctx->findTypefaceIdForChar(uni);
572 return SkTypefaceCache::FindByID(fontID);
573 }
574 return NULL;
575}
576
djsollen@google.com9a70f342013-06-25 18:07:45 +0000577FallbackFontList* SkFontConfigInterfaceAndroid::getCurrentLocaleFallbackFontList() {
578 SkString locale = SkFontConfigParser::GetLocale();
579 if (NULL == fLocaleFallbackFontList || locale != fCachedLocale) {
580 fCachedLocale = locale;
581 fLocaleFallbackFontList = this->findFallbackFontList(locale);
582 }
583 return fLocaleFallbackFontList;
584}
585
djsollen@google.com40078cb2013-05-24 20:31:57 +0000586FallbackFontList* SkFontConfigInterfaceAndroid::findFallbackFontList(const SkLanguage& lang,
587 bool isOriginal) {
djsollen@google.combfae9d32013-05-21 16:53:50 +0000588 const SkString& langTag = lang.getTag();
589 if (langTag.isEmpty()) {
590 return &fDefaultFallbackList;
591 }
592
593 FallbackFontList* fallbackFontList;
djsollen@google.com40078cb2013-05-24 20:31:57 +0000594 if (fFallbackFontDict.find(langTag.c_str(), langTag.size(), &fallbackFontList) ||
595 fFallbackFontAliasDict.find(langTag.c_str(), langTag.size(), &fallbackFontList)) {
djsollen@google.combfae9d32013-05-21 16:53:50 +0000596 return fallbackFontList;
597 }
598
599 // attempt a recursive fuzzy match
djsollen@google.combfae9d32013-05-21 16:53:50 +0000600 SkLanguage parent = lang.getParent();
djsollen@google.com40078cb2013-05-24 20:31:57 +0000601 fallbackFontList = findFallbackFontList(parent, false);
602
603 // cache the original lang so we don't have to do the recursion again.
604 if (isOriginal) {
605 DEBUG_FONT(("---- Created fallback list alias for \"%s\"", langTag.c_str()));
606 fFallbackFontAliasDict.set(langTag.c_str(), fallbackFontList);
607 }
608 return fallbackFontList;
djsollen@google.combfae9d32013-05-21 16:53:50 +0000609}
610
611SkTypeface* SkFontConfigInterfaceAndroid::nextLogicalTypeface(SkFontID currFontID,
612 SkFontID origFontID,
613 const SkPaintOptionsAndroid& opts) {
614 // Skia does not support font fallback by default. This enables clients such
615 // as WebKit to customize their font selection. In any case, clients can use
616 // GetFallbackFamilyNameForChar() to get the fallback font for individual
617 // characters.
618 if (!opts.isUsingFontFallbacks()) {
619 return NULL;
620 }
621
djsollen@google.combfae9d32013-05-21 16:53:50 +0000622 FallbackFontList* currentFallbackList = findFallbackFontList(opts.getLanguage());
623 SkASSERT(currentFallbackList);
624
djsollen@google.comb27eba72013-09-06 12:59:50 +0000625 SkTypeface::Style origStyle = SkTypeface::kNormal;
626 const SkTypeface* origTypeface = SkTypefaceCache::FindByID(origFontID);
627 if (NULL != origTypeface) {
628 origStyle = origTypeface->style();
629 }
630
djsollen@google.combfae9d32013-05-21 16:53:50 +0000631 // we must convert currTypeface into a FontRecID
djsollen@google.come47e7d12013-06-06 21:25:09 +0000632 FontRecID currFontRecID = INVALID_FONT_REC_ID;
633 const SkTypeface* currTypeface = SkTypefaceCache::FindByID(currFontID);
634 // non-system fonts are not in the font cache so if we are asked to fallback
635 // for a non-system font we will start at the front of the chain.
djsollen@google.com29bf8622013-07-31 15:48:10 +0000636 if (NULL != currTypeface && currFontID != origFontID) {
djsollen@google.come47e7d12013-06-06 21:25:09 +0000637 currFontRecID = ((FontConfigTypeface*)currTypeface)->getIdentity().fID;
638 SkASSERT(INVALID_FONT_REC_ID != currFontRecID);
639 }
djsollen@google.combfae9d32013-05-21 16:53:50 +0000640
djsollen@google.comb27eba72013-09-06 12:59:50 +0000641 FamilyRecID currFamilyRecID = INVALID_FAMILY_REC_ID;
642 if (INVALID_FONT_REC_ID != currFontRecID) {
643 currFamilyRecID = fFonts[currFontRecID].fFamilyRecID;
644 }
645
djsollen@google.come47e7d12013-06-06 21:25:09 +0000646 // lookup the index next font in the chain
djsollen@google.comb27eba72013-09-06 12:59:50 +0000647 int currFallbackFontIndex = currentFallbackList->find(currFamilyRecID);
djsollen@google.come47e7d12013-06-06 21:25:09 +0000648 // We add 1 to the returned index for 2 reasons: (1) if find succeeds it moves
649 // our index to the next entry in the list; (2) if find() fails it returns
650 // -1 and incrementing it will set our starting index to 0 (the head of the list)
djsollen@google.combfae9d32013-05-21 16:53:50 +0000651 int nextFallbackFontIndex = currFallbackFontIndex + 1;
djsollen@google.combfae9d32013-05-21 16:53:50 +0000652
djsollen@google.com40078cb2013-05-24 20:31:57 +0000653 if(nextFallbackFontIndex >= currentFallbackList->count()) {
djsollen@google.combfae9d32013-05-21 16:53:50 +0000654 return NULL;
655 }
656
657 // If a rec object is set to prefer "kDefault_Variant" it means they have no preference
658 // In this case, we set the value to "kCompact_Variant"
659 SkPaintOptionsAndroid::FontVariant variant = opts.getFontVariant();
660 if (variant == SkPaintOptionsAndroid::kDefault_Variant) {
661 variant = SkPaintOptionsAndroid::kCompact_Variant;
662 }
663
664 int32_t acceptedVariants = SkPaintOptionsAndroid::kDefault_Variant | variant;
665
666 SkTypeface* nextLogicalTypeface = 0;
667 while (nextFallbackFontIndex < currentFallbackList->count()) {
djsollen@google.comb27eba72013-09-06 12:59:50 +0000668 FamilyRecID familyRecID = currentFallbackList->getAt(nextFallbackFontIndex);
669 if ((fFontFamilies[familyRecID].fPaintOptions.getFontVariant() & acceptedVariants) != 0) {
670 FontRecID matchedFont = find_best_style(fFontFamilies[familyRecID], origStyle);
671 nextLogicalTypeface = this->getTypefaceForFontRec(matchedFont);
djsollen@google.combfae9d32013-05-21 16:53:50 +0000672 break;
673 }
674 nextFallbackFontIndex++;
675 }
676
677 DEBUG_FONT(("---- nextLogicalFont: currFontID=%d, origFontID=%d, currRecID=%d, "
djsollen@google.com40078cb2013-05-24 20:31:57 +0000678 "lang=%s, variant=%d, nextFallbackIndex[%d,%d] => nextLogicalTypeface=%d",
djsollen@google.combfae9d32013-05-21 16:53:50 +0000679 currFontID, origFontID, currFontRecID, opts.getLanguage().getTag().c_str(),
djsollen@google.com40078cb2013-05-24 20:31:57 +0000680 variant, nextFallbackFontIndex, currentFallbackList->getAt(nextFallbackFontIndex),
djsollen@google.combfae9d32013-05-21 16:53:50 +0000681 (nextLogicalTypeface) ? nextLogicalTypeface->uniqueID() : 0));
682 return SkSafeRef(nextLogicalTypeface);
683}
684
djsollen@google.com5df5e612013-10-03 14:42:24 +0000685SkTypeface* SkFontConfigInterfaceAndroid::getTypefaceForGlyphID(uint16_t glyphID,
686 const SkTypeface* origTypeface,
687 const SkPaintOptionsAndroid& opts,
688 int* lBounds, int* uBounds) {
689 // If we aren't using fallbacks then we shouldn't be calling this
690 SkASSERT(opts.isUsingFontFallbacks());
691 SkASSERT(origTypeface);
692
693 SkTypeface* currentTypeface = NULL;
694 int lowerBounds = 0; //inclusive
695 int upperBounds = origTypeface->countGlyphs(); //exclusive
696
697 // check to see if the glyph is in the bounds of the origTypeface
698 if (glyphID < upperBounds) {
699 currentTypeface = const_cast<SkTypeface*>(origTypeface);
700 } else {
701 FallbackFontList* currentFallbackList = findFallbackFontList(opts.getLanguage());
702 SkASSERT(currentFallbackList);
703
704 // If an object is set to prefer "kDefault_Variant" it means they have no preference
705 // In this case, we set the value to "kCompact_Variant"
706 SkPaintOptionsAndroid::FontVariant variant = opts.getFontVariant();
707 if (variant == SkPaintOptionsAndroid::kDefault_Variant) {
708 variant = SkPaintOptionsAndroid::kCompact_Variant;
709 }
710
711 int32_t acceptedVariants = SkPaintOptionsAndroid::kDefault_Variant | variant;
712 SkTypeface::Style origStyle = origTypeface->style();
713
714 for (int x = 0; x < currentFallbackList->count(); ++x) {
715 const FamilyRecID familyRecID = currentFallbackList->getAt(x);
716 const SkPaintOptionsAndroid& familyOptions = fFontFamilies[familyRecID].fPaintOptions;
717 if ((familyOptions.getFontVariant() & acceptedVariants) != 0) {
718 FontRecID matchedFont = find_best_style(fFontFamilies[familyRecID], origStyle);
719 currentTypeface = this->getTypefaceForFontRec(matchedFont);
720 lowerBounds = upperBounds;
721 upperBounds += currentTypeface->countGlyphs();
722 if (glyphID < upperBounds) {
723 break;
724 }
725 }
726 }
727 }
728
729 if (NULL != currentTypeface) {
730 if (lBounds) {
731 *lBounds = lowerBounds;
732 }
733 if (uBounds) {
734 *uBounds = upperBounds;
735 }
736 }
737 return currentTypeface;
738}
739
djsollen@google.combfae9d32013-05-21 16:53:50 +0000740///////////////////////////////////////////////////////////////////////////////
741
742bool SkGetFallbackFamilyNameForChar(SkUnichar uni, SkString* name) {
743 SkFontConfigInterfaceAndroid* fontConfig = getSingletonInterface();
commit-bot@chromium.orgc0445fe2013-10-07 19:49:13 +0000744 return fontConfig->getFallbackFamilyNameForChar(uni, NULL, name);
djsollen@google.com9902c382013-09-19 18:22:30 +0000745}
746
747bool SkGetFallbackFamilyNameForChar(SkUnichar uni, const char* lang, SkString* name) {
748 SkFontConfigInterfaceAndroid* fontConfig = getSingletonInterface();
749 return fontConfig->getFallbackFamilyNameForChar(uni, lang, name);
djsollen@google.combfae9d32013-05-21 16:53:50 +0000750}
751
752void SkUseTestFontConfigFile(const char* mainconf, const char* fallbackconf,
753 const char* fontsdir) {
754 gTestMainConfigFile = mainconf;
755 gTestFallbackConfigFile = fallbackconf;
756 gTestFontFilePrefix = fontsdir;
757 SkASSERT(gTestMainConfigFile);
758 SkASSERT(gTestFallbackConfigFile);
759 SkASSERT(gTestFontFilePrefix);
760 SkDEBUGF(("Use Test Config File Main %s, Fallback %s, Font Dir %s",
761 gTestMainConfigFile, gTestFallbackConfigFile, gTestFontFilePrefix));
762}
763
764SkTypeface* SkAndroidNextLogicalTypeface(SkFontID currFontID, SkFontID origFontID,
765 const SkPaintOptionsAndroid& options) {
766 SkFontConfigInterfaceAndroid* fontConfig = getSingletonInterface();
767 return fontConfig->nextLogicalTypeface(currFontID, origFontID, options);
768
769}
770
djsollen@google.com5df5e612013-10-03 14:42:24 +0000771SkTypeface* SkGetTypefaceForGlyphID(uint16_t glyphID, const SkTypeface* origTypeface,
772 const SkPaintOptionsAndroid& options,
773 int* lowerBounds, int* upperBounds) {
774 SkFontConfigInterfaceAndroid* fontConfig = getSingletonInterface();
775 return fontConfig->getTypefaceForGlyphID(glyphID, origTypeface, options,
776 lowerBounds, upperBounds);
777}
778
djsollen@google.combfae9d32013-05-21 16:53:50 +0000779///////////////////////////////////////////////////////////////////////////////
780
djsollen@google.com40078cb2013-05-24 20:31:57 +0000781#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
782
783struct HB_UnicodeMapping {
784 // TODO: when the WebView no longer needs harfbuzz_old, remove
785 HB_Script script_old;
786 hb_script_t script;
787 const SkUnichar unicode;
788};
789
790/*
791 * The following scripts are not complex fonts and we do not expect them to be parsed by this table
792 * HB_SCRIPT_COMMON,
793 * HB_SCRIPT_GREEK,
794 * HB_SCRIPT_CYRILLIC,
795 * HB_SCRIPT_HANGUL
796 * HB_SCRIPT_INHERITED
797 */
798
799/* Harfbuzz (old) is missing a number of scripts in its table. For these,
800 * we include a value which can never happen. We won't get complex script
801 * shaping in these cases, but the library wouldn't know how to shape
802 * them anyway. */
803#define HB_Script_Unknown HB_ScriptCount
804
805static HB_UnicodeMapping HB_UnicodeMappingArray[] = {
806 {HB_Script_Armenian, HB_SCRIPT_ARMENIAN, 0x0531},
807 {HB_Script_Hebrew, HB_SCRIPT_HEBREW, 0x0591},
808 {HB_Script_Arabic, HB_SCRIPT_ARABIC, 0x0600},
809 {HB_Script_Syriac, HB_SCRIPT_SYRIAC, 0x0710},
810 {HB_Script_Thaana, HB_SCRIPT_THAANA, 0x0780},
811 {HB_Script_Nko, HB_SCRIPT_NKO, 0x07C0},
812 {HB_Script_Devanagari, HB_SCRIPT_DEVANAGARI, 0x0901},
813 {HB_Script_Bengali, HB_SCRIPT_BENGALI, 0x0981},
814 {HB_Script_Gurmukhi, HB_SCRIPT_GURMUKHI, 0x0A10},
815 {HB_Script_Gujarati, HB_SCRIPT_GUJARATI, 0x0A90},
816 {HB_Script_Oriya, HB_SCRIPT_ORIYA, 0x0B10},
817 {HB_Script_Tamil, HB_SCRIPT_TAMIL, 0x0B82},
818 {HB_Script_Telugu, HB_SCRIPT_TELUGU, 0x0C10},
819 {HB_Script_Kannada, HB_SCRIPT_KANNADA, 0x0C90},
820 {HB_Script_Malayalam, HB_SCRIPT_MALAYALAM, 0x0D10},
821 {HB_Script_Sinhala, HB_SCRIPT_SINHALA, 0x0D90},
822 {HB_Script_Thai, HB_SCRIPT_THAI, 0x0E01},
823 {HB_Script_Lao, HB_SCRIPT_LAO, 0x0E81},
824 {HB_Script_Tibetan, HB_SCRIPT_TIBETAN, 0x0F00},
825 {HB_Script_Myanmar, HB_SCRIPT_MYANMAR, 0x1000},
826 {HB_Script_Georgian, HB_SCRIPT_GEORGIAN, 0x10A0},
827 {HB_Script_Unknown, HB_SCRIPT_ETHIOPIC, 0x1200},
828 {HB_Script_Unknown, HB_SCRIPT_CHEROKEE, 0x13A0},
829 {HB_Script_Ogham, HB_SCRIPT_OGHAM, 0x1680},
830 {HB_Script_Runic, HB_SCRIPT_RUNIC, 0x16A0},
831 {HB_Script_Khmer, HB_SCRIPT_KHMER, 0x1780},
832 {HB_Script_Unknown, HB_SCRIPT_TAI_LE, 0x1950},
833 {HB_Script_Unknown, HB_SCRIPT_NEW_TAI_LUE, 0x1980},
834 {HB_Script_Unknown, HB_SCRIPT_TAI_THAM, 0x1A20},
835 {HB_Script_Unknown, HB_SCRIPT_CHAM, 0xAA00},
836};
837
838static hb_script_t getHBScriptFromHBScriptOld(HB_Script script_old) {
839 hb_script_t script = HB_SCRIPT_INVALID;
840 int numSupportedFonts = sizeof(HB_UnicodeMappingArray) / sizeof(HB_UnicodeMapping);
841 for (int i = 0; i < numSupportedFonts; i++) {
842 if (script_old == HB_UnicodeMappingArray[i].script_old) {
843 script = HB_UnicodeMappingArray[i].script;
844 break;
845 }
846 }
847 return script;
848}
849
850// returns 0 for "Not Found"
851static SkUnichar getUnicodeFromHBScript(hb_script_t script) {
852 SkUnichar unichar = 0;
853 int numSupportedFonts = sizeof(HB_UnicodeMappingArray) / sizeof(HB_UnicodeMapping);
854 for (int i = 0; i < numSupportedFonts; i++) {
855 if (script == HB_UnicodeMappingArray[i].script) {
856 unichar = HB_UnicodeMappingArray[i].unicode;
857 break;
858 }
859 }
860 return unichar;
861}
862
863struct TypefaceLookupStruct {
864 hb_script_t script;
865 SkTypeface::Style style;
866 SkPaintOptionsAndroid::FontVariant fontVariant;
867 SkTypeface* typeface;
868};
869
870SK_DECLARE_STATIC_MUTEX(gTypefaceTableMutex); // This is the mutex for gTypefaceTable
871static SkTDArray<TypefaceLookupStruct> gTypefaceTable; // This is protected by gTypefaceTableMutex
872
873static int typefaceLookupCompare(const TypefaceLookupStruct& first,
874 const TypefaceLookupStruct& second) {
875 if (first.script != second.script) {
876 return (first.script > second.script) ? 1 : -1;
877 }
878 if (first.style != second.style) {
879 return (first.style > second.style) ? 1 : -1;
880 }
881 if (first.fontVariant != second.fontVariant) {
882 return (first.fontVariant > second.fontVariant) ? 1 : -1;
883 }
884 return 0;
885}
886
887SkTypeface* SkCreateTypefaceForScriptNG(hb_script_t script, SkTypeface::Style style,
888 SkPaintOptionsAndroid::FontVariant fontVariant) {
889 SkAutoMutexAcquire ac(gTypefaceTableMutex);
890
891 TypefaceLookupStruct key;
892 key.script = script;
893 key.style = style;
894 key.fontVariant = fontVariant;
895
896 int index = SkTSearch<TypefaceLookupStruct>(
897 (const TypefaceLookupStruct*) gTypefaceTable.begin(),
898 gTypefaceTable.count(), key, sizeof(TypefaceLookupStruct),
899 typefaceLookupCompare);
900
901 SkTypeface* retTypeface = NULL;
902 if (index >= 0) {
903 retTypeface = gTypefaceTable[index].typeface;
904 }
905 else {
906 SkUnichar unichar = getUnicodeFromHBScript(script);
907 if (!unichar) {
908 return NULL;
909 }
910
911 SkFontConfigInterfaceAndroid* fontConfig = getSingletonInterface();
912 retTypeface = fontConfig->getTypefaceForChar(unichar, style, fontVariant);
913
914 // add to the lookup table
915 key.typeface = retTypeface;
916 *gTypefaceTable.insert(~index) = key;
917 }
918
919 // we ref(), the caller is expected to unref when they are done
920 return SkSafeRef(retTypeface);
921}
922
923SkTypeface* SkCreateTypefaceForScript(HB_Script script, SkTypeface::Style style,
924 SkPaintOptionsAndroid::FontVariant fontVariant) {
925 return SkCreateTypefaceForScriptNG(getHBScriptFromHBScriptOld(script), style, fontVariant);
926}
927
928#endif
929
930///////////////////////////////////////////////////////////////////////////////
931
djsollen@google.combfae9d32013-05-21 16:53:50 +0000932SkFontMgr* SkFontMgr::Factory() {
933 return NULL;
934}