TTF字体的渲染曲线
您能否向我指出一种用于渲染和填充 TTF 字体中使用的曲线的有效算法?我将数据作为点的轮廓加载,所以我只是想知道绘制曲线的有效方法。我也非常希望它支持平滑。
到目前为止我所知道的:
- TTF 使用贝塞尔曲线和样条线
- TTF 将其点分类为定义直线的点和定义曲线的点,后者要么在相关曲线上,要么在我们的曲线上(控制点)
- 人们可以制作一个多边形出曲线轮廓,其中弯曲部分由像素大小的线条组成。
- 人们可以使用这个多边形来渲染填充的轮廓,如果也将数据用作浮点数而不是整数,则可以实现字体平滑。
那么你能给我指点某种指南吗?
谢谢。
Could you point me to an effective algorithm for rendering and filling the curves used in TTF fonts? I have the data loaded as contours of points so I;m only wondering about an effective way of drawing the curves. I'd also very much like it to support smoothing.
What I know up to this point:
- TTF uses bezier curves and splines
- TTF categorizes it's points as points defining lines, and points defining curve, the latter being either on the curve in question or our of it (control points)
- One can make a polygon out of a curve contour where the curved parts are made of lines the size of a pixel.
- One could use this polygon to render the filled contour and if one also uses the data as floats rather than ints, one could achieve font smoothing.
So could you point me to a guide of some sort or something?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您已经拥有矢量数据,那么您必须使用某种扫描线填充算法对其进行光栅化。为了平滑,将像素划分为 n × n 块,对字符进行光栅化并计算与填充子像素数量相对应的灰度值。然而,我认为处理贝塞尔曲线和样条曲线并不容易。如果可能的话,我会使用像 freetype 或类似的库。
If you already have the vector data, then you have to rasterize it with some scanline fill algorithm. For smoothing divide the pixels into n by n blocks, rasterize the characters and compute the a gray value corresponding to the number of filled subpixels. Handling bezier curves and splines, however, is not going to be easy, I think. If it is possible, I would use a library like freetype or similar.