Easy3D 2.6.1
Loading...
Searching...
No Matches
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.
 
 ~TextMesher ()
 Destructor.
 
void set_font (const std::string &font_file)
 Change the font.
 
SurfaceMeshgenerate (const std::string &text, float x, float y, int font_size, float height, bool collision_free=false)
 Generate a 3D surface mesh of a text.
 
bool generate (SurfaceMesh *mesh, const std::string &text, float x, float y, int font_size, float height, bool collision_free=false)
 Generate 3D surface representation of a text and append the surface to an existing mesh.
 
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.
 

Detailed Description

Generate a 3D surface mesh from a text string.

Examples
Tutorial_310_TextMesher/main.cpp.

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 a "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 height,
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.
heightThe 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.

◆ 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 this variable.
collision_freeIf true, the generated contours will be free of intersections between characters.
Returns
true on success and false on failure.

◆ generate() [3/3]

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

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

Parameters
meshThe existing mesh to which the generated mesh will be appended.
textThe input text.
xThe x-coordinate of the starting position.
yThe y-coordinate of the starting position.
font_sizeThe size of the font.
heightThe 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 a "ttf" extension).
Note
The font will be used in all subsequent generation until being modified by calling to set_font().

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