fix: adjust text y-coordinate to account for librsvg baseline rendering limitations
Build and Push Multi-Platform Images / build-and-push (push) Successful in 28s

This commit is contained in:
2026-05-08 08:00:02 +02:00
parent c6b5431fab
commit 45c371a60d
@@ -51,8 +51,11 @@ export class LabelRendererService {
const fontWeight = el.bold ? 'bold' : 'normal';
const textAnchor = el.align === 'center' ? 'middle' : el.align === 'right' ? 'end' : 'start';
const maxWidthAttr = el.maxWidth ? ` textLength="${mm(el.maxWidth)}" lengthAdjust="spacingAndGlyphs"` : '';
// librsvg (used by sharp) ignores dominant-baseline; add fontSize to y so that
// the stored coordinate is the top of the text, not the baseline.
const yBaseline = y + fontSize;
parts.push(
`<text x="${x}" y="${y}" font-family="Arial,Helvetica,sans-serif" font-size="${fontSize}" font-weight="${fontWeight}" text-anchor="${textAnchor}" dominant-baseline="hanging"${maxWidthAttr}>${content}</text>`,
`<text x="${x}" y="${yBaseline}" font-family="Arial,Helvetica,sans-serif" font-size="${fontSize}" font-weight="${fontWeight}" text-anchor="${textAnchor}"${maxWidthAttr}>${content}</text>`,
);
} else if (el.type === 'qr') {
const x = mm(el.x);