| 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 "SkFixed.h" | 8 #include "SkFixed.h" |
| 9 #include "SkFontDescriptor.h" | 9 #include "SkFontDescriptor.h" |
| 10 #include "SkFontHost_FreeType_common.h" | 10 #include "SkFontHost_FreeType_common.h" |
| 11 #include "SkFontMgr.h" | 11 #include "SkFontMgr.h" |
| 12 #include "SkFontMgr_android.h" | 12 #include "SkFontMgr_android.h" |
| 13 #include "SkFontMgr_android_parser.h" | 13 #include "SkFontMgr_android_parser.h" |
| 14 #include "SkFontStyle.h" | 14 #include "SkFontStyle.h" |
| 15 #include "SkPaint.h" |
| 15 #include "SkRefCnt.h" | 16 #include "SkRefCnt.h" |
| 16 #include "SkString.h" | 17 #include "SkString.h" |
| 17 #include "SkStream.h" | 18 #include "SkStream.h" |
| 18 #include "SkTArray.h" | 19 #include "SkTArray.h" |
| 19 #include "SkTDArray.h" | 20 #include "SkTDArray.h" |
| 20 #include "SkTSearch.h" | 21 #include "SkTSearch.h" |
| 21 #include "SkTemplates.h" | 22 #include "SkTemplates.h" |
| 22 #include "SkTypeface.h" | |
| 23 #include "SkTypefaceCache.h" | 23 #include "SkTypefaceCache.h" |
| 24 | 24 |
| 25 #include <limits> | 25 #include <limits> |
| 26 | 26 |
| 27 class SkData; | 27 class SkData; |
| 28 | 28 |
| 29 class SkTypeface_Android : public SkTypeface_FreeType { | 29 class SkTypeface_Android : public SkTypeface_FreeType { |
| 30 public: | 30 public: |
| 31 SkTypeface_Android(const SkFontStyle& style, | 31 SkTypeface_Android(const SkFontStyle& style, |
| 32 bool isFixedPitch, | 32 bool isFixedPitch, |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 SkAutoTUnref<SkTypeface_AndroidSystem> face(family->matchStyle(style
)); | 400 SkAutoTUnref<SkTypeface_AndroidSystem> face(family->matchStyle(style
)); |
| 401 | 401 |
| 402 if (!langTag.isEmpty() && !face->fLang.getTag().startsWith(langTag.c
_str())) { | 402 if (!langTag.isEmpty() && !face->fLang.getTag().startsWith(langTag.c
_str())) { |
| 403 continue; | 403 continue; |
| 404 } | 404 } |
| 405 | 405 |
| 406 if (SkToBool(face->fVariantStyle & kElegant_FontVariant) != elegant)
{ | 406 if (SkToBool(face->fVariantStyle & kElegant_FontVariant) != elegant)
{ |
| 407 continue; | 407 continue; |
| 408 } | 408 } |
| 409 | 409 |
| 410 if (face->charsToGlyphs(&character, SkTypeface::kUTF32_Encoding, NUL
L, 0)) { | 410 SkPaint paint; |
| 411 paint.setTypeface(face); |
| 412 paint.setTextEncoding(SkPaint::kUTF32_TextEncoding); |
| 413 |
| 414 uint16_t glyphID; |
| 415 paint.textToGlyphs(&character, sizeof(character), &glyphID); |
| 416 if (glyphID != 0) { |
| 411 return face.detach(); | 417 return face.detach(); |
| 412 } | 418 } |
| 413 } | 419 } |
| 414 return NULL; | 420 return NULL; |
| 415 } | 421 } |
| 416 | 422 |
| 417 virtual SkTypeface* onMatchFamilyStyleCharacter(const char familyName[], | 423 virtual SkTypeface* onMatchFamilyStyleCharacter(const char familyName[], |
| 418 const SkFontStyle& style, | 424 const SkFontStyle& style, |
| 419 const char* bcp47[], | 425 const char* bcp47[], |
| 420 int bcp47Count, | 426 int bcp47Count, |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 SkASSERT(custom->fSystemFontUse < SK_ARRAY_COUNT(gSystemFontUseStrings))
; | 586 SkASSERT(custom->fSystemFontUse < SK_ARRAY_COUNT(gSystemFontUseStrings))
; |
| 581 SkDEBUGF(("SystemFontUse: %s BasePath: %s Fonts: %s FallbackFonts: %s\n"
, | 587 SkDEBUGF(("SystemFontUse: %s BasePath: %s Fonts: %s FallbackFonts: %s\n"
, |
| 582 gSystemFontUseStrings[custom->fSystemFontUse], | 588 gSystemFontUseStrings[custom->fSystemFontUse], |
| 583 custom->fBasePath, | 589 custom->fBasePath, |
| 584 custom->fFontsXml, | 590 custom->fFontsXml, |
| 585 custom->fFallbackFontsXml)); | 591 custom->fFallbackFontsXml)); |
| 586 } | 592 } |
| 587 | 593 |
| 588 return SkNEW_ARGS(SkFontMgr_Android, (custom)); | 594 return SkNEW_ARGS(SkFontMgr_Android, (custom)); |
| 589 } | 595 } |
| OLD | NEW |