获取 truetype 字体中字母的矢量点
由于 True Type 字体只是向量,我想知道是否有一种方法可以获取字母的向量(点数组),因为我正在使用 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 i'm using the WinAPI.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将 GetGlyphOutline 函数与 GGO_NATIVE 选项结合使用。
http://msdn.microsoft.com/ en-us/library/dd144891%28v=VS.85%29.aspx
实际上,True Type 字体是由 Bezier 曲线而不是矢量定义的,因此您会得到一个曲线列表。大多数图形库都有一种绘制贝塞尔曲线的方法,因此您只需知道曲线是由多个控制点定义的即可。
字体将预先适合网格(例如,提示)。
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).
我不知道Win32 API是否会给你一个解构的字形。 FOSS FreeType2 库在
FT_Outline::points
中提供字形点。请注意,字形不仅仅是它的点。您必须使用贝塞尔曲线和提示才能正确再现字形。提示部分对于小字体至关重要,而且很难正确完成。 FreeType 通常会为您完成所有这些工作。
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.