Fonts: use craft-fonts as an optional build input

With CRAFT_FONTS_DIR=<craft-fonts checkout>, crates/text/build.rs embeds the
fonts in its manifest as effectcraft_text::fonts::CRAFT_FONTS (wasm32: only
BIZ UDPGothic Regular). Unset, CRAFT_FONTS is empty and nothing changes.

- Text engine: the Jpan faces are registered after the bundled ones and are
  the Japanese fallback before any system font (Mincho for serif text, BIZ
  UDPGothic otherwise; Han only when the locale puts Japanese first).
- UI: the Jpan faces are appended to every egui family, BIZ UDPGothic first.
- Tests: Japanese renders with real glyphs (text layout and every UI family)
  when built with craft-fonts, skipped otherwise; the app works without it.
- CI (FreeBSD) and release.yml check out craft-fonts at a pinned commit;
  releases set CRAFT_FONTS_REQUIRED=1 and packages carry the OFL licences.
- AGENTS.md, CLAUDE.md, CONTRIBUTING.md, README, docs, ATTRIBUTION.md and
  NOTICE: fonts live in craft-fonts; how to build with it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Brandon Thomas
2026-10-06 14:23:06 -04:00
co-authored by Claude Opus 5.5
parent 1a9288f83c
commit 12083230a8
17 changed files with 407 additions and 8 deletions
+10 -1
View File
@@ -11,6 +11,7 @@ on:
- Cargo.lock
- "**/Cargo.toml"
- .github/workflows/freebsd.yml
- "**/build.rs"
workflow_dispatch:
concurrency:
@@ -27,6 +28,14 @@ jobs:
timeout-minutes: 300
steps:
- uses: actions/checkout@v4
# The optional craft-fonts build input (craftrules standards/fonts.md), so the Japanese font
# tests run here instead of skipping.
- name: Check out craft-fonts (pinned)
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
repository: storytold/craft-fonts
ref: abb83316d96aa59c1cf64784289e378fe9fa5695
path: craft-fonts
- name: Build and test in a FreeBSD VM
uses: vmactions/freebsd-vm@c46abacb49f09938ca4e1702d15d836285d694cc # v1
with:
@@ -45,4 +54,4 @@ jobs:
git config --global --add safe.directory "*"
rustc --version
CARGO_PROFILE_DEV_DEBUG=0 cargo build --workspace --all-targets --locked
CARGO_PROFILE_DEV_DEBUG=0 cargo test --workspace --locked
CRAFT_FONTS_DIR="$PWD/craft-fonts" CARGO_PROFILE_DEV_DEBUG=0 cargo test --workspace --locked
+29
View File
@@ -30,6 +30,11 @@ env:
RUST_BACKTRACE: 1
EFFECTCRAFT_BUILD_SHA: ${{ github.sha }}
INPUT_VERSION: ${{ inputs.version }}
# Official builds embed the shared fonts from storytold/craft-fonts (checked out at a pinned
# commit in every build job; see craftrules standards/fonts.md). REQUIRED makes a missing or
# broken checkout a build error instead of a silent build without the fonts.
CRAFT_FONTS_DIR: ${{ github.workspace }}/craft-fonts
CRAFT_FONTS_REQUIRED: "1"
jobs:
version:
@@ -70,6 +75,12 @@ jobs:
EFFECTCRAFT_BUILD_DATE: ${{ needs.version.outputs.date }}
steps:
- uses: actions/checkout@v4
- name: Check out craft-fonts (pinned)
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
repository: storytold/craft-fonts
ref: abb83316d96aa59c1cf64784289e378fe9fa5695
path: craft-fonts
- uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-apple-darwin, x86_64-apple-darwin
@@ -120,6 +131,12 @@ jobs:
EFFECTCRAFT_BUILD_DATE: ${{ needs.version.outputs.date }}
steps:
- uses: actions/checkout@v4
- name: Check out craft-fonts (pinned)
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
repository: storytold/craft-fonts
ref: abb83316d96aa59c1cf64784289e378fe9fa5695
path: craft-fonts
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
@@ -170,6 +187,12 @@ jobs:
NFPM_VERSION: 2.47.0
steps:
- uses: actions/checkout@v4
- name: Check out craft-fonts (pinned)
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
repository: storytold/craft-fonts
ref: abb83316d96aa59c1cf64784289e378fe9fa5695
path: craft-fonts
- name: Install build and packaging tools
run: |
sudo apt-get update
@@ -215,6 +238,12 @@ jobs:
WASM_BINDGEN_VERSION: 0.2.129
steps:
- uses: actions/checkout@v4
- name: Check out craft-fonts (pinned)
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
repository: storytold/craft-fonts
ref: abb83316d96aa59c1cf64784289e378fe9fa5695
path: craft-fonts
- uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown