JFLib

text crate root#

FONT_REG: u32 = 0
FONT_SEMI: u32 = 1
FONT_BOLD: u32 = 2
FONT_ICON: u32 = 3
  • struct Text
    • ol: Outline -- the outline buffer of runtime / derived fonts
    • gp: Gp -- the glyph transform used by glyph_path
    • path: Path
    • ras: Raster
    • png_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]) -> Text font_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) -> i32 ceil(ascender px)
  • fn descent(&self) -> i32 ceil(descender px), positive
  • fn line_h(&self) -> i32 round((asc - desc + gap) px)
  • fn measure(&mut self, s: &str) -> i32 text_measure: advance of the run (24.8), up to NUL / newline
  • fn measure_n(&mut self, s: &[u8], len: usize) -> i32 text_measure_n(s, len)
  • fn width(&mut self, s: &str) -> i32 text_width: px, rounded up
  • fn width_n(&mut self, s: &[u8], len: usize) -> i32
  • fn draw(&mut self, dc: &mut Dc, sf: &mut Surface, x: i32, y: i32, s: &[u8]) -> i32 text_draw(x, y = baseline, s) -> width px
  • fn draw_n(&mut self, dc: &mut Dc, sf: &mut Surface, x: i32, y: i32, s: &[u8], len: usize) -> i32 text_draw_n(x, y, s, len) -> width px
  • fn caret_x(&mut self, s: &[u8], index: usize) -> i32 text_caret_x(s, index) -> x px (rounded) of the caret before byte index
  • fn hit(&mut self, s: &[u8], len: Option<usize>, x: i32) -> usize text_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

Source: docs/API.md in the JFLib repository.