Revert "SkAdvancedTypefaceMetrics: factor out GlyphToUnicode"
This reverts commit 1c2bcd8b14e029a70e88b1e81acd29553cab0d1c.
Reason for revert: breaking chrome roll
Original change's description:
> SkAdvancedTypefaceMetrics: factor out GlyphToUnicode
>
> Change-Id: Iedce8c1ea2c405d5ab64ccac353970d5cd2b9d63
> Reviewed-on: https://skia-review.googlesource.com/126507
> Commit-Queue: Hal Canary <halcanary@google.com>
> Reviewed-by: Ben Wagner <bungeman@google.com>
TBR=halcanary@google.com,bungeman@google.com,reed@google.com
Change-Id: Ib1ff8484ffd09cdb88d461ac00745aa32c191124
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/127000
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
diff --git a/src/pdf/SkPDFMakeToUnicodeCmap.cpp b/src/pdf/SkPDFMakeToUnicodeCmap.cpp
index c93aa6f..afe7732 100644
--- a/src/pdf/SkPDFMakeToUnicodeCmap.cpp
+++ b/src/pdf/SkPDFMakeToUnicodeCmap.cpp
@@ -147,12 +147,15 @@
// For the worst case (having 65536 continuous unicode and we use every other
// one of them), the possible savings by aggressive optimization is 416KB
// pre-compressed and does not provide enough motivation for implementation.
-void SkPDFAppendCmapSections(const SkUnichar* glyphToUnicode,
+void SkPDFAppendCmapSections(const SkTDArray<SkUnichar>& glyphToUnicode,
const SkBitSet* subset,
SkDynamicMemoryWStream* cmap,
bool multiByteGlyphs,
SkGlyphID firstGlyphID,
SkGlyphID lastGlyphID) {
+ if (glyphToUnicode.isEmpty()) {
+ return;
+ }
int glyphOffset = 0;
if (!multiByteGlyphs) {
glyphOffset = firstGlyphID - 1;
@@ -163,7 +166,8 @@
BFRange currentRangeEntry = {0, 0, 0};
bool rangeEmpty = true;
- const int limit = (int)lastGlyphID + 1 - glyphOffset;
+ const int limit =
+ SkMin32(lastGlyphID + 1, glyphToUnicode.count()) - glyphOffset;
for (int i = firstGlyphID - glyphOffset; i < limit + 1; ++i) {
bool inSubset = i < limit &&
@@ -206,7 +210,7 @@
}
sk_sp<SkPDFStream> SkPDFMakeToUnicodeCmap(
- const SkUnichar* glyphToUnicode,
+ const SkTDArray<SkUnichar>& glyphToUnicode,
const SkBitSet* subset,
bool multiByteGlyphs,
SkGlyphID firstGlyphID,