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

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

Issue 23966003: Update the freetype backed fonthost to keep the style and fixed width attributes for a font stream. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: updating per comments Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « src/ports/SkFontConfigTypeface.h ('k') | no next file » | 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 ///////////////////////////////////////////////////////////////////////////////
23 ///////////////////////////////////////////////////////////////////////////////
24
18 SK_DECLARE_STATIC_MUTEX(gFontConfigInterfaceMutex); 25 SK_DECLARE_STATIC_MUTEX(gFontConfigInterfaceMutex);
19 static SkFontConfigInterface* gFontConfigInterface; 26 static SkFontConfigInterface* gFontConfigInterface;
20 27
21 SkFontConfigInterface* SkFontConfigInterface::RefGlobal() { 28 SkFontConfigInterface* SkFontConfigInterface::RefGlobal() {
22 SkAutoMutexAcquire ac(gFontConfigInterfaceMutex); 29 SkAutoMutexAcquire ac(gFontConfigInterfaceMutex);
23 30
24 return SkSafeRef(gFontConfigInterface); 31 return SkSafeRef(gFontConfigInterface);
25 } 32 }
26 33
27 SkFontConfigInterface* SkFontConfigInterface::SetGlobal(SkFontConfigInterface* f c) { 34 SkFontConfigInterface* SkFontConfigInterface::SetGlobal(SkFontConfigInterface* f c) {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 return NULL; 129 return NULL;
123 } 130 }
124 const size_t length = stream->getLength(); 131 const size_t length = stream->getLength();
125 if (!length) { 132 if (!length) {
126 return NULL; 133 return NULL;
127 } 134 }
128 if (length >= 1024 * 1024 * 1024) { 135 if (length >= 1024 * 1024 * 1024) {
129 return NULL; // don't accept too large fonts (>= 1GB) for safety. 136 return NULL; // don't accept too large fonts (>= 1GB) for safety.
130 } 137 }
131 138
132 // TODO should the caller give us the style? 139 // ask freetype for reported style and if it is a fixed width font
133 SkTypeface::Style style = SkTypeface::kNormal; 140 SkTypeface::Style style = SkTypeface::kNormal;
134 SkTypeface* face = SkNEW_ARGS(FontConfigTypeface, (style, stream)); 141 bool isFixedWidth = false;
142 if (!find_name_and_attributes(stream, NULL, &style, &isFixedWidth)) {
143 return NULL;
144 }
145
146 SkTypeface* face = SkNEW_ARGS(FontConfigTypeface, (style, isFixedWidth, stre am));
135 return face; 147 return face;
136 } 148 }
137 149
138 SkTypeface* SkFontHost::CreateTypefaceFromFile(const char path[]) { 150 SkTypeface* SkFontHost::CreateTypefaceFromFile(const char path[]) {
139 SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path)); 151 SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path));
140 return stream.get() ? CreateTypefaceFromStream(stream) : NULL; 152 return stream.get() ? CreateTypefaceFromStream(stream) : NULL;
141 } 153 }
142 154
143 #endif 155 #endif
144 156
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 198
187 void FontConfigTypeface::onGetFontDescriptor(SkFontDescriptor* desc, 199 void FontConfigTypeface::onGetFontDescriptor(SkFontDescriptor* desc,
188 bool* isLocalStream) const { 200 bool* isLocalStream) const {
189 desc->setFamilyName(this->getFamilyName()); 201 desc->setFamilyName(this->getFamilyName());
190 *isLocalStream = SkToBool(this->getLocalStream()); 202 *isLocalStream = SkToBool(this->getLocalStream());
191 } 203 }
192 204
193 SkTypeface* FontConfigTypeface::onRefMatchingStyle(Style style) const { 205 SkTypeface* FontConfigTypeface::onRefMatchingStyle(Style style) const {
194 return LegacyCreateTypeface(this, NULL, style); 206 return LegacyCreateTypeface(this, NULL, style);
195 } 207 }
OLDNEW
« no previous file with comments | « src/ports/SkFontConfigTypeface.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698