From 939c748aa11cdf34540aae569cd6f7b026a266a1 Mon Sep 17 00:00:00 2001 From: pacien Date: Wed, 18 Jul 2018 23:10:40 +0200 Subject: Workaround for pdfjs font bug --- pointless/viewer/screen.js | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/pointless/viewer/screen.js b/pointless/viewer/screen.js index 8a6891c..0c1c3ad 100644 --- a/pointless/viewer/screen.js +++ b/pointless/viewer/screen.js @@ -38,11 +38,28 @@ class Screen { this.context.transform(1, 0, 0, 1, xOffset, 0); } + _makeWorkCanvas(width, height) { + var canvas = document.createElement("canvas"); + canvas.width = width; + canvas.height = height; + return canvas; + } + + _transferCanvas(source) { + this.context.drawImage(source, 0, 0); + } + _paintPage() { var renderRatio = this.canvas.height / this.page.getViewport(1).height; var renderViewport = this.page.getViewport(renderRatio); - var renderContext = { canvasContext: this.context, viewport: renderViewport }; - this.page.render(renderContext); + var workCanvas = this._makeWorkCanvas(renderViewport.width, renderViewport.height); + var workContext = workCanvas.getContext("2d"); + var renderContext = { canvasContext: workContext, viewport: renderViewport }; + + var self = this; + this.page.render(renderContext).then(function() { + self._transferCanvas(workCanvas); + }); } _refreshPage() { -- cgit v1.2.3