aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpacien2018-07-18 23:10:40 +0200
committerpacien2018-07-18 23:10:40 +0200
commit939c748aa11cdf34540aae569cd6f7b026a266a1 (patch)
tree36d499c2e077327f608d89c7282e27ba365c60f8
parentbfaf317d5ee07dcc2dd65ad5239b439736722fc2 (diff)
downloadbeamer-viewer-939c748aa11cdf34540aae569cd6f7b026a266a1.tar.gz
Workaround for pdfjs font bug
-rw-r--r--pointless/viewer/screen.js21
1 files 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 {
38 this.context.transform(1, 0, 0, 1, xOffset, 0); 38 this.context.transform(1, 0, 0, 1, xOffset, 0);
39 } 39 }
40 40
41 _makeWorkCanvas(width, height) {
42 var canvas = document.createElement("canvas");
43 canvas.width = width;
44 canvas.height = height;
45 return canvas;
46 }
47
48 _transferCanvas(source) {
49 this.context.drawImage(source, 0, 0);
50 }
51
41 _paintPage() { 52 _paintPage() {
42 var renderRatio = this.canvas.height / this.page.getViewport(1).height; 53 var renderRatio = this.canvas.height / this.page.getViewport(1).height;
43 var renderViewport = this.page.getViewport(renderRatio); 54 var renderViewport = this.page.getViewport(renderRatio);
44 var renderContext = { canvasContext: this.context, viewport: renderViewport }; 55 var workCanvas = this._makeWorkCanvas(renderViewport.width, renderViewport.height);
45 this.page.render(renderContext); 56 var workContext = workCanvas.getContext("2d");
57 var renderContext = { canvasContext: workContext, viewport: renderViewport };
58
59 var self = this;
60 this.page.render(renderContext).then(function() {
61 self._transferCanvas(workCanvas);
62 });
46 } 63 }
47 64
48 _refreshPage() { 65 _refreshPage() {