aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/pdf/SkPDFMakeToUnicodeCmap.cpp
diff options
context:
space:
mode:
authorGravatar halcanary <halcanary@google.com>2016-09-16 12:09:01 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-09-16 12:09:01 -0700
commitdbd16345a5b2b824f2696af791bb0f01304cf549 (patch)
tree6ba2505fdd725b02da7458e7065f4bf8656dfc13 /src/pdf/SkPDFMakeToUnicodeCmap.cpp
parentbe7e3c0db3caa7a86ae233a6bd26281817b83882 (diff)
SkPDF: Implement /ActualText to make text extraction correct.
For old API: no change. For new API: LTR text is perfectly extracted, RTL needs better testing. BUG=skia:5434 GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2322403002 Review-Url: https://codereview.chromium.org/2322403002
Diffstat (limited to 'src/pdf/SkPDFMakeToUnicodeCmap.cpp')
-rw-r--r--src/pdf/SkPDFMakeToUnicodeCmap.cpp14
1 files changed, 2 insertions, 12 deletions
diff --git a/src/pdf/SkPDFMakeToUnicodeCmap.cpp b/src/pdf/SkPDFMakeToUnicodeCmap.cpp
index b610934bcc..afe773207d 100644
--- a/src/pdf/SkPDFMakeToUnicodeCmap.cpp
+++ b/src/pdf/SkPDFMakeToUnicodeCmap.cpp
@@ -69,16 +69,6 @@ struct BFRange {
};
} // namespace
-static void write_utf16be(SkDynamicMemoryWStream* wStream, SkUnichar utf32) {
- SkGlyphID utf16[2] = {0, 0};
- size_t len = SkUTF16_FromUnichar(utf32, utf16);
- SkASSERT(len == 1 || len == 2);
- SkPDFUtils::WriteUInt16BE(wStream, utf16[0]);
- if (len == 2) {
- SkPDFUtils::WriteUInt16BE(wStream, utf16[1]);
- }
-}
-
static void write_glyph(SkDynamicMemoryWStream* cmap,
bool multiByte,
SkGlyphID gid) {
@@ -102,7 +92,7 @@ static void append_bfchar_section(const SkTDArray<BFChar>& bfchar,
cmap->writeText("<");
write_glyph(cmap, multiByte, bfchar[i + j].fGlyphId);
cmap->writeText("> <");
- write_utf16be(cmap, bfchar[i + j].fUnicode);
+ SkPDFUtils::WriteUTF16beHex(cmap, bfchar[i + j].fUnicode);
cmap->writeText(">\n");
}
cmap->writeText("endbfchar\n");
@@ -124,7 +114,7 @@ static void append_bfrange_section(const SkTDArray<BFRange>& bfrange,
cmap->writeText("> <");
write_glyph(cmap, multiByte, bfrange[i + j].fEnd);
cmap->writeText("> <");
- write_utf16be(cmap, bfrange[i + j].fUnicode);
+ SkPDFUtils::WriteUTF16beHex(cmap, bfrange[i + j].fUnicode);
cmap->writeText(">\n");
}
cmap->writeText("endbfrange\n");