modeling/text

Texts provide sets of segments for each character or text strings. The segments can be used to create outlines for both 2D and 3D geometry. Note: Only ASCII characters are supported.

Source:
Example
const { vectorChar, vectorText } = require('@jscad/modeling').text

Methods

(static) vectorChar(optionsopt, charopt) → {VectorCharObject}

Source:

Construct a VectorCharObject from a ascii character whose code is between 31 and 127, if the character is not supported it is replaced by a question mark.

Example
let vectorCharObject = vectorChar()
or
let vectorCharObject = vectorChar('A')
or
let vectorCharObject = vectorChar({ xOffset: 57 }, 'C')
or
let vectorCharObject = vectorChar({ xOffset: 78, input: '!' })
Parameters:
Name Type Attributes Default Description
options Object | String <optional>

options for construction or ascii character

Properties
Name Type Attributes Default Description
xOffset Float <optional>
0

x offset

yOffset Float <optional>
0

y offset

height Float <optional>
21

font size (uppercase height)

extrudeOffset Float <optional>
0

width of the extrusion that will be applied (manually) after the creation of the character

input String <optional>
'?'

ascii character (ignored/overwrited if provided as seconds parameter)

char String <optional>
'?'

ascii character

Returns:
Type
VectorCharObject

(static) vectorText(optionsopt, textopt) → {Array}

Source:

Construct an array of character segments from a ascii string whose characters code is between 31 and 127, if one character is not supported it is replaced by a question mark.

Example
let textSegments = vectorText()
or
let textSegments = vectorText('OpenJSCAD')
or
let textSegments = vectorText({ yOffset: -50 }, 'OpenJSCAD')
or
let textSegments = vectorText({ yOffset: -80, input: 'OpenJSCAD' })
Parameters:
Name Type Attributes Default Description
options Object | String <optional>

options for construction or ascii string

Properties
Name Type Attributes Default Description
xOffset Float <optional>
0

x offset

yOffset Float <optional>
0

y offset

height Float <optional>
21

font size (uppercase height)

lineSpacing Float <optional>
1.4

line spacing expressed as a percentage of font size

letterSpacing Float <optional>
1

extra letter spacing expressed as a percentage of font size

align String <optional>
'left'

multi-line text alignement: left, center or right

extrudeOffset Float <optional>
0

width of the extrusion that will be applied (manually) after the creation of the character

input String <optional>
'?'

ascii string (ignored/overwrited if provided as seconds parameter)

text String <optional>
'?'

ascii string

Returns:

characters segments [[[x, y], ...], ...]

Type
Array