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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 /////////////////////////////////////////////////////////////////////////////// | 46 /////////////////////////////////////////////////////////////////////////////// |
47 | 47 |
48 typedef int32_t FontRecID; | 48 typedef int32_t FontRecID; |
49 #define INVALID_FONT_REC_ID -1 | 49 #define INVALID_FONT_REC_ID -1 |
50 | 50 |
51 typedef int32_t FamilyRecID; | 51 typedef int32_t FamilyRecID; |
52 #define INVALID_FAMILY_REC_ID -1 | 52 #define INVALID_FAMILY_REC_ID -1 |
53 | 53 |
54 // used to record our notion of the pre-existing fonts | 54 // used to record our notion of the pre-existing fonts |
55 struct FontRec { | 55 struct FontRec { |
56 SkRefPtr<SkTypeface> fTypeface; | 56 SkAutoTUnref<SkTypeface> fTypeface; |
57 SkString fFileName; | 57 SkString fFileName; |
58 SkTypeface::Style fStyle; | 58 SkTypeface::Style fStyle; |
59 bool fIsValid; | 59 bool fIsValid; |
60 FamilyRecID fFamilyRecID; | 60 FamilyRecID fFamilyRecID; |
61 }; | 61 }; |
62 | 62 |
63 struct FamilyRec { | 63 struct FamilyRec { |
64 FamilyRec() { | 64 FamilyRec() { |
65 memset(fFontRecID, INVALID_FONT_REC_ID, sizeof(fFontRecID)); | 65 memset(fFontRecID, INVALID_FONT_REC_ID, sizeof(fFontRecID)); |
66 } | 66 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 SkTypeface* getTypefaceForGlyphID(uint16_t glyphID, const SkTypeface* origTy
peface, | 108 SkTypeface* getTypefaceForGlyphID(uint16_t glyphID, const SkTypeface* origTy
peface, |
109 const SkPaintOptionsAndroid& options, | 109 const SkPaintOptionsAndroid& options, |
110 int* lowerBounds, int* upperBounds); | 110 int* lowerBounds, int* upperBounds); |
111 | 111 |
112 private: | 112 private: |
113 void addFallbackFamily(FamilyRecID fontRecID); | 113 void addFallbackFamily(FamilyRecID fontRecID); |
114 SkTypeface* getTypefaceForFontRec(FontRecID fontRecID); | 114 SkTypeface* getTypefaceForFontRec(FontRecID fontRecID); |
115 FallbackFontList* getCurrentLocaleFallbackFontList(); | 115 FallbackFontList* getCurrentLocaleFallbackFontList(); |
116 FallbackFontList* findFallbackFontList(const SkLanguage& lang, bool isOrigin
al = true); | 116 FallbackFontList* findFallbackFontList(const SkLanguage& lang, bool isOrigin
al = true); |
117 | 117 |
118 SkTArray<FontRec> fFonts; | 118 SkTArray<FontRec, true> fFonts; |
119 SkTArray<FamilyRec> fFontFamilies; | 119 SkTArray<FamilyRec, true> fFontFamilies; |
120 SkTDict<FamilyRecID> fFamilyNameDict; | 120 SkTDict<FamilyRecID> fFamilyNameDict; |
121 FamilyRecID fDefaultFamilyRecID; | 121 FamilyRecID fDefaultFamilyRecID; |
122 | 122 |
123 // (SkLanguage)<->(fallback chain index) translation | 123 // (SkLanguage)<->(fallback chain index) translation |
124 SkTDict<FallbackFontList*> fFallbackFontDict; | 124 SkTDict<FallbackFontList*> fFallbackFontDict; |
125 SkTDict<FallbackFontList*> fFallbackFontAliasDict; | 125 SkTDict<FallbackFontList*> fFallbackFontAliasDict; |
126 FallbackFontList fDefaultFallbackList; | 126 FallbackFontList fDefaultFallbackList; |
127 | 127 |
128 // fallback info for current locale | 128 // fallback info for current locale |
129 SkString fCachedLocale; | 129 SkString fCachedLocale; |
(...skipping 26 matching lines...) Expand all Loading... |
156 return gFontConfigInterface; | 156 return gFontConfigInterface; |
157 } | 157 } |
158 | 158 |
159 SkFontConfigInterface* SkFontConfigInterface::GetSingletonDirectInterface(SkBase
Mutex*) { | 159 SkFontConfigInterface* SkFontConfigInterface::GetSingletonDirectInterface(SkBase
Mutex*) { |
160 // Doesn't need passed-in mutex because getSingletonInterface() uses one | 160 // Doesn't need passed-in mutex because getSingletonInterface() uses one |
161 return getSingletonInterface(); | 161 return getSingletonInterface(); |
162 } | 162 } |
163 | 163 |
164 /////////////////////////////////////////////////////////////////////////////// | 164 /////////////////////////////////////////////////////////////////////////////// |
165 | 165 |
166 static bool has_font(const SkTArray<FontRec>& array, const SkString& filename) { | 166 static bool has_font(const SkTArray<FontRec, true>& array, const SkString& filen
ame) { |
167 for (int i = 0; i < array.count(); i++) { | 167 for (int i = 0; i < array.count(); i++) { |
168 if (array[i].fFileName == filename) { | 168 if (array[i].fFileName == filename) { |
169 return true; | 169 return true; |
170 } | 170 } |
171 } | 171 } |
172 return false; | 172 return false; |
173 } | 173 } |
174 | 174 |
175 #ifndef SK_FONT_FILE_PREFIX | 175 #ifndef SK_FONT_FILE_PREFIX |
176 #define SK_FONT_FILE_PREFIX "/fonts/" | 176 #define SK_FONT_FILE_PREFIX "/fonts/" |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 | 496 |
497 // if it is not in the cache then create it | 497 // if it is not in the cache then create it |
498 if (!face) { | 498 if (!face) { |
499 const char* familyName = NULL; | 499 const char* familyName = NULL; |
500 SkAssertResult(fFamilyNameDict.findKey(fontRec.fFamilyRecID, &family
Name)); | 500 SkAssertResult(fFamilyNameDict.findKey(fontRec.fFamilyRecID, &family
Name)); |
501 SkASSERT(familyName); | 501 SkASSERT(familyName); |
502 face = SkTypeface::CreateFromName(familyName, fontRec.fStyle); | 502 face = SkTypeface::CreateFromName(familyName, fontRec.fStyle); |
503 } | 503 } |
504 | 504 |
505 // store the result for subsequent lookups | 505 // store the result for subsequent lookups |
506 fontRec.fTypeface = face; | 506 fontRec.fTypeface.reset(face); |
507 } | 507 } |
508 SkASSERT(face); | 508 SkASSERT(face); |
509 return face; | 509 return face; |
510 } | 510 } |
511 | 511 |
512 bool SkFontConfigInterfaceAndroid::getFallbackFamilyNameForChar(SkUnichar uni, | 512 bool SkFontConfigInterfaceAndroid::getFallbackFamilyNameForChar(SkUnichar uni, |
513 const char* lang
, | 513 const char* lang
, |
514 SkString* name)
{ | 514 SkString* name)
{ |
515 FallbackFontList* fallbackFontList = NULL; | 515 FallbackFontList* fallbackFontList = NULL; |
516 const SkString langTag(lang); | 516 const SkString langTag(lang); |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
905 return SkSafeRef(retTypeface); | 905 return SkSafeRef(retTypeface); |
906 } | 906 } |
907 | 907 |
908 #endif | 908 #endif |
909 | 909 |
910 /////////////////////////////////////////////////////////////////////////////// | 910 /////////////////////////////////////////////////////////////////////////////// |
911 | 911 |
912 SkFontMgr* SkFontMgr::Factory() { | 912 SkFontMgr* SkFontMgr::Factory() { |
913 return NULL; | 913 return NULL; |
914 } | 914 } |
OLD | NEW |