Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Introduction

fonts-rs is a Rust workspace for integrating font families into GTK4 projects. It provides a modular framework for exporting glyphs as SVG icons, generating GResource bundles, resolving icon names to Unicode codepoints, and rendering text with software rasterization.

Architecture Overview

The workspace is organized into three layers:

  1. Generic framework - fonts-rs-model (shared types) and fonts-rs-generator (build-time pipeline)
  2. Font family crates - one crate per font family (e.g. fonts-rs-doto, fonts-rs-bravura, fonts-rs-seven-segment)
  3. Nerd Fonts integration - nerd-fonts-model, nerd-fonts-generator, and nerd-fonts-rs for the legacy Nerd Fonts-specific API
graph TD
    subgraph "Generic Framework"
        Model["fonts-rs-model<br/>Shared types"]
        Gen["fonts-rs-generator<br/>Build pipeline"]
    end

    subgraph "Font Family Crates"
        Doto["fonts-rs-doto"]
        Bravura["fonts-rs-bravura"]
        SevenSeg["fonts-rs-seven-segment"]
        NotoEmoji["fonts-rs-noto-emoji"]
        Other["... 10 more"]
    end

    subgraph "Nerd Fonts"
        NFModel["nerd-fonts-model"]
        NFGen["nerd-fonts-generator"]
        NFRs["nerd-fonts-rs"]
    end

    Model --> Gen
    Model --> Doto
    Model --> Bravura
    Model --> SevenSeg
    Model --> NotoEmoji
    Model --> Other
    Gen --> Doto
    Gen --> Bravura
    Gen --> SevenSeg
    Gen --> NotoEmoji
    Gen --> Other
    Model --> NFModel
    Gen --> NFGen
    NFModel --> NFGen
    NFGen --> NFRs
    Model --> NFRs

Features

  • Modular font family crates - each font family is a separate crate with its own build script, GResource bundle, and runtime API
  • Type-safe glyph names - GlyphName<F> phantom typing prevents mix-ups between font families at compile time
  • Variable font support - variants via Cargo features with axis-based rendering (e.g. weight, roundness)
  • GTK4 integration - GResource registration, icon name resolution, CSS providers
  • Software rendering - font loading via ab_glyph for headless rendering (see pixel-drawing)
  • Build-time code generation - phf::Map codepoint maps, Rust constants, and GResource XML generated from font files
  • Metadata generation - keywords, categories, and aliases for search functionality (e.g. Noto Emoji CLDR annotations)

Available Font Families

CrateFontLicenseVariants
fonts-rs-dotoDotoOFL-1.1Variable (wght, ROND)
fonts-rs-seven-segmentDSEG7OFL-1.1Multiple files
fonts-rs-fourteen-segmentDSEG14OFL-1.1Multiple files
fonts-rs-barcode-code39Lib Barcode 39OFL-1.1-
fonts-rs-barcode-code128Lib Barcode 128OFL-1.1-
fonts-rs-barcode-ean13Lib Barcode EAN13OFL-1.1-
fonts-rs-bravuraBravuraOFL-1.1-
fonts-rs-redactedRedactedOFL-1.1-
fonts-rs-dicefontDiceFontOFL-1.1-
fonts-rs-cuernavacaCuernavacaOFL-1.1-
fonts-rs-noto-emojiNoto EmojiOFL-1.1-
nerd-fonts-rsNerd FontsMIT-

License

MIT for framework code. Font files retain their original licenses (OFL-1.1 for most fonts, MIT for Nerd Fonts). See LICENSE.