text() — 3D Text

text

text(str, height, options) — Extrudes a string into a 3D shape using an OpenType font.

async — always use await text(...).

Syntax

const t = await text(str, height, options)
Parameter Type Default Description
str string Text to extrude
height number Extrusion depth (mm)
size number 10 Font size (mm)
segs number 8 Curve smoothness
font string 'Roboto' Font name

text() is async — always use await.

Examples

// Simple text
const t = await text('Hello', 3, { size: 15 });
const result = t;
// Bold font, centered on a box
// "label" is a text parameter defined in the Parameters tab (default: 'MB3D')
const base  = box(60, 20, 5);
const t  = await text(label, 2, { size: 10, font: 'Roboto-Bold' });
const tw = await text_width(label, { size: 10, font: 'Roboto-Bold' });
const result = base.add(t.translate([-tw/2, -5, 5]));

text_width

text_width(str, options) — Returns the width of a string in mm without creating a 3D shape.

const w = await text_width('Hello', { size: 10, font: 'Roboto' });

Available fonts

Name Style
Roboto Regular
Roboto-Bold Bold
Roboto-Italic Italic
Roboto-BoldItalic Bold Italic
OpenSans Regular
OpenSans-Bold Bold
Montserrat Regular
Montserrat-Bold Bold
Orbitron Regular (futuristic)
Lora Regular (serif)
Lora-Bold Bold (serif)
ShareTechMono Monospace
Pacifico Script
BebasNeue Display