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

Side by Side Diff: src/ports/SkFontMgr_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/ports/SkFontConfigParser_android.cpp ('k') | tests/AndroidPaintTest.cpp » ('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 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkFontConfigParser_android.h" 8 #include "SkFontConfigParser_android.h"
9 #include "SkFontDescriptor.h" 9 #include "SkFontDescriptor.h"
10 #include "SkFontHost_FreeType_common.h" 10 #include "SkFontHost_FreeType_common.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 }; 54 };
55 55
56 class SkTypeface_AndroidSystem : public SkTypeface_Android { 56 class SkTypeface_AndroidSystem : public SkTypeface_Android {
57 public: 57 public:
58 SkTypeface_AndroidSystem(const SkString pathName, 58 SkTypeface_AndroidSystem(const SkString pathName,
59 int index, 59 int index,
60 Style style, 60 Style style,
61 bool isFixedPitch, 61 bool isFixedPitch,
62 const SkString familyName, 62 const SkString familyName,
63 const SkLanguage& lang, 63 const SkLanguage& lang,
64 FontVariant variantStyle) 64 uint32_t variantStyle)
65 : INHERITED(index, style, isFixedPitch, familyName) 65 : INHERITED(index, style, isFixedPitch, familyName)
66 , fPathName(pathName) 66 , fPathName(pathName)
67 , fLang(lang) 67 , fLang(lang)
68 , fVariantStyle(variantStyle) { } 68 , fVariantStyle(variantStyle) { }
69 69
70 virtual void onGetFontDescriptor(SkFontDescriptor* desc, 70 virtual void onGetFontDescriptor(SkFontDescriptor* desc,
71 bool* serialize) const SK_OVERRIDE { 71 bool* serialize) const SK_OVERRIDE {
72 SkASSERT(desc); 72 SkASSERT(desc);
73 SkASSERT(serialize); 73 SkASSERT(serialize);
74 desc->setFamilyName(fFamilyName.c_str()); 74 desc->setFamilyName(fFamilyName.c_str());
75 desc->setFontFileName(fPathName.c_str()); 75 desc->setFontFileName(fPathName.c_str());
76 *serialize = false; 76 *serialize = false;
77 } 77 }
78 virtual SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE { 78 virtual SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE {
79 *ttcIndex = fIndex; 79 *ttcIndex = fIndex;
80 return SkStream::NewFromFile(fPathName.c_str()); 80 return SkStream::NewFromFile(fPathName.c_str());
81 } 81 }
82 82
83 const SkString fPathName; 83 const SkString fPathName;
84 const SkLanguage fLang; 84 const SkLanguage fLang;
85 const FontVariant fVariantStyle; 85 const uint32_t fVariantStyle;
86 86
87 typedef SkTypeface_Android INHERITED; 87 typedef SkTypeface_Android INHERITED;
88 }; 88 };
89 89
90 class SkTypeface_AndroidStream : public SkTypeface_Android { 90 class SkTypeface_AndroidStream : public SkTypeface_Android {
91 public: 91 public:
92 SkTypeface_AndroidStream(SkStream* stream, 92 SkTypeface_AndroidStream(SkStream* stream,
93 int index, 93 int index,
94 Style style, 94 Style style,
95 bool isFixedPitch, 95 bool isFixedPitch,
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 const int ttcIndex = fontFile.fIndex; 146 const int ttcIndex = fontFile.fIndex;
147 SkString familyName; 147 SkString familyName;
148 SkTypeface::Style style; 148 SkTypeface::Style style;
149 bool isFixedWidth; 149 bool isFixedWidth;
150 if (!SkTypeface_FreeType::ScanFont(stream.get(), ttcIndex, 150 if (!SkTypeface_FreeType::ScanFont(stream.get(), ttcIndex,
151 &familyName, &style, &isFixedWidt h)) { 151 &familyName, &style, &isFixedWidt h)) {
152 DEBUG_FONT(("---- SystemFonts[%d] file=%s (INVALID)", i, pathNam e.c_str())); 152 DEBUG_FONT(("---- SystemFonts[%d] file=%s (INVALID)", i, pathNam e.c_str()));
153 continue; 153 continue;
154 } 154 }
155 155
156 const SkLanguage& lang = family.fLanguage; 156 const SkLanguage& lang = fontFile.fPaintOptions.getLanguage();
157 uint32_t variant = family.fVariant; 157 uint32_t variant = fontFile.fPaintOptions.getFontVariant();
158 if (kDefault_FontVariant == variant) { 158 if (SkPaintOptionsAndroid::kDefault_Variant == variant) {
159 variant = kCompact_FontVariant | kElegant_FontVariant; 159 variant = SkPaintOptionsAndroid::kCompact_Variant |
160 SkPaintOptionsAndroid::kElegant_Variant;
160 } 161 }
161 162
162 // The first specified family name overrides the family name found i n the font. 163 // The first specified family name overrides the family name found i n the font.
163 // TODO: SkTypeface_AndroidSystem::onCreateFamilyNameIterator should return 164 // TODO: SkTypeface_AndroidSystem::onCreateFamilyNameIterator should return
164 // all of the specified family names in addition to the names found in the font. 165 // all of the specified family names in addition to the names found in the font.
165 if (cannonicalFamilyName != NULL) { 166 if (cannonicalFamilyName != NULL) {
166 familyName = *cannonicalFamilyName; 167 familyName = *cannonicalFamilyName;
167 } 168 }
168 169
169 fStyles.push_back().reset(SkNEW_ARGS(SkTypeface_AndroidSystem, 170 fStyles.push_back().reset(SkNEW_ARGS(SkTypeface_AndroidSystem,
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 const SkFontStyle& style, 328 const SkFontStyle& style,
328 const char bpc47[], 329 const char bpc47[],
329 uint32_t character) const SK _OVERRIDE 330 uint32_t character) const SK _OVERRIDE
330 { 331 {
331 // The variant 'elegant' is 'not squashed', 'compact' is 'stays in ascen t/descent'. 332 // The variant 'elegant' is 'not squashed', 'compact' is 'stays in ascen t/descent'.
332 // The variant 'default' means 'compact and elegant'. 333 // The variant 'default' means 'compact and elegant'.
333 // As a result, it is not possible to know the variant context from the font alone. 334 // As a result, it is not possible to know the variant context from the font alone.
334 // TODO: add 'is_elegant' and 'is_compact' bits to 'style' request. 335 // TODO: add 'is_elegant' and 'is_compact' bits to 'style' request.
335 336
336 // For compatibility, try 'elegant' fonts first in fallback. 337 // For compatibility, try 'elegant' fonts first in fallback.
337 uint32_t variantMask = kElegant_FontVariant; 338 uint32_t variantMask = SkPaintOptionsAndroid::kElegant_Variant;
338 339
339 // The first time match anything in the mask, second time anything not i n the mask. 340 // The first time match anything in the mask, second time anything not i n the mask.
340 for (bool maskMatches = true; maskMatches != false; maskMatches = false) { 341 for (bool maskMatches = true; maskMatches != false; maskMatches = false) {
341 SkLanguage lang(bpc47); 342 SkLanguage lang(bpc47);
342 // Match against the language, removing a segment each time. 343 // Match against the language, removing a segment each time.
343 // The last time through the loop, the language will be empty. 344 // The last time through the loop, the language will be empty.
344 // The empty language is special, and matches all languages. 345 // The empty language is special, and matches all languages.
345 do { 346 do {
346 const SkString& langTag = lang.getTag(); 347 const SkString& langTag = lang.getTag();
347 for (int i = 0; i < fFallbackNameToFamilyMap.count(); ++i) { 348 for (int i = 0; i < fFallbackNameToFamilyMap.count(); ++i) {
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 } 480 }
480 481
481 typedef SkFontMgr INHERITED; 482 typedef SkFontMgr INHERITED;
482 }; 483 };
483 484
484 /////////////////////////////////////////////////////////////////////////////// 485 ///////////////////////////////////////////////////////////////////////////////
485 486
486 SkFontMgr* SkFontMgr::Factory() { 487 SkFontMgr* SkFontMgr::Factory() {
487 return SkNEW(SkFontMgr_Android); 488 return SkNEW(SkFontMgr_Android);
488 } 489 }
OLDNEW
« no previous file with comments | « src/ports/SkFontConfigParser_android.cpp ('k') | tests/AndroidPaintTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698