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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 return SkRef(closest); | 250 return SkRef(closest); |
251 } | 251 } |
252 | 252 |
253 private: | 253 private: |
254 SkFontStyle style(int index) { | 254 SkFontStyle style(int index) { |
255 return fStyles[index]->fontStyle(); | 255 return fStyles[index]->fontStyle(); |
256 } | 256 } |
257 static int match_score(const SkFontStyle& pattern, const SkFontStyle& candid
ate) { | 257 static int match_score(const SkFontStyle& pattern, const SkFontStyle& candid
ate) { |
258 int score = 0; | 258 int score = 0; |
259 score += SkTAbs((pattern.width() - candidate.width()) * 100); | 259 score += SkTAbs((pattern.width() - candidate.width()) * 100); |
260 score += SkTAbs((pattern.isItalic() == candidate.isItalic()) ? 0 : 1000)
; | 260 score += SkTAbs((pattern.slant() == candidate.slant()) ? 0 : 1000); |
261 score += SkTAbs(pattern.weight() - candidate.weight()); | 261 score += SkTAbs(pattern.weight() - candidate.weight()); |
262 return score; | 262 return score; |
263 } | 263 } |
264 | 264 |
265 SkTArray<SkAutoTUnref<SkTypeface_AndroidSystem>, true> fStyles; | 265 SkTArray<SkAutoTUnref<SkTypeface_AndroidSystem>, true> fStyles; |
266 | 266 |
267 friend struct NameToFamily; | 267 friend struct NameToFamily; |
268 friend class SkFontMgr_Android; | 268 friend class SkFontMgr_Android; |
269 | 269 |
270 typedef SkFontStyleSet INHERITED; | 270 typedef SkFontStyleSet INHERITED; |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
578 SkASSERT(custom->fSystemFontUse < SK_ARRAY_COUNT(gSystemFontUseStrings))
; | 578 SkASSERT(custom->fSystemFontUse < SK_ARRAY_COUNT(gSystemFontUseStrings))
; |
579 SkDEBUGF(("SystemFontUse: %s BasePath: %s Fonts: %s FallbackFonts: %s\n"
, | 579 SkDEBUGF(("SystemFontUse: %s BasePath: %s Fonts: %s FallbackFonts: %s\n"
, |
580 gSystemFontUseStrings[custom->fSystemFontUse], | 580 gSystemFontUseStrings[custom->fSystemFontUse], |
581 custom->fBasePath, | 581 custom->fBasePath, |
582 custom->fFontsXml, | 582 custom->fFontsXml, |
583 custom->fFallbackFontsXml)); | 583 custom->fFallbackFontsXml)); |
584 } | 584 } |
585 | 585 |
586 return new SkFontMgr_Android(custom); | 586 return new SkFontMgr_Android(custom); |
587 } | 587 } |
OLD | NEW |