开发者

Getting the vector points of a letter in a truetype font

开发者 https://www.devze.com 2022-12-28 16:27 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号