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

Side by Side Diff: src/pdf/SkPDFFont.cpp

Issue 1772493002: SkPDF: AutoTUnref<T> changes in use (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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/pdf/SkPDFDevice.cpp ('k') | src/pdf/SkPDFFormXObject.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 Google Inc. 2 * Copyright 2011 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 <ctype.h> 8 #include <ctype.h>
9 9
10 #include "SkData.h" 10 #include "SkData.h"
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 SkASSERT(advanceInfo->fAdvance.count() == 1); 336 SkASSERT(advanceInfo->fAdvance.count() == 1);
337 *defaultAdvance = advanceInfo->fAdvance[0]; 337 *defaultAdvance = advanceInfo->fAdvance[0];
338 break; 338 break;
339 } 339 }
340 case SkAdvancedTypefaceMetrics::WidthRange::kRange: { 340 case SkAdvancedTypefaceMetrics::WidthRange::kRange: {
341 SkAutoTUnref<SkPDFArray> advanceArray(new SkPDFArray()); 341 SkAutoTUnref<SkPDFArray> advanceArray(new SkPDFArray());
342 for (int j = 0; j < advanceInfo->fAdvance.count(); j++) 342 for (int j = 0; j < advanceInfo->fAdvance.count(); j++)
343 appendAdvance(advanceInfo->fAdvance[j], emSize, 343 appendAdvance(advanceInfo->fAdvance[j], emSize,
344 advanceArray.get()); 344 advanceArray.get());
345 result->appendInt(advanceInfo->fStartId); 345 result->appendInt(advanceInfo->fStartId);
346 result->appendObject(advanceArray.detach()); 346 result->appendObject(advanceArray.release());
347 break; 347 break;
348 } 348 }
349 case SkAdvancedTypefaceMetrics::WidthRange::kRun: { 349 case SkAdvancedTypefaceMetrics::WidthRange::kRun: {
350 SkASSERT(advanceInfo->fAdvance.count() == 1); 350 SkASSERT(advanceInfo->fAdvance.count() == 1);
351 result->appendInt(advanceInfo->fStartId); 351 result->appendInt(advanceInfo->fStartId);
352 result->appendInt(advanceInfo->fEndId); 352 result->appendInt(advanceInfo->fEndId);
353 appendAdvance(advanceInfo->fAdvance[0], emSize, result); 353 appendAdvance(advanceInfo->fAdvance[0], emSize, result);
354 break; 354 break;
355 } 355 }
356 } 356 }
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after
1015 #endif 1015 #endif
1016 1016
1017 bool SkPDFType0Font::populate(const SkPDFGlyphSet* subset) { 1017 bool SkPDFType0Font::populate(const SkPDFGlyphSet* subset) {
1018 insertName("Subtype", "Type0"); 1018 insertName("Subtype", "Type0");
1019 insertName("BaseFont", fontInfo()->fFontName); 1019 insertName("BaseFont", fontInfo()->fFontName);
1020 insertName("Encoding", "Identity-H"); 1020 insertName("Encoding", "Identity-H");
1021 1021
1022 SkAutoTUnref<SkPDFCIDFont> newCIDFont( 1022 SkAutoTUnref<SkPDFCIDFont> newCIDFont(
1023 new SkPDFCIDFont(fontInfo(), typeface(), subset)); 1023 new SkPDFCIDFont(fontInfo(), typeface(), subset));
1024 SkAutoTUnref<SkPDFArray> descendantFonts(new SkPDFArray()); 1024 SkAutoTUnref<SkPDFArray> descendantFonts(new SkPDFArray());
1025 descendantFonts->appendObjRef(newCIDFont.detach()); 1025 descendantFonts->appendObjRef(newCIDFont.release());
1026 this->insertObject("DescendantFonts", descendantFonts.detach()); 1026 this->insertObject("DescendantFonts", descendantFonts.release());
1027 1027
1028 this->populateToUnicodeTable(subset); 1028 this->populateToUnicodeTable(subset);
1029 1029
1030 SkDEBUGCODE(fPopulated = true); 1030 SkDEBUGCODE(fPopulated = true);
1031 return true; 1031 return true;
1032 } 1032 }
1033 1033
1034 /////////////////////////////////////////////////////////////////////////////// 1034 ///////////////////////////////////////////////////////////////////////////////
1035 // class SkPDFCIDFont 1035 // class SkPDFCIDFont
1036 /////////////////////////////////////////////////////////////////////////////// 1036 ///////////////////////////////////////////////////////////////////////////////
1037 1037
1038 SkPDFCIDFont::SkPDFCIDFont(const SkAdvancedTypefaceMetrics* info, 1038 SkPDFCIDFont::SkPDFCIDFont(const SkAdvancedTypefaceMetrics* info,
1039 SkTypeface* typeface, 1039 SkTypeface* typeface,
1040 const SkPDFGlyphSet* subset) 1040 const SkPDFGlyphSet* subset)
1041 : SkPDFFont(info, typeface, nullptr) { 1041 : SkPDFFont(info, typeface, nullptr) {
1042 this->populate(subset); 1042 this->populate(subset);
1043 } 1043 }
1044 1044
1045 SkPDFCIDFont::~SkPDFCIDFont() {} 1045 SkPDFCIDFont::~SkPDFCIDFont() {}
1046 1046
1047 bool SkPDFCIDFont::addFontDescriptor(int16_t defaultWidth, 1047 bool SkPDFCIDFont::addFontDescriptor(int16_t defaultWidth,
1048 const SkTDArray<uint32_t>* subset) { 1048 const SkTDArray<uint32_t>* subset) {
1049 SkAutoTUnref<SkPDFDict> descriptor(new SkPDFDict("FontDescriptor")); 1049 SkAutoTUnref<SkPDFDict> descriptor(new SkPDFDict("FontDescriptor"));
1050 setFontDescriptor(descriptor.get()); 1050 setFontDescriptor(descriptor.get());
1051 if (!addCommonFontDescriptorEntries(defaultWidth)) { 1051 if (!addCommonFontDescriptorEntries(defaultWidth)) {
1052 this->insertObjRef("FontDescriptor", descriptor.detach()); 1052 this->insertObjRef("FontDescriptor", descriptor.release());
1053 return false; 1053 return false;
1054 } 1054 }
1055 SkASSERT(this->canEmbed()); 1055 SkASSERT(this->canEmbed());
1056 1056
1057 switch (getType()) { 1057 switch (getType()) {
1058 case SkAdvancedTypefaceMetrics::kTrueType_Font: { 1058 case SkAdvancedTypefaceMetrics::kTrueType_Font: {
1059 size_t fontSize = 0; 1059 size_t fontSize = 0;
1060 #if defined(SK_SFNTLY_SUBSETTER) 1060 #if defined(SK_SFNTLY_SUBSETTER)
1061 if (this->canSubset()) { 1061 if (this->canSubset()) {
1062 SkAutoTUnref<SkPDFStream> fontStream; 1062 SkAutoTUnref<SkPDFStream> fontStream;
1063 SkPDFStream* rawStream = nullptr; 1063 SkPDFStream* rawStream = nullptr;
1064 fontSize = get_subset_font_stream(fontInfo()->fFontName.c_str(), 1064 fontSize = get_subset_font_stream(fontInfo()->fFontName.c_str(),
1065 typeface(), 1065 typeface(),
1066 *subset, 1066 *subset,
1067 &rawStream); 1067 &rawStream);
1068 if (rawStream) { 1068 if (rawStream) {
1069 fontStream.reset(rawStream); 1069 fontStream.reset(rawStream);
1070 fontStream->insertInt("Length1", fontSize); 1070 fontStream->insertInt("Length1", fontSize);
1071 descriptor->insertObjRef("FontFile2", fontStream.detach()); 1071 descriptor->insertObjRef("FontFile2", fontStream.release());
1072 break; 1072 break;
1073 } 1073 }
1074 } 1074 }
1075 #endif 1075 #endif
1076 SkAutoTUnref<SkPDFSharedStream> fontStream; 1076 SkAutoTUnref<SkPDFSharedStream> fontStream;
1077 SkAutoTDelete<SkStreamAsset> fontData( 1077 SkAutoTDelete<SkStreamAsset> fontData(
1078 this->typeface()->openStream(nullptr)); 1078 this->typeface()->openStream(nullptr));
1079 SkASSERT(fontData); 1079 SkASSERT(fontData);
1080 fontSize = fontData->getLength(); 1080 fontSize = fontData->getLength();
1081 SkASSERT(fontSize > 0); 1081 SkASSERT(fontSize > 0);
1082 fontStream.reset(new SkPDFSharedStream(fontData.detach())); 1082 fontStream.reset(new SkPDFSharedStream(fontData.detach()));
1083 fontStream->dict()->insertInt("Length1", fontSize); 1083 fontStream->dict()->insertInt("Length1", fontSize);
1084 descriptor->insertObjRef("FontFile2", fontStream.detach()); 1084 descriptor->insertObjRef("FontFile2", fontStream.release());
1085 break; 1085 break;
1086 } 1086 }
1087 case SkAdvancedTypefaceMetrics::kCFF_Font: 1087 case SkAdvancedTypefaceMetrics::kCFF_Font:
1088 case SkAdvancedTypefaceMetrics::kType1CID_Font: { 1088 case SkAdvancedTypefaceMetrics::kType1CID_Font: {
1089 SkAutoTUnref<SkPDFSharedStream> fontStream( 1089 SkAutoTUnref<SkPDFSharedStream> fontStream(
1090 new SkPDFSharedStream(this->typeface()->openStream(nullptr)) ); 1090 new SkPDFSharedStream(this->typeface()->openStream(nullptr)) );
1091 1091
1092 if (getType() == SkAdvancedTypefaceMetrics::kCFF_Font) { 1092 if (getType() == SkAdvancedTypefaceMetrics::kCFF_Font) {
1093 fontStream->dict()->insertName("Subtype", "Type1C"); 1093 fontStream->dict()->insertName("Subtype", "Type1C");
1094 } else { 1094 } else {
1095 fontStream->dict()->insertName("Subtype", "CIDFontType0c"); 1095 fontStream->dict()->insertName("Subtype", "CIDFontType0c");
1096 } 1096 }
1097 descriptor->insertObjRef("FontFile3", fontStream.detach()); 1097 descriptor->insertObjRef("FontFile3", fontStream.release());
1098 break; 1098 break;
1099 } 1099 }
1100 default: 1100 default:
1101 SkASSERT(false); 1101 SkASSERT(false);
1102 } 1102 }
1103 this->insertObjRef("FontDescriptor", descriptor.detach()); 1103 this->insertObjRef("FontDescriptor", descriptor.release());
1104 return true; 1104 return true;
1105 } 1105 }
1106 1106
1107 bool SkPDFCIDFont::populate(const SkPDFGlyphSet* subset) { 1107 bool SkPDFCIDFont::populate(const SkPDFGlyphSet* subset) {
1108 // Generate new font metrics with advance info for true type fonts. 1108 // Generate new font metrics with advance info for true type fonts.
1109 if (fontInfo()->fType == SkAdvancedTypefaceMetrics::kTrueType_Font) { 1109 if (fontInfo()->fType == SkAdvancedTypefaceMetrics::kTrueType_Font) {
1110 // Generate glyph id array. 1110 // Generate glyph id array.
1111 SkTDArray<uint32_t> glyphIDs; 1111 SkTDArray<uint32_t> glyphIDs;
1112 if (subset) { 1112 if (subset) {
1113 // Always include glyph 0. 1113 // Always include glyph 0.
(...skipping 26 matching lines...) Expand all
1140 insertName("Subtype", "CIDFontType2"); 1140 insertName("Subtype", "CIDFontType2");
1141 insertName("CIDToGIDMap", "Identity"); 1141 insertName("CIDToGIDMap", "Identity");
1142 } else { 1142 } else {
1143 SkASSERT(false); 1143 SkASSERT(false);
1144 } 1144 }
1145 1145
1146 SkAutoTUnref<SkPDFDict> sysInfo(new SkPDFDict); 1146 SkAutoTUnref<SkPDFDict> sysInfo(new SkPDFDict);
1147 sysInfo->insertString("Registry", "Adobe"); 1147 sysInfo->insertString("Registry", "Adobe");
1148 sysInfo->insertString("Ordering", "Identity"); 1148 sysInfo->insertString("Ordering", "Identity");
1149 sysInfo->insertInt("Supplement", 0); 1149 sysInfo->insertInt("Supplement", 0);
1150 this->insertObject("CIDSystemInfo", sysInfo.detach()); 1150 this->insertObject("CIDSystemInfo", sysInfo.release());
1151 1151
1152 if (fontInfo()->fGlyphWidths.get()) { 1152 if (fontInfo()->fGlyphWidths.get()) {
1153 int16_t defaultWidth = 0; 1153 int16_t defaultWidth = 0;
1154 SkAutoTUnref<SkPDFArray> widths( 1154 SkAutoTUnref<SkPDFArray> widths(
1155 composeAdvanceData(fontInfo()->fGlyphWidths.get(), 1155 composeAdvanceData(fontInfo()->fGlyphWidths.get(),
1156 fontInfo()->fEmSize, &appendWidth, 1156 fontInfo()->fEmSize, &appendWidth,
1157 &defaultWidth)); 1157 &defaultWidth));
1158 if (widths->size()) 1158 if (widths->size())
1159 this->insertObject("W", widths.detach()); 1159 this->insertObject("W", widths.release());
1160 if (defaultWidth != 0) { 1160 if (defaultWidth != 0) {
1161 this->insertScalar( 1161 this->insertScalar(
1162 "DW", 1162 "DW",
1163 scaleFromFontUnits(defaultWidth, fontInfo()->fEmSize)); 1163 scaleFromFontUnits(defaultWidth, fontInfo()->fEmSize));
1164 } 1164 }
1165 } 1165 }
1166 if (fontInfo()->fVerticalMetrics.get()) { 1166 if (fontInfo()->fVerticalMetrics.get()) {
1167 struct SkAdvancedTypefaceMetrics::VerticalMetric defaultAdvance; 1167 struct SkAdvancedTypefaceMetrics::VerticalMetric defaultAdvance;
1168 defaultAdvance.fVerticalAdvance = 0; 1168 defaultAdvance.fVerticalAdvance = 0;
1169 defaultAdvance.fOriginXDisp = 0; 1169 defaultAdvance.fOriginXDisp = 0;
1170 defaultAdvance.fOriginYDisp = 0; 1170 defaultAdvance.fOriginYDisp = 0;
1171 SkAutoTUnref<SkPDFArray> advances( 1171 SkAutoTUnref<SkPDFArray> advances(
1172 composeAdvanceData(fontInfo()->fVerticalMetrics.get(), 1172 composeAdvanceData(fontInfo()->fVerticalMetrics.get(),
1173 fontInfo()->fEmSize, &appendVerticalAdvance, 1173 fontInfo()->fEmSize, &appendVerticalAdvance,
1174 &defaultAdvance)); 1174 &defaultAdvance));
1175 if (advances->size()) 1175 if (advances->size())
1176 this->insertObject("W2", advances.detach()); 1176 this->insertObject("W2", advances.release());
1177 if (defaultAdvance.fVerticalAdvance || 1177 if (defaultAdvance.fVerticalAdvance ||
1178 defaultAdvance.fOriginXDisp || 1178 defaultAdvance.fOriginXDisp ||
1179 defaultAdvance.fOriginYDisp) { 1179 defaultAdvance.fOriginYDisp) {
1180 this->insertObject("DW2", 1180 this->insertObject("DW2",
1181 appendVerticalAdvance(defaultAdvance, 1181 appendVerticalAdvance(defaultAdvance,
1182 fontInfo()->fEmSize, 1182 fontInfo()->fEmSize,
1183 new SkPDFArray)); 1183 new SkPDFArray));
1184 } 1184 }
1185 } 1185 }
1186 1186
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1218 SkAutoTUnref<SkData> fontData(handle_type1_stream(rawFontData.get(), &header , 1218 SkAutoTUnref<SkData> fontData(handle_type1_stream(rawFontData.get(), &header ,
1219 &data, &trailer)); 1219 &data, &trailer));
1220 if (fontData.get() == nullptr) { 1220 if (fontData.get() == nullptr) {
1221 return false; 1221 return false;
1222 } 1222 }
1223 SkASSERT(this->canEmbed()); 1223 SkASSERT(this->canEmbed());
1224 SkAutoTUnref<SkPDFStream> fontStream(new SkPDFStream(fontData.get())); 1224 SkAutoTUnref<SkPDFStream> fontStream(new SkPDFStream(fontData.get()));
1225 fontStream->insertInt("Length1", header); 1225 fontStream->insertInt("Length1", header);
1226 fontStream->insertInt("Length2", data); 1226 fontStream->insertInt("Length2", data);
1227 fontStream->insertInt("Length3", trailer); 1227 fontStream->insertInt("Length3", trailer);
1228 descriptor->insertObjRef("FontFile", fontStream.detach()); 1228 descriptor->insertObjRef("FontFile", fontStream.release());
1229 1229
1230 this->insertObjRef("FontDescriptor", descriptor.detach()); 1230 this->insertObjRef("FontDescriptor", descriptor.release());
1231 1231
1232 return addCommonFontDescriptorEntries(defaultWidth); 1232 return addCommonFontDescriptorEntries(defaultWidth);
1233 } 1233 }
1234 1234
1235 bool SkPDFType1Font::populate(int16_t glyphID) { 1235 bool SkPDFType1Font::populate(int16_t glyphID) {
1236 SkASSERT(!fontInfo()->fVerticalMetrics.get()); 1236 SkASSERT(!fontInfo()->fVerticalMetrics.get());
1237 SkASSERT(fontInfo()->fGlyphWidths.get()); 1237 SkASSERT(fontInfo()->fGlyphWidths.get());
1238 1238
1239 adjustGlyphRangeForSingleByteEncoding(glyphID); 1239 adjustGlyphRangeForSingleByteEncoding(glyphID);
1240 1240
(...skipping 28 matching lines...) Expand all
1269 1269
1270 1270
1271 SkAutoTUnref<SkPDFArray> encDiffs(new SkPDFArray); 1271 SkAutoTUnref<SkPDFArray> encDiffs(new SkPDFArray);
1272 encDiffs->reserve(lastGlyphID() - firstGlyphID() + 2); 1272 encDiffs->reserve(lastGlyphID() - firstGlyphID() + 2);
1273 encDiffs->appendInt(1); 1273 encDiffs->appendInt(1);
1274 for (int gID = firstGlyphID(); gID <= lastGlyphID(); gID++) { 1274 for (int gID = firstGlyphID(); gID <= lastGlyphID(); gID++) {
1275 encDiffs->appendName(fontInfo()->fGlyphNames->get()[gID].c_str()); 1275 encDiffs->appendName(fontInfo()->fGlyphNames->get()[gID].c_str());
1276 } 1276 }
1277 1277
1278 SkAutoTUnref<SkPDFDict> encoding(new SkPDFDict("Encoding")); 1278 SkAutoTUnref<SkPDFDict> encoding(new SkPDFDict("Encoding"));
1279 encoding->insertObject("Differences", encDiffs.detach()); 1279 encoding->insertObject("Differences", encDiffs.release());
1280 this->insertObject("Encoding", encoding.detach()); 1280 this->insertObject("Encoding", encoding.release());
1281 return true; 1281 return true;
1282 } 1282 }
1283 1283
1284 void SkPDFType1Font::addWidthInfoFromRange( 1284 void SkPDFType1Font::addWidthInfoFromRange(
1285 int16_t defaultWidth, 1285 int16_t defaultWidth,
1286 const SkAdvancedTypefaceMetrics::WidthRange* widthRangeEntry) { 1286 const SkAdvancedTypefaceMetrics::WidthRange* widthRangeEntry) {
1287 SkAutoTUnref<SkPDFArray> widthArray(new SkPDFArray()); 1287 SkAutoTUnref<SkPDFArray> widthArray(new SkPDFArray());
1288 int firstChar = 0; 1288 int firstChar = 0;
1289 if (widthRangeEntry) { 1289 if (widthRangeEntry) {
1290 const uint16_t emSize = fontInfo()->fEmSize; 1290 const uint16_t emSize = fontInfo()->fEmSize;
1291 int startIndex = firstGlyphID() - widthRangeEntry->fStartId; 1291 int startIndex = firstGlyphID() - widthRangeEntry->fStartId;
1292 int endIndex = startIndex + lastGlyphID() - firstGlyphID() + 1; 1292 int endIndex = startIndex + lastGlyphID() - firstGlyphID() + 1;
1293 if (startIndex < 0) 1293 if (startIndex < 0)
1294 startIndex = 0; 1294 startIndex = 0;
1295 if (endIndex > widthRangeEntry->fAdvance.count()) 1295 if (endIndex > widthRangeEntry->fAdvance.count())
1296 endIndex = widthRangeEntry->fAdvance.count(); 1296 endIndex = widthRangeEntry->fAdvance.count();
1297 if (widthRangeEntry->fStartId == 0) { 1297 if (widthRangeEntry->fStartId == 0) {
1298 appendWidth(widthRangeEntry->fAdvance[0], emSize, widthArray.get()); 1298 appendWidth(widthRangeEntry->fAdvance[0], emSize, widthArray.get());
1299 } else { 1299 } else {
1300 firstChar = startIndex + widthRangeEntry->fStartId; 1300 firstChar = startIndex + widthRangeEntry->fStartId;
1301 } 1301 }
1302 for (int i = startIndex; i < endIndex; i++) { 1302 for (int i = startIndex; i < endIndex; i++) {
1303 appendWidth(widthRangeEntry->fAdvance[i], emSize, widthArray.get()); 1303 appendWidth(widthRangeEntry->fAdvance[i], emSize, widthArray.get());
1304 } 1304 }
1305 } else { 1305 } else {
1306 appendWidth(defaultWidth, 1000, widthArray.get()); 1306 appendWidth(defaultWidth, 1000, widthArray.get());
1307 } 1307 }
1308 this->insertInt("FirstChar", firstChar); 1308 this->insertInt("FirstChar", firstChar);
1309 this->insertInt("LastChar", firstChar + widthArray->size() - 1); 1309 this->insertInt("LastChar", firstChar + widthArray->size() - 1);
1310 this->insertObject("Widths", widthArray.detach()); 1310 this->insertObject("Widths", widthArray.release());
1311 } 1311 }
1312 1312
1313 /////////////////////////////////////////////////////////////////////////////// 1313 ///////////////////////////////////////////////////////////////////////////////
1314 // class SkPDFType3Font 1314 // class SkPDFType3Font
1315 /////////////////////////////////////////////////////////////////////////////// 1315 ///////////////////////////////////////////////////////////////////////////////
1316 1316
1317 SkPDFType3Font::SkPDFType3Font(const SkAdvancedTypefaceMetrics* info, 1317 SkPDFType3Font::SkPDFType3Font(const SkAdvancedTypefaceMetrics* info,
1318 SkTypeface* typeface, 1318 SkTypeface* typeface,
1319 uint16_t glyphID) 1319 uint16_t glyphID)
1320 : SkPDFFont(info, typeface, nullptr) { 1320 : SkPDFFont(info, typeface, nullptr) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1373 SkPDFUtils::PaintPath(paint.getStyle(), path->getFillType(), 1373 SkPDFUtils::PaintPath(paint.getStyle(), path->getFillType(),
1374 &content); 1374 &content);
1375 } 1375 }
1376 SkAutoTDelete<SkMemoryStream> glyphStream(new SkMemoryStream()); 1376 SkAutoTDelete<SkMemoryStream> glyphStream(new SkMemoryStream());
1377 glyphStream->setData(content.copyToData())->unref(); 1377 glyphStream->setData(content.copyToData())->unref();
1378 1378
1379 charProcs->insertObjRef(characterName, 1379 charProcs->insertObjRef(characterName,
1380 new SkPDFStream(glyphStream.get())); 1380 new SkPDFStream(glyphStream.get()));
1381 } 1381 }
1382 1382
1383 encoding->insertObject("Differences", encDiffs.detach()); 1383 encoding->insertObject("Differences", encDiffs.release());
1384 1384
1385 this->insertObject("CharProcs", charProcs.detach()); 1385 this->insertObject("CharProcs", charProcs.release());
1386 this->insertObject("Encoding", encoding.detach()); 1386 this->insertObject("Encoding", encoding.release());
1387 1387
1388 this->insertObject("FontBBox", makeFontBBox(bbox, 1000)); 1388 this->insertObject("FontBBox", makeFontBBox(bbox, 1000));
1389 this->insertInt("FirstChar", 1); 1389 this->insertInt("FirstChar", 1);
1390 this->insertInt("LastChar", lastGlyphID() - firstGlyphID() + 1); 1390 this->insertInt("LastChar", lastGlyphID() - firstGlyphID() + 1);
1391 this->insertObject("Widths", widthArray.detach()); 1391 this->insertObject("Widths", widthArray.release());
1392 this->insertName("CIDToGIDMap", "Identity"); 1392 this->insertName("CIDToGIDMap", "Identity");
1393 1393
1394 this->populateToUnicodeTable(nullptr); 1394 this->populateToUnicodeTable(nullptr);
1395 return true; 1395 return true;
1396 } 1396 }
1397 1397
1398 SkPDFFont::Match SkPDFFont::IsMatch(SkPDFFont* existingFont, 1398 SkPDFFont::Match SkPDFFont::IsMatch(SkPDFFont* existingFont,
1399 uint32_t existingFontID, 1399 uint32_t existingFontID,
1400 uint16_t existingGlyphID, 1400 uint16_t existingGlyphID,
1401 uint32_t searchFontID, 1401 uint32_t searchFontID,
(...skipping 25 matching lines...) Expand all
1427 SkAutoTUnref<const SkAdvancedTypefaceMetrics> fontMetrics( 1427 SkAutoTUnref<const SkAdvancedTypefaceMetrics> fontMetrics(
1428 face->getAdvancedTypefaceMetrics( 1428 face->getAdvancedTypefaceMetrics(
1429 SkTypeface::kNo_PerGlyphInfo, nullptr, 0)); 1429 SkTypeface::kNo_PerGlyphInfo, nullptr, 0));
1430 if (fontMetrics) { 1430 if (fontMetrics) {
1431 canEmbed = !SkToBool( 1431 canEmbed = !SkToBool(
1432 fontMetrics->fFlags & 1432 fontMetrics->fFlags &
1433 SkAdvancedTypefaceMetrics::kNotEmbeddable_FontFlag); 1433 SkAdvancedTypefaceMetrics::kNotEmbeddable_FontFlag);
1434 } 1434 }
1435 return *canon->fCanEmbedTypeface.set(id, canEmbed); 1435 return *canon->fCanEmbedTypeface.set(id, canEmbed);
1436 } 1436 }
OLDNEW
« no previous file with comments | « src/pdf/SkPDFDevice.cpp ('k') | src/pdf/SkPDFFormXObject.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698