Easy3D 2.5.3
TextMesher Class Reference

Generate a 3D surface mesh from a text string. More...

#include <easy3d/algo/text_mesher.h>

Public Member Functions

 TextMesher (const std::string &font_file, unsigned short quality=4)
 Create an instance of TextMesher. More...
 
void set_font (const std::string &font_file)
 Change the font. More...
 
SurfaceMeshgenerate (const std::string &text, float x, float y, int font_size, float extrude, bool collision_free=false)
 Generate a 3D surface mesh of a text. More...
 
bool generate (SurfaceMesh *mesh, const std::string &text, float x, float y, int font_size, float extrude, bool collision_free=false)
 Generate 3D surface representation of a text and append the surface to an existing mesh. More...
 
bool generate (const std::string &text, float x, float y, int font_size, std::vector< std::vector< Polygon2 > > &contours, bool collision_free)
 Generate contours from a text. More...
 

Detailed Description

Generate a 3D surface mesh from a text string.

Examples
Tutorial_310_TextMesher.

Constructor & Destructor Documentation

◆ TextMesher()

TextMesher ( const std::string &  font_file,
unsigned short  quality = 4 
)
explicit

Create an instance of TextMesher.

Parameters
font_fileThe full path name to a TrueType font file (normally with an "ttf" extension).
qualityThis parameter controls the smoothness of the curved corners. A greater value results in a smoother transitions but more vertices. The suggested value is 4.
Note
The font will be used in all subsequent generation until being modified by calling to set_font().

Member Function Documentation

◆ generate() [1/3]

SurfaceMesh * generate ( const std::string &  text,
float  x,
float  y,
int  font_size,
float  extrude,
bool  collision_free = false 
)

Generate a 3D surface mesh of a text.

Parameters
textThe input text.
xThe x-coordinate of the starting position.
yThe y-coordinate of the starting position.
font_sizeThe size of the font.
extrudeThe height (in the Z direction) of the 3D model.
collision_freeIf true, the final mesh will be free of intersections between characters.
Returns
The generated triangular surface mesh.
Examples
Tutorial_310_TextMesher.

◆ generate() [2/3]

bool generate ( const std::string &  text,
float  x,
float  y,
int  font_size,
std::vector< std::vector< Polygon2 > > &  contours,
bool  collision_free 
)

Generate contours from a text.

Parameters
textThe input text.
xThe x-coordinate of the starting position.
yThe y-coordinate of the starting position.
font_sizeThe size of the font.
contoursThe contours of the text (each character may have multiple contours). The generated contours are simply appended to his variable.
collision_freeIf true, the generated contours will be free of intersections between characters.

◆ generate() [3/3]

bool generate ( SurfaceMesh mesh,
const std::string &  text,
float  x,
float  y,
int  font_size,
float  extrude,
bool  collision_free = false 
)

Generate 3D surface representation of a text and append the surface to an existing mesh.

Parameters
textThe input text.
xThe x-coordinate of the starting position.
yThe y-coordinate of the starting position.
font_sizeThe size of the font.
extrudeThe height (in the Z direction) of the 3D model.
collision_freeIf true, the final mesh will be free of intersections between characters.
Returns
true on success and false on failure.

◆ set_font()

void set_font ( const std::string &  font_file)

Change the font.

Parameters
font_fileThe full path name to a TrueType font file (normally with an "ttf" extension).
Note
The font will be used in all subsequent generation until being modified by calling to set_font().
Examples
Tutorial_310_TextMesher.

The documentation for this class was generated from the following files: