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

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

Issue 488083004: Remove SK_FONT_HOST_DOES_NOT_USE_FONTMGR and guarded code. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 4 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/core/SkFontHost.cpp ('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"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 if (face) { 113 if (face) {
114 return face; 114 return face;
115 } 115 }
116 116
117 face = FontConfigTypeface::Create(outStyle, indentity, outFamilyName); 117 face = FontConfigTypeface::Create(outStyle, indentity, outFamilyName);
118 SkTypefaceCache::Add(face, style); 118 SkTypefaceCache::Add(face, style);
119 // SkDebugf("add face <%s> <%s> %p [%d]\n", familyName, outFamilyName.c_str() , face, face->getRefCnt()); 119 // SkDebugf("add face <%s> <%s> %p [%d]\n", familyName, outFamilyName.c_str() , face, face->getRefCnt());
120 return face; 120 return face;
121 } 121 }
122 122
123 #ifdef SK_FONTHOST_DOES_NOT_USE_FONTMGR
124
125 SkTypeface* SkFontHost::CreateTypeface(const SkTypeface* familyFace,
126 const char familyName[],
127 SkTypeface::Style style) {
128 return FontConfigTypeface::LegacyCreateTypeface(familyFace, familyName,
129 style);
130 }
131
132 SkTypeface* SkFontHost::CreateTypefaceFromStream(SkStream* stream) {
133 if (!stream) {
134 return NULL;
135 }
136 const size_t length = stream->getLength();
137 if (!length) {
138 return NULL;
139 }
140 if (length >= 1024 * 1024 * 1024) {
141 return NULL; // don't accept too large fonts (>= 1GB) for safety.
142 }
143
144 // ask freetype for reported style and if it is a fixed width font
145 SkTypeface::Style style = SkTypeface::kNormal;
146 bool isFixedWidth = false;
147 if (!SkTypeface_FreeType::ScanFont(stream, 0, NULL, &style, &isFixedWidth)) {
148 return NULL;
149 }
150
151 SkTypeface* face = SkNEW_ARGS(FontConfigTypeface, (style, isFixedWidth, stre am));
152 return face;
153 }
154
155 SkTypeface* SkFontHost::CreateTypefaceFromFile(const char path[]) {
156 SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path));
157 return stream.get() ? CreateTypefaceFromStream(stream) : NULL;
158 }
159
160 #endif
161
162 /////////////////////////////////////////////////////////////////////////////// 123 ///////////////////////////////////////////////////////////////////////////////
163 124
164 SkStream* FontConfigTypeface::onOpenStream(int* ttcIndex) const { 125 SkStream* FontConfigTypeface::onOpenStream(int* ttcIndex) const {
165 SkStream* stream = this->getLocalStream(); 126 SkStream* stream = this->getLocalStream();
166 if (stream) { 127 if (stream) {
167 // should have been provided by CreateFromStream() 128 // should have been provided by CreateFromStream()
168 *ttcIndex = 0; 129 *ttcIndex = 0;
169 130
170 SkAutoTUnref<SkStream> dupStream(stream->duplicate()); 131 SkAutoTUnref<SkStream> dupStream(stream->duplicate());
171 if (dupStream) { 132 if (dupStream) {
(...skipping 27 matching lines...) Expand all
199 *ttcIndex = this->getIdentity().fTTCIndex; 160 *ttcIndex = this->getIdentity().fTTCIndex;
200 } 161 }
201 return stream; 162 return stream;
202 } 163 }
203 164
204 void FontConfigTypeface::onGetFontDescriptor(SkFontDescriptor* desc, 165 void FontConfigTypeface::onGetFontDescriptor(SkFontDescriptor* desc,
205 bool* isLocalStream) const { 166 bool* isLocalStream) const {
206 desc->setFamilyName(this->getFamilyName()); 167 desc->setFamilyName(this->getFamilyName());
207 *isLocalStream = SkToBool(this->getLocalStream()); 168 *isLocalStream = SkToBool(this->getLocalStream());
208 } 169 }
OLDNEW
« no previous file with comments | « src/core/SkFontHost.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698