view README.md @ 0:b5a96b547b01

initial public version
author ark
date 2026-11-03 01:29 +0100
parents
children aa23650954d6
line wrap: on
line source

# House number

3D-printed house numbers, or any other text, to screw to a wall. Each glyph
is a separate flat piece with two countersunk screw holes. Distance washers
behind the holes keep it off the wall and take up unevenness. The glyphs
print face down. A two-colour look with an outline band is possible on a
single-colour printer by changing filament once.

The work is split in three steps:

1. `make_preview.py` renders the text in every installed font, to choose
   one.
2. `make_glyphs.py` turns the text in the chosen font into glyph outlines,
   works out the largest printable size and places the screw holes.
3. `main.scad` builds the printable parts in OpenSCAD, and a drilling
   template, which `make_template.py` splits into printable pages.

## Requirements

- Python 3 with fontTools, Pillow and numpy. `make_template.py` needs only
  the standard library.
- fontconfig's `fc-list`, which the scripts use to find fonts.
- An OpenSCAD development snapshot. The model uses features newer than the
  2021.01 release.

## Choosing a font

    ./make_preview.py --text 24

writes one PNG per font into `preview/`. Each image shows the text as it
will be printed, drawn from the same outlines as the model. The caption
gives family, style, PostScript name, weight, classification and the
largest printable size. The file name is the font's PostScript name, so the
image can be passed to `make_glyphs.py` as it is. Named instances of
variable fonts, such as the weights of SF Pro, count as separate fonts.
Fonts that lack a character of the text are skipped.

On the development machine, all installed fonts took about 2 minutes and
244 MB. Filters narrow the selection:

    ./make_preview.py --text 24 --family 'helvetica|futura' --weight-min 600
    ./make_preview.py --text 24 --class serif --no-italic

`--family` and `--name` take regular expressions, matched against the
family and the PostScript name. `--italic`, `--mono` and their `--no-`
forms select by style. `--class serif` or `--class sans` keeps only fonts
that classify themselves that way; many fonts carry no classification and
appear only without this filter. `--list` prints the matching fonts
without rendering.

To see the two-colour look, give the band width in mm:

    ./make_preview.py --text 24 --band 4 --fill '#202020' --outline '#c03030' --background '#e8e4dc'

The band is scaled to each font's largest print size in the single-glyph
layout, or in the whole-text layout with `--layout text`.

## Glyph data

    ./make_glyphs.py preview/Futura-Bold.png 24
    ./make_glyphs.py Futura-Bold 24

The font is given by PostScript name or preview image. The script writes
`glyphs.scad`, which `main.scad` includes, and a directory
`generated/<font>_<text>/` with an SVG outline and a check image per glyph.
It prints the largest sizes and the hole positions; warnings go to standard
error.

### Size

Size is the height of the tallest glyph, in mm. The usable area is the bed
(300 mm) minus its margin (10 mm) and the frame of the two-colour print:
280 mm minus 4 line widths. Two layouts fit differently:

- text: the whole text in one print, spaced as the font spaces it.
- glyph: one glyph per print, all glyphs at the same size.

For both, the script reports the largest size unrotated and at the best
angle between 0 and 90 degrees. In Helvetica Bold, "24" reaches 189 mm in
the text layout and 278 mm per glyph; rotation gains nothing. In SF Extra
Compressed Thin, turning the glyphs by 45 degrees raises the size per glyph
from 278 to 325 mm.

The holes are placed for one size, by default the largest unrotated size in
the glyph layout. `--layout`, `--angle` (-1 for the best) and `--size`
choose another. OpenSCAD can scale to any size later; it then checks that
the screw heads still fit.

### Screw holes

Each glyph gets two holes, one near its upper and one near its lower end:

1. Only points where the screw head (8 mm, `--head-d`) plus a wall of 2
   line widths (`--wall-lines`) fits inside the glyph are considered.
2. The glyph's main axis is found from its inked area. It follows the slant
   of italic and script fonts and turns sideways for wide glyphs.
   `--vertical-axis` forces it upright.
3. Along the axis, the holes aim at 85% and 15% of the glyph length
   (`--target`). Distance from the axis is penalised (`--side-weight`);
   sitting in the middle of the stroke is rewarded (`--centre-weight`).
4. Where no point has room for the head, the hole goes to the thickest
   point of that half, and the script warns.

The check images show the glyph in grey, the area with room for the head in
green, the axis in blue and the holes in red, orange where the head does not
fit.

### Glyphs of several parts

