aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/PDFGlyphsToUnicodeTest.cpp
diff options
context:
space:
mode:
authorGravatar Hal Canary <halcanary@google.com>2018-05-09 11:50:34 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-05-09 18:00:35 +0000
commit46cc3dabaff7daa6b57e3c33997153d986219579 (patch)
tree809ca0d62fddcbd3b378d0a4d330692ebd58748d /tests/PDFGlyphsToUnicodeTest.cpp
parent06d374694a515d064a26e6c5391bce9a0c5c8aa0 (diff)
Revert "Revert "SkAdvancedTypefaceMetrics: factor out GlyphToUnicode""
This reverts commit 97c1108607584b6050a6880d6ce22846e4913a92. Change-Id: Ic3c6addc64ced39766bbee3e10b4d88faf61ba2f Reviewed-on: https://skia-review.googlesource.com/127021 Reviewed-by: Hal Canary <halcanary@google.com> Commit-Queue: Hal Canary <halcanary@google.com>
Diffstat (limited to 'tests/PDFGlyphsToUnicodeTest.cpp')
-rw-r--r--tests/PDFGlyphsToUnicodeTest.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/tests/PDFGlyphsToUnicodeTest.cpp b/tests/PDFGlyphsToUnicodeTest.cpp
index 332520bfb0..2aeedf0330 100644
--- a/tests/PDFGlyphsToUnicodeTest.cpp
+++ b/tests/PDFGlyphsToUnicodeTest.cpp
@@ -74,9 +74,12 @@ DEF_TEST(SkPDF_ToUnicode, reporter) {
glyphsInSubset.push(0x101);
glyphToUnicode.push(0x1013);
+ SkGlyphID lastGlyphID = SkToU16(glyphToUnicode.count() - 1);
+
SkDynamicMemoryWStream buffer;
subset.setAll(glyphsInSubset.begin(), glyphsInSubset.count());
- SkPDFAppendCmapSections(glyphToUnicode, &subset, &buffer, true, 0, 0xFFFF);
+ SkPDFAppendCmapSections(&glyphToUnicode[0], &subset, &buffer, true, 0,
+ SkTMin<SkGlyphID>(0xFFFF, lastGlyphID));
char expectedResult[] =
"4 beginbfchar\n\
@@ -98,7 +101,8 @@ endbfrange\n";
// Remove characters and ranges.
buffer.reset();
- SkPDFAppendCmapSections(glyphToUnicode, &subset, &buffer, true, 8, 0x00FF);
+ SkPDFAppendCmapSections(&glyphToUnicode[0], &subset, &buffer, true, 8,
+ SkTMin<SkGlyphID>(0x00FF, lastGlyphID));
char expectedResultChop1[] =
"2 beginbfchar\n\
@@ -116,7 +120,8 @@ endbfrange\n";
// Remove characters from range to downdrade it to one char.
buffer.reset();
- SkPDFAppendCmapSections(glyphToUnicode, &subset, &buffer, true, 0x00D, 0x00FE);
+ SkPDFAppendCmapSections(&glyphToUnicode[0], &subset, &buffer, true, 0x00D,
+ SkTMin<SkGlyphID>(0x00FE, lastGlyphID));
char expectedResultChop2[] =
"2 beginbfchar\n\
@@ -129,7 +134,8 @@ endbfchar\n";
buffer.reset();
- SkPDFAppendCmapSections(glyphToUnicode, nullptr, &buffer, false, 0xFC, 0x110);
+ SkPDFAppendCmapSections(&glyphToUnicode[0], nullptr, &buffer, false, 0xFC,
+ SkTMin<SkGlyphID>(0x110, lastGlyphID));
char expectedResultSingleBytes[] =
"2 beginbfchar\n\
@@ -155,6 +161,7 @@ endbfrange\n";
for (SkUnichar i = 0; i < 100; ++i) {
glyphToUnicode.push(i + 29);
}
+ lastGlyphID = SkToU16(glyphToUnicode.count() - 1);
glyphsInSubset.push(0x2C);
glyphsInSubset.push(0x44);
@@ -165,7 +172,8 @@ endbfrange\n";
SkDynamicMemoryWStream buffer2;
subset2.setAll(glyphsInSubset.begin(), glyphsInSubset.count());
- SkPDFAppendCmapSections(glyphToUnicode, &subset2, &buffer2, true, 0, 0xffff);
+ SkPDFAppendCmapSections(&glyphToUnicode[0], &subset2, &buffer2, true, 0,
+ SkTMin<SkGlyphID>(0xFFFF, lastGlyphID));
char expectedResult2[] =
"4 beginbfchar\n\