Star 历史趋势
数据来源: GitHub API · 生成自 Stargazers.cn
README.md

CI Status Fuzzing Status

Fontations

This repo contains a number of foundational crates for reading and manipulating OpenType font files. It is motivated by a desire to have more robust and performant open tools for a variety of font engineering and production tasks. For an overview of the motivations, see googlefonts/oxidize.

Structure

Currently, this repo contains five main crates: font-types, read-fonts, write-fonts, skrifa, and skera:

  • font-types Crates.io contains common definitions of the core types used in the OpenType spec. This is a small crate, and is intended as a basic dependency for any project reading or manipulating font data.
  • read-fonts Crates.io contains code for parsing and accessing font files. It is intended to be a high performance parser, suitable for shaping. In particular this means that it performs no allocation and no copying.
  • write-fonts Crates.io contains code for modifying and writing font data. It contains owned types representing the various tables and records in the specification, as well as code for compiling these and writing out font files. It has an optional dependency on read-fonts, in which case it can also parse font data, which can then be modified and written back out to disk.
  • skrifa Crates.io is a mid level library that provides access to various types of metadata contained in a font as well as support for loading glyph outlines.
  • skera Crates.io is a library and CLI tool for subsetting font files according to provided input (such as Unicode characters, glyph IDs, and layout features).

Other published crates in this workspace:

depgraph

Shows the non-dev dependency relationships among the font-related crates in fontations. fontc primarily uses the fontations crates via write-fonts and skrifa.

%% This is a map of non-dev font-related dependencies.
%% See https://mermaid.live/edit for a lightweight editing environment for
%% mermaid diagrams.

graph LR
    %% First we define the nodes and give them short descriptions.
    %% We group them into subgraphs by repo so that the visual layout
    %% maps to the source layout, as this is intended for contributors.
    %% https://github.com/googlefonts/fontations
    subgraph fontations[fontations repo]
        fauntlet[fauntlet\ncompares Skrifa & freetype]
        font-types[font-types\ndefinitions of types\nfrom OpenType and a bit more]
        incremental-font-transfer[incremental-font-transfer\nclient side IFT patch application]
        read-fonts[read-fonts\nparses and reads OpenType fonts]
        skera[skera\nsubsetting\ncreate font subsets]
        skrifa[skrifa\nhigher level lib\nfor reading OpenType fonts]
        write-fonts[write-fonts\ncreates and edits font-files]
    end

    %% https://github.com/linebender/kurbo
    kurbo[kurbo\n2d curves lib]
    %% https://github.com/linebender/norad
    norad[norad\nhandles Unified Font Object files]
    %% https://github.com/PistonDevelopers/freetype-rs
    freetype-rs[freetype-rs\nbindings for the FreeType library]

    %% Now define the edges.
    %% Up to date as of June 2026
    %% Can be updated by inspecting all Cargo.toml files.
    fauntlet --> skrifa
    fauntlet --> freetype-rs
    read-fonts --> font-types
    skrifa --> read-fonts
    write-fonts --> font-types
    write-fonts --> read-fonts
    write-fonts --> kurbo
    norad --> kurbo
    skera --> skrifa
    skera --> write-fonts
    incremental-font-transfer --> font-types
    incremental-font-transfer --> read-fonts
    incremental-font-transfer --> skrifa
    incremental-font-transfer --> write-fonts
    incremental-font-transfer --> skera

codegen

Much of the code in the read-fonts and write-fonts crate is generated automatically. Code generation is performed by the font-codegen crate. For an overview of what we generate and how it works, see the codegen-tour. For an overview of how to use the font-codegen crate, see the readme at font-codegen/README.md.

Fuzzing

To reproduce a fuzzer issue:

  1. Download the file from the testcase, e.g. https://oss-fuzz.com/testcase-detail/6213391169945600
  2. Build the fuzzers
    • cargo +nightly fuzz build -O --debug-assertions
  3. Pass the repro file to the fuzzer
    • target/x86_64-unknown-linux-gnu/release/fuzz_skrifa_outline ~/Downloads/clusterfuzz-testcase-minimized-fuzz_skrifa_outline-6213391169945600

Performance

Harfbuzz

https://github.com/harfbuzz/harfbuzz/blob/main/perf/README.md has instructions on running harfbuzz benchmarks, including against Fontations.

Contributing

We have included a few git hooks that you may choose to use to ensure that patches will pass CI; these are in resources/githooks.

If you would like to have these run automatically when you commit or push changes, you can set this as your git hooksPath:

git config core.hooksPath "./resources/githooks"

note: If you wish to use the hooks on macOS, install the gnu coreutils (brew install coreutils, via homebrew.)

Releasing

See docs/RELEASE.md for instructions on releasing crates.

What version is running where?

Chrome

Given a Chrome version:

OR look through commit history for the latest Fontations roll.

Skia and Chromium builds

An experimental SkTypeface implementation based on Fontations exists. This build is available in the Skia and Chromium repositories. The goal is to eventually use Fontations + Skia in Chromium as a memory-safe font backend. Tracking bugs: Skia, Chromium. To build the backends in Skia or Chromium follow the instructions below. This process is currently only tested on Linux.

Skia build

  1. Download Skia https://skia.org/docs/user/download/, including bazelisk
  2. $ bazelisk build --sandbox_base=/dev/shm --with_fontations //tools/viewer //tests:FontationsTest (to build debug, add -c dbg after build)
    • You should now have executables at bazel-bin/tests/FontationsTest and bazel-bin/tools/viewer/viewer

Skia Fontations unit tests

Build as above, then run the executable to run tests:

$ bazel-bin/tests/FontationsTest

OR compile and test in one command:

$ bazelisk test --sandbox_base=/dev/shm --with_fontations //tests:FontationsTest

Skia Fontations GM

Build as above then:

$ bazel-bin/tools/viewer/viewer --slide GM_typeface_fontations_roboto

OR build and run in one command:

$ bazelisk run --sandbox_base=/dev/shm --with_fontations //tools/viewer -- --slide GM_typeface_fontations_roboto

chromium build

  1. Follow the instructions for getting and building Chromium
  2. Add use_typeface_fontations = true to your args.gn using $ gn args out/<builddir>
  3. Build Chromium using autoninja -C out/<builddir> chrome
  4. Run Chromium using $ out/<builddir>/chrome
  5. Go to chrome://flags/#enable-fontations-backend and activate the flag, restart Chrome.
  6. Navigate to any URL, observe web fonts being displayed with Fontations + Skia path rendering.

关于 About

Reading and writing font files

语言 Languages

Rust98.3%
PostScript0.8%
Python0.7%
Shell0.2%
Roff0.0%

提交活跃度 Commit Activity

代码提交热力图
过去 52 周的开发活跃度
1233
Total Commits
峰值: 113次/周
Less
More

核心贡献者 Contributors