epiphany/crates/epiphany-render-svg
Levi Neuwirth eec63aa244 Agent I-4a: reconcile the Bravura metrics with the 1.392 outlines
The layout metrics table claimed Bravura 1.38.0 while the renderer's outlines are
extracted from 1.392, so the advances/bboxes the engraver reserves space and
evaluates collisions from did not match the ink actually drawn (P12-I3). Both now
come from the SAME SHA-pinned bravura-1.392 font.

  - BRAVURA_METRICS is regenerated from 1.392 by tools/extract_bravura_outlines.py
    (the same font and script the outlines come from; the regenerated outlines are
    byte-identical to the committed ones, and the extracted timeSig rows match the
    values bundled earlier -- two integrity checks that the extraction is faithful).
    Several old rows were not just stale but wrong: flag8thUp had its ink above the
    origin when the glyph hangs below the stem tip; restWhole/restHalf and the
    clefs had approximate or mis-signed bounds.
  - The metric bbox is rounded OUTWARD from the outline bounds (floor the mins,
    ceil the maxes) rather than to the nearest 1/1024, so the integer metric box
    always CONTAINS the drawn outline -- the engraver evaluates collisions from
    that box, and a containing box keeps a hard no-collision result honest on
    paper. A new render-svg test (metric_bboxes_contain_the_drawn_outlines) proves
    the containment for every bundled glyph, so a future re-extraction cannot
    silently regress it.
  - BRAVURA_VERSION is 1.38.0 -> the literal font version: name-table ID 5 reads
    "Version 1.392" and head.fontRevision ~= 1.392 (a single decimal), recorded
    verbatim as SemVer { major: 1, minor: 392, patch: 0 } so the identifier
    round-trips to the font's own string. The canonical mapping rule is documented
    on BRAVURA_VERSION; DECISIONS.md is updated to match.

The corrected metrics surfaced a coupled placement bug: the old barlineSingle
metric falsely centred the glyph (+/-2048), so the bottom-origin Bravura barline
(which runs 0..4 staff spaces UP from its origin) was anchored at staff-centre and
floated above the midline. It is now anchored at the staff bottom (yo), so a
barline connects the bottom and top staff lines.

Goldens regenerated (stub + engrave) for the corrected geometry. Full gate green:
build, fmt, clippy, 581 tests, conformance scale 1.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-26 22:45:33 -04:00
..
examples Phase 2 (Agent I): visible-slice scaffold — Bravura SVG renderer vs stub 2026-06-23 20:01:40 -04:00
src Agent I-4a: reconcile the Bravura metrics with the 1.392 outlines 2026-06-26 22:45:33 -04:00
tests Agent I-4a: reconcile the Bravura metrics with the 1.392 outlines 2026-06-26 22:45:33 -04:00
tools Agent I-4a: reconcile the Bravura metrics with the 1.392 outlines 2026-06-26 22:45:33 -04:00
Cargo.toml Phase 2 (Agent I): visible-slice scaffold — Bravura SVG renderer vs stub 2026-06-23 20:01:40 -04:00
DECISIONS.md Phase 2 (Agent I): visible-slice scaffold — Bravura SVG renderer vs stub 2026-06-23 20:01:40 -04:00
README.md Phase 2 (Agent I): visible-slice scaffold — Bravura SVG renderer vs stub 2026-06-23 20:01:40 -04:00

README.md

epiphany-render-svg

Agent I's SVG renderer behind the Epiphany RenderIR interface (spec Chapter 7): turns a ResolvedLayoutIR into well-formed SVG 1.1, drawing each glyph as a genuine Bravura SMuFL outline <path>. It is the visible end of the v0 Score → layout IR pipeline.

Status: renderer against the stub solver

This phase builds and golden-locks the renderer against the stub solver's output (the QUICKSTART development pattern), before the real engraving solver and the score→real-notation engraving pass land. The stub returns the IR geometry verbatim — a structural projection (each object becomes one arbitrary glyph in a row), not yet recognizable notation — so what is proven here is renderer correctness and faithfulness: real outlines, provenance preserved, output XML-valid and deterministic. The renderer consumes any solver's output, so the picture improves with no renderer change once epiphany-engrave lands.

Demo

# Render a fixture to SVG (stub solver by default):
cargo run -p epiphany-render-svg --example render_fixture -- \
    ten_measure_single_staff > out.svg

# Drive Agent I's engrave solver instead, to bisect renderer-vs-solver:
cargo run -p epiphany-render-svg --example render_fixture -- \
    ten_measure_single_staff --solver=real > out.svg

Fixtures: ten_measure_single_staff, valid_score_rich, valid_score. Stats and diagnostics go to stderr; the SVG goes to stdout.

Library

use epiphany_render_svg::{render, RenderOptions};

let out = render(&resolved_layout_ir, &RenderOptions::default());
assert!(out.is_well_formed());
println!("{}", out.svg);

render is pure and deterministic. RenderOptions controls SVG-encoding choices only (display scale, margin, provenance attributes) — nothing that changes engraving.

Bundled outlines

The glyph outlines in src/outlines_generated.rs are extracted from the official OFL Bravura.otf by tools/extract_bravura_outlines.py. The font is not vendored; only the generated Rust is committed. Bravura is © Steinberg Media Technologies GmbH under the SIL Open Font License 1.1 (tools/OFL.txt); the extracted outlines are redistributed under the same license. To regenerate:

cd crates/epiphany-render-svg/tools
python3 -m venv .venv && . .venv/bin/activate && pip install fonttools
python3 extract_bravura_outlines.py > ../src/outlines_generated.rs