Skip to content

fix(virtues): add body-text auto-shrink for vertical overflow (#190) - #420

Merged
jsboige merged 1 commit into
masterfrom
fix/virtues-overflow-body-autoshrink-190
Jun 2, 2026
Merged

fix(virtues): add body-text auto-shrink for vertical overflow (#190)#420
jsboige merged 1 commit into
masterfrom
fix/virtues-overflow-body-autoshrink-190

Conversation

@jsboige

@jsboige jsboige commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Problem

Virtues cards (and potentially other CardSets) have text that overflows vertically — the .texte container has overflow: hidden, so text is silently clipped. Issue #190 tracks this.

Worst FR offenders: Argument pertinent (178 ch), Arguments vertueux (167 ch), Distance emotionnelle adequat (143 ch). All languages affected — RU Cyrillic ~15-20pct wider.

Solution

Extends the proven title auto-shrink (PR #400, issue #316) to vertical body text overflow:

  • New autoFitBodyText() in frame.js: binary search on font-size for .desc_* and .exemple_* children of .texte container
  • Stops when scrollHeight lessThanOrEqual clientHeight (2px tolerance, matching OverflowDetector.cs)
  • No-op when text fits (common case) — same idempotent design as title shrink
  • Min font floor: 7px (readable at print DPI)
  • All cards generically, language/CardSet agnostic

Scope

  • frame.js only — +70 lines (new function + call)
  • No C#, template, or CSV changes

Validation

  • JS syntax valid (Node.js parse)
  • dotnet build: 0 errors
  • 131/131 unit tests pass
  • QA visuelle requise (ai-01 Playwright+vision) avant merge

Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com

Extends the proven title auto-shrink mechanism (PR #400, issue #316)
to handle vertical text overflow in card body content.

- New autoFitBodyText() function in frame.js: binary search on
  font-size for .desc_* and .exemple_* children of .texte container
  until scrollHeight <= clientHeight (2px tolerance, matching
  OverflowDetector.cs)
- Targets all language variants (.desc_fr, .desc_en, .desc_ru, etc.)
- No-op when text fits (common case) — same idempotent design as
  title shrink
- Min font floor: 7px (readable even at print DPI)
- Applied to all cards generically before capture

Worst Virtues overflow candidates: 'Argument pertinent' (178 ch
combined desc+remark), 'Arguments vertueux' (167 ch), 'Distance
émotionnelle adequat' (143 ch desc only).

Fixes overflow in ALL languages — RU Cyrillic (~15-20% wider),
AR/FA/ZH with different font metrics all benefit.

Build: 0 errors, 131/131 tests pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@jsboige

jsboige commented Jun 2, 2026

Copy link
Copy Markdown
Contributor Author

ai-01 Code Review — APPROVE (pending QA visuelle)

Code review OK — clean extension of #400 title auto-shrink pattern to body text.

Verified

  • Binary search (10 iters, factor-based) converges quickly
  • No-op when text fits (common case)
  • Idempotent reset to natural sizes before calc
  • 2px tolerance matches OverflowDetector.cs
  • Floor 7px readable at print DPI
  • 131/131 tests pass, dotnet build clean
  • Scope: 1 file (frame.js), +70/-1

One cosmetic note

The selector hardcodes .desc_XX / .exemple_XX for 8 langs. Could use attribute selectors for future-proofing, but matches existing title-shrink pattern — not blocking.

Before merge

QA visuelle on a Virtues card with long text (e.g. Argument pertinent 178ch FR) to confirm body text auto-shrinks instead of clipping.

@jsboige
jsboige merged commit 378bab9 into master Jun 2, 2026
3 checks passed
@jsboige
jsboige deleted the fix/virtues-overflow-body-autoshrink-190 branch June 2, 2026 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant