diff --git a/svelte-app/src/lib/canvas/renderer.ts b/svelte-app/src/lib/canvas/renderer.ts index c498ee6..ecb8648 100644 --- a/svelte-app/src/lib/canvas/renderer.ts +++ b/svelte-app/src/lib/canvas/renderer.ts @@ -556,13 +556,12 @@ function drawConveyanceLabel(ctx: CanvasRenderingContext2D, sym: PlacedSymbol) { let cx: number, cy: number, availW: number, availH: number; if (isSpurType(sym.symbolId)) { const w2 = sym.w2 ?? sym.w; - // Use the width at 40% from top (biased toward narrow end for safe fit) - const t = 0.4; + // Position text toward the wider end where there's more room + const t = 0.65; const widthAtT = w2 + t * (sym.w - w2); cx = sym.x + widthAtT / 2; cy = sym.y + sym.h * t; - // Use narrower of top/bottom edge with padding for safe text fit - availW = Math.min(w2, widthAtT) - pad * 2; + availW = widthAtT - pad * 2; availH = sym.h - pad * 2; } else { cx = sym.x + sym.w / 2; @@ -571,11 +570,11 @@ function drawConveyanceLabel(ctx: CanvasRenderingContext2D, sym: PlacedSymbol) { availH = sym.h - pad * 2; } - // Compute text correction so text is always readable: - // - Counter-rotate if symbol rotation makes text upside-down (91-269 deg) - // - Counter-mirror if symbol is mirrored (so text doesn't read backwards) + // Compute text correction so text is always readable. + // Mirror flips the effective angle: visual angle = (360 - rot) when mirrored. const rot = ((sym.rotation || 0) % 360 + 360) % 360; - const needsFlip = rot > 90 && rot < 270; + const effectiveAngle = sym.mirrored ? ((360 - rot) % 360) : rot; + const needsFlip = effectiveAngle > 90 && effectiveAngle < 270; const needsMirrorFix = !!sym.mirrored; const hasCorrection = needsFlip || needsMirrorFix; diff --git a/svelte-app/src/lib/export.ts b/svelte-app/src/lib/export.ts index 63c1f59..5a6222f 100644 --- a/svelte-app/src/lib/export.ts +++ b/svelte-app/src/lib/export.ts @@ -44,11 +44,11 @@ function emitConveyanceLabelInner(lines: string[], sym: PlacedSymbol) { textRotDeg = (textRotRad * 180) / Math.PI; } else if (isSpurType(sym.symbolId)) { const w2 = sym.w2 ?? sym.w; - const t = 0.4; + const t = 0.65; const widthAtT = w2 + t * (sym.w - w2); labelCx = sym.x + widthAtT / 2; labelCy = sym.y + sym.h * t; - availH = Math.min(sym.h - 4, widthAtT - 4); + availH = sym.h - 4; } else if (isInductionType(sym.symbolId)) { const stripTopY = sym.y + sym.h * INDUCTION_CONFIG.stripTopFrac; const stripBottomY = sym.y + sym.h * INDUCTION_CONFIG.stripBottomFrac; @@ -65,7 +65,8 @@ function emitConveyanceLabelInner(lines: string[], sym: PlacedSymbol) { let needsMirrorFix = false; if (!isCurvedType(sym.symbolId)) { const rot = ((sym.rotation || 0) % 360 + 360) % 360; - if (rot > 90 && rot < 270) textRotDeg = 180; + const effectiveAngle = sym.mirrored ? ((360 - rot) % 360) : rot; + if (effectiveAngle > 90 && effectiveAngle < 270) textRotDeg = 180; needsMirrorFix = !!sym.mirrored; }