public abstract class FontFile extends A3DObject
var font = FontFile.fromFile("CascadiaCode-Regular.otf");
var text = new Text();
text.setFont(font);
text.setContent("ABC");
text.setFontSize(10);
var linear = new LinearExtrusion(text, 10).toMesh();
var scene = new Scene(linear);
scene.save("test.stl");
name, properties| Constructor and Description |
|---|
FontFile() |
| Modifier and Type | Method and Description |
|---|---|
static FontFile |
fromFile(java.lang.String fileName)
Load FontFile from file name
|
static FontFile |
parse(byte[] bytes)
Parse FontFile from bytes
|
findProperty, getName, getProperties, getProperty, removeProperty, removeProperty, setName, setPropertypublic static FontFile fromFile(java.lang.String fileName) throws java.io.IOException
fileName - Path to the font filejava.io.IOException - Thrown when failed to read from file.
Example:
The following code shows how to create a 3D mesh from text using specified font file.
var font = FontFile.fromFile("CascadiaCode-Regular.otf");
var text = new Text();
text.setFont(font);
text.setContent("ABC");
text.setFontSize(10);
var linear = new LinearExtrusion(text, 10).toMesh();
var scene = new Scene(linear);
scene.save("test.stl");
public static FontFile parse(byte[] bytes)
bytes - OTF font file raw content