From b61b4d3229774145aee71208e10246162b35c7f3 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Thu, 28 Feb 2019 14:06:56 +0100 Subject: [PATCH] Ensure that the temporary canvas created in `CanvasGraphics.isFontSubpixelAAEnabled` will be cleared While this particular canvas may be small, there can still be an arbitrarily large number of them (one per page rendered), which can/will eventually add up memory wise. This can be easily avoided by using the `cachedCanvases` abstraction instead, which will ensure that the `isFontSubpixelAAEnabled` canvas is removed together with other temporary canvases in `CanvasGraphics.endDrawing`. --- src/display/canvas.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/display/canvas.js b/src/display/canvas.js index 4aadb70a3..4647860fc 100644 --- a/src/display/canvas.js +++ b/src/display/canvas.js @@ -1414,7 +1414,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { get isFontSubpixelAAEnabled() { // Checks if anti-aliasing is enabled when scaled text is painted. // On Windows GDI scaled fonts looks bad. - var ctx = this.canvasFactory.create(10, 10).context; + const { context: ctx, } = + this.cachedCanvases.getCanvas('isFontSubpixelAAEnabled', 10, 10); ctx.scale(1.5, 1); ctx.fillText('I', 0, 10); var data = ctx.getImageData(0, 0, 10, 10).data;