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

Side by Side Diff: src/core/SkFontMgr.cpp

Issue 1027373002: Font variations. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase Created 5 years, 7 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/SkFontDescriptor.cpp ('k') | src/core/SkTypeface.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 2015 Google Inc. 2 * Copyright 2015 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 "SkFontDescriptor.h"
8 #include "SkFontMgr.h" 9 #include "SkFontMgr.h"
9 #include "SkLazyPtr.h" 10 #include "SkLazyPtr.h"
10 #include "SkStream.h" 11 #include "SkStream.h"
11 #include "SkTypes.h" 12 #include "SkTypes.h"
12 13
13 class SkFontStyle; 14 class SkFontStyle;
14 class SkTypeface; 15 class SkTypeface;
15 16
16 class SkEmptyFontStyleSet : public SkFontStyleSet { 17 class SkEmptyFontStyleSet : public SkFontStyleSet {
17 public: 18 public:
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 return this->onCreateFromData(data, ttcIndex); 127 return this->onCreateFromData(data, ttcIndex);
127 } 128 }
128 129
129 SkTypeface* SkFontMgr::createFromStream(SkStreamAsset* stream, int ttcIndex) con st { 130 SkTypeface* SkFontMgr::createFromStream(SkStreamAsset* stream, int ttcIndex) con st {
130 if (NULL == stream) { 131 if (NULL == stream) {
131 return NULL; 132 return NULL;
132 } 133 }
133 return this->onCreateFromStream(stream, ttcIndex); 134 return this->onCreateFromStream(stream, ttcIndex);
134 } 135 }
135 136
137 SkTypeface* SkFontMgr::createFromFontData(SkFontData* data) const {
138 if (NULL == data) {
139 return NULL;
140 }
141 return this->onCreateFromFontData(data);
142 }
143
144 // This implementation is temporary until it can be made pure virtual.
145 SkTypeface* SkFontMgr::onCreateFromFontData(SkFontData* data) const {
146 SkTypeface* ret = this->createFromStream(data->detachStream(), data->getInde x());
147 delete data;
148 return ret;
149 }
150
136 SkTypeface* SkFontMgr::createFromFile(const char path[], int ttcIndex) const { 151 SkTypeface* SkFontMgr::createFromFile(const char path[], int ttcIndex) const {
137 if (NULL == path) { 152 if (NULL == path) {
138 return NULL; 153 return NULL;
139 } 154 }
140 return this->onCreateFromFile(path, ttcIndex); 155 return this->onCreateFromFile(path, ttcIndex);
141 } 156 }
142 157
143 SkTypeface* SkFontMgr::legacyCreateTypeface(const char familyName[], 158 SkTypeface* SkFontMgr::legacyCreateTypeface(const char familyName[],
144 unsigned styleBits) const { 159 unsigned styleBits) const {
145 return this->onLegacyCreateTypeface(familyName, styleBits); 160 return this->onLegacyCreateTypeface(familyName, styleBits);
146 } 161 }
147 162
148 // As a template argument this must have external linkage. 163 // As a template argument this must have external linkage.
149 SkFontMgr* sk_fontmgr_create_default() { 164 SkFontMgr* sk_fontmgr_create_default() {
150 SkFontMgr* fm = SkFontMgr::Factory(); 165 SkFontMgr* fm = SkFontMgr::Factory();
151 return fm ? fm : SkNEW(SkEmptyFontMgr); 166 return fm ? fm : SkNEW(SkEmptyFontMgr);
152 } 167 }
153 168
154 SK_DECLARE_STATIC_LAZY_PTR(SkFontMgr, singleton, sk_fontmgr_create_default); 169 SK_DECLARE_STATIC_LAZY_PTR(SkFontMgr, singleton, sk_fontmgr_create_default);
155 170
156 SkFontMgr* SkFontMgr::RefDefault() { 171 SkFontMgr* SkFontMgr::RefDefault() {
157 return SkRef(singleton.get()); 172 return SkRef(singleton.get());
158 } 173 }
OLDNEW
« no previous file with comments | « src/core/SkFontDescriptor.cpp ('k') | src/core/SkTypeface.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698