Function Reference: geom.text

drafting: R = geom.text (STR)

drafting: R = geom.text (STR, Name, Value, …)

The outlines of text, as regions.

R = geom.text (STR) returns the shapes of the letters of the character vector STR, in UTF-8, as a 1-by-N cell array of geom.Region objects, one for each separate piece of ink, largest first, or the empty cell (1, 0) when there is none. A letter with a counter, such as o or A, is a region with a hole; one in pieces, such as i, is several regions. The outlines are the font’s own curves, straight lines and splines, so the text is as smooth at any size. A newline in STR starts a new line. This is OpenSCAD’s text, ready to be extruded, engraved or embossed.

By default the text stands on the x axis of the world xy plane, starting at the origin, its capitals 10 millimetres high.

Name/Value pairs:

'Height'
The height of a capital letter in millimetres, as text is sized on a technical drawing, 10 by default. Lower case, ascenders and descenders follow the font.
'Font'
The name of an installed font family, such as 'DejaVu Sans'; 'sans-serif', 'serif' and 'monospace' name the system’s own. The default is 'sans-serif'. A font that is not installed is an error.
'Style'
'regular', the default, 'bold', 'italic' or 'bold italic'.
'HAlign'
Which part of the text lies on the origin across: 'left', the default, 'center' or 'right', by the box round the ink.
'VAlign'
Which part lies on the origin upwards: 'baseline', the default, the line the letters stand on, or 'bottom', 'center' or 'top' of the box round the ink.
'Box'
The largest size [W, H] in millimetres the ink may take, descenders included. The text is scaled evenly until it touches a side; a size of 0 leaves that direction free, so [40, 0] makes the text 40 wide. With 'Height' given as well, 'Box' only shrinks the text, and only when it would not fit at that height. It sets the size alone: 'HAlign', 'VAlign' and 'UCS' still place the text.
'UCS'
The geom.UCS the text is laid in, the world xy plane by default.
 
 ## A plate with its name raised 1 on its top face
 P = solid.box (60, 20, 4);
 R = geom.text ('DRAFTING', 'Height', 8, 'HAlign', 'center', ...
                'VAlign', 'center', 'UCS', geom.UCS ([0, 0, 1], [30, 10, 4]));
 for k = 1:numel (R)
   P = union (P, solid.extrude (R{k}, 1));
 endfor

Open CASCADE builds the outlines from the font.

See also: geom.Region, solid.extrude, geom.Region.offset

Source Code: geom.text