Getting the vector points of a letter in a truetype font
Since True Type fonts are just vectors, I was wondering if there was a way to get the vectors (array of points) for a letter given that开发者_JAVA百科 i'm using the WinAPI. Thanks
Use the GetGlyphOutline function with the GGO_NATIVE option.
http://msdn.microsoft.com/en-us/library/dd144891%28v=VS.85%29.aspx
Actually, True Type fonts are defined by Bezier curves, not vectors, so you get back a list of curves. Most graphics libraries have a way of drawing Bezier curves anyway so you can get by just knowing that a curve is defined by several control points.
The font will be pre-fitted to a grid (eg, hinting).
I don't know if the Win32 API will give you a deconstructed glyph. The FOSS FreeType2 library provides glyph points in FT_Outline::points
.
Note that a glyph is more than its points. You have to work with Bézier curves and hinting to reproduce a glyph correctly. The hinting part is crucial for small fonts, and is extremely difficult to get right. FreeType usually does all this for you.
精彩评论