c++opengldirect3dfreetypeglyph

Converting text to mesh


I need to convert text (string+font) into mesh (vertices, indices, triangles etc), but I don't need to draw anything. I'll just get a string from one API and push it as vertices & indices to another. What's the simplest/easiest/best way of doing this? Font metrics and text placing are of course available and no other transforms are needed.

I'm currently working with VC++. However, any kind of OpenSource (C/C++, C#, VB,...) and "non-open but free" COM/.NET -libraries would be great.

I've heard of FreeType. Does it answer my prayers or is there something even better?

EDIT: As Nico Schertler commented, there seems to be Mesh.TextFromFont -function in DirectX -libs that probably does the trick. Thank you Nico! I'll update when I have time to test this in practise.


Solution

  • Mesh.TextFromFont sounded good but it didn't save the day since I couldn't figure out how to get the actual point/triangle data from the mesh -object.

    But then I found this. In this project, GraphicsPath is used to create a point-path from a glyph. Then the points are coverted into Polygons and the polygons are then tesselated into triangles using Poly2Tri.

    A quick browse through the source code and with some small modifications and code stripping I ended up with a nice .NET -dll with one simple static function that does everything I need.