Files
Marcos Paulo e8c8c06d1e
ci / ci (macos-latest) (push) Has been cancelled
ci / ci (ubuntu-latest) (push) Has been cancelled
ci / ci (windows-latest) (push) Has been cancelled
feat: smart folder model, media time fragments, link card URL guard (MiniMax); specs for 10 more gaps (Codex) and the registry with bloat measurements
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-21 14:41:26 -03:00

3.3 KiB

TASK font-dedupe: embed each font once (Registry spec, task 0.2)

Runs through OpenCode (specs/agents/opencode-runbook.md is attached automatically). Task 0.2 of specs/registry/tasks.md. Measured in specs/registry/measurements.md 1.2: Inter-Regular.ttf and Inter-SemiBold.ttf are in the release binary twice (once in engine PDF export, once in ui-egui), 0.79 MiB wasted; PDF export also embeds JetBrainsMono-Regular.ttf (264 KiB) that nothing else uses.

OWNS

  • crates/engine/src/builtin/export_commands.rs (make the three font constants public and switch the mono one).
  • crates/engine/src/lib.rs (ONE line: pub use builtin::export_commands::{INTER_REGULAR, INTER_SEMIBOLD, JETBRAINS_MONO};; other people have uncommitted edits in this file, touch nothing else).
  • crates/ui-egui/src/design/fonts/mod.rs (the two Inter constants and the mono constant now come from the engine; keep INTER_MEDIUM and STIX_MATH as they are).
  • crates/ui-egui/src/design/fonts/tests.rs only to add the test below.

FILES TO OPEN

  • crates/engine/src/builtin/export_commands.rs lines 30-45 (the constants and fonts()).
  • crates/ui-egui/src/design/fonts/mod.rs lines 1-30 and install.
  • crates/engine/src/builtin/mod.rs (pub(crate) mod export_commands, so the re-export in lib.rs is the only public path).

GOAL / API

In export_commands.rs: pub const INTER_REGULAR: &[u8], pub const INTER_SEMIBOLD: &[u8] (same files as today) and pub const JETBRAINS_MONO: &[u8] = include_bytes!("../../../../assets/fonts/JetBrainsMono-NoLigatures.ttf"); (the UI font; PDF text has no ligature shaping, widths come from the file, so the PDF stays valid). Rustdoc on each (keep the existing sentences). lib.rs re-exports them. In ui-egui fonts mod.rs: delete the two Inter include_bytes! and the mono one, use notescraft_engine::{INTER_REGULAR, INTER_SEMIBOLD, JETBRAINS_MONO};. Do NOT delete any file under assets/fonts/ (the pdf crate's tests still read JetBrainsMono-Regular.ttf).

Expected result: the release binary shrinks by about 1.05 MiB (0.79 + 0.26).

TESTS

Add in ui-egui/src/design/fonts/tests.rs: the_ui_and_the_exporter_share_one_inter_copy asserting std::ptr::eq(notescraft_engine::INTER_REGULAR.as_ptr(), <the slice the UI installs>.as_ptr()) (expose the slice through a #[cfg(test)] pub(super) fn inter_regular() -> &'static [u8] or compare lengths and first 64 bytes if pointer access is awkward). Existing PDF export tests must still pass: if one compares exact PDF bytes or glyph widths of the mono font and fails, STOP and report the test name and the diff; do not edit the test.

VERIFY

export PATH="$HOME/.cargo/bin:$PATH"
cargo test -p notescraft-engine export
cargo test -p notescraft-ui-egui fonts
cargo clippy -p notescraft-engine -p notescraft-ui-egui --all-targets -- -D warnings
rustfmt --edition 2024 crates/engine/src/builtin/export_commands.rs crates/ui-egui/src/design/fonts/mod.rs crates/ui-egui/src/design/fonts/tests.rs

Optional if time: CARGO_TARGET_DIR=target/agent-fonts cargo build --release -p notescraft and report ls -l against 40,235,208 bytes.

DO NOT

Edit Cargo files; change INTER_MEDIUM, STIX_MATH, any font size, or the eframe features (task 0.3 does that); delete asset files; add a fonts module or crate; touch anything else in engine/src/lib.rs.