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`.
This commit is contained in:
Jonas Jenwald 2019-02-28 14:06:56 +01:00
parent 21d70b19c2
commit b61b4d3229

View File

@ -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;