From 4dbd0da0ec1ddbc9428aec72b8d9d8a00398f448 Mon Sep 17 00:00:00 2001 From: Boris Dayma Date: Wed, 17 Aug 2022 16:33:32 -0500 Subject: [PATCH] fix: correct text alignment --- src/render/canvas/canvas-renderer.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/render/canvas/canvas-renderer.ts b/src/render/canvas/canvas-renderer.ts index 6efb648..609d8a7 100644 --- a/src/render/canvas/canvas-renderer.ts +++ b/src/render/canvas/canvas-renderer.ts @@ -146,11 +146,11 @@ export class CanvasRenderer extends Renderer { renderTextWithLetterSpacing(text: TextBounds, letterSpacing: number, baseline: number): void { if (letterSpacing === 0) { - this.ctx.fillText(text.text, text.bounds.left, text.bounds.top + baseline); + this.ctx.fillText(text.text, text.bounds.left, text.bounds.top - text.bounds.height / 2 + baseline); } else { const letters = segmentGraphemes(text.text); letters.reduce((left, letter) => { - this.ctx.fillText(letter, left, text.bounds.top + baseline); + this.ctx.fillText(letter, left, text.bounds.top - text.bounds.height / 2 + baseline); return left + this.ctx.measureText(letter).width; }, text.bounds.left);