| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2013 The Android Open Source Project | 3 * Copyright 2013 The Android Open Source Project |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #include "SkFontConfigInterface.h" | 9 #include "SkFontConfigInterface.h" |
| 10 #include "SkTypeface_android.h" | 10 #include "SkTypeface_android.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 SkTArray<FontIdentity>*) SK_OVERRIDE; | 94 SkTArray<FontIdentity>*) SK_OVERRIDE; |
| 95 | 95 |
| 96 /** | 96 /** |
| 97 * Get the family name of the font in the default fallback font list that | 97 * Get the family name of the font in the default fallback font list that |
| 98 * contains the specified chararacter. if no font is found, returns false. | 98 * contains the specified chararacter. if no font is found, returns false. |
| 99 */ | 99 */ |
| 100 bool getFallbackFamilyNameForChar(SkUnichar uni, const char* lang, SkString*
name); | 100 bool getFallbackFamilyNameForChar(SkUnichar uni, const char* lang, SkString*
name); |
| 101 /** | 101 /** |
| 102 * | 102 * |
| 103 */ | 103 */ |
| 104 SkTypeface* getTypefaceForChar(SkUnichar uni, SkTypeface::Style style, | |
| 105 SkPaintOptionsAndroid::FontVariant fontVarian
t); | |
| 106 SkTypeface* nextLogicalTypeface(SkFontID currFontID, SkFontID origFontID, | 104 SkTypeface* nextLogicalTypeface(SkFontID currFontID, SkFontID origFontID, |
| 107 const SkPaintOptionsAndroid& options); | 105 const SkPaintOptionsAndroid& options); |
| 108 SkTypeface* getTypefaceForGlyphID(uint16_t glyphID, const SkTypeface* origTy
peface, | 106 SkTypeface* getTypefaceForGlyphID(uint16_t glyphID, const SkTypeface* origTy
peface, |
| 109 const SkPaintOptionsAndroid& options, | 107 const SkPaintOptionsAndroid& options, |
| 110 int* lowerBounds, int* upperBounds); | 108 int* lowerBounds, int* upperBounds); |
| 111 | 109 |
| 112 private: | 110 private: |
| 113 void addFallbackFamily(FamilyRecID fontRecID); | 111 void addFallbackFamily(FamilyRecID fontRecID); |
| 114 SkTypeface* getTypefaceForFontRec(FontRecID fontRecID); | 112 SkTypeface* getTypefaceForFontRec(FontRecID fontRecID); |
| 115 FallbackFontList* getCurrentLocaleFallbackFontList(); | 113 FallbackFontList* getCurrentLocaleFallbackFontList(); |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 uint16_t glyphID; | 538 uint16_t glyphID; |
| 541 paint.textToGlyphs(&uni, sizeof(uni), &glyphID); | 539 paint.textToGlyphs(&uni, sizeof(uni), &glyphID); |
| 542 if (glyphID != 0) { | 540 if (glyphID != 0) { |
| 543 name->set(fFontFamilies[familyRecID].fFallbackName); | 541 name->set(fFontFamilies[familyRecID].fFallbackName); |
| 544 return true; | 542 return true; |
| 545 } | 543 } |
| 546 } | 544 } |
| 547 return false; | 545 return false; |
| 548 } | 546 } |
| 549 | 547 |
| 550 SkTypeface* SkFontConfigInterfaceAndroid::getTypefaceForChar(SkUnichar uni, | |
| 551 SkTypeface::Style s
tyle, | |
| 552 SkPaintOptionsAndro
id::FontVariant fontVariant) { | |
| 553 FontRecID fontRecID = find_best_style(fFontFamilies[fDefaultFamilyRecID], st
yle); | |
| 554 SkTypeface* face = this->getTypefaceForFontRec(fontRecID); | |
| 555 | |
| 556 SkPaintOptionsAndroid paintOptions; | |
| 557 paintOptions.setFontVariant(fontVariant); | |
| 558 paintOptions.setUseFontFallbacks(true); | |
| 559 | |
| 560 SkPaint paint; | |
| 561 paint.setTypeface(face); | |
| 562 paint.setTextEncoding(SkPaint::kUTF16_TextEncoding); | |
| 563 paint.setPaintOptionsAndroid(paintOptions); | |
| 564 | |
| 565 SkAutoGlyphCache autoCache(paint, NULL, NULL); | |
| 566 SkGlyphCache* cache = autoCache.getCache(); | |
| 567 | |
| 568 SkScalerContext* ctx = cache->getScalerContext(); | |
| 569 if (ctx) { | |
| 570 SkFontID fontID = ctx->findTypefaceIdForChar(uni); | |
| 571 return SkTypefaceCache::FindByID(fontID); | |
| 572 } | |
| 573 return NULL; | |
| 574 } | |
| 575 | |
| 576 FallbackFontList* SkFontConfigInterfaceAndroid::getCurrentLocaleFallbackFontList
() { | 548 FallbackFontList* SkFontConfigInterfaceAndroid::getCurrentLocaleFallbackFontList
() { |
| 577 SkString locale = SkFontConfigParser::GetLocale(); | 549 SkString locale = SkFontConfigParser::GetLocale(); |
| 578 if (NULL == fLocaleFallbackFontList || locale != fCachedLocale) { | 550 if (NULL == fLocaleFallbackFontList || locale != fCachedLocale) { |
| 579 fCachedLocale = locale; | 551 fCachedLocale = locale; |
| 580 fLocaleFallbackFontList = this->findFallbackFontList(locale); | 552 fLocaleFallbackFontList = this->findFallbackFontList(locale); |
| 581 } | 553 } |
| 582 return fLocaleFallbackFontList; | 554 return fLocaleFallbackFontList; |
| 583 } | 555 } |
| 584 | 556 |
| 585 FallbackFontList* SkFontConfigInterfaceAndroid::findFallbackFontList(const SkLan
guage& lang, | 557 FallbackFontList* SkFontConfigInterfaceAndroid::findFallbackFontList(const SkLan
guage& lang, |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 | 734 |
| 763 } | 735 } |
| 764 | 736 |
| 765 SkTypeface* SkGetTypefaceForGlyphID(uint16_t glyphID, const SkTypeface* origType
face, | 737 SkTypeface* SkGetTypefaceForGlyphID(uint16_t glyphID, const SkTypeface* origType
face, |
| 766 const SkPaintOptionsAndroid& options, | 738 const SkPaintOptionsAndroid& options, |
| 767 int* lowerBounds, int* upperBounds) { | 739 int* lowerBounds, int* upperBounds) { |
| 768 SkFontConfigInterfaceAndroid* fontConfig = getSingletonInterface(); | 740 SkFontConfigInterfaceAndroid* fontConfig = getSingletonInterface(); |
| 769 return fontConfig->getTypefaceForGlyphID(glyphID, origTypeface, options, | 741 return fontConfig->getTypefaceForGlyphID(glyphID, origTypeface, options, |
| 770 lowerBounds, upperBounds); | 742 lowerBounds, upperBounds); |
| 771 } | 743 } |
| OLD | NEW |