This commit is contained in:
Boris Dayma 2022-08-26 01:38:33 +00:00 committed by GitHub
commit 5bd17e4663
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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