From ff64ef0243e57b18a73368e8132bd214a28ca378 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sun, 8 Nov 2015 13:18:23 +0100 Subject: [PATCH] Prevent `readCmapTable` from failing if the `cmap` is missing in TrueType fonts Fixes http://arrow.dit.ie/cgi/viewcontent.cgi?article=1000&context=aaschadpoth#page=3. --- src/core/fonts.js | 9 +++++++++ test/pdfs/.gitignore | 1 + test/pdfs/TrueType_without_cmap.pdf | Bin 0 -> 3989 bytes test/test_manifest.json | 7 +++++++ 4 files changed, 17 insertions(+) create mode 100644 test/pdfs/TrueType_without_cmap.pdf diff --git a/src/core/fonts.js b/src/core/fonts.js index cd9c34f46..b04fbdc57 100644 --- a/src/core/fonts.js +++ b/src/core/fonts.js @@ -3226,6 +3226,15 @@ var Font = (function FontClosure() { * PDF spec */ function readCmapTable(cmap, font, isSymbolicFont, hasEncoding) { + if (!cmap) { + warn('No cmap table available.'); + return { + platformId: -1, + encodingId: -1, + mappings: [], + hasShortCmap: false + }; + } var segment; var start = (font.start ? font.start : 0) + cmap.offset; font.pos = start; diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index 7bad8e6b0..cd4ec0205 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -2,6 +2,7 @@ *.error !tracemonkey.pdf +!TrueType_without_cmap.pdf !franz.pdf !franz_2.pdf !xref_command_missing.pdf diff --git a/test/pdfs/TrueType_without_cmap.pdf b/test/pdfs/TrueType_without_cmap.pdf new file mode 100644 index 0000000000000000000000000000000000000000..0cfad2da81e422146ad75567b908c9503203ecda GIT binary patch literal 3989 zcmb_fdpuO>8`svhHLY$ctmKqS?lb4i%$b=;WsDjc*9j$;!5G7s(acCv*-9>}NJ_bd zk}isrB~fCxq9WZWi%=7?B}wI$-+RVo`?dS~=l9v+eBSdu@AG`0@AEw8yytzi?JO*f zU}FkSyZy!eM>rTFKq4=H2xn@F!&{1kQX5Vn7sA^(SUWRW1}u(*FTvp*rQAR#h%lyL z$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0S|D^M;%0PksRlINV@h@PzO}^Ho zuMg{X93EE!k%0)b5o4!*ItMfgBHq{Mdu)C3e9z+g@Hyj+19%4kRWbpz4Ay)f3FL}m zNMJ@61!E1#1g6~0*NB+jB%&QhjI}T0EdB?+16Lvn7JCD>lTFh29e8Nv{6QxH{()Aa)rY? z^L?a#pxGMp^xypwgf(@OS;f|Hc!m(PLwq3*0+zxxLJ5CD0NOUbc$@^`Yo1sTfAJja zqEHH^G2S(qvwxs8y$Glj8U)wP0V4eP7pf~=c>CIK@c;(9zxU=>bXH| zD;$H3`-jbco0#j1BS179Ve$vINivZP`9hO2u%*dYA>pJ90o&C#G6aD^e~A75(j&sO zzu6KI(%)=}*qi*VEr|?@_YEGlWlqYZVh-qz#W?wc;vf=9A?%q4rEuhL=Yp8z$>WHn R@*s&|SH)>-Gi)t!{{ap;pW^@k literal 0 HcmV?d00001 diff --git a/test/test_manifest.json b/test/test_manifest.json index 825b5c8c6..c40cfcd43 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -1196,6 +1196,13 @@ "rounds": 1, "type": "eq" }, + { "id": "TrueType_without_cmap", + "file": "pdfs/TrueType_without_cmap.pdf", + "md5": "afca8bb11f2e1f7298b4e5dd85785fb0", + "link": false, + "rounds": 1, + "type": "eq" + }, { "id": "issue3323", "file": "pdfs/issue3323.pdf", "md5": "1a14ff574013caeafa9d598269988764",