Convert TTF font glyphs to polygons

44 views Asked by At

Goal: need to scale and convert TTF glyphs into polygons. TTF font is user-defined, can be Japanese or Chinese, might have CW and CCW glyph outlines, possibly with self-intersections.. Result polygons (outline and hole contours, no arcs) will be processed as regular geometry shapes. Possible options

  1. Use FreeType library to extract geometry as Bezier curves, scale and approximate curves with polygons. Merge result polygons to resolve self-intersections with Clipper
  2. Similar approach with a single library https://github.com/fetisov/ttf2mesh But it doesn't include merge and doesn't work good for complex fonts.
  3. Use bitmap representation from FreeType as for rendering. Scale as bitmap them convert to polygon contours and triangles. Should work but it sounds like roundtrip )

Overall task seems to be pretty common but I cannot find any standard solution for this. Like using distance filed to display TTF glyphs in OpenGL

0

There are 0 answers