OLD | NEW |
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 Loading... |
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 int weight = fontFile.fWeight != 0 ? fontFile.fWeight : style.weight
(); | 146 if (fontFile.fWeight != 0) { |
147 SkFontStyle::Slant slant; | 147 style = SkFontStyle(fontFile.fWeight, style.width(), 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; | |
153 } | 148 } |
154 style = SkFontStyle(weight, style.width(), slant); | |
155 | 149 |
156 const SkLanguage& lang = family.fLanguage; | 150 const SkLanguage& lang = family.fLanguage; |
157 uint32_t variant = family.fVariant; | 151 uint32_t variant = family.fVariant; |
158 if (kDefault_FontVariant == variant) { | 152 if (kDefault_FontVariant == variant) { |
159 variant = kCompact_FontVariant | kElegant_FontVariant; | 153 variant = kCompact_FontVariant | kElegant_FontVariant; |
160 } | 154 } |
161 | 155 |
162 // The first specified family name overrides the family name found i
n the font. | 156 // The first specified family name overrides the family name found i
n the font. |
163 // TODO: SkTypeface_AndroidSystem::onCreateFamilyNameIterator should
return | 157 // TODO: SkTypeface_AndroidSystem::onCreateFamilyNameIterator should
return |
164 // all of the specified family names in addition to the names found
in the font. | 158 // 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 Loading... |
544 { | 538 { |
545 gTestFontsXml = fontsXml; | 539 gTestFontsXml = fontsXml; |
546 gTestFallbackFontsXml = fallbackFontsXml; | 540 gTestFallbackFontsXml = fallbackFontsXml; |
547 gTestBasePath = basePath; | 541 gTestBasePath = basePath; |
548 SkASSERT(gTestFontsXml); | 542 SkASSERT(gTestFontsXml); |
549 SkASSERT(gTestFallbackFontsXml); | 543 SkASSERT(gTestFallbackFontsXml); |
550 SkASSERT(gTestBasePath); | 544 SkASSERT(gTestBasePath); |
551 SkDEBUGF(("Test BasePath: %s Fonts: %s FallbackFonts: %s\n", | 545 SkDEBUGF(("Test BasePath: %s Fonts: %s FallbackFonts: %s\n", |
552 gTestBasePath, gTestFontsXml, gTestFallbackFontsXml)); | 546 gTestBasePath, gTestFontsXml, gTestFallbackFontsXml)); |
553 } | 547 } |
OLD | NEW |