diff --git a/fonts.js b/fonts.js index 343583acd..7d9b48465 100644 --- a/fonts.js +++ b/fonts.js @@ -11,6 +11,7 @@ var kMaxWaitForFontFace = 1000; // Unicode Private Use Area var kCmapGlyphOffset = 0xE000; +var kSizeOfGlyphArea = 0x1900; // PDF Glyph Space Units are one Thousandth of a TextSpace Unit // except for Type 3 fonts @@ -1217,18 +1218,21 @@ var Font = (function Font() { } var encoding = properties.encoding, i; + + // offsetting glyphs to avoid problematic unicode ranges for (i in encoding) { if (encoding.hasOwnProperty(i)) { var unicode = encoding[i].unicode; - if (unicode <= 0x1f || (unicode >= 127 && unicode <= 255)) - encoding[i].unicode = unicode += kCmapGlyphOffset; + if (unicode <= 0x1f || + (unicode >= 127 && unicode < kSizeOfGlyphArea)) + encoding[i].unicode += kCmapGlyphOffset; } } var glyphs = []; for (i = 1; i < numGlyphs; i++) { glyphs.push({ - unicode: i <= 0x1f || (i >= 127 && i <= 255) ? + unicode: i <= 0x1f || (i >= 127 && i < kSizeOfGlyphArea) ? i + kCmapGlyphOffset : i }); } diff --git a/pdf.js b/pdf.js index a98837621..a8955d259 100644 --- a/pdf.js +++ b/pdf.js @@ -5605,7 +5605,9 @@ var CanvasGraphics = (function canvasGraphics() { var bbox = stream.dict.get('BBox'); if (bbox && isArray(bbox) && 4 == bbox.length) { - this.rectangle.apply(this, bbox); + var width = bbox[2] - bbox[0]; + var height = bbox[3] - bbox[1]; + this.rectangle(bbox[0], bbox[1], width, height); this.clip(); this.endPath(); } @@ -6360,7 +6362,9 @@ var TilingPattern = (function tilingPattern() { graphics.transform.apply(graphics, tmpTranslate); if (bbox && isArray(bbox) && 4 == bbox.length) { - graphics.rectangle.apply(graphics, bbox); + var bboxWidth = bbox[2] - bbox[0]; + var bboxHeight = bbox[3] - bbox[1]; + graphics.rectangle(bbox[0], bbox[1], bboxWidth, bboxHeight); graphics.clip(); graphics.endPath(); } diff --git a/test/pdfs/ThuluthFeatures.pdf b/test/pdfs/ThuluthFeatures.pdf new file mode 100755 index 000000000..95e6b7419 Binary files /dev/null and b/test/pdfs/ThuluthFeatures.pdf differ diff --git a/test/test.py b/test/test.py index 313a5e03a..46106965b 100644 --- a/test/test.py +++ b/test/test.py @@ -435,9 +435,9 @@ def checkEq(task, results, browser, masterMode): # NB: this follows the format of Mozilla reftest # output so that we can reuse its reftest-analyzer # script - print >>eqLog, 'REFTEST TEST-UNEXPECTED-FAIL |', browser +'-'+ taskId +'-page'+ str(page + 1), '| image comparison (==)' - print >>eqLog, 'REFTEST IMAGE 1 (TEST):', snapshot - print >>eqLog, 'REFTEST IMAGE 2 (REFERENCE):', ref + eqLog.write('REFTEST TEST-UNEXPECTED-FAIL | ' + browser +'-'+ taskId +'-page'+ str(page + 1) + ' | image comparison (==)\n') + eqLog.write('REFTEST IMAGE 1 (TEST): ' + snapshot + '\n') + eqLog.write('REFTEST IMAGE 2 (REFERENCE): ' + ref + '\n') passed = False State.numEqFailures += 1 @@ -457,7 +457,6 @@ def checkEq(task, results, browser, masterMode): if passed: print 'TEST-PASS | eq test', task['id'], '| in', browser - def checkFBF(task, results, browser): round0, round1 = results[0], results[1] assert len(round0) == len(round1) @@ -543,7 +542,8 @@ def runTests(options, browsers): teardownBrowsers(browsers) t2 = time.time() print "Runtime was", int(t2 - t1), "seconds" - + if State.eqLog: + State.eqLog.close(); if options.masterMode: maybeUpdateRefImages(options, browsers[0]) elif options.reftest and State.numEqFailures > 0: diff --git a/test/test_manifest.json b/test/test_manifest.json index b45c9ac5c..d4936154c 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -69,6 +69,11 @@ "rounds": 1, "type": "load" }, + { "id": "thuluthfont-pdf", + "file": "pdfs/ThuluthFeatures.pdf", + "rounds": 1, + "type": "eq" + }, { "id": "wnv_chinese-pdf", "file": "pdfs/wnv_chinese.pdf", "link": true,