Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(585)

Side by Side Diff: src/ports/SkFontConfigInterface_android.cpp

Issue 447873003: Remove SkPaintOptionsAndroid (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2013 The Android Open Source Project 3 * Copyright 2013 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "SkFontConfigInterface.h" 9 #include "SkFontConfigInterface.h"
10 #include "SkTypeface_android.h" 10 #include "SkTypeface_android.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 62
63 struct FamilyRec { 63 struct FamilyRec {
64 FamilyRec() { 64 FamilyRec() {
65 memset(fFontRecID, INVALID_FONT_REC_ID, sizeof(fFontRecID)); 65 memset(fFontRecID, INVALID_FONT_REC_ID, sizeof(fFontRecID));
66 } 66 }
67 67
68 static const int FONT_STYLE_COUNT = 4; 68 static const int FONT_STYLE_COUNT = 4;
69 FontRecID fFontRecID[FONT_STYLE_COUNT]; 69 FontRecID fFontRecID[FONT_STYLE_COUNT];
70 bool fIsFallbackFont; 70 bool fIsFallbackFont;
71 SkString fFallbackName; 71 SkString fFallbackName;
72 SkPaintOptionsAndroid fPaintOptions; 72 SkLanguage fLanguage;
73 FontVariant fVariant;
73 }; 74 };
74 75
75 76
76 typedef SkTDArray<FamilyRecID> FallbackFontList; 77 typedef SkTDArray<FamilyRecID> FallbackFontList;
77 78
78 class SkFontConfigInterfaceAndroid : public SkFontConfigInterface { 79 class SkFontConfigInterfaceAndroid : public SkFontConfigInterface {
79 public: 80 public:
80 SkFontConfigInterfaceAndroid(SkTDArray<FontFamily*>& fontFamilies); 81 SkFontConfigInterfaceAndroid(SkTDArray<FontFamily*>& fontFamilies);
81 virtual ~SkFontConfigInterfaceAndroid(); 82 virtual ~SkFontConfigInterfaceAndroid();
82 83
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 } 246 }
246 247
247 // create a familyRec now that we know that at least one font in 248 // create a familyRec now that we know that at least one font in
248 // the family is valid 249 // the family is valid
249 if (familyRec == NULL) { 250 if (familyRec == NULL) {
250 familyRec = &fFontFamilies.push_back(); 251 familyRec = &fFontFamilies.push_back();
251 familyRecID = fFontFamilies.count() - 1; 252 familyRecID = fFontFamilies.count() - 1;
252 fontRec.fFamilyRecID = familyRecID; 253 fontRec.fFamilyRecID = familyRecID;
253 254
254 familyRec->fIsFallbackFont = family->fIsFallbackFont; 255 familyRec->fIsFallbackFont = family->fIsFallbackFont;
255 familyRec->fPaintOptions = family->fFontFiles[j].fPaintOptions; 256 familyRec->fLanguage = family->fLanguage;
256 257 familyRec->fVariant = family->fVariant;
257 } else if (familyRec->fPaintOptions != family->fFontFiles[j].fPaintO ptions) {
258 SkDebugf("Every font file within a family must have identical"
259 "language and variant attributes");
260 sk_throw();
261 } 258 }
262 259
263 // add this font to the current familyRec 260 // add this font to the current familyRec
264 if (INVALID_FONT_REC_ID != familyRec->fFontRecID[fontRec.fStyle]) { 261 if (INVALID_FONT_REC_ID != familyRec->fFontRecID[fontRec.fStyle]) {
265 DEBUG_FONT(("Overwriting familyRec for style[%d] old,new:(%d,%d) ", 262 DEBUG_FONT(("Overwriting familyRec for style[%d] old,new:(%d,%d) ",
266 fontRec.fStyle, familyRec->fFontRecID[fontRec.fStyle ], 263 fontRec.fStyle, familyRec->fFontRecID[fontRec.fStyle ],
267 fontRecID)); 264 fontRecID));
268 } 265 }
269 familyRec->fFontRecID[fontRec.fStyle] = fontRecID; 266 familyRec->fFontRecID[fontRec.fStyle] = fontRecID;
270 } 267 }
(...skipping 27 matching lines...) Expand all
298 // scans the default fallback font chain, adding every entry to every other 295 // scans the default fallback font chain, adding every entry to every other
299 // fallback font chain to which it does not belong. this results in every 296 // fallback font chain to which it does not belong. this results in every
300 // language-specific fallback font chain having all of its fallback fonts at 297 // language-specific fallback font chain having all of its fallback fonts at
301 // the front of the chain, and everything else at the end. 298 // the front of the chain, and everything else at the end.
302 FallbackFontList* fallbackList; 299 FallbackFontList* fallbackList;
303 SkTDict<FallbackFontList*>::Iter iter(fFallbackFontDict); 300 SkTDict<FallbackFontList*>::Iter iter(fFallbackFontDict);
304 const char* fallbackLang = iter.next(&fallbackList); 301 const char* fallbackLang = iter.next(&fallbackList);
305 while(fallbackLang != NULL) { 302 while(fallbackLang != NULL) {
306 for (int i = 0; i < fDefaultFallbackList.count(); i++) { 303 for (int i = 0; i < fDefaultFallbackList.count(); i++) {
307 FamilyRecID familyRecID = fDefaultFallbackList[i]; 304 FamilyRecID familyRecID = fDefaultFallbackList[i];
308 const SkString& fontLang = fFontFamilies[familyRecID].fPaintOptions. getLanguage().getTag(); 305 const SkString& fontLang = fFontFamilies[familyRecID].fLanguage.getT ag();
309 if (strcmp(fallbackLang, fontLang.c_str()) != 0) { 306 if (strcmp(fallbackLang, fontLang.c_str()) != 0) {
310 fallbackList->push(familyRecID); 307 fallbackList->push(familyRecID);
311 } 308 }
312 } 309 }
313 // move to the next fallback list in the dictionary 310 // move to the next fallback list in the dictionary
314 fallbackLang = iter.next(&fallbackList); 311 fallbackLang = iter.next(&fallbackList);
315 } 312 }
316 } 313 }
317 314
318 SkFontConfigInterfaceAndroid::~SkFontConfigInterfaceAndroid() { 315 SkFontConfigInterfaceAndroid::~SkFontConfigInterfaceAndroid() {
(...skipping 14 matching lines...) Expand all
333 // needed by getFallbackFamilyNameForChar() so that fallback 330 // needed by getFallbackFamilyNameForChar() so that fallback
334 // families can be identified by a unique name. The unique 331 // families can be identified by a unique name. The unique
335 // identifier that we've chosen is the familyID in hex (e.g. '0F##fallback') . 332 // identifier that we've chosen is the familyID in hex (e.g. '0F##fallback') .
336 familyRec.fFallbackName.printf("%.2x##fallback", familyRecID); 333 familyRec.fFallbackName.printf("%.2x##fallback", familyRecID);
337 insert_into_name_dict(fFamilyNameDict, familyRec.fFallbackName.c_str(), fami lyRecID); 334 insert_into_name_dict(fFamilyNameDict, familyRec.fFallbackName.c_str(), fami lyRecID);
338 335
339 // add to the default fallback list 336 // add to the default fallback list
340 fDefaultFallbackList.push(familyRecID); 337 fDefaultFallbackList.push(familyRecID);
341 338
342 // stop here if it is the default language tag 339 // stop here if it is the default language tag
343 const SkString& languageTag = familyRec.fPaintOptions.getLanguage().getTag() ; 340 const SkString& languageTag = familyRec.fLanguage.getTag();
344 if (languageTag.isEmpty()) { 341 if (languageTag.isEmpty()) {
345 return; 342 return;
346 } 343 }
347 344
348 // add to the appropriate language's custom fallback list 345 // add to the appropriate language's custom fallback list
349 FallbackFontList* customList = NULL; 346 FallbackFontList* customList = NULL;
350 if (!fFallbackFontDict.find(languageTag.c_str(), &customList)) { 347 if (!fFallbackFontDict.find(languageTag.c_str(), &customList)) {
351 DEBUG_FONT(("---- Created fallback list for \"%s\"", languageTag.c_str( ))); 348 DEBUG_FONT(("---- Created fallback list for \"%s\"", languageTag.c_str( )));
352 customList = SkNEW(FallbackFontList); 349 customList = SkNEW(FallbackFontList);
353 fFallbackFontDict.set(languageTag.c_str(), customList); 350 fFallbackFontDict.set(languageTag.c_str(), customList);
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 if (NULL == fLocaleFallbackFontList || locale != fCachedLocale) { 501 if (NULL == fLocaleFallbackFontList || locale != fCachedLocale) {
505 fCachedLocale = locale; 502 fCachedLocale = locale;
506 fLocaleFallbackFontList = this->findFallbackFontList(locale); 503 fLocaleFallbackFontList = this->findFallbackFontList(locale);
507 } 504 }
508 FallbackFontList* fallbackFontList = fLocaleFallbackFontList; 505 FallbackFontList* fallbackFontList = fLocaleFallbackFontList;
509 506
510 for (int i = 0; i < fallbackFontList->count(); i++) { 507 for (int i = 0; i < fallbackFontList->count(); i++) {
511 FamilyRecID familyRecID = fallbackFontList->getAt(i); 508 FamilyRecID familyRecID = fallbackFontList->getAt(i);
512 509
513 // if it is not one of the accepted variants then move to the next famil y 510 // if it is not one of the accepted variants then move to the next famil y
514 int32_t acceptedVariants = SkPaintOptionsAndroid::kDefault_Variant | 511 int32_t acceptedVariants = kDefault_FontVariant |
515 SkPaintOptionsAndroid::kElegant_Variant; 512 kElegant_FontVariant;
516 if (!(fFontFamilies[familyRecID].fPaintOptions.getFontVariant() & accept edVariants)) { 513 if (!(fFontFamilies[familyRecID].fVariant & acceptedVariants)) {
517 continue; 514 continue;
518 } 515 }
519 516
520 FontRecID fontRecID = find_best_style(fFontFamilies[familyRecID], SkType face::kNormal); 517 FontRecID fontRecID = find_best_style(fFontFamilies[familyRecID], SkType face::kNormal);
521 SkTypeface* face = this->getTypefaceForFontRec(fontRecID); 518 SkTypeface* face = this->getTypefaceForFontRec(fontRecID);
522 519
523 SkPaint paint; 520 SkPaint paint;
524 paint.setTypeface(face); 521 paint.setTypeface(face);
525 paint.setTextEncoding(SkPaint::kUTF32_TextEncoding); 522 paint.setTextEncoding(SkPaint::kUTF32_TextEncoding);
526 523
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 const char* fontsdir) { 567 const char* fontsdir) {
571 gTestMainConfigFile = mainconf; 568 gTestMainConfigFile = mainconf;
572 gTestFallbackConfigFile = fallbackconf; 569 gTestFallbackConfigFile = fallbackconf;
573 gTestFontFilePrefix = fontsdir; 570 gTestFontFilePrefix = fontsdir;
574 SkASSERT(gTestMainConfigFile); 571 SkASSERT(gTestMainConfigFile);
575 SkASSERT(gTestFallbackConfigFile); 572 SkASSERT(gTestFallbackConfigFile);
576 SkASSERT(gTestFontFilePrefix); 573 SkASSERT(gTestFontFilePrefix);
577 SkDEBUGF(("Use Test Config File Main %s, Fallback %s, Font Dir %s", 574 SkDEBUGF(("Use Test Config File Main %s, Fallback %s, Font Dir %s",
578 gTestMainConfigFile, gTestFallbackConfigFile, gTestFontFilePrefix) ); 575 gTestMainConfigFile, gTestFallbackConfigFile, gTestFontFilePrefix) );
579 } 576 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698