As of OpenSCAD 2019 text has gotten a lot easier to add in OpenSCAD. Basic text can be added with just the bare Command:
text( "Basic Text" );
This command can be translated and rotated just liky any other object in OpenSCAD, but keep in mind it is 2d first and needs to be extruded.
linear_extrude() text( "Extruded Text");
So the defaults for size are 10 for text size and 100 for linear_extrude let’s fix that by giving some sizes.
linear_extrude(3) text( "Extruded Text", size= 5);
The text is now 5 Units Tall, and it is extruded 3 units in thickness
Using Different Fonts
We can change the Font Type using the Font keyword.
OpenSCAD can use any of the system fonts found in the installation. To make it easier to use a font stlye you can list fonts from the Help menu.
Click Help-Font List to get this list:
Select the font you would like to use and click “Copy to The Clipboard” This will copy the Font and Style in the correctly formatted string.
text( "Text",size=5,font="Uechi:style=Gothic" , $fn=50);
We can place text into various orientation, by using the direction keyword. There are four directions we can organize lettering.
text( "Left to Right" ,size=5, direction="ltr"); translate([5,0,0]) text( "Up" ,size=5, direction="btt"); translate([20,0,0]) text( "Down" ,size=5, direction="ttb"); translate([0,10,0]) text( "Right to left" ,size=5, direction="rtt");
Adding Horizontal Alignment
Horizontal alignment is in regard to to origin and the bounding box of the text. It is best explained visual. Take note of where the origin is for each alignment. The alignment is by length of the rendered text NOT by character count.
text( "Left Aligned" ,halign = "left" );
text( "Right Aligned" ,halign = "right" );
text( "Center Aligned" ,halign = "center" );
Below you can see the 3 vertical alignments. The alignment refers to were origin will align with the text.
text( "Text", valign="top"); text( "Text", valign="center"); text( "Text", valign="bottom");
There are a few more options for Text in OpenSCAD but the above are the ones you will use the most.