pub struct FontConfig {
pub font: String,
pub weight: String,
pub font_type: FontType,
pub source: Option<String>,
}Expand description
Font configuration for the site.
By default, the font is loaded from Google Fonts via a <link> tag.
Set source to a local font file path (relative to site root) to use
a self-hosted font instead — this generates a @font-face declaration
and skips the Google Fonts request entirely.
# Google Fonts (default)
[font]
font = "Noto Sans"
weight = "600"
font_type = "sans"
# Local font (put the file in your assets directory)
[font]
font = "My Custom Font"
weight = "400"
font_type = "sans"
source = "fonts/MyFont.woff2"Fields§
§font: StringFont family name (Google Fonts family or custom name for local fonts).
weight: StringFont weight to load (e.g. "600").
font_type: FontTypeFont category: "sans" or "serif" — determines fallback fonts.
source: Option<String>Path to a local font file, relative to the site root (e.g. "fonts/MyFont.woff2").
When set, generates @font-face CSS instead of loading from Google Fonts.
The file should be placed in the assets directory so it gets copied to the output.
Implementations§
Source§impl FontConfig
impl FontConfig
pub fn merge(self, other: PartialFontConfig) -> Self
Sourcepub fn is_local(&self) -> bool
pub fn is_local(&self) -> bool
Whether this font is loaded from a local file (vs. Google Fonts).
Sourcepub fn stylesheet_url(&self) -> Option<String>
pub fn stylesheet_url(&self) -> Option<String>
Google Fonts stylesheet URL for use in a <link> element.
Returns None for local fonts.
Sourcepub fn font_face_css(&self) -> Option<String>
pub fn font_face_css(&self) -> Option<String>
Generate @font-face CSS for a local font.
Returns None for Google Fonts.
Sourcepub fn font_family_css(&self) -> String
pub fn font_family_css(&self) -> String
CSS font-family value with fallbacks based on font_type.
Trait Implementations§
Source§impl Clone for FontConfig
impl Clone for FontConfig
Source§fn clone(&self) -> FontConfig
fn clone(&self) -> FontConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FontConfig
impl Debug for FontConfig
Source§impl Default for FontConfig
impl Default for FontConfig
Source§impl<'de> Deserialize<'de> for FontConfigwhere
FontConfig: Default,
impl<'de> Deserialize<'de> for FontConfigwhere
FontConfig: Default,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for FontConfig
impl PartialEq for FontConfig
Source§impl Serialize for FontConfig
impl Serialize for FontConfig
impl StructuralPartialEq for FontConfig
Auto Trait Implementations§
impl Freeze for FontConfig
impl RefUnwindSafe for FontConfig
impl Send for FontConfig
impl Sync for FontConfig
impl Unpin for FontConfig
impl UnsafeUnpin for FontConfig
impl UnwindSafe for FontConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more