aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar edisonn@google.com <edisonn@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-09-18 19:29:08 +0000
committerGravatar edisonn@google.com <edisonn@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-09-18 19:29:08 +0000
commit26d2e046cd3e11cb61d1b0b3ace304a6dc8c995b (patch)
treeb6884c047fb85951ed6fe77315055b62f9cf1da2 /tests
parente3289d39f857f1d7deab08e5719645dd1536c94e (diff)
pdf: write only ToUnicode mappings needed by the font, trimming anything out of [firstChar, lastChar] interval.
R=vandebo@chromium.org Review URL: https://codereview.chromium.org/23519006 git-svn-id: http://skia.googlecode.com/svn/trunk@11360 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests')
-rw-r--r--tests/ToUnicode.cpp46
1 files changed, 41 insertions, 5 deletions
diff --git a/tests/ToUnicode.cpp b/tests/ToUnicode.cpp
index ea9e258ac3..69ec614bcf 100644
--- a/tests/ToUnicode.cpp
+++ b/tests/ToUnicode.cpp
@@ -27,7 +27,9 @@ static bool stream_equals(const SkDynamicMemoryWStream& stream, size_t offset,
void append_cmap_sections(const SkTDArray<SkUnichar>& glyphToUnicode,
const SkPDFGlyphSet* subset,
- SkDynamicMemoryWStream* cmap);
+ SkDynamicMemoryWStream* cmap,
+ uint16_t firstGlypthID,
+ uint16_t lastGlypthID);
static void TestToUnicode(skiatest::Reporter* reporter) {
SkTDArray<SkUnichar> glyphToUnicode;
@@ -56,7 +58,9 @@ static void TestToUnicode(skiatest::Reporter* reporter) {
glyphToUnicode.push(0x35); // 11
glyphsInSubset.push(12);
glyphToUnicode.push(0x36); // 12
- for (uint16_t i = 13; i < 0xFE; ++i) {
+ glyphsInSubset.push(13);
+ glyphToUnicode.push(0x37); // 13
+ for (uint16_t i = 14; i < 0xFE; ++i) {
glyphToUnicode.push(0); // Zero from index 0x9 to 0xFD
}
glyphsInSubset.push(0xFE);
@@ -70,7 +74,7 @@ static void TestToUnicode(skiatest::Reporter* reporter) {
SkDynamicMemoryWStream buffer;
subset.set(glyphsInSubset.begin(), glyphsInSubset.count());
- append_cmap_sections(glyphToUnicode, &subset, &buffer);
+ append_cmap_sections(glyphToUnicode, &subset, &buffer, 0, 0xFFFF);
char expectedResult[] =
"4 beginbfchar\n\
@@ -81,7 +85,7 @@ static void TestToUnicode(skiatest::Reporter* reporter) {
endbfchar\n\
4 beginbfrange\n\
<0005> <0007> <0027>\n\
-<000B> <000C> <0035>\n\
+<000B> <000D> <0035>\n\
<00FE> <00FF> <1010>\n\
<0100> <0101> <1012>\n\
endbfrange\n";
@@ -89,6 +93,38 @@ endbfrange\n";
REPORTER_ASSERT(reporter, stream_equals(buffer, 0, expectedResult,
buffer.getOffset()));
+ // Remove characters and ranges.
+ buffer.reset();
+
+ append_cmap_sections(glyphToUnicode, &subset, &buffer, 8, 0x00FF);
+
+ char expectedResultChop1[] =
+"2 beginbfchar\n\
+<0008> <002F>\n\
+<0009> <0033>\n\
+endbfchar\n\
+2 beginbfrange\n\
+<000B> <000D> <0035>\n\
+<00FE> <00FF> <1010>\n\
+endbfrange\n";
+
+ REPORTER_ASSERT(reporter, stream_equals(buffer, 0, expectedResultChop1,
+ buffer.getOffset()));
+
+ // Remove characters from range to downdrade it to one char.
+ buffer.reset();
+
+ append_cmap_sections(glyphToUnicode, &subset, &buffer, 0x00D, 0x00FE);
+
+ char expectedResultChop2[] =
+"2 beginbfchar\n\
+<000D> <0037>\n\
+<00FE> <1010>\n\
+endbfchar\n";
+
+ REPORTER_ASSERT(reporter, stream_equals(buffer, 0, expectedResultChop2,
+ buffer.getOffset()));
+
glyphToUnicode.reset();
glyphsInSubset.reset();
SkPDFGlyphSet subset2;
@@ -110,7 +146,7 @@ endbfrange\n";
SkDynamicMemoryWStream buffer2;
subset2.set(glyphsInSubset.begin(), glyphsInSubset.count());
- append_cmap_sections(glyphToUnicode, &subset2, &buffer2);
+ append_cmap_sections(glyphToUnicode, &subset2, &buffer2, 0, 0xffff);
char expectedResult2[] =
"4 beginbfchar\n\