Skip to content

fix: fit the tower section labels to their faces - #5

Merged
CameronBrooks11 merged 3 commits into
mainfrom
fix/fit-section-labels
Nov 16, 2026
Merged

CameronBrooks11 merged 3 commits into
mainfrom
fix/fit-section-labels

Conversation

@CameronBrooks11

@CameronBrooks11 CameronBrooks11 commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

The temperature, retraction and flow towers sized each section label from the section height alone (size × 0.401). In their examples, every label came out wider than the face it's carved into. Head-on renders show the first and last strokes cut off at the face edges: "180C" reads as "80C", and "6mm" and "115%" are clipped the same way. The detailed temperature and speed towers carve their labels on wider faces and were already fine.

Measured with textmetrics() at each example's settings (font "Arial:style=Bold", which resolves to Liberation Sans Bold here):

tower face labels before after
temperature 8.0 mm 10.25–10.38 mm, all 9 overrun 7.2 mm, size 3.21 → 2.23–2.25
retraction 8.0 mm 9.85–10.06 mm, all 6 overrun 7.2 mm, size 3.21 → 2.30–2.35
flow 8.4 mm 9.08–11.55 mm, all 7 overrun 7.56 mm, size 3.37 → 2.21–2.80

Each tower gets a *_label_size() function. It shrinks a label, only when needed, until the label spans at most 90% of its face. An assert stops the render if a label still overruns. OpenSCAD 2021.01 has no textmetrics(); there, the label keeps its old size.

Checked:

  • Fit: all 22 labels fit; head-on renders show them whole.
  • Mutation: with the fit disabled in the temperature tower, just test exits 1 with section label "220C" is wider than its face. Restored, it passes all 16.

The labels are smaller than before, about 2.2–2.8 mm instead of 3.2–3.4 mm. Shorter suffixes (e.g. no "C") would let them stay bigger, if you'd rather.

OpenSCAD version: textmetrics() is built in from the 2026.10.15 snapshot. CI's earlier pin, 2026.08.19, still treats it as experimental, and CI's --hardwarnings stopped on that warning. CI now pins 2026.10.15, the same snapshot the docs engine uses. I ran the flow example on 2026.08.19 without --hardwarnings: it warns, the fit returns the full font size (3.3688), and the model renders (exit 0) with the old, overrunning labels. The README now says this.

The temperature, retraction and flow towers sized each section label
from the section height alone, so every label in their examples was
wider than the face it is carved into: 9.1 to 11.6 mm on faces of 8.0
and 8.4 mm. A printed tower lost the label's first and last strokes
off the edges ("180C" read as "80C").

Each label now shrinks, when it has to, until it spans at most 90% of
its face, measured with textmetrics(). An assert stops the render if a
label still overruns, so just test catches a regression: with the fit
disabled it fails on "220C". OpenSCAD 2021.01, which has no
textmetrics(), keeps the old size.
The label fit uses textmetrics(), which the 2026.08.19 snapshot still
treats as experimental: CI's --hardwarnings render stopped on that
warning. CI now pins 2026.10.15, the snapshot the docs engine uses.

On 2026.08.19 without --hardwarnings the flow tower example still
renders (exit 0): textmetrics() warns, the fit returns the full font
size (3.3688), and the labels keep their old size. The README says so.
@CameronBrooks11
CameronBrooks11 merged commit 1af5601 into main Nov 16, 2026
6 checks passed
@CameronBrooks11
CameronBrooks11 deleted the fix/fit-section-labels branch November 16, 2026 02:48
CameronBrooks11 added a commit that referenced this pull request Nov 16, 2026
The README had no pictures, and `.gitignore` excluded every PNG.

`just images` renders three labelled sheets into `images/` with OpenSCAD
and ImageMagick:
- **`towers.png`:** temperature, detailed temperature, retraction, flow
and speed.
- **`bed-level-patterns.png`:** the eight patterns, seen from straight
above (orthographic), where single lines read best.
- **`cube-and-torture-test.png`:** the XYZ calibration cube and the
torture test.

Each model is trimmed to its outline before it goes on a sheet. Each
sheet is then quantized to 128 colours without dithering: 1.4 MB for the
three instead of 3.2 MB. I compared both versions and saw no banding,
even on the shaded retraction column. `.gitignore` now lets
`images/*.png` through, and the README shows the three sheets under its
opening paragraph.

These pictures are rendered after #5, so the towers show the fitted
labels. They're also how #5's defect was found: the first render showed
"180C", "6mm" and "115%" running off their faces. I looked at all three
sheets. `just test` renders all 16 examples.
CameronBrooks11 added a commit that referenced this pull request Nov 16, 2026
Since #5, `section_label_height_multiplier` sets the largest section
label size on the flow, temperature and retraction towers: a label wider
than its face is drawn smaller. The three parameter tables in
`docs/towers.md` still described it as the size. The detailed
temperature and speed towers don't fit their labels, so their rows are
unchanged.
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