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