https://github.com/rana/google-fonts
Download and cache TTF fonts from Google with Rust.
https://github.com/rana/google-fonts
font fonts glyph google graphics rust rust-crate rust-lang rust-library text text-rendering true-type ttf typography
Last synced: 10 months ago
JSON representation
Download and cache TTF fonts from Google with Rust.
- Host: GitHub
- URL: https://github.com/rana/google-fonts
- Owner: rana
- License: mit
- Created: 2024-07-12T15:43:30.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-18T16:45:12.000Z (over 1 year ago)
- Last Synced: 2025-06-05T08:27:24.655Z (12 months ago)
- Topics: font, fonts, glyph, google, graphics, rust, rust-crate, rust-lang, rust-library, text, text-rendering, true-type, ttf, typography
- Language: Rust
- Homepage:
- Size: 42 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# google-fonts
Download and cache TTF fonts from Google.
`11,689` fonts and `1,708` font families.
Similar to Android Studio [Downloadable Fonts](https://developer.android.com/develop/ui/views/text-and-emoji/downloadable-fonts), and Google API [Web Fonts](https://developers.google.com/fonts/docs/developer_api).
# Example
Download font data with a few approaches.
```rust
use google_fonts::lemonada_variable;
use google_fonts::Font::NotoSansRegular;
use google_fonts::Font::RobotoRegular;
use ttf_parser::Face;
fn main() {
// Get and cache font data with a named function.
let font_data = lemonada_variable().unwrap();
let face = Face::parse(&font_data, 0).unwrap();
eprintln!("Font data: {:?}", face);
// Get and cache font data with an enum variant function.
let font_data = NotoSansRegular.get_with_cache().unwrap();
let face = Face::parse(&font_data, 0).unwrap();
eprintln!("Font data: {:?}", face);
// Get font data without caching by using an enum variant function.
let font_data = RobotoRegular.get().unwrap();
let face = Face::parse(&font_data, 0).unwrap();
eprintln!("Font data: {:?}", face);
}
```
# Crate features
`full`, `variable`, and `static` crate features are available.
* `variable` enables only fonts with [variable font technology](https://fonts.google.com/knowledge/using_variable_fonts_on_the_web).
* `static` enables only fonts with _static font technology_.
* `full` enables both `variable` and `static` features.
`variable` is the default feature.
Variable font technology is newer, more flexible, and provides style variations in one or two files. Static font technology uses more font files to accomplish the same thing. A majority of the fonts are in the `static` feature.
Prefer the `variable` feature when possible.
Enable `variable` to significantly improve build time, crate size, and rust-analyzer performance.
# Doc comment font images
View font images from docs.
