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 "SkFontConfigParser_android.h" | 8 #include "SkFontConfigParser_android.h" |
9 #include "SkFontDescriptor.h" | 9 #include "SkFontDescriptor.h" |
10 #include "SkFontHost_FreeType_common.h" | 10 #include "SkFontHost_FreeType_common.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 SkString fFamilyName; | 44 SkString fFamilyName; |
45 | 45 |
46 private: | 46 private: |
47 typedef SkTypeface_FreeType INHERITED; | 47 typedef SkTypeface_FreeType INHERITED; |
48 }; | 48 }; |
49 | 49 |
50 class SkTypeface_AndroidSystem : public SkTypeface_Android { | 50 class SkTypeface_AndroidSystem : public SkTypeface_Android { |
51 public: | 51 public: |
52 SkTypeface_AndroidSystem(const SkString& pathName, | 52 SkTypeface_AndroidSystem(const SkString& pathName, |
53 int index, | 53 int index, |
| 54 const SkTArray<SkFixed, true>& axes, |
54 const SkFontStyle& style, | 55 const SkFontStyle& style, |
55 bool isFixedPitch, | 56 bool isFixedPitch, |
56 const SkString& familyName, | 57 const SkString& familyName, |
57 const SkLanguage& lang, | 58 const SkLanguage& lang, |
58 FontVariant variantStyle) | 59 FontVariant variantStyle) |
59 : INHERITED(index, style, isFixedPitch, familyName) | 60 : INHERITED(index, style, isFixedPitch, familyName) |
60 , fPathName(pathName) | 61 , fPathName(pathName) |
61 , fLang(lang) | 62 , fLang(lang) |
62 , fVariantStyle(variantStyle) { } | 63 , fVariantStyle(variantStyle) |
| 64 , fAxes(axes) { } |
63 | 65 |
64 virtual void onGetFontDescriptor(SkFontDescriptor* desc, | 66 virtual void onGetFontDescriptor(SkFontDescriptor* desc, |
65 bool* serialize) const SK_OVERRIDE { | 67 bool* serialize) const SK_OVERRIDE { |
66 SkASSERT(desc); | 68 SkASSERT(desc); |
67 SkASSERT(serialize); | 69 SkASSERT(serialize); |
68 desc->setFamilyName(fFamilyName.c_str()); | 70 desc->setFamilyName(fFamilyName.c_str()); |
69 desc->setFontFileName(fPathName.c_str()); | 71 desc->setFontFileName(fPathName.c_str()); |
70 desc->setFontIndex(fIndex); | 72 desc->getFontParameters().fIndex = fIndex; |
71 *serialize = false; | 73 *serialize = false; |
72 } | 74 } |
73 SkStreamAsset* onOpenStream(int* ttcIndex) const SK_OVERRIDE { | 75 SkStreamAsset* onOpenStream(int* ttcIndex) const SK_OVERRIDE { |
74 *ttcIndex = fIndex; | 76 *ttcIndex = fIndex; |
75 return SkStream::NewFromFile(fPathName.c_str()); | 77 return SkStream::NewFromFile(fPathName.c_str()); |
76 } | 78 } |
| 79 SkStreamAsset* onOpenStream2(SkFontParameters* params) const SK_OVERRIDE { |
| 80 params->fIndex = fIndex; |
| 81 params->fAxis.reset(fAxes.count()); |
| 82 for (int i = 0 ; i < fAxes.count(); ++i) { |
| 83 params->fAxis[i] = fAxes[i]; |
| 84 } |
| 85 return SkStream::NewFromFile(fPathName.c_str()); |
| 86 } |
77 | 87 |
78 const SkString fPathName; | 88 const SkString fPathName; |
79 const SkLanguage fLang; | 89 const SkLanguage fLang; |
80 const FontVariant fVariantStyle; | 90 const FontVariant fVariantStyle; |
| 91 const SkTArray<SkFixed, true> fAxes; |
81 | 92 |
82 typedef SkTypeface_Android INHERITED; | 93 typedef SkTypeface_Android INHERITED; |
83 }; | 94 }; |
84 | 95 |
85 class SkTypeface_AndroidStream : public SkTypeface_Android { | 96 class SkTypeface_AndroidStream : public SkTypeface_Android { |
86 public: | 97 public: |
87 SkTypeface_AndroidStream(SkStreamAsset* stream, | 98 SkTypeface_AndroidStream(SkStreamAsset* stream, |
88 int index, | 99 int index, |
89 const SkFontStyle& style, | 100 const SkFontStyle& style, |
90 bool isFixedPitch, | 101 bool isFixedPitch, |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 } | 167 } |
157 | 168 |
158 // The first specified family name overrides the family name found i
n the font. | 169 // The first specified family name overrides the family name found i
n the font. |
159 // TODO: SkTypeface_AndroidSystem::onCreateFamilyNameIterator should
return | 170 // TODO: SkTypeface_AndroidSystem::onCreateFamilyNameIterator should
return |
160 // all of the specified family names in addition to the names found
in the font. | 171 // all of the specified family names in addition to the names found
in the font. |
161 if (cannonicalFamilyName != NULL) { | 172 if (cannonicalFamilyName != NULL) { |
162 familyName = *cannonicalFamilyName; | 173 familyName = *cannonicalFamilyName; |
163 } | 174 } |
164 | 175 |
165 fStyles.push_back().reset(SkNEW_ARGS(SkTypeface_AndroidSystem, | 176 fStyles.push_back().reset(SkNEW_ARGS(SkTypeface_AndroidSystem, |
166 (pathName, ttcIndex, | 177 (pathName, ttcIndex, fontFile.f
Axes, |
167 style, isFixedWidth, familyNam
e, | 178 style, isFixedWidth, familyNam
e, |
168 lang, variant))); | 179 lang, variant))); |
169 } | 180 } |
170 } | 181 } |
171 | 182 |
172 int count() SK_OVERRIDE { | 183 int count() SK_OVERRIDE { |
173 return fStyles.count(); | 184 return fStyles.count(); |
174 } | 185 } |
175 void getStyle(int index, SkFontStyle* style, SkString* name) SK_OVERRIDE { | 186 void getStyle(int index, SkFontStyle* style, SkString* name) SK_OVERRIDE { |
176 if (index < 0 || fStyles.count() <= index) { | 187 if (index < 0 || fStyles.count() <= index) { |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 { | 551 { |
541 gTestFontsXml = fontsXml; | 552 gTestFontsXml = fontsXml; |
542 gTestFallbackFontsXml = fallbackFontsXml; | 553 gTestFallbackFontsXml = fallbackFontsXml; |
543 gTestBasePath = basePath; | 554 gTestBasePath = basePath; |
544 SkASSERT(gTestFontsXml); | 555 SkASSERT(gTestFontsXml); |
545 SkASSERT(gTestFallbackFontsXml); | 556 SkASSERT(gTestFallbackFontsXml); |
546 SkASSERT(gTestBasePath); | 557 SkASSERT(gTestBasePath); |
547 SkDEBUGF(("Test BasePath: %s Fonts: %s FallbackFonts: %s\n", | 558 SkDEBUGF(("Test BasePath: %s Fonts: %s FallbackFonts: %s\n", |
548 gTestBasePath, gTestFontsXml, gTestFallbackFontsXml)); | 559 gTestBasePath, gTestFontsXml, gTestFallbackFontsXml)); |
549 } | 560 } |
OLD | NEW |