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

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

Issue 2030683002: Update typeface serialization style. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase Created 4 years, 6 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/fonts/SkFontMgr_fontconfig.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 2011 The Android Open Source Project 2 * Copyright 2011 The Android Open Source Project
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 "SkAdvancedTypefaceMetrics.h" 8 #include "SkAdvancedTypefaceMetrics.h"
9 #include "SkEndian.h" 9 #include "SkEndian.h"
10 #include "SkFontDescriptor.h" 10 #include "SkFontDescriptor.h"
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 } 160 }
161 161
162 /////////////////////////////////////////////////////////////////////////////// 162 ///////////////////////////////////////////////////////////////////////////////
163 163
164 void SkTypeface::serialize(SkWStream* wstream) const { 164 void SkTypeface::serialize(SkWStream* wstream) const {
165 if (gSerializeTypefaceDelegate) { 165 if (gSerializeTypefaceDelegate) {
166 (*gSerializeTypefaceDelegate)(this, wstream); 166 (*gSerializeTypefaceDelegate)(this, wstream);
167 return; 167 return;
168 } 168 }
169 bool isLocal = false; 169 bool isLocal = false;
170 SkFontDescriptor desc(this->style()); 170 SkFontDescriptor desc;
171 this->onGetFontDescriptor(&desc, &isLocal); 171 this->onGetFontDescriptor(&desc, &isLocal);
172 172
173 // Embed font data if it's a local font. 173 // Embed font data if it's a local font.
174 if (isLocal && !desc.hasFontData()) { 174 if (isLocal && !desc.hasFontData()) {
175 desc.setFontData(this->onCreateFontData()); 175 desc.setFontData(this->onCreateFontData());
176 } 176 }
177 desc.serialize(wstream); 177 desc.serialize(wstream);
178 } 178 }
179 179
180 sk_sp<SkTypeface> SkTypeface::MakeDeserialize(SkStream* stream) { 180 sk_sp<SkTypeface> SkTypeface::MakeDeserialize(SkStream* stream) {
181 if (gDeserializeTypefaceDelegate) { 181 if (gDeserializeTypefaceDelegate) {
182 return (*gDeserializeTypefaceDelegate)(stream); 182 return (*gDeserializeTypefaceDelegate)(stream);
183 } 183 }
184 184
185 SkFontDescriptor desc; 185 SkFontDescriptor desc;
186 if (!SkFontDescriptor::Deserialize(stream, &desc)) { 186 if (!SkFontDescriptor::Deserialize(stream, &desc)) {
187 return nullptr; 187 return nullptr;
188 } 188 }
189 189
190 SkFontData* data = desc.detachFontData(); 190 SkFontData* data = desc.detachFontData();
191 if (data) { 191 if (data) {
192 sk_sp<SkTypeface> typeface(SkTypeface::MakeFromFontData(data)); 192 sk_sp<SkTypeface> typeface(SkTypeface::MakeFromFontData(data));
193 if (typeface) { 193 if (typeface) {
194 return typeface; 194 return typeface;
195 } 195 }
196 } 196 }
197 197
198 return SkTypeface::MakeFromName(desc.getFamilyName(), 198 return SkTypeface::MakeFromName(desc.getFamilyName(), desc.getStyle());
199 SkFontStyle::FromOldStyle(desc.getStyle()));
200 } 199 }
201 200
202 /////////////////////////////////////////////////////////////////////////////// 201 ///////////////////////////////////////////////////////////////////////////////
203 202
204 int SkTypeface::countTables() const { 203 int SkTypeface::countTables() const {
205 return this->onGetTableTags(nullptr); 204 return this->onGetTableTags(nullptr);
206 } 205 }
207 206
208 int SkTypeface::getTableTags(SkFontTableTag tags[]) const { 207 int SkTypeface::getTableTags(SkFontTableTag tags[]) const {
209 return this->onGetTableTags(tags); 208 return this->onGetTableTags(tags);
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 SkAutoTDelete<SkScalerContext> ctx(this->createScalerContext(noeffects, desc , true)); 353 SkAutoTDelete<SkScalerContext> ctx(this->createScalerContext(noeffects, desc , true));
355 if (ctx.get()) { 354 if (ctx.get()) {
356 SkPaint::FontMetrics fm; 355 SkPaint::FontMetrics fm;
357 ctx->getFontMetrics(&fm); 356 ctx->getFontMetrics(&fm);
358 bounds->set(fm.fXMin * invTextSize, fm.fTop * invTextSize, 357 bounds->set(fm.fXMin * invTextSize, fm.fTop * invTextSize,
359 fm.fXMax * invTextSize, fm.fBottom * invTextSize); 358 fm.fXMax * invTextSize, fm.fBottom * invTextSize);
360 return true; 359 return true;
361 } 360 }
362 return false; 361 return false;
363 } 362 }
OLDNEW
« no previous file with comments | « src/core/SkFontDescriptor.cpp ('k') | src/fonts/SkFontMgr_fontconfig.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698