2 Commits

Author SHA1 Message Date
s4luorth
17eebcfe6a Signatur: kompakter + Abstand pro Signatur regelbar
All checks were successful
Build & Deploy / deploy (push) Successful in 15s
Signatur reserviert nur noch die tatsaechlich gerenderte Hoehe statt fix 2
Zeilen; Standard-Abstand = halber Zeilenabstand, pro Signatur ueber
signature_offsets[key].spacing (mm) ueberschreibbar. Zielhoehe kompakter (~1,2
statt 2 Zeilen).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-10-01 10:36:08 +02:00
s4luorth
9984b822aa A5-Greifrand an die KURZE Seite
All checks were successful
Build & Deploy / deploy (push) Successful in 10s
A5 hoch (a5p) unten, A5 quer (a5l) rechts - A5 wird an der kurzen (148 mm)
Seite gegriffen. A6 und DIN lang bleiben an der langen Seite.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-09-30 11:43:27 +02:00
2 changed files with 26 additions and 12 deletions

View File

@@ -9,9 +9,10 @@ const FONT_SIZE_PX = 26;
const DEFAULT_LINE_LIMITS = { a4: 27, a5p: 19, a5l: 13, a6p: 14, a6l: 11, dinlang_karte: 11 }; const DEFAULT_LINE_LIMITS = { a4: 27, a5p: 19, a5l: 13, a6p: 14, a6l: 11, dinlang_karte: 11 };
const DEFAULT_FORMAT_LAYOUTS = { const DEFAULT_FORMAT_LAYOUTS = {
a4: { marginTopMm: 25, marginLeftMm: 20, lineHeightFactor: 1.35 }, a4: { marginTopMm: 25, marginLeftMm: 20, lineHeightFactor: 1.35 },
// Greifrand IMMER an der langen (210 mm) Seite: hoch → rechts, quer/DIN lang → unten. // A5 greift an der KURZEN (148 mm) Seite: hoch → unten, quer → rechts.
a5p: { marginTopMm: 20, marginLeftMm: 15, marginRightMm: 14, lineHeightFactor: 1.35 }, a5p: { marginTopMm: 20, marginLeftMm: 15, marginBottomMm: 14, lineHeightFactor: 1.35 },
a5l: { marginTopMm: 20, marginLeftMm: 15, marginBottomMm: 14, lineHeightFactor: 1.35 }, a5l: { marginTopMm: 20, marginLeftMm: 15, marginRightMm: 14, lineHeightFactor: 1.35 },
// DIN lang greift an der langen (210 mm) Seite → unten.
dinlang_karte: { marginTopMm: 8, marginLeftMm: 10, marginBottomMm: 14, lineHeightFactor: 1.2 }, dinlang_karte: { marginTopMm: 8, marginLeftMm: 10, marginBottomMm: 14, lineHeightFactor: 1.2 },
// A6-Greifrand IMMER an der langen (148 mm) Seite: // A6-Greifrand IMMER an der langen (148 mm) Seite:
// • a6p (hoch, 105×148): lange Seite = rechts → marginRightMm (Breite) // • a6p (hoch, 105×148): lange Seite = rechts → marginRightMm (Breite)

View File

@@ -156,12 +156,13 @@ function generateLetterSVG(text, format, options = {}) {
// ── Pfad mit Signaturen: Text in Segmente aufteilen ─────────────────────── // ── Pfad mit Signaturen: Text in Segmente aufteilen ───────────────────────
// Jede Signatur-Zeile ist 2 Zeilen hoch; bis zu 3 Signaturen nebeneinander. // 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 sigSlotW = maxWidthPx / 3; // Breite pro Signatur-Slot
const sigScaleH = sigHeightPx / SIG_CANVAS_H; const sigScale = Math.min((lineHeightPx * 1.2) / SIG_CANVAS_H, sigSlotW / SIG_CANVAS_W);
const sigScaleW = sigSlotW / SIG_CANVAS_W; // Standard-Abstand ober-/unterhalb der Signatur = halber Zeilenabstand.
const sigScale = Math.min(sigScaleH, sigScaleW); // gleichmäßig skalieren // Pro Signatur über signatureOffsets[key].spacing (mm) überschreibbar.
const sigPaddingPx = lineHeightPx * 0.3; // kleiner Abstand ober/unterhalb const defaultSpacingPx = lineHeightPx * 0.5;
const rawText = String(text || ''); const rawText = String(text || '');
const segments = []; const segments = [];
@@ -217,13 +218,25 @@ function generateLetterSVG(text, format, options = {}) {
totalLineCount += lines.length; totalLineCount += lines.length;
si++; si++;
} else { } else {
// Aufeinanderfolgende Signaturen als Zeile nebeneinander rendern // Aufeinanderfolgende Signaturen als Zeile nebeneinander rendern.
const sigRow = []; const sigRow = [];
while (si < segments.length && segments[si].type === 'sig') { while (si < segments.length && segments[si].type === 'sig') {
sigRow.push(segments[si]); sigRow.push(segments[si]);
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) => { sigRow.forEach((sigSeg, slotIdx) => {
const svgString = signatures[sigSeg.key] || null; const svgString = signatures[sigSeg.key] || null;
if (svgString) { if (svgString) {
@@ -237,8 +250,8 @@ function generateLetterSVG(text, format, options = {}) {
if (sigEl) allSvgElements.push(sigEl); if (sigEl) allSvgElements.push(sigEl);
} }
}); });
currentY += sigHeightPx + sigPaddingPx; currentY += rowHeightPx + spacingPx;
totalLineCount += 2; // ganze Zeile zählt als 2 Zeilen, unabhängig von Anzahl totalLineCount += Math.max(1, Math.ceil((2 * spacingPx + rowHeightPx) / lineHeightPx));
} }
} }