Skip to main content

init_font_database

Function init_font_database 

Source
pub fn init_font_database(extra_fonts: Vec<Vec<u8>>) -> bool
Expand description

Initialize the font database with system fonts plus additional font data.

Call this once at startup, before any chart rendering, to register fonts that aren’t installed system-wide (e.g. design-system fonts embedded via include_bytes!). If you call this AFTER the first render has already triggered lazy initialization, the call has no effect and returns false.

Returns true if the database was initialized by this call, false if it was already initialized (either by a previous init_font_database call or by lazy init on first render).

§Example

let dm_sans = include_bytes!("../../fonts/DMSans-Regular.ttf").to_vec();
let geist_mono = include_bytes!("../../fonts/GeistMono-Regular.ttf").to_vec();
chartml_render::init_font_database(vec![dm_sans, geist_mono]);