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

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

Issue 113093004: [PDF] Fix font width generation when glyph 0 is used. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « src/core/SkAdvancedTypefaceMetrics.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 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 1125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1136 1136
1137 insert("FontDescriptor", new SkPDFObjRef(descriptor.get()))->unref(); 1137 insert("FontDescriptor", new SkPDFObjRef(descriptor.get()))->unref();
1138 return addCommonFontDescriptorEntries(defaultWidth); 1138 return addCommonFontDescriptorEntries(defaultWidth);
1139 } 1139 }
1140 1140
1141 bool SkPDFCIDFont::populate(const SkPDFGlyphSet* subset) { 1141 bool SkPDFCIDFont::populate(const SkPDFGlyphSet* subset) {
1142 // Generate new font metrics with advance info for true type fonts. 1142 // Generate new font metrics with advance info for true type fonts.
1143 if (fontInfo()->fType == SkAdvancedTypefaceMetrics::kTrueType_Font) { 1143 if (fontInfo()->fType == SkAdvancedTypefaceMetrics::kTrueType_Font) {
1144 // Generate glyph id array. 1144 // Generate glyph id array.
1145 SkTDArray<uint32_t> glyphIDs; 1145 SkTDArray<uint32_t> glyphIDs;
1146 glyphIDs.push(0); // Always include glyph 0.
1147 if (subset) { 1146 if (subset) {
1147 // Always include glyph 0.
1148 if (!subset->has(0)) {
1149 glyphIDs.push(0);
1150 }
1148 subset->exportTo(&glyphIDs); 1151 subset->exportTo(&glyphIDs);
1149 } 1152 }
1150 1153
1151 SkAdvancedTypefaceMetrics::PerGlyphInfo info; 1154 SkAdvancedTypefaceMetrics::PerGlyphInfo info;
1152 info = SkAdvancedTypefaceMetrics::kGlyphNames_PerGlyphInfo; 1155 info = SkAdvancedTypefaceMetrics::kGlyphNames_PerGlyphInfo;
1153 info = SkTBitOr<SkAdvancedTypefaceMetrics::PerGlyphInfo>( 1156 info = SkTBitOr<SkAdvancedTypefaceMetrics::PerGlyphInfo>(
1154 info, SkAdvancedTypefaceMetrics::kHAdvance_PerGlyphInfo); 1157 info, SkAdvancedTypefaceMetrics::kHAdvance_PerGlyphInfo);
1155 uint32_t* glyphs = (glyphIDs.count() == 1) ? NULL : glyphIDs.begin(); 1158 uint32_t* glyphs = (glyphIDs.count() == 0) ? NULL : glyphIDs.begin();
1156 uint32_t glyphsCount = glyphs ? glyphIDs.count() : 0; 1159 uint32_t glyphsCount = glyphs ? glyphIDs.count() : 0;
1157 SkAutoTUnref<SkAdvancedTypefaceMetrics> fontMetrics( 1160 SkAutoTUnref<SkAdvancedTypefaceMetrics> fontMetrics(
1158 typeface()->getAdvancedTypefaceMetrics(info, glyphs, glyphsCount)); 1161 typeface()->getAdvancedTypefaceMetrics(info, glyphs, glyphsCount));
1159 setFontInfo(fontMetrics.get()); 1162 setFontInfo(fontMetrics.get());
1160 addFontDescriptor(0, &glyphIDs); 1163 addFontDescriptor(0, &glyphIDs);
1161 } else { 1164 } else {
1162 // Other CID fonts 1165 // Other CID fonts
1163 addFontDescriptor(0, NULL); 1166 addFontDescriptor(0, NULL);
1164 } 1167 }
1165 1168
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
1421 1424
1422 insert("FontBBox", makeFontBBox(bbox, 1000))->unref(); 1425 insert("FontBBox", makeFontBBox(bbox, 1000))->unref();
1423 insertInt("FirstChar", firstGlyphID()); 1426 insertInt("FirstChar", firstGlyphID());
1424 insertInt("LastChar", lastGlyphID()); 1427 insertInt("LastChar", lastGlyphID());
1425 insert("Widths", widthArray.get()); 1428 insert("Widths", widthArray.get());
1426 insertName("CIDToGIDMap", "Identity"); 1429 insertName("CIDToGIDMap", "Identity");
1427 1430
1428 populateToUnicodeTable(NULL); 1431 populateToUnicodeTable(NULL);
1429 return true; 1432 return true;
1430 } 1433 }
OLDNEW
« no previous file with comments | « src/core/SkAdvancedTypefaceMetrics.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698