pub fn load_unicode_system_font(
text: Option<&str>,
) -> Result<FontFamily<FontData>, Error>Expand description
Loads a Unicode-capable system font with good international character support.
This function attempts to find and load a font from the system that supports a wide range of Unicode characters, making it suitable for documents with international text (Romanian, Cyrillic, Greek, etc.).
§Priority Order
- Noto Sans - Google’s comprehensive Unicode font
- DejaVu Sans - Popular open-source Unicode font
- Liberation Sans - Red Hat’s Unicode font
- Arial Unicode MS - Microsoft’s Unicode font (if available)
- Fallback to Helvetica (PDF built-in, limited to Windows-1252)
§Arguments
text- Optional text to check coverage for. If provided, will verify the selected font supports all characters.
§Returns
Ok(FontFamily<FontData>)- A font family with good Unicode supportErr(Error)- If no suitable font could be loaded
§Example
use markdown2pdf::fonts::load_unicode_system_font;
// Load best available Unicode font
let font = load_unicode_system_font(None)?;
// Load and verify coverage for Romanian text
let romanian_text = "ăâîșț ĂÂÎȘȚ";
let font = load_unicode_system_font(Some(romanian_text))?;