| 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 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 Loading... |
| 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 } |
| OLD | NEW |