| 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" |
| 11 | 11 |
| 12 #include "SkFontConfigParser_android.h" | 12 #include "SkFontConfigParser_android.h" |
| 13 #include "SkFontConfigTypeface.h" | 13 #include "SkFontConfigTypeface.h" |
| 14 #include "SkFontHost_FreeType_common.h" |
| 14 #include "SkFontMgr.h" | 15 #include "SkFontMgr.h" |
| 15 #include "SkGlyphCache.h" | 16 #include "SkGlyphCache.h" |
| 16 #include "SkPaint.h" | 17 #include "SkPaint.h" |
| 17 #include "SkString.h" | 18 #include "SkString.h" |
| 18 #include "SkStream.h" | 19 #include "SkStream.h" |
| 19 #include "SkThread.h" | 20 #include "SkThread.h" |
| 20 #include "SkTypefaceCache.h" | 21 #include "SkTypefaceCache.h" |
| 21 #include "SkTArray.h" | 22 #include "SkTArray.h" |
| 22 #include "SkTDict.h" | 23 #include "SkTDict.h" |
| 23 #include "SkTSearch.h" | 24 #include "SkTSearch.h" |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 const char* name, FamilyRecID familyRecID) { | 190 const char* name, FamilyRecID familyRecID) { |
| 190 SkAutoAsciiToLC tolc(name); | 191 SkAutoAsciiToLC tolc(name); |
| 191 if (familyNameDict.find(tolc.lc())) { | 192 if (familyNameDict.find(tolc.lc())) { |
| 192 SkDebugf("---- system font attempting to use a the same name [%s] for" | 193 SkDebugf("---- system font attempting to use a the same name [%s] for" |
| 193 "multiple families. skipping subsequent occurrences", tolc.lc()
); | 194 "multiple families. skipping subsequent occurrences", tolc.lc()
); |
| 194 } else { | 195 } else { |
| 195 familyNameDict.set(tolc.lc(), familyRecID); | 196 familyNameDict.set(tolc.lc(), familyRecID); |
| 196 } | 197 } |
| 197 } | 198 } |
| 198 | 199 |
| 199 // Defined in SkFontHost_FreeType.cpp | |
| 200 bool find_name_and_attributes(SkStream* stream, SkString* name, | |
| 201 SkTypeface::Style* style, bool* isFixedWidth); | |
| 202 | |
| 203 /////////////////////////////////////////////////////////////////////////////// | 200 /////////////////////////////////////////////////////////////////////////////// |
| 204 | 201 |
| 205 SkFontConfigInterfaceAndroid::SkFontConfigInterfaceAndroid(SkTDArray<FontFamily*
>& fontFamilies) : | 202 SkFontConfigInterfaceAndroid::SkFontConfigInterfaceAndroid(SkTDArray<FontFamily*
>& fontFamilies) : |
| 206 fFonts(fontFamilies.count()), | 203 fFonts(fontFamilies.count()), |
| 207 fFontFamilies(fontFamilies.count() / FamilyRec::FONT_STYLE_COUNT), | 204 fFontFamilies(fontFamilies.count() / FamilyRec::FONT_STYLE_COUNT), |
| 208 fFamilyNameDict(1024), | 205 fFamilyNameDict(1024), |
| 209 fDefaultFamilyRecID(INVALID_FAMILY_REC_ID), | 206 fDefaultFamilyRecID(INVALID_FAMILY_REC_ID), |
| 210 fFallbackFontDict(128), | 207 fFallbackFontDict(128), |
| 211 fFallbackFontAliasDict(128), | 208 fFallbackFontAliasDict(128), |
| 212 fLocaleFallbackFontList(NULL) { | 209 fLocaleFallbackFontList(NULL) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 234 fontRec.fStyle = SkTypeface::kNormal; | 231 fontRec.fStyle = SkTypeface::kNormal; |
| 235 fontRec.fIsValid = false; | 232 fontRec.fIsValid = false; |
| 236 fontRec.fFamilyRecID = familyRecID; | 233 fontRec.fFamilyRecID = familyRecID; |
| 237 | 234 |
| 238 const FontRecID fontRecID = fFonts.count() - 1; | 235 const FontRecID fontRecID = fFonts.count() - 1; |
| 239 | 236 |
| 240 SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(filename.c_str()
)); | 237 SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(filename.c_str()
)); |
| 241 if (stream.get() != NULL) { | 238 if (stream.get() != NULL) { |
| 242 bool isFixedWidth; | 239 bool isFixedWidth; |
| 243 SkString name; | 240 SkString name; |
| 244 fontRec.fIsValid = find_name_and_attributes(stream.get(), &name, | 241 fontRec.fIsValid = SkTypeface_FreeType::ScanFont(stream.get(), 0
, |
| 245 &fontRec.fStyle, &is
FixedWidth); | 242 &name, &fontRec
.fStyle, |
| 243 &isFixedWidth); |
| 246 } else { | 244 } else { |
| 247 if (!family->fIsFallbackFont) { | 245 if (!family->fIsFallbackFont) { |
| 248 SkDebugf("---- failed to open <%s> as a font\n", filename.c_
str()); | 246 SkDebugf("---- failed to open <%s> as a font\n", filename.c_
str()); |
| 249 } | 247 } |
| 250 } | 248 } |
| 251 | 249 |
| 252 if (fontRec.fIsValid) { | 250 if (fontRec.fIsValid) { |
| 253 DEBUG_FONT(("---- SystemFonts[%d][%d] fallback=%d file=%s", | 251 DEBUG_FONT(("---- SystemFonts[%d][%d] fallback=%d file=%s", |
| 254 i, fFonts.count() - 1, family->fIsFallbackFont, filen
ame.c_str())); | 252 i, fFonts.count() - 1, family->fIsFallbackFont, filen
ame.c_str())); |
| 255 } else { | 253 } else { |
| (...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 907 return SkSafeRef(retTypeface); | 905 return SkSafeRef(retTypeface); |
| 908 } | 906 } |
| 909 | 907 |
| 910 #endif | 908 #endif |
| 911 | 909 |
| 912 /////////////////////////////////////////////////////////////////////////////// | 910 /////////////////////////////////////////////////////////////////////////////// |
| 913 | 911 |
| 914 SkFontMgr* SkFontMgr::Factory() { | 912 SkFontMgr* SkFontMgr::Factory() { |
| 915 return NULL; | 913 return NULL; |
| 916 } | 914 } |
| OLD | NEW |