From 34e2aa5d21f3186ed8cb739d6c07da9e72d3e746 Mon Sep 17 00:00:00 2001 From: notmasteryet Date: Sat, 4 Feb 2012 12:45:18 -0600 Subject: [PATCH 01/49] Browser minimal font adjustment --- src/canvas.js | 25 ++++++++++++++++++++----- test/pdfs/issue1169.pdf.link | 1 + test/test_manifest.json | 7 +++++++ 3 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 test/pdfs/issue1169.pdf.link diff --git a/src/canvas.js b/src/canvas.js index f4815a655..131db979d 100644 --- a/src/canvas.js +++ b/src/canvas.js @@ -17,11 +17,14 @@ var TextRenderingMode = { ADD_TO_PATH: 7 }; +var MIN_FONT_SIZE = 8; + var CanvasExtraState = (function CanvasExtraStateClosure() { function CanvasExtraState(old) { // Are soft masks and alpha values shapes or opacities? this.alphaIsShape = false; this.fontSize = 0; + this.fontSizeScale = 1; this.textMatrix = IDENTITY_MATRIX; this.fontMatrix = IDENTITY_MATRIX; this.leading = 0; @@ -577,6 +580,9 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { this.current.font = fontObj; this.current.fontSize = size; + if (fontObj.coded) + return; // we don't need ctx.font for Type3 fonts + var name = fontObj.loadedName || 'sans-serif'; var bold = fontObj.black ? (fontObj.bold ? 'bolder' : 'bold') : (fontObj.bold ? 'bold' : 'normal'); @@ -584,7 +590,12 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { var italic = fontObj.italic ? 'italic' : 'normal'; var serif = fontObj.isSerifFont ? 'serif' : 'sans-serif'; var typeface = '"' + name + '", ' + serif; - var rule = italic + ' ' + bold + ' ' + size + 'px ' + typeface; + + var browserFontSize = size >= MIN_FONT_SIZE ? size : MIN_FONT_SIZE; + this.current.fontSizeScale = browserFontSize != MIN_FONT_SIZE ? 1.0 : + size / MIN_FONT_SIZE; + + var rule = italic + ' ' + bold + ' ' + browserFontSize + 'px ' + typeface; this.ctx.font = rule; }, setTextRenderingMode: function canvasGraphicsSetTextRenderingMode(mode) { @@ -647,6 +658,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { var font = current.font; var glyphs = font.charsToGlyphs(str); var fontSize = current.fontSize; + var fontSizeScale = current.fontSizeScale; var charSpacing = current.charSpacing; var wordSpacing = current.wordSpacing; var textHScale = current.textHScale; @@ -715,6 +727,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { if (textSelection) text.geom = this.getTextGeometry(); + ctx.scale(fontSizeScale, fontSizeScale); + var x = 0; for (var i = 0; i < glyphsLength; ++i) { var glyph = glyphs[i]; @@ -728,20 +742,21 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { var charWidth = glyph.width * fontSize * 0.001 + Util.sign(current.fontMatrix[0]) * charSpacing; + var scaledX = x / fontSizeScale; switch (textRenderingMode) { default: // other unsupported rendering modes case TextRenderingMode.FILL: case TextRenderingMode.FILL_ADD_TO_PATH: - ctx.fillText(char, x, 0); + ctx.fillText(char, scaledX, 0); break; case TextRenderingMode.STROKE: case TextRenderingMode.STROKE_ADD_TO_PATH: - ctx.strokeText(char, x, 0); + ctx.strokeText(char, scaledX, 0); break; case TextRenderingMode.FILL_STROKE: case TextRenderingMode.FILL_STROKE_ADD_TO_PATH: - ctx.fillText(char, x, 0); - ctx.strokeText(char, x, 0); + ctx.fillText(char, scaledX, 0); + ctx.strokeText(char, scaledX, 0); break; case TextRenderingMode.INVISIBLE: break; diff --git a/test/pdfs/issue1169.pdf.link b/test/pdfs/issue1169.pdf.link new file mode 100644 index 000000000..46559a078 --- /dev/null +++ b/test/pdfs/issue1169.pdf.link @@ -0,0 +1 @@ +http://www.cs.txstate.edu/~mb92/papers/gpgpu11.pdf diff --git a/test/test_manifest.json b/test/test_manifest.json index 2b0541edb..f4d671a04 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -438,6 +438,13 @@ "link": true, "type": "eq" }, + { "id": "issue1169", + "file": "pdfs/issue1169.pdf", + "md5": "3df3ed21fd43ac7fdb21e2015c8a7809", + "rounds": 1, + "link": true, + "type": "eq" + }, { "id": "zerowidthline", "file": "pdfs/zerowidthline.pdf", "md5": "295d26e61a85635433f8e4b768953f60", From a617aff425d4106595abeacf5b85edc304676462 Mon Sep 17 00:00:00 2001 From: gigaherz Date: Sat, 4 Feb 2012 21:13:12 +0100 Subject: [PATCH 02/49] Quick & dirty sidebar pinning. --- web/images/pin_down.png | Bin 0 -> 210 bytes web/images/pin_up.png | Bin 0 -> 213 bytes web/viewer.css | 27 +++++++++++++++++++++--- web/viewer.html | 44 ++++++++++++++++++++++++++++++++++++++-- 4 files changed, 66 insertions(+), 5 deletions(-) create mode 100644 web/images/pin_down.png create mode 100644 web/images/pin_up.png diff --git a/web/images/pin_down.png b/web/images/pin_down.png new file mode 100644 index 0000000000000000000000000000000000000000..06c985b6a677ea334c7c3f4b4b78748ab5491987 GIT binary patch literal 210 zcmeAS@N?(olHy`uVBq!ia0vp^+(693!3HF^taP6Tq*&4&eH|GXHuiJ>Nn{1`ISV`@ ziy0XB4uUY_j)~cCfr3&ct`Q}{`DrEPiAAXl0g0J;C3=3YAqr*2dZv1Y1_ob>76MiI zdAc};Xapz!`2XLYdE<<89ZJ6T-G@yGywq1 C|3ps! literal 0 HcmV?d00001 diff --git a/web/images/pin_up.png b/web/images/pin_up.png new file mode 100644 index 0000000000000000000000000000000000000000..aff30c15eeb573e9ba0a67cd7b8a5e840c069e4b GIT binary patch literal 213 zcmeAS@N?(olHy`uVBq!ia0vp^+(693!3HF^taP6Tq*&4&eH|GXHuiJ>Nn{1`ISV`@ ziy0XB4uLSEsD@VqP*AGGHKHUqKdq!Zu_%=xATcwqM9KLZGTZ zPZ!4!jo{=T|Nq-FZmdKI;Vst E0CuQC@Bjb+ literal 0 HcmV?d00001 diff --git a/web/viewer.css b/web/viewer.css index 681e5046a..e8071a5ce 100644 --- a/web/viewer.css +++ b/web/viewer.css @@ -76,11 +76,15 @@ span#info { } /* === Sidebar === */ + #sidebar { position: fixed; width: 350px; top: 62px; bottom: 18px; +} + +#sidebar.released { left: -290px; transition: left 0.25s ease-in-out 1s; -o-transition: left 0.25s ease-in-out 1s; @@ -89,7 +93,8 @@ span#info { z-index: 1; } -#sidebar:hover { +#sidebar.pinned, +#sidebar.released:hover { left: 0px; transition: left 0.25s ease-in-out 0s; -o-transition: left 0.25s ease-in-out 0s; @@ -97,6 +102,22 @@ span#info { -webkit-transition: left 0.25s ease-in-out 0s; } +#pinIcon { + position: absolute; + top: 4px; + right: 56px; + width: 11px; + height: 12px; +} + +#pinIcon.released { + background-image: url('images/pin_up.png'); +} + +#pinIcon.pinned { + background-image: url('images/pin_down.png'); +} + #sidebarBox { background-color: rgba(0, 0, 0, 0.7); width: 300px; @@ -116,7 +137,7 @@ span#info { position: absolute; overflow: hidden; overflow-y: auto; - top: 10px; + top: 20px; bottom: 10px; left: 10px; width: 280px; @@ -382,4 +403,4 @@ canvas { #loading { margin: 100px 0; text-align: center; -} +} \ No newline at end of file diff --git a/web/viewer.html b/web/viewer.html index 7c55ec735..c9a35816f 100644 --- a/web/viewer.html +++ b/web/viewer.html @@ -33,6 +33,45 @@ + + +
@@ -120,9 +159,10 @@
-