#font #source #repository #google #find #metadata #finding

bin+lib google-fonts-sources

finding source repositories of Google Fonts fonts

3 releases (breaking)

0.3.0 Aug 22, 2024
0.2.0 Aug 14, 2024
0.1.0 Jul 3, 2024

#160 in Configuration

Download history 89/week @ 2024-06-27 64/week @ 2024-07-04 108/week @ 2024-07-11 173/week @ 2024-07-18 73/week @ 2024-07-25 93/week @ 2024-08-01 122/week @ 2024-08-08 139/week @ 2024-08-15 287/week @ 2024-08-22 113/week @ 2024-08-29

684 downloads per month

MIT/Apache

34KB
698 lines

google-fonts-sources

Rust utility to help find the sources of Google Fonts fonts.

This is currently bare-bones; it inspects (or checks out) the repository at github.com/google/fonts, and for each font parses its metadata file, looking for a repository.

For each repository we find, we then look for a config.yaml file in that repository's /source directory, which is present by convention on sources intended to be built by Google Fonts.

use

To use this tool from the command line, in order to generate a JSON dictionary containing information about source repositories:

cargo run -- -o repo_list.json

To use this tool from another Rust crate, see the docs.


lib.rs:

Finding sources for Google Fonts fonts

basic usage:

// get a list of repositories:

let font_repo_cache = Path::new("~/where_i_want_to_checkout_fonts");
let font_repos = google_fonts_sources::discover_sources(None, Some(font_repo_cache), false)

// for each repo we find, do something with each source:

for repo in &font_repos {
    let sources = match repo.get_sources(font_repo_cache) {
        Ok(sources) => sources,
        Err(e) => {
            eprintln!("skipping repo '{}': '{e}'", repo.repo_name);
            continue;
        }
    };

    println!("repo '{}' contains sources {sources:?}", repo.repo_name);
}

Dependencies

~8–18MB
~288K SLoC