From 8cd37fffabfec219a13aac591de4a07e66657082 Mon Sep 17 00:00:00 2001 From: fuzhenn Date: Wed, 17 Jun 2020 12:29:25 +0800 Subject: [PATCH] add offsetY when painting canvas2d text --- src/core/Canvas.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/Canvas.js b/src/core/Canvas.js index 779314254..8ddd97495 100644 --- a/src/core/Canvas.js +++ b/src/core/Canvas.js @@ -23,6 +23,7 @@ let hitTesting = false; let TEMP_CANVAS = null; const RADIAN = Math.PI / 180; +const textOffsetY = 1; const Canvas = { setHitTesting(testing) { @@ -339,7 +340,7 @@ const Canvas = { ctx.lineCap = 'round'; ctx.lineWidth = textHaloRadius * 2; ctx.strokeStyle = textHaloFill; - ctx.strokeText(text, Math.round(pt.x), Math.round(pt.y)); + ctx.strokeText(text, Math.round(pt.x), Math.round(pt.y + textOffsetY)); ctx.miterLimit = 10; //default ctx.globalAlpha = alpha; @@ -370,7 +371,7 @@ const Canvas = { if (rgba) { ctx.fillStyle = rgba; } - ctx.fillText(text, Math.round(pt.x), Math.round(pt.y)); + ctx.fillText(text, Math.round(pt.x), Math.round(pt.y + textOffsetY)); }, _stroke(ctx, strokeOpacity, x, y) {