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) { |