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 "SkTypes.h" | 8 #include "SkTypes.h" |
9 | 9 |
10 #include "SkData.h" | 10 #include "SkData.h" |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 } | 191 } |
192 | 192 |
193 // The first specified family name overrides the family name found i
n the font. | 193 // The first specified family name overrides the family name found i
n the font. |
194 // TODO: SkTypeface_AndroidSystem::onCreateFamilyNameIterator should
return | 194 // TODO: SkTypeface_AndroidSystem::onCreateFamilyNameIterator should
return |
195 // all of the specified family names in addition to the names found
in the font. | 195 // all of the specified family names in addition to the names found
in the font. |
196 if (cannonicalFamilyName != nullptr) { | 196 if (cannonicalFamilyName != nullptr) { |
197 familyName = *cannonicalFamilyName; | 197 familyName = *cannonicalFamilyName; |
198 } | 198 } |
199 | 199 |
200 SkAutoSTMalloc<4, SkFixed> axisValues(axisDefinitions.count()); | 200 SkAutoSTMalloc<4, SkFixed> axisValues(axisDefinitions.count()); |
201 for (int i = 0; i < axisDefinitions.count(); ++i) { | 201 Scanner::computeAxisValues(axisDefinitions, |
202 const Scanner::AxisDefinition& axisDefinition = axisDefinitions[
i]; | 202 fontFile.fAxes.begin(), fontFile.fAxes.co
unt(), |
203 axisValues[i] = axisDefinition.fDefault; | 203 axisValues, familyName); |
204 for (int j = 0; j < fontFile.fAxes.count(); ++j) { | |
205 const FontFileInfo::Axis& axisSpecified = fontFile.fAxes[j]; | |
206 if (axisDefinition.fTag == axisSpecified.fTag) { | |
207 axisValues[i] = SkTPin(axisSpecified.fValue, axisDefinit
ion.fMinimum, | |
208 axisDefinit
ion.fMaximum); | |
209 if (axisValues[i] != axisSpecified.fValue) { | |
210 SkDEBUGF(("Requested font axis value out of range: " | |
211 "%s '%c%c%c%c' %f; pinned to %f.\n", | |
212 familyName.c_str(), | |
213 (axisDefinition.fTag >> 24) & 0xFF, | |
214 (axisDefinition.fTag >> 16) & 0xFF, | |
215 (axisDefinition.fTag >> 8) & 0xFF, | |
216 (axisDefinition.fTag ) & 0xFF, | |
217 SkFixedToDouble(axisSpecified.fValue), | |
218 SkFixedToDouble(axisValues[i]))); | |
219 } | |
220 break; | |
221 } | |
222 } | |
223 // TODO: warn on defaulted axis? | |
224 } | |
225 | |
226 SkDEBUGCODE( | |
227 // Check for axis specified, but not matched in font. | |
228 for (int i = 0; i < fontFile.fAxes.count(); ++i) { | |
229 SkFourByteTag skTag = fontFile.fAxes[i].fTag; | |
230 bool found = false; | |
231 for (int j = 0; j < axisDefinitions.count(); ++j) { | |
232 if (skTag == axisDefinitions[j].fTag) { | |
233 found = true; | |
234 break; | |
235 } | |
236 } | |
237 if (!found) { | |
238 SkDEBUGF(("Requested font axis not found: %s '%c%c%c%c'\
n", | |
239 familyName.c_str(), (skTag >> 24) & 0xFF, | |
240 (skTag >> 16) & 0xFF, (skTag >> 8) & 0xFF, (
skTag)&0xFF)); | |
241 } | |
242 } | |
243 ) | |
244 | 204 |
245 fStyles.push_back().reset(new SkTypeface_AndroidSystem( | 205 fStyles.push_back().reset(new SkTypeface_AndroidSystem( |
246 pathName, cacheFontFiles, ttcIndex, axisValues.get(), axisDe
finitions.count(), | 206 pathName, cacheFontFiles, ttcIndex, axisValues.get(), axisDe
finitions.count(), |
247 style, isFixedWidth, familyName, lang, variant)); | 207 style, isFixedWidth, familyName, lang, variant)); |
248 } | 208 } |
249 } | 209 } |
250 | 210 |
251 int count() override { | 211 int count() override { |
252 return fStyles.count(); | 212 return fStyles.count(); |
253 } | 213 } |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 SkASSERT(custom->fSystemFontUse < SK_ARRAY_COUNT(gSystemFontUseStrings))
; | 582 SkASSERT(custom->fSystemFontUse < SK_ARRAY_COUNT(gSystemFontUseStrings))
; |
623 SkDEBUGF(("SystemFontUse: %s BasePath: %s Fonts: %s FallbackFonts: %s\n"
, | 583 SkDEBUGF(("SystemFontUse: %s BasePath: %s Fonts: %s FallbackFonts: %s\n"
, |
624 gSystemFontUseStrings[custom->fSystemFontUse], | 584 gSystemFontUseStrings[custom->fSystemFontUse], |
625 custom->fBasePath, | 585 custom->fBasePath, |
626 custom->fFontsXml, | 586 custom->fFontsXml, |
627 custom->fFallbackFontsXml)); | 587 custom->fFallbackFontsXml)); |
628 } | 588 } |
629 | 589 |
630 return new SkFontMgr_Android(custom); | 590 return new SkFontMgr_Android(custom); |
631 } | 591 } |
OLD | NEW |