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 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1117 const uint16_t* glyphIDs = NULL; | 1117 const uint16_t* glyphIDs = NULL; |
1118 int numGlyphs = force_glyph_encoding(paint, text, len, &storage, &glyphIDs); | 1118 int numGlyphs = force_glyph_encoding(paint, text, len, &storage, &glyphIDs); |
1119 textPaint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); | 1119 textPaint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); |
1120 | 1120 |
1121 SkDrawCacheProc glyphCacheProc = textPaint.getDrawCacheProc(); | 1121 SkDrawCacheProc glyphCacheProc = textPaint.getDrawCacheProc(); |
1122 align_text(glyphCacheProc, textPaint, glyphIDs, numGlyphs, &x, &y); | 1122 align_text(glyphCacheProc, textPaint, glyphIDs, numGlyphs, &x, &y); |
1123 content.entry()->fContent.writeText("BT\n"); | 1123 content.entry()->fContent.writeText("BT\n"); |
1124 set_text_transform(x, y, textPaint.getTextSkewX(), | 1124 set_text_transform(x, y, textPaint.getTextSkewX(), |
1125 &content.entry()->fContent); | 1125 &content.entry()->fContent); |
1126 int consumedGlyphCount = 0; | 1126 int consumedGlyphCount = 0; |
| 1127 |
| 1128 SkTDArray<uint16_t> glyphIDsCopy(glyphIDs, numGlyphs); |
| 1129 |
1127 while (numGlyphs > consumedGlyphCount) { | 1130 while (numGlyphs > consumedGlyphCount) { |
1128 updateFont(textPaint, glyphIDs[consumedGlyphCount], content.entry()); | 1131 updateFont(textPaint, glyphIDs[consumedGlyphCount], content.entry()); |
1129 SkPDFFont* font = content.entry()->fState.fFont; | 1132 SkPDFFont* font = content.entry()->fState.fFont; |
1130 //TODO: the const_cast here is a bug if the encoding started out as glyp
h encoding. | 1133 |
1131 int availableGlyphs = | 1134 int availableGlyphs = font->glyphsToPDFFontEncoding( |
1132 font->glyphsToPDFFontEncoding(const_cast<uint16_t*>(glyphIDs) + cons
umedGlyphCount, | 1135 glyphIDsCopy.begin() + consumedGlyphCount, |
1133 numGlyphs - consumedGlyphCount); | 1136 numGlyphs - consumedGlyphCount); |
1134 fFontGlyphUsage->noteGlyphUsage(font, glyphIDs + consumedGlyphCount, | 1137 fFontGlyphUsage->noteGlyphUsage( |
1135 availableGlyphs); | 1138 font, glyphIDsCopy.begin() + consumedGlyphCount, |
| 1139 availableGlyphs); |
1136 SkString encodedString = | 1140 SkString encodedString = |
1137 SkPDFString::FormatString(glyphIDs + consumedGlyphCount, | 1141 SkPDFString::FormatString(glyphIDsCopy.begin() + consumedGlyphCount, |
1138 availableGlyphs, font->multiByteGlyphs()); | 1142 availableGlyphs, font->multiByteGlyphs()); |
1139 content.entry()->fContent.writeText(encodedString.c_str()); | 1143 content.entry()->fContent.writeText(encodedString.c_str()); |
1140 consumedGlyphCount += availableGlyphs; | 1144 consumedGlyphCount += availableGlyphs; |
1141 content.entry()->fContent.writeText(" Tj\n"); | 1145 content.entry()->fContent.writeText(" Tj\n"); |
1142 } | 1146 } |
1143 content.entry()->fContent.writeText("ET\n"); | 1147 content.entry()->fContent.writeText("ET\n"); |
1144 } | 1148 } |
1145 | 1149 |
1146 void SkPDFDevice::drawPosText(const SkDraw& d, const void* text, size_t len, | 1150 void SkPDFDevice::drawPosText(const SkDraw& d, const void* text, size_t len, |
1147 const SkScalar pos[], int scalarsPerPos, | 1151 const SkScalar pos[], int scalarsPerPos, |
(...skipping 1041 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2189 SkAutoTUnref<SkPDFObject> image( | 2193 SkAutoTUnref<SkPDFObject> image( |
2190 SkPDFCreateImageObject(*bitmap, subset, fEncoder)); | 2194 SkPDFCreateImageObject(*bitmap, subset, fEncoder)); |
2191 if (!image) { | 2195 if (!image) { |
2192 return; | 2196 return; |
2193 } | 2197 } |
2194 | 2198 |
2195 SkPDFUtils::DrawFormXObject(this->addXObjectResource(image.get()), | 2199 SkPDFUtils::DrawFormXObject(this->addXObjectResource(image.get()), |
2196 &content.entry()->fContent); | 2200 &content.entry()->fContent); |
2197 } | 2201 } |
2198 | 2202 |
OLD | NEW |