aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/pdf/SkPDFMakeToUnicodeCmap.cpp
diff options
context:
space:
mode:
authorGravatar halcanary <halcanary@google.com>2016-09-16 13:21:08 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-09-16 13:21:08 -0700
commit3b294d5ba96b68ae1cbe59cfea29b112959cca09 (patch)
tree00fc53138d453588c011e7b64beea1d6d3f22feb /src/pdf/SkPDFMakeToUnicodeCmap.cpp
parent875b8f6d35510523b0267e9a78217a91b2484698 (diff)
Revert of SkPDF: Implement /ActualText to make text extraction correct. (patchset #11 id:220001 of https://codereview.chromium.org/2322403002/ )
Reason for revert: MSAN, ASAN errors Original issue's description: > 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 > > Committed: https://skia.googlesource.com/skia/+/dbd16345a5b2b824f2696af791bb0f01304cf549 TBR=tomhudson@google.com,bungeman@google.com # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia:5434 Review-Url: https://codereview.chromium.org/2338213008
Diffstat (limited to 'src/pdf/SkPDFMakeToUnicodeCmap.cpp')
-rw-r--r--src/pdf/SkPDFMakeToUnicodeCmap.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/pdf/SkPDFMakeToUnicodeCmap.cpp b/src/pdf/SkPDFMakeToUnicodeCmap.cpp
index afe773207d..b610934bcc 100644
--- a/src/pdf/SkPDFMakeToUnicodeCmap.cpp
+++ b/src/pdf/SkPDFMakeToUnicodeCmap.cpp
@@ -69,6 +69,16 @@ 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) {
@@ -92,7 +102,7 @@ static void append_bfchar_section(const SkTDArray<BFChar>& bfchar,
cmap->writeText("<");
write_glyph(cmap, multiByte, bfchar[i + j].fGlyphId);
cmap->writeText("> <");
- SkPDFUtils::WriteUTF16beHex(cmap, bfchar[i + j].fUnicode);
+ write_utf16be(cmap, bfchar[i + j].fUnicode);
cmap->writeText(">\n");
}
cmap->writeText("endbfchar\n");
@@ -114,7 +124,7 @@ static void append_bfrange_section(const SkTDArray<BFRange>& bfrange,
cmap->writeText("> <");
write_glyph(cmap, multiByte, bfrange[i + j].fEnd);
cmap->writeText("> <");
- SkPDFUtils::WriteUTF16beHex(cmap, bfrange[i + j].fUnicode);
+ write_utf16be(cmap, bfrange[i + j].fUnicode);
cmap->writeText(">\n");
}
cmap->writeText("endbfrange\n");