text crate root#
FONT_REG: u32 = 0
FONT_SEMI: u32 = 1
FONT_BOLD: u32 = 2
FONT_ICON: u32 = 3
struct Textol: Outline-- the outline buffer of runtime / derived fontsgp: Gp-- the glyph transform used by glyph_pathpath: Pathras: Rasterpng_decode: Option<colr::PngDecode>-- PNG decoder and bilinear scaler for CBDT colour bitmaps (set by the app / ui)img_scale: Option<colr::ImgScale>
impl Text
fn new(fonts: [&'static [u8]; 4], names: [[&'static str; 5]; 4]) -> Textfont_init: register FONT_REG, FONT_SEMI, FONT_BOLD, FONT_ICON (the style's embedded fonts, SGF1 or TrueType/OpenType) with their names (family, style, full, typographic family / style). Each face starts with the legacy raster policy.fn set_font(&mut self, font: u32, size_fx: i32)text_font(font, size_fx)fn get_font(&self) -> (u32, i32)text_get_font() -> (font, size_fx)fn ascent(&self) -> i32ceil(ascender px)fn descent(&self) -> i32ceil(descender px), positivefn line_h(&self) -> i32round((asc - desc + gap) px)fn measure(&mut self, s: &str) -> i32text_measure: advance of the run (24.8), up to NUL / newlinefn measure_n(&mut self, s: &[u8], len: usize) -> i32text_measure_n(s, len)fn width(&mut self, s: &str) -> i32text_width: px, rounded upfn width_n(&mut self, s: &[u8], len: usize) -> i32fn draw(&mut self, dc: &mut Dc, sf: &mut Surface, x: i32, y: i32, s: &[u8]) -> i32text_draw(x, y = baseline, s) -> width pxfn draw_n(&mut self, dc: &mut Dc, sf: &mut Surface, x: i32, y: i32, s: &[u8], len: usize) -> i32text_draw_n(x, y, s, len) -> width pxfn caret_x(&mut self, s: &[u8], index: usize) -> i32text_caret_x(s, index) -> x px (rounded) of the caret before byte indexfn hit(&mut self, s: &[u8], len: Option<usize>, x: i32) -> usizetext_hit(s, len, x) -> byte index whose caret position is closest to x (len None: up to NUL)fn decor(&self, dc: &Dc, sf: &mut Surface, x: i32, y: i32, w: i32, flags: u32)text_decor(x, y, w, flags): underline / strikeout rectangles of the current font and size (filled from x, w px long; y = baseline)fn icon_draw(&mut self, dc: &mut Dc, sf: &mut Surface, cp: u32, x: i32, y: i32, size_fx: i32)icon_draw(cp, x, y, size_fx): the icon's em box has its top-left corner at x, y