From f0431becf93a766881a24bf7fad4687f7a9fa908 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Mestres?= Date: Thu, 30 May 2024 12:47:26 +0200 Subject: [PATCH] fix: fix issue with top alignement when text contains spaces --- app/services/text-maker.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/services/text-maker.ts b/app/services/text-maker.ts index 0225bea..48c1fc9 100644 --- a/app/services/text-maker.ts +++ b/app/services/text-maker.ts @@ -313,11 +313,13 @@ export default class TextMakerService extends Service { const x = ox + info.dx; const y = info.dy; + const emptyGlyph = lineText.glyphs[info.g].length === 0; + const glyphBounds = this.getSVGPathSegmentsBoundingBox(lineText.glyphs[info.g]); const glyphHeight = glyphBounds.y2 - glyphBounds.y1; - const minY = Math.min(glyphBounds.y1, glyphBounds.y2); - const maxY = Math.max(glyphBounds.y1, glyphBounds.y2); + const minY = emptyGlyph ? 0 : Math.min(glyphBounds.y1, glyphBounds.y2); + const maxY = emptyGlyph ? 0 : Math.max(glyphBounds.y1, glyphBounds.y2); lineMinMaxY.maxY = Math.max(lineMinMaxY.maxY, maxY); lineMinMaxY.minY = Math.min(lineMinMaxY.minY, minY);