@@ -156,12 +156,13 @@ function generateLetterSVG(text, format, options = {}) {
// ── Pfad mit Signaturen: Text in Segmente aufteilen ───────────────────────
// Jede Signatur-Zeile ist 2 Zeilen hoch; bis zu 3 Signaturen nebeneinander.
const sigHeightPx = 2 * lineHeightPx ;
// Signatur-Größe: kompakte Zielhöhe (~1,2 Zeilen statt fix 2) ODER schmaler Slot –
// gleichmäßig skalieren. Über signatureOffsets[key].scale je Signatur anpassbar.
const sigSlotW = maxWidthPx / 3 ; // Breite pro Signatur-Slot
const sigScaleH = sigHeightPx / SIG _CANVAS _H ;
const sigScaleW = sigSlotW / SIG _CANVAS _W ;
const sigScale = Math . min ( sigScaleH , sigScaleW ) ; // gleichmäßig skalieren
const sigPadd ingPx = lineHeightPx * 0.3 ; // kleiner Abstand ober/unterhalb
const sigScale = Math . min ( ( lineHeightPx * 1.2 ) / SIG _CANVAS _H , sigSlotW / SIG _CANVAS _W ) ;
// Standard-Abstand ober-/unterhalb der Signatur = halber Zeilenabstand.
// Pro Signatur über signatureOffsets[key].spacing (mm) überschreibbar.
const defaultSpac ingPx = lineHeightPx * 0.5 ;
const rawText = String ( text || '' ) ;
const segments = [ ] ;
@@ -217,13 +218,25 @@ function generateLetterSVG(text, format, options = {}) {
totalLineCount += lines . length ;
si ++ ;
} else {
// Aufeinanderfolgende Signaturen als Zeile nebeneinander rendern
// Aufeinanderfolgende Signaturen als Zeile nebeneinander rendern.
const sigRow = [ ] ;
while ( si < segments . length && segments [ si ] . type === 'sig' ) {
sigRow . push ( segments [ si ] ) ;
si ++ ;
}
currentY += sigPaddingPx ;
// Tatsächlich gerenderte Höhe der Zeile + individueller Abstand je Signatur
// (Default halber Zeilenabstand). So wird nur der real benötigte Platz
// reserviert statt fix 2 Zeilen – Signaturen „fressen" keinen Platz mehr.
let rowHeightPx = 0 ;
let spacingPx = defaultSpacingPx ;
for ( const sigSeg of sigRow ) {
const off = signatureOffsets [ sigSeg . key ] || { } ;
const sc = Number ( off . scale ) > 0 ? Number ( off . scale ) : 1 ;
if ( signatures [ sigSeg . key ] ) rowHeightPx = Math . max ( rowHeightPx , SIG _CANVAS _H * sigScale * sc ) ;
if ( off . spacing != null && off . spacing !== '' ) spacingPx = Math . max ( 0 , mmToPx ( Number ( off . spacing ) ) ) ;
}
if ( rowHeightPx <= 0 ) rowHeightPx = lineHeightPx ; // keine SVG → eine Platzhalterzeile
currentY += spacingPx ;
sigRow . forEach ( ( sigSeg , slotIdx ) => {
const svgString = signatures [ sigSeg . key ] || null ;
if ( svgString ) {
@@ -237,8 +250,8 @@ function generateLetterSVG(text, format, options = {}) {
if ( sigEl ) allSvgElements . push ( sigEl ) ;
}
} ) ;
currentY += sig HeightPx + sigPadd ingPx ;
totalLineCount += 2 ; // ganze Zeile zählt als 2 Zeilen, unabhängig von Anzahl
currentY += row HeightPx + spac ingPx ;
totalLineCount += Math . max ( 1 , Math . ceil ( ( 2 * spacingPx + rowHeightPx ) / lineHeightPx ) ) ;
}
}