Font generator
Using the Font Generator
Section titled “Using the Font Generator”The Font Generator converts any TrueType or OpenType font into a JSCAD JavaScript file. Once added to your project you can render text as 2D outlines for laser cutting, or extrude them into 3D lettering for engraving and signage.
Opening the Font Generator
Section titled “Opening the Font Generator”Switch to the Modelling tab in the left sidebar and click the + button next to the file list. Select New font from the dropdown. The Font Generator overlay opens on top of the workspace.
Loading a font
Section titled “Loading a font”You have three options:
By name — type a font family name (e.g. Roboto, Playfair Display) into
the search box and press Enter. JavaSculpt fetches it automatically.
By URL — paste a Google Fonts URL such as
https://fonts.google.com/specimen/Roboto and the font is resolved for you.
Upload — drag a .ttf, .otf, .woff, or .woff2 file onto the drop
zone, or click the upload button to browse.
A live preview updates in the right panel as soon as the font loads.
Choosing a character subset
Section titled “Choosing a character subset”By default only the characters you actually need are included, keeping the generated file small. Use the checkboxes to select character classes:
| Class | Characters included |
|---|---|
| Decimal | 0–9 |
| Uppercase | A–Z |
| Lowercase | a–z |
| Common punctuation | . , ! ? ( ) - _ and others |
| Extended Latin | Accented and diacritic characters |
Enable Include all glyphs to bundle the entire font — useful when the text content is not known ahead of time, but produces a much larger file.
Curve resolution
Section titled “Curve resolution”Click Resolution… to choose how many straight-line segments are used to approximate each Bézier curve. Higher values give smoother letterforms at the cost of larger files and slower geometry operations. The default of 8 steps is a good balance for most uses; drop to 4 for screen preview work or raise to 16 for high-quality print or CNC output.
Adding to your project
Section titled “Adding to your project”Click Add to project. The font data file is written to your workspace:
fonts/<font-name>.js— the font data (glyph outlines and metrics)
The font rendering helper is built in and available as @javasculpt/lib/font-loader.
Using the font in a script
Section titled “Using the font in a script”Require the font file and the built-in helper, then call renderText:
const { renderText } = require('@javasculpt/lib/font-loader')const FONT_ROBOTO = require('./fonts/roboto').FONT_DATA
function main() { return renderText(FONT_ROBOTO, 'Hello world', { size: 20 })}renderText(font, text, options) returns a 2D geometry (geom2) — a flat
outline of the text ready for laser-cutting export or further operations.
| Option | Default | Effect |
|---|---|---|
size |
10 |
Cap height in JSCAD units (mm) |
letterSpacing |
0 |
Extra gap between glyphs in JSCAD units |
Extruding to 3D
Section titled “Extruding to 3D”Wrap the result with extrudeLinear to produce solid 3D lettering:
const { renderText } = require('@javasculpt/lib/font-loader')const { extrudeLinear } = require('@jscad/modeling').extrusionsconst FONT_ROBOTO = require('./fonts/roboto').FONT_DATA
function main() { const outline = renderText(FONT_ROBOTO, 'HELLO', { size: 15 }) return extrudeLinear({ height: 4 }, outline)}Parametric text
Section titled “Parametric text”Combine with getParameterDefinitions to let users change the text or size
interactively:
const { renderText } = require('@javasculpt/lib/font-loader')const { extrudeLinear } = require('@jscad/modeling').extrusionsconst FONT_ROBOTO = require('./fonts/roboto').FONT_DATA
const getParameterDefinitions = () => [ { name: 'text', type: 'text', caption: 'Text', default: 'HELLO' }, { name: 'size', type: 'number', widget: 'slider', caption: 'Size (mm)', default: 15, min: 5, max: 60, step: 1 }, { name: 'depth', type: 'number', widget: 'slider', caption: 'Extrude depth', default: 4, min: 1, max: 20, step: 0.5 },]
function main({ text, size, depth }) { const outline = renderText(FONT_ROBOTO, text, { size }) return extrudeLinear({ height: depth }, outline)}Previewing a font file
Section titled “Previewing a font file”If you select a fonts/*.js file in the file tree, a Preview font… button
appears in the toolbar above the editor. Click it to open a quick preview of the
glyphs included in that file.