dioxus-google-fonts
π Declarative Google Fonts embedding for Dioxus β done right.
This crate provides two declarative macros for working with Google Fonts in a Dioxus app:
google_fonts_url!β generates the Google Fonts<link>URLgoogle_fonts!β renders an actualdocument::Linknode for easy use inrsx!
π€ Features
β
Links are generated at compile time
β
Declarative macro syntax
β
Supports multiple fonts, weights and italics
β
Auto-generates ital,wght@... combinations
β
Automatically adds display=swap
β
Works out of the box with Dioxus Web + SSR
π¦ Installation
Add to your Cargo.toml:
# In your main Dioxus app
= "0.1"
# This is a procedural macro crate, it will bring in `proc-macro2`, `syn`, etc.
π§ͺ Example
use google_fonts_url;
use *;
use google_fonts;
π§ Supported Syntax
Each font entry uses a tuple-like DSL:
wght: weights, as numbers (400,700) or ranges ("200..800")ital: tuples like(1, 700)β italic, weightital,wght@...style gets auto-generateddisplay=swapis always added to the URL (sensible default)
π§± Example Output
https://fonts.googleapis.com/css2?
family=Roboto:ital,wght@1,700&
family=Manrope:wght@200..800&
display=swap
π Repo & Contributions
π¦ Crate: crates.io/crates/dioxus-google-fonts
π οΈ Repo: github.com/dsplce-co/dioxus-google-fonts
PRs welcome! Letβs make Dioxus + typography best friends. π€
π License
MIT or Apache-2.0, at your option.