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
Build and Push Multi-Platform Images / build-and-push (push) Successful in 28s
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user