Skip to content

Commit

Permalink
add offsetY when painting canvas2d text
Browse files Browse the repository at this point in the history
  • Loading branch information
fuzhenn committed Jun 17, 2020
1 parent f661bd0 commit 8cd37ff
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/core/Canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ let hitTesting = false;
let TEMP_CANVAS = null;

const RADIAN = Math.PI / 180;
const textOffsetY = 1;

const Canvas = {
setHitTesting(testing) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 8cd37ff

Please sign in to comment.