Glyphs such as "i", "รค" or "%" consist of separate parts. The script
reports them and works out a backing that connects them, see below. A hole
can land in a separate part when the target position lies there, such as
the dot of "i".

### Fonts with overlapping outlines

Many fonts, variable fonts in particular, draw glyphs from overlapping or
self-crossing contours. OpenSCAD's SVG import would turn the overlaps into
holes. The script splits and groups the contours so the imported shape
matches the font, and compares the result with the font's own filling. Both
scripts report a difference.

## The model

Open `main.scad` in OpenSCAD and set the parameters in the customizer. The
console shows the size, thicknesses, warnings and a file name for the
export.

### Parts

- `all`: the glyphs as they hang on the wall, with the washers behind them.
- `body`: the glyph in print orientation, face on the bed. In single-colour
  mode this is the whole print.
- `decal`: the outline band of the two-colour print.
- `washer`: one distance washer. Make copies in the slicer.
- `template`: the drilling template, 2D.

### Layout and size

`layout` chooses between the whole text and one glyph per print.
`glyph_index` picks the glyph, counted from 0 without spaces. `size` 0 uses
the largest size that fits, `angle` -1 the best angle. `bed_size` and
`bed_margin` describe the printer.

### Glyph

`glyph_layers` sets the thickness, 6 layers by default: 1.2 mm at 0.2 mm
layers. `backing` adds `backing_layers` (4 by default) behind the glyph,
covering its outline. For glyphs of several parts the backing is the outline
grown and shrunk back, so the parts join; where that does not work, it fills
the convex hull. The gaps between parts are bridged and may need supports.

### Screws

`screw_d` (4 mm) and `head_d` (8 mm) set the hole and the countersink, each
widened by `clearance` on both sides. The countersink is 90 degrees and
opens towards the bed. With thin glyphs it is deeper than the glyph: at the
defaults 2 mm against 1.2 mm. The washer then continues the cone.

### Washers

The washer wall is `washer_wall_lines` line widths around the hole, 8 by
default. `washer_height` defaults to 10 mm. It is raised, with a warning,
to the part of the countersink inside the washer plus 4 layers. The washer
prints with the glyph side up.

With `washers_on_body`, the washers are part of the body instead, standing
on the glyph's back. Where a washer is wider than the glyph at that point,
it is cut back to the outline so it does not overhang, and a warning is
shown.

### Two-colour print

With `two_colour`, the glyph is split into a body and a decal:

- The decal is a band of `band_width` (4 mm) along the glyph outline, two
  layers thick.
- The body leaves out the band plus one line width, so the nozzle does not
  touch the printed decal.
- Both contain the same frame, one layer high and one line width wide,
  around the glyphs. It makes the slicer place both parts in the same spot.

To print:

1. Slice decal and body with the same settings.
2. Print the decal.
3. Change filament. Remove the skirt, if any, and the frame.
4. Print the body on top.

Where a stroke is too narrow to leave body material between the bands, the
face shows only the decal colour.

### Export

Render (F6) and export the 3D parts as STL. The file name echoed in the
console carries font, text, glyph, options, size, angle and print settings,
for example

    house_number_body_Futura-Bold_24_g0_2c_cs_s2780a0t6_lw40lh20.stl

## Drilling template

The holes do not line up with each other, so a full-size template shows
where to drill. Set `part` to `template`, render and export as SVG. The
template uses the same size as the print and shows:

- the glyph outlines where they hang on the wall, spaced as the font spaces
  them, also when the glyphs are printed one at a time;
- a circle of the hole diameter at each hole, with a cross reaching past the
  washer;
- a level line along the baseline;
- a 100 mm scale bar with 10 mm ticks.

Then

    ./make_template.py house_number_template_Futura-Bold_24_s2780_lw40lh20.svg

writes a PDF of the same name, split over A4 pages, portrait or landscape,
whichever needs fewer. Print it at 100% and check the scale bar.
Neighbouring pages overlap by 10 mm. A dashed line with crosses every 50 mm
runs through the middle of each overlap. Trim one sheet along the line, lay
it over its neighbour so line and crosses match, and tape it. Each page
names its row and column in the bottom margin.

`--paper` (a4, a3, letter, legal), `--margin` (unprintable edge, 6 mm) and
`--overlap` change the page layout.

## Files

- `make_preview.py`, `make_glyphs.py`, `make_template.py`: the scripts.
  Each lists its options with `--help`.
- `fontlib.py`: code shared by the first two.
- `main.scad`: the model.
- `glyphs.scad`, `generated/`: written by `make_glyphs.py`.
- `preview/`: written by `make_preview.py`.