pub fn load_font_with_fallback_chain(
primary_name: &str,
fallback_names: &[String],
custom_paths: &[PathBuf],
_text: Option<&str>,
) -> Result<FontFamily<FontFallbackChain>, Error>Expand description
Loads fonts and creates a fallback chain for handling mixed-script documents.
This function creates a FontFallbackChain by:
- Loading the primary font
- Loading all specified fallback fonts
- Creating a chain where fonts are tried in order
When rendering text, the chain will automatically select the appropriate font for each character based on glyph coverage.
§Arguments
primary_name- Name of the primary font to loadfallback_names- List of fallback font names to trycustom_paths- Custom paths to search for fontstext- Optional text for validation (currently unused, kept for API compatibility)
§Returns
A FontFamily where each variant (regular, bold, etc.) is a FontFallbackChain
§Example
use markdown2pdf::fonts::load_font_with_fallback_chain;
use std::path::PathBuf;
let chain = load_font_with_fallback_chain(
"Noto Sans",
&["DejaVu Sans".to_string(), "Arial".to_string()],
&[PathBuf::from("./fonts")],
Some("Hello мир! 👋")
)?;