Following code presents example of converting text to mesh
- C++
#include <MRMesh/MRMesh.h>
#include <MRMesh/MRMeshSave.h>
#include <iostream>
int main(
int argc,
char* argv[] )
{
if ( argc < 3 )
{
std::cerr << "Usage: MeshFromText fontpath text" << std::endl;
return EXIT_FAILURE;
}
const auto* fontPath = argv[1];
const auto* text = argv[2];
.text = text,
.pathToFontFile = fontPath,
};
if ( !convRes )
{
std::cerr << "Failed to convert text to mesh: " << convRes.error() << std::endl;
return EXIT_FAILURE;
}
if ( !saveRes )
{
std::cerr << "Failed to save result: " << saveRes.error() << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
MRMESH_API Expected< void > toAnySupportedFormat(const Mesh &mesh, const std::filesystem::path &file, const SaveSettings &settings={})
MRSYMBOLMESH_API Expected< Mesh > createSymbolsMesh(const SymbolMeshParams ¶ms)
- See also
- MR::createSymbolsMesh
- Python
import sys
import meshlib.mrmeshpy as mrmeshpy
if len(sys.argv) < 3:
print("Usage: ./MeshFromText fontpath text", file=sys.stderr)
sys.exit(1)
font_path = sys.argv[1]
text = sys.argv[2]
params.text = text
params.pathToFontFile = font_path
try:
except ValueError as e:
print(f"Failed to convert text to mesh: {e}", file=sys.stderr)
sys.exit(1)
None saveMesh(Mesh mesh, os.PathLike|str|bytes file, SaveSettings settings='{}')
Mesh createSymbolsMesh(SymbolMeshParams params)