Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(258)

Side by Side Diff: src/ports/SkFontHost_fontconfig.cpp

Issue 382053003: Update find_name_and_attributes to take ttc index. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Move find_name_and_attributes to SkTypeface_FreeType::ScanFont. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/ports/SkFontHost_FreeType_common.h ('k') | src/ports/SkFontHost_linux.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2008 Google Inc. 2 * Copyright 2008 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 "SkFontConfigInterface.h" 8 #include "SkFontConfigInterface.h"
9 #include "SkFontConfigTypeface.h" 9 #include "SkFontConfigTypeface.h"
10 #include "SkFontDescriptor.h" 10 #include "SkFontDescriptor.h"
11 #include "SkFontHost.h" 11 #include "SkFontHost.h"
12 #include "SkFontHost_FreeType_common.h" 12 #include "SkFontHost_FreeType_common.h"
13 #include "SkFontStream.h" 13 #include "SkFontStream.h"
14 #include "SkStream.h" 14 #include "SkStream.h"
15 #include "SkTypeface.h" 15 #include "SkTypeface.h"
16 #include "SkTypefaceCache.h" 16 #include "SkTypefaceCache.h"
17 17
18 // Defined in SkFontHost_FreeType.cpp
19 bool find_name_and_attributes(SkStream* stream, SkString* name,
20 SkTypeface::Style* style, bool* isFixedWidth);
21
22 /////////////////////////////////////////////////////////////////////////////// 18 ///////////////////////////////////////////////////////////////////////////////
23 /////////////////////////////////////////////////////////////////////////////// 19 ///////////////////////////////////////////////////////////////////////////////
24 20
25 SK_DECLARE_STATIC_MUTEX(gFontConfigInterfaceMutex); 21 SK_DECLARE_STATIC_MUTEX(gFontConfigInterfaceMutex);
26 static SkFontConfigInterface* gFontConfigInterface; 22 static SkFontConfigInterface* gFontConfigInterface;
27 23
28 SkFontConfigInterface* SkFontConfigInterface::RefGlobal() { 24 SkFontConfigInterface* SkFontConfigInterface::RefGlobal() {
29 SkAutoMutexAcquire ac(gFontConfigInterfaceMutex); 25 SkAutoMutexAcquire ac(gFontConfigInterfaceMutex);
30 26
31 return SkSafeRef(gFontConfigInterface); 27 return SkSafeRef(gFontConfigInterface);
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 if (!length) { 137 if (!length) {
142 return NULL; 138 return NULL;
143 } 139 }
144 if (length >= 1024 * 1024 * 1024) { 140 if (length >= 1024 * 1024 * 1024) {
145 return NULL; // don't accept too large fonts (>= 1GB) for safety. 141 return NULL; // don't accept too large fonts (>= 1GB) for safety.
146 } 142 }
147 143
148 // ask freetype for reported style and if it is a fixed width font 144 // ask freetype for reported style and if it is a fixed width font
149 SkTypeface::Style style = SkTypeface::kNormal; 145 SkTypeface::Style style = SkTypeface::kNormal;
150 bool isFixedWidth = false; 146 bool isFixedWidth = false;
151 if (!find_name_and_attributes(stream, NULL, &style, &isFixedWidth)) { 147 if (!SkTypeface_FreeType::ScanFont(stream, 0, NULL, &style, &isFixedWidth)) {
152 return NULL; 148 return NULL;
153 } 149 }
154 150
155 SkTypeface* face = SkNEW_ARGS(FontConfigTypeface, (style, isFixedWidth, stre am)); 151 SkTypeface* face = SkNEW_ARGS(FontConfigTypeface, (style, isFixedWidth, stre am));
156 return face; 152 return face;
157 } 153 }
158 154
159 SkTypeface* SkFontHost::CreateTypefaceFromFile(const char path[]) { 155 SkTypeface* SkFontHost::CreateTypefaceFromFile(const char path[]) {
160 SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path)); 156 SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path));
161 return stream.get() ? CreateTypefaceFromStream(stream) : NULL; 157 return stream.get() ? CreateTypefaceFromStream(stream) : NULL;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 *ttcIndex = this->getIdentity().fTTCIndex; 199 *ttcIndex = this->getIdentity().fTTCIndex;
204 } 200 }
205 return stream; 201 return stream;
206 } 202 }
207 203
208 void FontConfigTypeface::onGetFontDescriptor(SkFontDescriptor* desc, 204 void FontConfigTypeface::onGetFontDescriptor(SkFontDescriptor* desc,
209 bool* isLocalStream) const { 205 bool* isLocalStream) const {
210 desc->setFamilyName(this->getFamilyName()); 206 desc->setFamilyName(this->getFamilyName());
211 *isLocalStream = SkToBool(this->getLocalStream()); 207 *isLocalStream = SkToBool(this->getLocalStream());
212 } 208 }
OLDNEW
« no previous file with comments | « src/ports/SkFontHost_FreeType_common.h ('k') | src/ports/SkFontHost_linux.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698