Skip to main content

Text

Text turns a string into outline geometry: each letter becomes a closed profile, counters included, that extrudes, cuts or wraps like any other sketch shape.

In the viewport

  1. Click Text on the sketch toolbar. The Text dialog opens with the string, font, size, weight, italic, alignment and spacing fields, and the laid-out glyph outlines preview in the viewport — the exact geometry the statement will build, refreshed on every edit.
  2. Click in the viewport to move the anchor (it snaps like any other point), or leave it on the sketch origin.
  3. Apply writes the text(…) statement and the render replaces the preview with the real outlines.

Text outline

The code behind it
label.part.js
import { sketch, text } from 'fluidcad/core';

sketch("xy", () => {
text("Hello").size(20)
})

By hand

text("Hello") // anchored at the sketch origin
text("Hello").at([0, 20]) // anchored at explicit coordinates
text("Hello").size(12) // cap height in model units (default 10)
text("Hello", path) // laid along a curve — see below

The size is the cap height in the file's unit; thickness comes from the operation that consumes the text.

Constraints and text

note

The glyph outlines are not constraint targets — you cannot make a letter's edge coincident, tangent or dimensioned. The one solver entity a text registers is its anchor point, t.anchor(): constrain that to position the whole text. The anchor exists only for text that is not following a path; path text is placed by the path.

const t = text("A1").size(8);
coincident(t.anchor(), bore.center()); // the label rides the bore

Fonts and weight

By default text() uses a system font. Pass a system font name to .font(), or a workspace-relative font file ending in .ttf / .otf (.font("fonts/Brand.ttf")). .weight() takes "regular", "bold" or a number 100–900; .italic() slants it:

Bold serif text from a named system font

The code behind it
label.part.js
import { sketch, text } from 'fluidcad/core';

sketch("xy", () => {
text("Serif").size(20).font("Times New Roman").weight("bold")
})

If the named font is not installed, the closest match is substituted ("Arial" → a system sans-serif), and ultimately a default font.

Extruding text

Text is ordinary sketch geometry, so the follow-up feature is the usual one — the counters (the holes in o, e, A) are kept automatically:

Extruded 3D text

The code behind it
label.part.js
import { sketch, text, extrude } from 'fluidcad/core';

sketch("xy", () => text("FluidCAD").size(20))
extrude(6)

For multi-line strings (\n), set .align("left" | "center" | "right"); fine-tune spacing with .lineSpacing() and .letterSpacing().

Text along a path

The dialog's Path slot switches to the path form: arming it turns viewport clicks into whole-curve picks, and the anchor stands down because the path owns placement. In code, text(string, path) lays the glyphs along the curve. The path can be a curve in the same sketch, a whole sketch (sketch("xy", () => circle([0, 0], 80))), or edges selected from existing geometry (select(edge().circle()) for a cylinder rim). It must be planar; the text lies in its plane.

Text along an arc

The code behind it
label.part.js
import { arc, extrude, sketch, text } from 'fluidcad/core';

sketch("xy", () => {
const path = arc([0, 0], [100, 0], [50, -120]).cw().guide();
text("CURVED TEXT", path).size(12).align("center");
});
extrude(4);

The path stays in the scene, so several texts can share it. When it lives in the same sketch, mark it .guide() so the curve stays out of the extruded profile.

Glyph spacing is measured as arc length, so kerning and .letterSpacing() behave as they do on a straight baseline. .startAt(d) slides the start of the text along the path by an arc-length distance.

Aligning on a path

.align() positions the run against the path ("left" / "right" are synonyms of "start" / "end"):

The code behind it
label.part.js
import { arc, sketch, text } from 'fluidcad/core';

sketch("xy", () => {
const path = arc([0, 0], [180, 0], [90, -216]).cw().guide();
text("start", path).size(14).align("start");
});

"start" (the default) begins the text at the path's start:

Path text aligned to the start

"center" centres it on the path's midpoint:

Path text centred on the path

"end" finishes at the path's end:

Path text aligned to the end

"space-between" justifies the glyphs across the whole path, first glyph at the start and last at the end:

Path text justified with space-between

"space-around" distributes them evenly too, with half a gap before the first glyph and after the last:

Path text distributed with space-around

Outside or inside: flip

On a closed path the text wraps around and sits on the outside by default. .flip() mirrors it to the other side and reverses the reading direction: inside on a circle, below the curve on an open path:

Text outside and inside a circle

The code behind it
label.part.js
import { sketch, circle, extrude, text } from 'fluidcad/core';

const ring = sketch("xy", () => circle([0, 0], 90));
const outside = text("OUTSIDE", ring).size(10).align("center");
// startAt(141) ≈ half the circumference: badge-style text on the far side.
const inside = text("INSIDE", ring).size(10).align("center").flip().startAt(141);
extrude(3, outside);
extrude(3, inside);

Floating off the path: offset

.offset(d) shifts the baseline perpendicular to the path — positive floats the text above the curve, negative tucks it below:

Text offset above and below an arc

The code behind it
label.part.js
import { arc, sketch, text } from 'fluidcad/core';

sketch("xy", () => {
// The path is a guide arc: it shapes the text but never joins the profile.
const path = arc([0, 0], [100, 0], [50, -120]).cw().guide();
// Positive offset floats the baseline above the curve, negative tucks it below.
text("FLOATING ABOVE", path).size(8).align("center").offset(10);
text("TUCKED BELOW", path).size(8).align("center").offset(-14);
});