pub struct Rasterizer { /* private fields */ }Expand description
The shaping and glyph-raster state — a font database, a glyph cache, and the per-heading layout cache — shared across every raster so fonts load once per session and a heading shapes once per edit, not once per frame.
Implementations§
Source§impl Rasterizer
impl Rasterizer
pub fn new() -> Self
Sourcepub fn heading(
&mut self,
spec: &HeadingSpec<'_>,
ink: (u8, u8, u8),
ui: &EditingUi,
) -> RgbaImage
pub fn heading( &mut self, spec: &HeadingSpec<'_>, ink: (u8, u8, u8), ui: &EditingUi, ) -> RgbaImage
Rasterize a heading to an RGBA frame: bold glyphs in ink over a
transparent ground, the selection’s fill and re-inked glyphs under and
among them, and the caret bar on top.
Sourcepub fn heading_hit(&mut self, spec: &HeadingSpec<'_>, x: f32, y: f32) -> usize
pub fn heading_hit(&mut self, spec: &HeadingSpec<'_>, x: f32, y: f32) -> usize
The byte offset (a char boundary in the spec’s text) a pixel position
hits — the reverse of Rasterizer::heading, answered by the same
cached layout, so a click on the raster lands on the glyph it visually
struck rather than on whatever happens to share its character cell.
Sourcepub fn heading_fits(&mut self, spec: &HeadingSpec<'_>) -> bool
pub fn heading_fits(&mut self, spec: &HeadingSpec<'_>) -> bool
Whether the heading lays out on the single line its box has room for. A longer title wraps onto a second layout line that the box height culls — its tail would be neither drawn nor clickable, and a caret in it would have nowhere truthful to stand — so the caller keeps such a heading as ordinary text instead of rasterizing it.