pub struct FontConfig {
pub default_font: Option<String>,
pub code_font: Option<String>,
pub default_font_source: Option<FontSource>,
pub code_font_source: Option<FontSource>,
pub fallback_fonts: Vec<String>,
pub fallback_font_sources: Vec<FontSource>,
pub enable_subsetting: bool,
}Expand description
Configuration for fonts used in the generated PDF.
Both default_font and code_font accept friendly names (“Georgia”,
“Helvetica”, “/path/to/font.ttf”) and are resolved at render time.
Explicit *_source fields take priority when set.
Fields§
§default_font: Option<String>Default font name for body text.
code_font: Option<String>Font name for code blocks.
default_font_source: Option<FontSource>Font source for body text. Takes priority over default_font if set.
code_font_source: Option<FontSource>Font source for code blocks. Takes priority over code_font if set.
fallback_fonts: Vec<String>Ordered list of fallback font names (system / path / built-in
alias). Resolved the same way as default_font at render time.
Composed with fallback_font_sources (sources first, then names)
and with any fallback_fonts set on [defaults] in the TOML
config.
fallback_font_sources: Vec<FontSource>Ordered list of pre-resolved fallback font sources. Useful when
embedding fonts via include_bytes! or pointing at a known
path. Composed before fallback_fonts.
enable_subsetting: boolEnable font subsetting for smaller PDFs.
Implementations§
Source§impl FontConfig
impl FontConfig
Sourcepub fn with_default_font(self, font: impl Into<String>) -> Self
pub fn with_default_font(self, font: impl Into<String>) -> Self
Set the default body font.
Sourcepub fn with_code_font(self, font: impl Into<String>) -> Self
pub fn with_code_font(self, font: impl Into<String>) -> Self
Set the code font.
Sourcepub fn with_default_font_source(self, source: FontSource) -> Self
pub fn with_default_font_source(self, source: FontSource) -> Self
Set the font source for body text directly.
Sourcepub fn with_code_font_source(self, source: FontSource) -> Self
pub fn with_code_font_source(self, source: FontSource) -> Self
Set the font source for code blocks directly.
Sourcepub fn with_subsetting(self, enabled: bool) -> Self
pub fn with_subsetting(self, enabled: bool) -> Self
Enable or disable font subsetting.
Sourcepub fn with_fallback_fonts<I, S>(self, names: I) -> Self
pub fn with_fallback_fonts<I, S>(self, names: I) -> Self
Replace the fallback-font name list. See FontConfig::fallback_fonts.
Sourcepub fn add_fallback_font(self, name: impl Into<String>) -> Self
pub fn add_fallback_font(self, name: impl Into<String>) -> Self
Append one fallback name to the existing list.
Sourcepub fn add_fallback_font_source(self, source: FontSource) -> Self
pub fn add_fallback_font_source(self, source: FontSource) -> Self
Append one pre-resolved fallback font source.