aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar halcanary <halcanary@google.com>2016-09-16 08:15:56 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-09-16 08:15:56 -0700
commit2bd295e5a3c24240f6536a72675cc268efb5414e (patch)
treecaadf21d74b4044c8328c9c4de5c0eb9ee195655
parent1bd72ba2cb349788223e3e7304f25751c87f1f95 (diff)
SkPDF: fix unembeddable text drawn with positioning (broken in 6059dc3)
-rw-r--r--src/pdf/SkPDFDevice.cpp34
1 files changed, 28 insertions, 6 deletions
diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp
index 608d284bf2..1a1bd8a411 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) {