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

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

Issue 450513002: Revert "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
« no previous file with comments | « src/core/SkScalerContext.cpp ('k') | src/ports/SkFontConfigParser_android.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 SkLanguage fLanguage; 72 SkPaintOptionsAndroid fPaintOptions;
73 FontVariant fVariant;
74 }; 73 };
75 74
76 75
77 typedef SkTDArray<FamilyRecID> FallbackFontList; 76 typedef SkTDArray<FamilyRecID> FallbackFontList;
78 77
79 class SkFontConfigInterfaceAndroid : public SkFontConfigInterface { 78 class SkFontConfigInterfaceAndroid : public SkFontConfigInterface {
80 public: 79 public:
81 SkFontConfigInterfaceAndroid(SkTDArray<FontFamily*>& fontFamilies); 80 SkFontConfigInterfaceAndroid(SkTDArray<FontFamily*>& fontFamilies);
82 virtual ~SkFontConfigInterfaceAndroid(); 81 virtual ~SkFontConfigInterfaceAndroid();
83 82
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 } 245 }
247 246
248 // create a familyRec now that we know that at least one font in 247 // create a familyRec now that we know that at least one font in
249 // the family is valid 248 // the family is valid
250 if (familyRec == NULL) { 249 if (familyRec == NULL) {
251 familyRec = &fFontFamilies.push_back(); 250 familyRec = &fFontFamilies.push_back();
252 familyRecID = fFontFamilies.count() - 1; 251 familyRecID = fFontFamilies.count() - 1;
253 fontRec.fFamilyRecID = familyRecID; 252 fontRec.fFamilyRecID = familyRecID;
254 253
255 familyRec->fIsFallbackFont = family->fIsFallbackFont; 254 familyRec->fIsFallbackFont = family->fIsFallbackFont;
256 familyRec->fLanguage = family->fLanguage; 255 familyRec->fPaintOptions = family->fFontFiles[j].fPaintOptions;
257 familyRec->fVariant = family->fVariant; 256
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();
258 } 261 }
259 262
260 // add this font to the current familyRec 263 // add this font to the current familyRec
261 if (INVALID_FONT_REC_ID != familyRec->fFontRecID[fontRec.fStyle]) { 264 if (INVALID_FONT_REC_ID != familyRec->fFontRecID[fontRec.fStyle]) {
262 DEBUG_FONT(("Overwriting familyRec for style[%d] old,new:(%d,%d) ", 265 DEBUG_FONT(("Overwriting familyRec for style[%d] old,new:(%d,%d) ",
263 fontRec.fStyle, familyRec->fFontRecID[fontRec.fStyle ], 266 fontRec.fStyle, familyRec->fFontRecID[fontRec.fStyle ],
264 fontRecID)); 267 fontRecID));
265 } 268 }
266 familyRec->fFontRecID[fontRec.fStyle] = fontRecID; 269 familyRec->fFontRecID[fontRec.fStyle] = fontRecID;
267 } 270 }
(...skipping 27 matching lines...) Expand all
295 // scans the default fallback font chain, adding every entry to every other 298 // scans the default fallback font chain, adding every entry to every other
296 // fallback font chain to which it does not belong. this results in every 299 // fallback font chain to which it does not belong. this results in every
297 // language-specific fallback font chain having all of its fallback fonts at 300 // language-specific fallback font chain having all of its fallback fonts at
298 // the front of the chain, and everything else at the end. 301 // the front of the chain, and everything else at the end.
299 FallbackFontList* fallbackList; 302 FallbackFontList* fallbackList;
300 SkTDict<FallbackFontList*>::Iter iter(fFallbackFontDict); 303 SkTDict<FallbackFontList*>::Iter iter(fFallbackFontDict);
301 const char* fallbackLang = iter.next(&fallbackList); 304 const char* fallbackLang = iter.next(&fallbackList);
302 while(fallbackLang != NULL) { 305 while(fallbackLang != NULL) {
303 for (int i = 0; i < fDefaultFallbackList.count(); i++) { 306 for (int i = 0; i < fDefaultFallbackList.count(); i++) {
304 FamilyRecID familyRecID = fDefaultFallbackList[i]; 307 FamilyRecID familyRecID = fDefaultFallbackList[i];
305 const SkString& fontLang = fFontFamilies[familyRecID].fLanguage.getT ag(); 308 const SkString& fontLang = fFontFamilies[familyRecID].fPaintOptions. getLanguage().getTag();
306 if (strcmp(fallbackLang, fontLang.c_str()) != 0) { 309 if (strcmp(fallbackLang, fontLang.c_str()) != 0) {
307 fallbackList->push(familyRecID); 310 fallbackList->push(familyRecID);
308 } 311 }
309 } 312 }
310 // move to the next fallback list in the dictionary 313 // move to the next fallback list in the dictionary
311 fallbackLang = iter.next(&fallbackList); 314 fallbackLang = iter.next(&fallbackList);
312 } 315 }
313 } 316 }
314 317
315 SkFontConfigInterfaceAndroid::~SkFontConfigInterfaceAndroid() { 318 SkFontConfigInterfaceAndroid::~SkFontConfigInterfaceAndroid() {
(...skipping 14 matching lines...) Expand all
330 // needed by getFallbackFamilyNameForChar() so that fallback 333 // needed by getFallbackFamilyNameForChar() so that fallback
331 // families can be identified by a unique name. The unique 334 // families can be identified by a unique name. The unique
332 // identifier that we've chosen is the familyID in hex (e.g. '0F##fallback') . 335 // identifier that we've chosen is the familyID in hex (e.g. '0F##fallback') .
333 familyRec.fFallbackName.printf("%.2x##fallback", familyRecID); 336 familyRec.fFallbackName.printf("%.2x##fallback", familyRecID);
334 insert_into_name_dict(fFamilyNameDict, familyRec.fFallbackName.c_str(), fami lyRecID); 337 insert_into_name_dict(fFamilyNameDict, familyRec.fFallbackName.c_str(), fami lyRecID);
335 338
336 // add to the default fallback list 339 // add to the default fallback list
337 fDefaultFallbackList.push(familyRecID); 340 fDefaultFallbackList.push(familyRecID);
338 341
339 // stop here if it is the default language tag 342 // stop here if it is the default language tag
340 const SkString& languageTag = familyRec.fLanguage.getTag(); 343 const SkString& languageTag = familyRec.fPaintOptions.getLanguage().getTag() ;
341 if (languageTag.isEmpty()) { 344 if (languageTag.isEmpty()) {
342 return; 345 return;
343 } 346 }
344 347
345 // add to the appropriate language's custom fallback list 348 // add to the appropriate language's custom fallback list
346 FallbackFontList* customList = NULL; 349 FallbackFontList* customList = NULL;
347 if (!fFallbackFontDict.find(languageTag.c_str(), &customList)) { 350 if (!fFallbackFontDict.find(languageTag.c_str(), &customList)) {
348 DEBUG_FONT(("---- Created fallback list for \"%s\"", languageTag.c_str( ))); 351 DEBUG_FONT(("---- Created fallback list for \"%s\"", languageTag.c_str( )));
349 customList = SkNEW(FallbackFontList); 352 customList = SkNEW(FallbackFontList);
350 fFallbackFontDict.set(languageTag.c_str(), customList); 353 fFallbackFontDict.set(languageTag.c_str(), customList);
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 if (NULL == fLocaleFallbackFontList || locale != fCachedLocale) { 504 if (NULL == fLocaleFallbackFontList || locale != fCachedLocale) {
502 fCachedLocale = locale; 505 fCachedLocale = locale;
503 fLocaleFallbackFontList = this->findFallbackFontList(locale); 506 fLocaleFallbackFontList = this->findFallbackFontList(locale);
504 } 507 }
505 FallbackFontList* fallbackFontList = fLocaleFallbackFontList; 508 FallbackFontList* fallbackFontList = fLocaleFallbackFontList;
506 509
507 for (int i = 0; i < fallbackFontList->count(); i++) { 510 for (int i = 0; i < fallbackFontList->count(); i++) {
508 FamilyRecID familyRecID = fallbackFontList->getAt(i); 511 FamilyRecID familyRecID = fallbackFontList->getAt(i);
509 512
510 // if it is not one of the accepted variants then move to the next famil y 513 // if it is not one of the accepted variants then move to the next famil y
511 int32_t acceptedVariants = kDefault_FontVariant | 514 int32_t acceptedVariants = SkPaintOptionsAndroid::kDefault_Variant |
512 kElegant_FontVariant; 515 SkPaintOptionsAndroid::kElegant_Variant;
513 if (!(fFontFamilies[familyRecID].fVariant & acceptedVariants)) { 516 if (!(fFontFamilies[familyRecID].fPaintOptions.getFontVariant() & accept edVariants)) {
514 continue; 517 continue;
515 } 518 }
516 519
517 FontRecID fontRecID = find_best_style(fFontFamilies[familyRecID], SkType face::kNormal); 520 FontRecID fontRecID = find_best_style(fFontFamilies[familyRecID], SkType face::kNormal);
518 SkTypeface* face = this->getTypefaceForFontRec(fontRecID); 521 SkTypeface* face = this->getTypefaceForFontRec(fontRecID);
519 522
520 SkPaint paint; 523 SkPaint paint;
521 paint.setTypeface(face); 524 paint.setTypeface(face);
522 paint.setTextEncoding(SkPaint::kUTF32_TextEncoding); 525 paint.setTextEncoding(SkPaint::kUTF32_TextEncoding);
523 526
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 const char* fontsdir) { 570 const char* fontsdir) {
568 gTestMainConfigFile = mainconf; 571 gTestMainConfigFile = mainconf;
569 gTestFallbackConfigFile = fallbackconf; 572 gTestFallbackConfigFile = fallbackconf;
570 gTestFontFilePrefix = fontsdir; 573 gTestFontFilePrefix = fontsdir;
571 SkASSERT(gTestMainConfigFile); 574 SkASSERT(gTestMainConfigFile);
572 SkASSERT(gTestFallbackConfigFile); 575 SkASSERT(gTestFallbackConfigFile);
573 SkASSERT(gTestFontFilePrefix); 576 SkASSERT(gTestFontFilePrefix);
574 SkDEBUGF(("Use Test Config File Main %s, Fallback %s, Font Dir %s", 577 SkDEBUGF(("Use Test Config File Main %s, Fallback %s, Font Dir %s",
575 gTestMainConfigFile, gTestFallbackConfigFile, gTestFontFilePrefix) ); 578 gTestMainConfigFile, gTestFallbackConfigFile, gTestFontFilePrefix) );
576 } 579 }
OLDNEW
« no previous file with comments | « src/core/SkScalerContext.cpp ('k') | src/ports/SkFontConfigParser_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698