load_font_with_config

Function load_font_with_config 

Source
pub fn load_font_with_config(
    name: &str,
    config: Option<&FontConfig>,
    text: Option<&str>,
) -> Result<FontFamily<FontData>, Error>
Expand description

Loads a font family using the provided FontConfig, with intelligent fallback. This is the main entry point for loading fonts with custom configuration.

§Arguments

  • name - The font family name to load
  • config - Optional font configuration with custom paths
  • text - Optional text content for font subsetting

§Returns

  • Ok(FontFamily<FontData>) if the font is found
  • Err(Error) if the font cannot be loaded from any source

§Loading strategy

  1. If custom_paths are provided in config, search there first
  2. Check if it’s a built-in font (helvetica, times, courier)
  3. Search system fonts
  4. Apply font subsetting if enabled and text is provided
  5. Return error if nothing found