This commit is contained in:
haztheo 2022-08-18 16:24:46 +00:00 committed by GitHub
commit 749b8bf737
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 3 deletions

View File

@ -146,12 +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 - baseline);
} else {
const letters = segmentGraphemes(text.text);
letters.reduce((left, letter) => {
this.ctx.fillText(letter, left, text.bounds.top + baseline);
this.ctx.fillText(text.text, text.bounds.left, text.bounds.top + text.bounds.height - baseline);
return left + this.ctx.measureText(letter).width;
}, text.bounds.left);
}