Skip to main content

Text in 3D compared

Bitbybit writes text in four ways. They differ in what you get back (lines, solids or the outlines of a real font), where the text lands, and which font it uses.

WayFunctionYou getFontPlan
Stroke wiresocct.shapes.wire.textWiresOne OCCT wire per pen stroke, lying on the groundA single-line Hershey font, built inFree
Stroke pointstext.vectorTextThe strokes as lists of points, plain data with no kernelA simple stroke font, built inFree
JSCAD strokesjscad.text.cylindricalText, sphericalText, createVectorTextStrokes as rounded solids, or as 2D pathsA single-line font, built inFree
Real fontsadvanced.text3d.createLetter faces or extruded letter solids from the outlines of a fontTen shipped fonts, or a font file from a URLSilver and Gold

The first three draw letters as pen strokes: each letter is one or more lines with no width, which is what a plotter, an engraver or a laser follows. Only text3d uses the filled outlines of a real typeface.

Here one word is written as OCCT stroke wires and another as JSCAD cylinder solids:

Bitbybit Platform

Text as wires and text as solids in Rete

rete logoRete
Script Source (rete)
{
"id": "rete-v2-json",
"nodes": {
"wires": {
"id": "wires",
"name": "bitbybit.occt.shapes.wire.textWires",
"customName": "text wires",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"text": "Wires",
"xOffset": 0,
"yOffset": 0,
"height": 1,
"lineSpacing": 2,
"letterSpacing": 0,
"align": "left",
"extrudeOffset": 0,
"centerOnOrigin": true
},
"inputs": {},
"position": [
40,
40
]
},
"solids": {
"id": "solids",
"name": "bitbybit.jscad.text.cylindricalText",
"customName": "cylindrical text",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"text": "Solids",
"extrusionHeight": 0.3,
"extrusionSize": 0.08,
"segments": 24,
"xOffset": 0,
"yOffset": 1.5,
"height": 1,
"lineSpacing": 1.4,
"letterSpacing": 1,
"align": "center",
"extrudeOffset": 0
},
"inputs": {},
"position": [
460,
40
]
}
},
"modules": {}
}

Where the text lands​

  • OCCT stroke wires and text3d lie on the ground, the XZ plane, reading along X, since Y points up in the editors. centerOnOrigin moves the middle of the text block to the origin.
  • JSCAD text stands up, in the XY plane, with the cylinders running along Z: JSCAD builds along Z (see Choosing a kernel). To lay it flat, turn it with jscad.transformSolids and a rotation of -90 degrees about X from babylon.transforms.rotationCenterAxis.
  • Stroke points are plain numbers on the ground plane, ready to turn into polylines, wires or anything else.

Every way takes height, the height of a capital letter in model units, and line and letter spacing; a line break in the text starts a new line.

From strokes to something you can make​

Stroke wires have no thickness. Sweep a circle along them with occt.operations.pipeWiresCylindrical for raised or engraved strokes of a given width (see Pipes and sweeps), cut those from a plate with a boolean for an engraving, or export the wires as they are to DXF for a plotter or a laser. textWiresWithData returns the wires packed per line with the size of the text block, for placing it.

jscad.text.cylindricalText and sphericalText already give solids, rounded like a pen of the given extrusionSize, which suits 3D printing; createVectorText gives the 2D paths to build your own.

Real fonts​

advanced.text3d.create builds letters from the outlines of a font: flat letter faces, or solids extruded by height. fontType picks one of the ten shipped families and fontVariant its weight or style. createTextOnFace lays the letters onto a curved face, and createWithUrl takes a font file from a URL instead. Advanced algorithms has an example in all three editors.

The shipped fonts load with the OCCT worker. The editors on bitbybit.dev load all ten when they start; with the runners and the npm packages, the loadFonts init option lists the families to load, an empty list loads none, and leaving it out loads them all. A font that was not loaded cannot be used by text3d; a font from a URL is loaded when it is used.