Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(103)

Unified Diff: tests/ToUnicode.cpp

Issue 23519006: pdf: write only ToUnicode mappings needed by the font, trimming anything out of [firstChar, lastCha… (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/pdf/SkPDFFont.cpp ('K') | « src/pdf/SkPDFFont.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/ToUnicode.cpp
===================================================================
--- tests/ToUnicode.cpp (revision 11071)
+++ tests/ToUnicode.cpp (working copy)
@@ -27,7 +27,9 @@
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;
@@ -70,7 +72,7 @@
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\
@@ -89,6 +91,38 @@
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> <000C> <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, 0x00C, 0x00FE);
+
+ char expectedResultChop2[] =
+"2 beginbfchar\n\
+<000C> <0035>\n\
+<00FE> <1010>\n\
+endbfchar\n";
+
+ REPORTER_ASSERT(reporter, stream_equals(buffer, 0, expectedResultChop2,
+ buffer.getOffset()));
+
glyphToUnicode.reset();
glyphsInSubset.reset();
SkPDFGlyphSet subset2;
@@ -110,7 +144,7 @@
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\
« src/pdf/SkPDFFont.cpp ('K') | « src/pdf/SkPDFFont.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698