Skip to main content

Rasterizer

Struct Rasterizer 

Source
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

Source

pub fn new() -> Self

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Default for Rasterizer

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.