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

Unified Diff: src/pdf/SkPDFDevice.cpp

Issue 2347183002: SkPDF: fix unembeddable text drawn with positioning (broken in 6059dc3) (Closed)
Patch Set: Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pdf/SkPDFDevice.cpp
diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp
index 608d284bf2befcc30ec8043a2014a8c7c5a9178a..1a1bd8a41136450061c3ad6fa996d1057505282c 100644
--- a/src/pdf/SkPDFDevice.cpp
+++ b/src/pdf/SkPDFDevice.cpp
@@ -1023,22 +1023,44 @@ void SkPDFDevice::internalDrawText(
if (!metrics) {
return;
}
+ int glyphCount = paint.textToGlyphs(sourceText, sourceByteCount, nullptr);
+ if (glyphCount <= 0) {
+ return;
+ }
// TODO(halcanary): use metrics->fGlyphToUnicode to check Unicode mapping.
const SkGlyphID maxGlyphID = metrics->fLastGlyphID;
if (!SkPDFFont::CanEmbedTypeface(typeface, fDocument->canon())) {
SkPath path; // https://bug.skia.org/3866
- paint.getTextPath(sourceText, sourceByteCount,
- offset.x(), offset.y(), &path);
+ switch (positioning) {
+ case SkTextBlob::kDefault_Positioning:
+ srcPaint.getTextPath(sourceText, sourceByteCount,
+ offset.x(), offset.y(), &path);
+ break;
+ case SkTextBlob::kHorizontal_Positioning: {
+ SkAutoTMalloc<SkPoint> positionsBuffer(glyphCount);
+ for (int i = 0; i < glyphCount; ++i) {
+ positionsBuffer[i] = offset + SkPoint{pos[i], 0};
+ }
+ srcPaint.getPosTextPath(sourceText, sourceByteCount,
+ &positionsBuffer[0], &path);
+ break;
+ }
+ case SkTextBlob::kFull_Positioning: {
+ SkAutoTMalloc<SkPoint> positionsBuffer(glyphCount);
+ for (int i = 0; i < glyphCount; ++i) {
+ positionsBuffer[i] = offset + SkPoint{pos[2 * i], pos[2 * i + 1]};
+ }
+ srcPaint.getPosTextPath(sourceText, sourceByteCount,
+ &positionsBuffer[0], &path);
+ break;
+ }
+ }
this->drawPath(d, path, srcPaint, &SkMatrix::I(), true);
// Draw text transparently to make it copyable/searchable/accessable.
draw_transparent_text(this, d, sourceText, sourceByteCount,
offset.x(), offset.y(), paint);
return;
}
- int glyphCount = paint.textToGlyphs(sourceText, sourceByteCount, nullptr);
- if (glyphCount <= 0) {
- return;
- }
SkAutoSTMalloc<128, SkGlyphID> glyphStorage;
const SkGlyphID* glyphs = nullptr;
if (paint.getTextEncoding() == SkPaint::kGlyphID_TextEncoding) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698