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

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

Issue 1092093002: Respect declared font style on Android. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Always assign style. Created 5 years, 8 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') | no next file » | 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 const int ttcIndex = fontFile.fIndex; 136 const int ttcIndex = fontFile.fIndex;
137 SkString familyName; 137 SkString familyName;
138 SkFontStyle style; 138 SkFontStyle style;
139 bool isFixedWidth; 139 bool isFixedWidth;
140 if (!scanner.scanFont(stream.get(), ttcIndex, &familyName, &style, & isFixedWidth)) { 140 if (!scanner.scanFont(stream.get(), ttcIndex, &familyName, &style, & isFixedWidth)) {
141 SkDEBUGF(("Requested font file %s exists, but is not a valid fon t.\n", 141 SkDEBUGF(("Requested font file %s exists, but is not a valid fon t.\n",
142 pathName.c_str())); 142 pathName.c_str()));
143 continue; 143 continue;
144 } 144 }
145 145
146 if (fontFile.fWeight != 0) { 146 int weight = fontFile.fWeight != 0 ? fontFile.fWeight : style.weight ();
147 style = SkFontStyle(fontFile.fWeight, style.width(), style.slant ()); 147 SkFontStyle::Slant slant = style.slant();
148 switch (fontFile.fStyle) {
149 case FontFileInfo::Style::kAuto: slant = style.slant(); break;
150 case FontFileInfo::Style::kNormal: slant = SkFontStyle::kUpright _Slant; break;
151 case FontFileInfo::Style::kItalic: slant = SkFontStyle::kItalic_ Slant; break;
152 default: SkASSERT(false); break;
148 } 153 }
154 style = SkFontStyle(weight, style.width(), slant);
149 155
150 const SkLanguage& lang = family.fLanguage; 156 const SkLanguage& lang = family.fLanguage;
151 uint32_t variant = family.fVariant; 157 uint32_t variant = family.fVariant;
152 if (kDefault_FontVariant == variant) { 158 if (kDefault_FontVariant == variant) {
153 variant = kCompact_FontVariant | kElegant_FontVariant; 159 variant = kCompact_FontVariant | kElegant_FontVariant;
154 } 160 }
155 161
156 // The first specified family name overrides the family name found i n the font. 162 // The first specified family name overrides the family name found i n the font.
157 // TODO: SkTypeface_AndroidSystem::onCreateFamilyNameIterator should return 163 // TODO: SkTypeface_AndroidSystem::onCreateFamilyNameIterator should return
158 // all of the specified family names in addition to the names found in the font. 164 // all of the specified family names in addition to the names found in the font.
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 { 544 {
539 gTestFontsXml = fontsXml; 545 gTestFontsXml = fontsXml;
540 gTestFallbackFontsXml = fallbackFontsXml; 546 gTestFallbackFontsXml = fallbackFontsXml;
541 gTestBasePath = basePath; 547 gTestBasePath = basePath;
542 SkASSERT(gTestFontsXml); 548 SkASSERT(gTestFontsXml);
543 SkASSERT(gTestFallbackFontsXml); 549 SkASSERT(gTestFallbackFontsXml);
544 SkASSERT(gTestBasePath); 550 SkASSERT(gTestBasePath);
545 SkDEBUGF(("Test BasePath: %s Fonts: %s FallbackFonts: %s\n", 551 SkDEBUGF(("Test BasePath: %s Fonts: %s FallbackFonts: %s\n",
546 gTestBasePath, gTestFontsXml, gTestFallbackFontsXml)); 552 gTestBasePath, gTestFontsXml, gTestFallbackFontsXml));
547 } 553 }
OLDNEW
« no previous file with comments | « src/ports/SkFontConfigParser_android.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698