{"id":20828042,"url":"https://github.com/googlefonts/fontations","last_synced_at":"2025-05-14T02:03:56.351Z","repository":{"id":38343071,"uuid":"455581993","full_name":"googlefonts/fontations","owner":"googlefonts","description":"Reading and writing font files","archived":false,"fork":false,"pushed_at":"2025-05-07T23:57:42.000Z","size":12196,"stargazers_count":624,"open_issues_count":180,"forks_count":38,"subscribers_count":29,"default_branch":"main","last_synced_at":"2025-05-08T00:19:31.779Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/googlefonts.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-02-04T14:42:21.000Z","updated_at":"2025-05-07T23:04:20.000Z","dependencies_parsed_at":"2024-02-26T06:32:25.806Z","dependency_job_id":"22bfca86-80c2-4c1b-95a1-215e41bf6e99","html_url":"https://github.com/googlefonts/fontations","commit_stats":{"total_commits":774,"total_committers":5,"mean_commits":154.8,"dds":0.25968992248062017,"last_synced_commit":"b1b7f7e8471aa1dc7f616689d1f0b1f7b9fb14a0"},"previous_names":[],"tags_count":251,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/googlefonts%2Ffontations","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/googlefonts%2Ffontations/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/googlefonts%2Ffontations/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/googlefonts%2Ffontations/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/googlefonts","download_url":"https://codeload.github.com/googlefonts/fontations/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254052667,"owners_count":22006716,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-17T23:13:41.080Z","updated_at":"2025-05-14T02:03:56.340Z","avatar_url":"https://github.com/googlefonts.png","language":"Rust","funding_links":[],"categories":["Font/Text Library"],"sub_categories":["Rust 2D renderer"],"readme":"[![CI Status](https://github.com/googlefonts/fontations/actions/workflows/rust.yml/badge.svg)](https://github.com/googlefonts/fontations/actions/workflows/rust.yml)\n[![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/fontations.svg)](https://oss-fuzz-build-logs.storage.googleapis.com/index.html#fontations)\n\n\n\n# Fontations\n\nThis repo contains a number of foundational crates for reading and\nmanipulating OpenType font files. It is motivated by a desire to have more\nrobust and performant open tools for a variety of font engineering and\nproduction tasks. For an overview of the motivations, see\n[googlefonts/oxidize][oxidize].\n\n## Structure\n\nCurrently, this repo contains four main library crates: [`font-types`][], [`read-fonts`][],\n[`write-fonts`][], and [`skrifa`][]:\n\n- [`font-types`][] contains common definitions of the core types used in the\n  OpenType spec. This is a small crate, and is intended as a basic dependency\n  for any project reading or manipulating font data.\n- [`read-fonts`][] contains code for parsing and accessing font files. It is\n  intended to be a high performance parser, suitable for shaping. In particular\n  this means that it performs no allocation and no copying.\n- [`write-fonts`][] contains code for modifying and writing font data. It contains\n  owned types representing the various tables and records in the specification,\n  as well as code for compiling these and writing out font files. It has an\n  optional dependency on `read-fonts`, in which case it can also parse font\n  data, which can then be modified and written back out to disk.\n- [`skrifa`][] is a mid level library that provides access to various types of\n  metadata contained in a font as well as support for loading glyph outlines.\n    - It's primary purpose is to replace FreeType in Google applications.\n    - See https://developer.chrome.com/blog/memory-safety-fonts\n    - It is also used for tasks such as produce assets for https://fonts.google.com/icons\n\n## depgraph\n\nShows the non-dev dependency relationships among the font-related crates in fontations. fontc primarily uses the fontations crates via write-fonts and skrifa.\n\n```mermaid\n%% This is a map of non-dev font-related dependencies.\n%% See https://mermaid.live/edit for a lightweight editing environment for\n%% mermaid diagrams.\n\ngraph LR\n    %% First we define the nodes and give them short descriptions.\n    %% We group them into subgraphs by repo so that the visual layout\n    %% maps to the source layout, as this is intended for contributors.\n    %% https://github.com/googlefonts/fontations\n    subgraph fontations[fontations repo]\n        fauntlet[fauntlet\\ncompares Skrifa \u0026 freetype]\n        font-types[font-types\\ndefinitions of types\\nfrom OpenType and a bit more]\n        read-fonts[read-fonts\\nparses and reads OpenType fonts]\n        skrifa[skrifa\\nhigher level lib\\nfor reading OpenType fonts]\n        write-fonts[write-fonts\\ncreates and edits font-files]\n    end\n\n    %% https://github.com/linebender/kurbo\n    kurbo[kurbo\\n2d curves lib]\n    %% https://github.com/linebender/norad\n    norad[norad\\nhandles Unified Font Object files]\n    %% https://github.com/PistonDevelopers/freetype-rs\n    freetype-rs[freetype-rs\\nbindings for the FreeType library]\n\n    %% Now define the edges.\n    %% Made by hand on March 20, 2024, probably not completely correct.\n    %% Should be easy to automate if we want to, main thing is to\n    %% define the crates of interest.\n    fauntlet --\u003e skrifa\n    fauntlet --\u003e freetype-rs\n    read-fonts --\u003e font-types\n    skrifa --\u003e read-fonts\n    write-fonts --\u003e font-types\n    write-fonts --\u003e read-fonts\n    write-fonts --\u003e kurbo\n    norad --\u003e kurbo\n```\n\n## codegen\n\nMuch of the code in the `read-fonts` and `write-fonts` crate is generated\nautomatically. Code generation is performed by the `font-codegen` crate. For an\noverview of what we generate and how it works, see the [codegen-tour][]. For an\noverview of how to use the `font-codegen` crate, see the readme at\n[`font-codegen/README.md`][codegen-readme].\n\n## Fuzzing\n\n* Coverage can be viewed at https://oss-fuzz.com/, and search for \"fontations\"\n* The `fuzz/` crate in this repo contains our fuzzers\n* fuzzers are implemented using the [`cargo-fuzz`](https://rust-fuzz.github.io/book/cargo-fuzz.html) crate\n* [oss-fuzz](https://github.com/google/oss-fuzz) configuration lives in https://github.com/google/oss-fuzz/tree/master/projects/fontations\n   * [build.sh](https://github.com/google/oss-fuzz/blob/master/projects/fontations/build.sh) looks for `target/x86_64-unknown-linux-gnu/release/fuzz_*`\n   * ^ is meant to mean we can add additional fuzzers to fontations without having to touch oss-fuzz every time\n   * `build.sh` also controls the test corpus, look for the `git clone` lines\n \nTo reproduce a fuzzer issue:\n\n1. Download the file from the testcase, e.g. https://oss-fuzz.com/testcase-detail/6213391169945600\n1. Build the fuzzers\n   * `cargo +nightly  fuzz build -O --debug-assertions`\n1. Pass the repro file to the fuzzer\n   * `target/x86_64-unknown-linux-gnu/release/fuzz_skrifa_outline ~/Downloads/clusterfuzz-testcase-minimized-fuzz_skrifa_outline-6213391169945600`\n\n## Performance\n\n### Harfbuzz\n\nhttps://github.com/harfbuzz/harfbuzz/blob/main/perf/README.md has instructions on\nrunning harfbuzz benchmarks, including against Fontations.\n\n## Contributing\n\nWe have included a few git hooks that you may choose to use to ensure that\npatches will pass CI; these are in `resources/githooks`.\n\nIf you would like to have these run automatically when you commit or push\nchanges, you can set this as your git hooksPath:\n\n```sh\ngit config core.hooksPath \"./resources/githooks\"\n```\n\n**note**: If you wish to use the hooks on macOS, install the gnu coreutils\n(`brew install coreutils`, via homebrew.)\n\n## Releasing\n\nWe use [`cargo-release`] to help guide the release process. It can be installed\nwith `cargo install cargo-release`. You may need to install `pkg-config` via your\npackage manager for this to work.\n\nReleasing involves the following steps:\n\n1. Determine which crates may need to be published: run `cargo release changes`\n   to see which crates have been modified since their last release.\n1. Determine the new versions for the crates.\n   * Before 1.0, breaking changes bump the *minor* version number, and non-breaking changes modify the *patch* number.\n1. Update manifest versions and release. `./resources/scripts/bump-version.sh` orchestrates this process.\n   * `cargo release` does all the heavy lifting\n\n   ```shell\n   # To see usage\n   ./resources/scripts/bump-version.sh\n   # To do the thing\n   ./resources/scripts/bump-version.sh read-fonts write-fonts patch\n   ```\n\n1. Commit these changes to a new branch, get it approved and merged, and switch\n   to the up-to-date `main`.\n1. Publish the crates. `./resources/scripts/release.sh` orchestrates the process.\n   * You will be prompted to review changes along the way\n\n   ```shell\n   # To see usage\n   ./resources/scripts/release.sh\n   # To do the thing\n   ./resources/scripts/release.sh read-fonts write-fonts\n   ```\n\n## What version is running where?\n\n### Chrome\n\nGiven a Chrome version:\n\n* Find the tag at https://chromium.googlesource.com/chromium/src/\n* Look at the version in `third_party/rust/chromium_crates_io/Cargo.lock`\n\nOR look through commit history for the latest Fontations roll.\n\n## Skia and Chromium builds\n\nAn experimental `SkTypeface` implementation based on Fontations exists. This\nbuild is available in the Skia and Chromium repositories. The goal is to\neventually use Fontations + Skia in Chromium as a memory-safe font\nbackend. Tracking bugs: [Skia](https://crbug.com/skia/14259),\n[Chromium](https://crbug.com/1446251). To build the backends in Skia or Chromium\nfollow the instructions below. This process is currently only tested on Linux.\n\n### Skia build\n\n1. Download Skia https://skia.org/docs/user/download/, including bazelisk\n1. `$ bazelisk build --sandbox_base=/dev/shm --with_fontations //tools/viewer\n   //tests:FontationsTest` (to build debug, add `-c dbg` after `build`)\n   * You should now have executables at `bazel-bin/tests/FontationsTest` and `bazel-bin/tools/viewer/viewer`\n\n#### Skia Fontations unit tests\n\nBuild as above, then run the executable to run tests:\n\n`$ bazel-bin/tests/FontationsTest`\n\nOR compile and test in one command:\n\n`$ bazelisk  test --sandbox_base=/dev/shm --with_fontations //tests:FontationsTest`\n\n#### Skia Fontations GM\n\nBuild as above then:\n\n`$ bazel-bin/tools/viewer/viewer --slide GM_typeface_fontations_roboto`\n\nOR build and run in one command:\n\n`$ bazelisk run --sandbox_base=/dev/shm --with_fontations //tools/viewer -- --slide GM_typeface_fontations_roboto`\n\n### chromium build\n\n1. Follow the instructions for [getting and building\n   Chromium](https://chromium.googlesource.com/chromium/src/+/main/docs/linux/build_instructions.md)\n1. Add `use_typeface_fontations = true` to your `args.gn` using `$ gn args\n   out/\u003cbuilddir\u003e`\n1. Build Chromium using `autoninja -C out/\u003cbuilddir\u003e chrome`\n1. Run Chromium using `$ out/\u003cbuilddir\u003e/chrome`\n1. Go to chrome://flags/#enable-fontations-backend and activate the flag, restart Chrome.\n1. Navigate to any URL, observe web fonts being displayed with Fontations + Skia path rendering.\n\n[codegen-readme]: ./font-codegen/README.md\n[`read-fonts`]: ./read-fonts\n[`font-types`]: ./font-types\n[`write-fonts`]: ./write-fonts\n[`skrifa`]: ./skrifa\n[oxidize]: https://github.com/googlefonts/oxidize\n[codegen-tour]: ./docs/codegen-tour.md\n[`cargo-release`]: https://github.com/crate-ci/cargo-release\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgooglefonts%2Ffontations","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgooglefonts%2Ffontations","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgooglefonts%2Ffontations/lists"}