MeshLib Documentation
Loading...
Searching...
No Matches
Convert text to mesh

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];
    // set text-to-mesh parameters
    // input text
    .text = text,
    // font file name
    .pathToFontFile = fontPath,
    };
    auto convRes = MR::createSymbolsMesh( params );
    if ( !convRes )
    {
    std::cerr << "Failed to convert text to mesh: " << convRes.error() << std::endl;
    return EXIT_FAILURE;
    }
    auto saveRes = MR::MeshSave::toAnySupportedFormat( *convRes, "mesh.ply" );
    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 &params)
    See also
    MR::createSymbolsMesh