Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ jobs:
steps:
- uses: actions/checkout@v7

# A pinned snapshot, the OpenSCAD these examples are checked on.
# A pinned snapshot, the OpenSCAD these examples are checked on: 2026.10.15 or
# later, where textmetrics() is no longer experimental.
- name: Install OpenSCAD snapshot and just
# The AppImage and its checksum; update both together.
env:
OPENSCAD_SNAPSHOT: OpenSCAD-2026.08.19-x86_64.AppImage
OPENSCAD_SHA256: fdd818025e890f465ffacffbe7d0c6fa3ebeb3f7c18ee860a909ab41396be643
OPENSCAD_SNAPSHOT: OpenSCAD-2026.10.15-x86_64.AppImage
OPENSCAD_SHA256: 9d26e390d3a5c94f2e304d94d7b2eff77fb11fcd25829f2814de147ba92ac363
run: |
set -euo pipefail
sudo apt-get update -qq
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ examples/
torture_test_examples/ -- torture test example
```

## OpenSCAD version

The towers fit each section label to its face with `textmetrics()`, built in
from the OpenSCAD 2026.10.15 development snapshot. Earlier versions warn that
the function is missing or experimental and carve the labels at their full
size, which can run off the face.

## Quality / rendering

All examples set `$fn` based on `$preview`:
Expand Down
14 changes: 13 additions & 1 deletion src/flowtower.scad
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ module generate_section(
}

// Generate the text that will be carved into the square section column
// The font size, at most `size`, at which `txt` is no wider than `width`. Where
// textmetrics() is missing (OpenSCAD 2021.01) it returns `size` unchanged.
function flow_label_size(txt, size, font, width) =
let (w = textmetrics(text=txt, size=size, font=font).size[0])
is_undef(w) || w <= width ? size : size * width / w;

module generate_section_label(
label,
section_size,
Expand All @@ -144,14 +150,20 @@ module generate_section_label(
section_label_font_size
) {
full_label = str(section_label_prefix, label, section_label_suffix);
// The label may span 90% of the face it is carved into.
label_width = section_size * 0.9;
label_size = flow_label_size(full_label, section_label_font_size, font, label_width);
fitted_width = textmetrics(text=full_label, size=label_size, font=font).size[0];
assert(is_undef(fitted_width) || fitted_width <= label_width + 1e-3,
str("section label \"", full_label, "\" is wider than its face"));
translate([-section_size / 2, -section_size, section_size / 2])
rotate([90, 0, 0])
translate([0, 0, -label_depth])
linear_extrude(height=label_depth + iota)
text(
text=full_label,
font=font,
size=section_label_font_size,
size=label_size,
halign="center",
valign="center"
);
Expand Down
14 changes: 13 additions & 1 deletion src/retracttower.scad
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ module generate_retract_round_column(cube_size, cap_size, cap_height, wall_thick
}

// Generate the section label carved into the square column
// The font size, at most `size`, at which `txt` is no wider than `width`. Where
// textmetrics() is missing (OpenSCAD 2021.01) it returns `size` unchanged.
function retract_label_size(txt, size, font, width) =
let (w = textmetrics(text=txt, size=size, font=font).size[0])
is_undef(w) || w <= width ? size : size * width / w;

module generate_retract_section_label(
label,
section_label_prefix,
Expand All @@ -135,14 +141,20 @@ module generate_retract_section_label(
iota
) {
full_label = str(section_label_prefix, label, section_label_suffix);
// The label may span 90% of the face it is carved into.
label_width = cube_size * 0.9;
label_size = retract_label_size(full_label, section_label_font_size, font, label_width);
fitted_width = textmetrics(text=full_label, size=label_size, font=font).size[0];
assert(is_undef(fitted_width) || fitted_width <= label_width + 1e-3,
str("section label \"", full_label, "\" is wider than its face"));
translate([-tower_width / 2 + cube_size / 2, -cube_size / 2 - iota, cube_size / 2])
rotate([90, 0, 0])
translate([0, 0, -label_depth])
linear_extrude(label_depth + iota)
text(
text=full_label,
font=font,
size=section_label_font_size,
size=label_size,
halign="center",
valign="center"
);
Expand Down
14 changes: 13 additions & 1 deletion src/temptower.scad
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ module generate_temp_right_bridge_support(
}

// Generate the section label carved into the left column
// The font size, at most `size`, at which `txt` is no wider than `width`. Where
// textmetrics() is missing (OpenSCAD 2021.01) it returns `size` unchanged.
function temp_label_size(txt, size, font, width) =
let (w = textmetrics(text=txt, size=size, font=font).size[0])
is_undef(w) || w <= width ? size : size * width / w;

module generate_temp_section_label(
label,
section_label_prefix,
Expand All @@ -164,14 +170,20 @@ module generate_temp_section_label(
iota
) {
full_label = str(section_label_prefix, label, section_label_suffix);
// The label may span 90% of the face it is carved into.
label_width = cube_size * 0.9;
label_size = temp_label_size(full_label, section_label_font_size, font, label_width);
fitted_width = textmetrics(text=full_label, size=label_size, font=font).size[0];
assert(is_undef(fitted_width) || fitted_width <= label_width + 1e-3,
str("section label \"", full_label, "\" is wider than its face"));
translate([-tower_width / 2 + cube_size / 2, -cube_size / 2 - iota, cube_size / 2])
rotate([90, 0, 0])
translate([0, 0, -label_depth])
linear_extrude(label_depth + iota)
text(
text=full_label,
font=font,
size=section_label_font_size,
size=label_size,
halign="center",
valign="center"
);
Expand Down
Loading