Skip to content

Make text zone fill the box (grow + wrap)#79

Merged
flocom merged 1 commit into
mainfrom
claude/elegant-archimedes-2nh79p
Jun 21, 2026
Merged

Make text zone fill the box (grow + wrap)#79
flocom merged 1 commit into
mainfrom
claude/elegant-archimedes-2nh79p

Conversation

@flocom

@flocom flocom commented Jun 21, 2026

Copy link
Copy Markdown
Owner

Summary

The text-zone auto-fit previously only shrank the text, so a headline could stay on a single line and never wrap to use the box. This makes the zone behave like a real text box: the font grows or shrinks so the wrapped block fills the zone — short text grows and wraps onto multiple lines to fill the box, long text shrinks — always within the zone's height and width, and never breaking a word across lines.

Implementation

  • app.jszoneFitForText now searches [0.1, 6]× for the largest wrapped block that fits the zone height, then caps the scale so the widest word still fits the zone width on one line (prevents mid-word breaks and bounds growth). Combined with the existing "Same size for all languages" pass, the fill is computed for the most-constrained language and applied uniformly.
  • index.html — zone hint updated to "auto-size and wrap to fill the box".

Verification

  • node --check app.js passes.
  • Standalone algorithm tests: short title → grows (~2.6×) and wraps to 3 lines filling the height; narrow zone → grows (~1.6×) and wraps to many lines, capped by word width; long title → shrinks (~0.6×) and wraps; every case stays inside the zone with no word cut.
  • Dev server serves the updated assets (HTTP 200).

🤖 Generated with Claude Code


Generated by Claude Code

The zone auto-fit only shrank the text, so it could stay on one line and
never wrap to use the box. Now the font grows or shrinks so the wrapped
block fills the zone: short text grows and wraps to fill the box, long
text shrinks — always within the zone height and width, and never
breaking a word across lines.

- app.js: zoneFitForText searches [0.1, 6]x for the largest wrapped block
  that fits the zone height, capped by the widest word fitting the zone
  width (prevents mid-word breaks and bounds growth)
- index.html: zone hint updated to "auto-size and wrap to fill the box"

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y5pzx2vkZB8DN2dDy4YRNH
@flocom
flocom merged commit aa2f0b7 into main Jun 21, 2026
1 check passed
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.

2 participants