#字体 #真型 #otf #文本渲染 #文本

无需std ab_glyph_rasterizer

线、二次贝塞尔和三次贝塞尔的覆盖光栅化

9个版本

0.1.8 2023年1月13日
0.1.7 2022年9月17日
0.1.5 2021年10月28日
0.1.4 2020年10月9日
0.1.1 2020年4月13日

#6 in 数据格式

Download history 80382/week @ 2024-04-19 82452/week @ 2024-04-26 73882/week @ 2024-05-03 81436/week @ 2024-05-10 75050/week @ 2024-05-17 77845/week @ 2024-05-24 83859/week @ 2024-05-31 94043/week @ 2024-06-07 94212/week @ 2024-06-14 92100/week @ 2024-06-21 84101/week @ 2024-06-28 86294/week @ 2024-07-05 83969/week @ 2024-07-12 89394/week @ 2024-07-19 88661/week @ 2024-07-26 83405/week @ 2024-08-02

359,884 每月下载量
1,384 个crate中使用 (4个直接使用)

Apache-2.0

22KB
310

ab_glyph_rasterizer crates.io 文档

线、二次贝塞尔和三次贝塞尔的覆盖光栅化。用于绘制.otf字体符号很有用。

灵感来自 font-rsstb_truetype

示例

let mut rasterizer = ab_glyph_rasterizer::Rasterizer::new(106, 183);

// draw a 300px 'ę' character
rasterizer.draw_cubic(point(103.0, 163.5), point(86.25, 169.25), point(77.0, 165.0), point(82.25, 151.5));
rasterizer.draw_cubic(point(82.25, 151.5), point(86.75, 139.75), point(94.0, 130.75), point(102.0, 122.0));
rasterizer.draw_line(point(102.0, 122.0), point(100.25, 111.25));
rasterizer.draw_cubic(point(100.25, 111.25), point(89.0, 112.75), point(72.75, 114.25), point(58.5, 114.25));
rasterizer.draw_cubic(point(58.5, 114.25), point(30.75, 114.25), point(18.5, 105.25), point(16.75, 72.25));
rasterizer.draw_line(point(16.75, 72.25), point(77.0, 72.25));
rasterizer.draw_cubic(point(77.0, 72.25), point(97.0, 72.25), point(105.25, 60.25), point(104.75, 38.5));
rasterizer.draw_cubic(point(104.75, 38.5), point(104.5, 13.5), point(89.0, 0.75), point(54.25, 0.75));
rasterizer.draw_cubic(point(54.25, 0.75), point(16.0, 0.75), point(0.0, 16.75), point(0.0, 64.0));
rasterizer.draw_cubic(point(0.0, 64.0), point(0.0, 110.5), point(16.0, 128.0), point(56.5, 128.0));
rasterizer.draw_cubic(point(56.5, 128.0), point(66.0, 128.0), point(79.5, 127.0), point(90.0, 125.0));
rasterizer.draw_cubic(point(90.0, 125.0), point(78.75, 135.25), point(73.25, 144.5), point(70.75, 152.0));
rasterizer.draw_cubic(point(70.75, 152.0), point(64.5, 169.0), point(75.5, 183.0), point(105.0, 170.5));
rasterizer.draw_line(point(105.0, 170.5), point(103.0, 163.5));
rasterizer.draw_cubic(point(55.0, 14.5), point(78.5, 14.5), point(88.5, 21.75), point(88.75, 38.75));
rasterizer.draw_cubic(point(88.75, 38.75), point(89.0, 50.75), point(85.75, 59.75), point(73.5, 59.75));
rasterizer.draw_line(point(73.5, 59.75), point(16.5, 59.75));
rasterizer.draw_cubic(point(16.5, 59.75), point(17.25, 25.5), point(27.0, 14.5), point(55.0, 14.5));
rasterizer.draw_line(point(55.0, 14.5), point(55.0, 14.5));

// iterate over the resultant pixel alphas, e.g. save pixel to a buffer
rasterizer.for_each_pixel(|index, alpha| {
    // ...
});

将结果像素alpha值作为8位灰度值渲染

reference_otf_tailed_e

no_std

使用 alloclibm 支持no_std环境。

ab_glyph_rasterizer = { default-features = false, features = ["libm"] }

依赖项

~105KB