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

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

Issue 334443002: [PDF] Fix font embedding restrictions. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 6 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 | « include/pdf/SkPDFDocument.h ('k') | src/pdf/SkPDFDocument.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 "SkFontDescriptor.h" 10 #include "SkFontDescriptor.h"
10 #include "SkFontHost.h" 11 #include "SkFontHost.h"
11 #include "SkLazyPtr.h" 12 #include "SkLazyPtr.h"
13 #include "SkOTTable_OS_2.h"
12 #include "SkStream.h" 14 #include "SkStream.h"
13 #include "SkTypeface.h" 15 #include "SkTypeface.h"
14 16
15 //#define TRACE_LIFECYCLE 17 //#define TRACE_LIFECYCLE
16 18
17 #ifdef TRACE_LIFECYCLE 19 #ifdef TRACE_LIFECYCLE
18 static int32_t gTypefaceCounter; 20 static int32_t gTypefaceCounter;
19 #endif 21 #endif
20 22
21 SkTypeface::SkTypeface(Style style, SkFontID fontID, bool isFixedPitch) 23 SkTypeface::SkTypeface(Style style, SkFontID fontID, bool isFixedPitch)
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 bool isLocal = false; 264 bool isLocal = false;
263 SkFontDescriptor desc(this->style()); 265 SkFontDescriptor desc(this->style());
264 this->onGetFontDescriptor(&desc, &isLocal); 266 this->onGetFontDescriptor(&desc, &isLocal);
265 name->set(desc.getFamilyName()); 267 name->set(desc.getFamilyName());
266 } 268 }
267 269
268 SkAdvancedTypefaceMetrics* SkTypeface::getAdvancedTypefaceMetrics( 270 SkAdvancedTypefaceMetrics* SkTypeface::getAdvancedTypefaceMetrics(
269 SkAdvancedTypefaceMetrics::PerGlyphInfo info, 271 SkAdvancedTypefaceMetrics::PerGlyphInfo info,
270 const uint32_t* glyphIDs, 272 const uint32_t* glyphIDs,
271 uint32_t glyphIDsCount) const { 273 uint32_t glyphIDsCount) const {
272 return this->onGetAdvancedTypefaceMetrics(info, glyphIDs, glyphIDsCount); 274 SkAdvancedTypefaceMetrics* result =
275 this->onGetAdvancedTypefaceMetrics(info, glyphIDs, glyphIDsCount);
276 if (result && result->fType == SkAdvancedTypefaceMetrics::kTrueType_Font) {
277 struct SkOTTableOS2 os2table;
278 if (this->getTableData(SkTEndian_SwapBE32(SkOTTableOS2::TAG), 0,
279 sizeof(os2table), &os2table) > 0) {
280 if (os2table.version.v2.fsType.field.Bitmap ||
281 (os2table.version.v2.fsType.field.Restricted &&
282 !(os2table.version.v2.fsType.field.PreviewPrint ||
283 os2table.version.v2.fsType.field.Editable))) {
284 result->fFlags = SkTBitOr<SkAdvancedTypefaceMetrics::FontFlags>(
285 result->fFlags,
286 SkAdvancedTypefaceMetrics::kNotEmbeddable_FontFlag);
287 }
288 if (os2table.version.v2.fsType.field.NoSubsetting) {
289 result->fFlags = SkTBitOr<SkAdvancedTypefaceMetrics::FontFlags>(
290 result->fFlags,
291 SkAdvancedTypefaceMetrics::kNotSubsettable_FontFlag);
292 }
293 }
294 }
295 return result;
273 } 296 }
274 297
275 /////////////////////////////////////////////////////////////////////////////// 298 ///////////////////////////////////////////////////////////////////////////////
276 299
277 bool SkTypeface::onGetKerningPairAdjustments(const uint16_t glyphs[], int count, 300 bool SkTypeface::onGetKerningPairAdjustments(const uint16_t glyphs[], int count,
278 int32_t adjustments[]) const { 301 int32_t adjustments[]) const {
279 return false; 302 return false;
280 } 303 }
OLDNEW
« no previous file with comments | « include/pdf/SkPDFDocument.h ('k') | src/pdf/SkPDFDocument.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698