From d37d879ccbd291fec7026c1a3eee90b6d8abd5f4 Mon Sep 17 00:00:00 2001 From: Eric Li Date: Wed, 20 Dec 2017 19:06:56 +0800 Subject: [PATCH] add option fontAntiAlias, default value is true --- src/options/defaults.js | 1 + src/renderers/canvas.js | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/options/defaults.js b/src/options/defaults.js index f2362ffa..7231578e 100644 --- a/src/options/defaults.js +++ b/src/options/defaults.js @@ -10,6 +10,7 @@ var defaults = { textPosition: "bottom", textMargin: 2, fontSize: 20, + fontAntiAlias: true, background: "#ffffff", lineColor: "#000000", margin: 10, diff --git a/src/renderers/canvas.js b/src/renderers/canvas.js index bba16d41..2d32fe07 100644 --- a/src/renderers/canvas.js +++ b/src/renderers/canvas.js @@ -97,6 +97,10 @@ class CanvasRenderer{ y = options.height + options.textMargin + options.marginTop + options.fontSize; } + if(options.fontAntiAlias == false){ + ctx.antialias = 'none'; + } + ctx.font = font; // Draw the text in the correct X depending on the textAlign option @@ -113,7 +117,7 @@ class CanvasRenderer{ x = encoding.width / 2; ctx.textAlign = 'center'; } - + ctx.fillText(encoding.text, x, y); } }