OLD | NEW |
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 "SkPDFDevice.h" | 8 #include "SkPDFDevice.h" |
9 | 9 |
10 #include "SkAnnotation.h" | 10 #include "SkAnnotation.h" |
(...skipping 1143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1154 SkDrawCacheProc glyphCacheProc = textPaint.getDrawCacheProc(); | 1154 SkDrawCacheProc glyphCacheProc = textPaint.getDrawCacheProc(); |
1155 align_text(glyphCacheProc, textPaint, glyphIDs, numGlyphs, &x, &y); | 1155 align_text(glyphCacheProc, textPaint, glyphIDs, numGlyphs, &x, &y); |
1156 content.entry()->fContent.writeText("BT\n"); | 1156 content.entry()->fContent.writeText("BT\n"); |
1157 set_text_transform(x, y, textPaint.getTextSkewX(), | 1157 set_text_transform(x, y, textPaint.getTextSkewX(), |
1158 &content.entry()->fContent); | 1158 &content.entry()->fContent); |
1159 int consumedGlyphCount = 0; | 1159 int consumedGlyphCount = 0; |
1160 | 1160 |
1161 SkTDArray<uint16_t> glyphIDsCopy(glyphIDs, numGlyphs); | 1161 SkTDArray<uint16_t> glyphIDsCopy(glyphIDs, numGlyphs); |
1162 | 1162 |
1163 while (numGlyphs > consumedGlyphCount) { | 1163 while (numGlyphs > consumedGlyphCount) { |
1164 updateFont(textPaint, glyphIDs[consumedGlyphCount], content.entry()); | 1164 this->updateFont(textPaint, glyphIDs[consumedGlyphCount], content.entry(
)); |
1165 SkPDFFont* font = content.entry()->fState.fFont; | 1165 SkPDFFont* font = content.entry()->fState.fFont; |
1166 | 1166 |
1167 int availableGlyphs = font->glyphsToPDFFontEncoding( | 1167 int availableGlyphs = font->glyphsToPDFFontEncoding( |
1168 glyphIDsCopy.begin() + consumedGlyphCount, | 1168 glyphIDsCopy.begin() + consumedGlyphCount, |
1169 numGlyphs - consumedGlyphCount); | 1169 numGlyphs - consumedGlyphCount); |
1170 fFontGlyphUsage->noteGlyphUsage( | 1170 fFontGlyphUsage->noteGlyphUsage( |
1171 font, glyphIDsCopy.begin() + consumedGlyphCount, | 1171 font, glyphIDsCopy.begin() + consumedGlyphCount, |
1172 availableGlyphs); | 1172 availableGlyphs); |
1173 SkString encodedString = | 1173 SkString encodedString = |
1174 format_wide_string(glyphIDsCopy.begin() + consumedGlyphCount, | 1174 format_wide_string(glyphIDsCopy.begin() + consumedGlyphCount, |
(...skipping 24 matching lines...) Expand all Loading... |
1199 return; | 1199 return; |
1200 } | 1200 } |
1201 | 1201 |
1202 SkGlyphStorage storage(0); | 1202 SkGlyphStorage storage(0); |
1203 const uint16_t* glyphIDs = NULL; | 1203 const uint16_t* glyphIDs = NULL; |
1204 size_t numGlyphs = force_glyph_encoding(paint, text, len, &storage, &glyphID
s); | 1204 size_t numGlyphs = force_glyph_encoding(paint, text, len, &storage, &glyphID
s); |
1205 textPaint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); | 1205 textPaint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); |
1206 | 1206 |
1207 SkDrawCacheProc glyphCacheProc = textPaint.getDrawCacheProc(); | 1207 SkDrawCacheProc glyphCacheProc = textPaint.getDrawCacheProc(); |
1208 content.entry()->fContent.writeText("BT\n"); | 1208 content.entry()->fContent.writeText("BT\n"); |
1209 updateFont(textPaint, glyphIDs[0], content.entry()); | 1209 this->updateFont(textPaint, glyphIDs[0], content.entry()); |
1210 for (size_t i = 0; i < numGlyphs; i++) { | 1210 for (size_t i = 0; i < numGlyphs; i++) { |
1211 SkPDFFont* font = content.entry()->fState.fFont; | 1211 SkPDFFont* font = content.entry()->fState.fFont; |
1212 uint16_t encodedValue = glyphIDs[i]; | 1212 uint16_t encodedValue = glyphIDs[i]; |
1213 if (font->glyphsToPDFFontEncoding(&encodedValue, 1) != 1) { | 1213 if (font->glyphsToPDFFontEncoding(&encodedValue, 1) != 1) { |
1214 // The current pdf font cannot encode the current glyph. | 1214 // The current pdf font cannot encode the current glyph. |
1215 // Try to get a pdf font which can encode the current glyph. | 1215 // Try to get a pdf font which can encode the current glyph. |
1216 updateFont(textPaint, glyphIDs[i], content.entry()); | 1216 this->updateFont(textPaint, glyphIDs[i], content.entry()); |
1217 font = content.entry()->fState.fFont; | 1217 font = content.entry()->fState.fFont; |
1218 if (font->glyphsToPDFFontEncoding(&encodedValue, 1) != 1) { | 1218 if (font->glyphsToPDFFontEncoding(&encodedValue, 1) != 1) { |
1219 SkDEBUGFAIL("PDF could not encode glyph."); | 1219 SkDEBUGFAIL("PDF could not encode glyph."); |
1220 continue; | 1220 continue; |
1221 } | 1221 } |
1222 } | 1222 } |
1223 | 1223 |
1224 fFontGlyphUsage->noteGlyphUsage(font, &encodedValue, 1); | 1224 fFontGlyphUsage->noteGlyphUsage(font, &encodedValue, 1); |
1225 SkScalar x = offset.x() + pos[i * scalarsPerPos]; | 1225 SkScalar x = offset.x() + pos[i * scalarsPerPos]; |
1226 SkScalar y = offset.y() + (2 == scalarsPerPos ? pos[i * scalarsPerPos +
1] : 0); | 1226 SkScalar y = offset.y() + (2 == scalarsPerPos ? pos[i * scalarsPerPos +
1] : 0); |
(...skipping 968 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2195 return; | 2195 return; |
2196 } | 2196 } |
2197 SkAutoTUnref<SkPDFObject> image(SkPDFBitmap::Create(fCanon, subsetBitmap)); | 2197 SkAutoTUnref<SkPDFObject> image(SkPDFBitmap::Create(fCanon, subsetBitmap)); |
2198 if (!image) { | 2198 if (!image) { |
2199 return; | 2199 return; |
2200 } | 2200 } |
2201 | 2201 |
2202 SkPDFUtils::DrawFormXObject(this->addXObjectResource(image.get()), | 2202 SkPDFUtils::DrawFormXObject(this->addXObjectResource(image.get()), |
2203 &content.entry()->fContent); | 2203 &content.entry()->fContent); |
2204 } | 2204 } |
OLD | NEW |