Expand description
iReal Pro chart renderer — SVG with chord-name typography, repeat barlines, ending brackets, section labels, and music symbols.
This crate renders an chordsketch_ireal::IrealSong AST as a
fixed-size SVG document. The current scope covers the page
frame, the metadata header (title / composer / style / key),
the 4-bars-per-line grid with section line breaks, superscript
chord-name typography (root + accidental at base size, quality
/ extensions raised as superscript, slash + bass back at base
size), repeat / final / double barline glyphs, N-th-ending
brackets with 1. / 2. labels, section-letter labels above
each section start, and music symbols (segno / coda glyphs;
D.C. / D.S. / Fine text directives) above the bar that
carries them. Tracked under
#2050.
§Layout overview
Output is a fixed-size SVG (595 × 842) with deterministic
integer coordinates so golden snapshots remain byte-stable.
The page is divided into:
- Header band — title (top), composer (right), style + key (left, beneath the title).
- Bar grid — bars laid out 4-per-row by the
layout::compute_layoutengine. Each cell carries a centred chord-name<text>with mixed<tspan>runs: root + accidental at base size, quality / extensions raised as superscript at a smaller size, slash + bass at base size on the original baseline. Bar boundaries display the appropriate barline glyph (Singlevia the cell-rect stroke;Double,Final,OpenRepeat,CloseRepeatoverlay the cell stroke). N-th-ending brackets, section- letter labels, and music-symbol glyphs all sit above the row in the same band; music symbols are drawn last so they layer on top of any overlapping bracket. Trailing cells in a section’s last row are filled with empty placeholders so the visible grid stays a clean rectangle.
§Dependency policy
Only depends on chordsketch_ireal for the AST. SVG
generation is hand-rolled — no xmlwriter, no svg crate, no
templating engine. Keeps the transitive-dep surface minimal and
mirrors the zero-external-dep posture of chordsketch-chordpro
/ chordsketch-ireal.
Enabling the png cargo feature additionally pulls in resvg
and tiny-skia for the png::render_png rasteriser; enabling
pdf pulls in svg2pdf for the pdf::render_pdf converter.
Both features are off by default; SVG-only consumers stay on
the single-dep build. (Inline code-spans — not intra-doc links —
because the png and pdf modules are #[cfg(feature = ...)]
and a crate-level rustdoc link would break the default-features
cargo doc --no-deps run that gates CI.)
§Cargo features
| Feature | Default? | Notes |
|---|---|---|
png | off | Enables png::render_png (rasterises the SVG via resvg). |
pdf | off | Enables pdf::render_pdf (converts the SVG to PDF via svg2pdf). |
§Stability
Pre-1.0. The SVG output structure is expected to grow new
elements as the iReal Pro tracker (#2050) closes its remaining
items. Existing elements stay stable so that crate consumers
(the playground preview, the PDF rasteriser #2063, the PNG
rasteriser #2064) can rely on a small set of stable selectors
/ IDs (class="title", class="composer", class="meta",
class="bar-grid", class="chord", class="chord-root",
class="chord-ext", class="chord-slash", class="chord-bass",
class="empty", class="section-label",
class="ending-bracket", class="ending-label",
class="barline-double", class="barline-final",
class="barline-repeat-thick", class="barline-repeat-thin",
class="barline-repeat-dot", class="music-symbol-segno",
class="music-symbol-coda", class="music-symbol-text",
class="staff-text").
The previous segno / coda selector set
(music-symbol-segno-curve / -slash / -dot and
music-symbol-coda-circle / -cross) covered SVG-primitive
approximations and was removed when #2348 swapped in real
Bravura SMuFL outlines as a single <path> element each.
Stylesheets that previously targeted any of those selectors
should retarget to the consolidated
class="music-symbol-segno" / class="music-symbol-coda",
which is now a single filled <path> per glyph (no stroke).
The crate is pre-1.0 so this is documented as a stability note
rather than a breaking-change deprecation cycle.
§Example
use chordsketch_ireal::IrealSong;
use chordsketch_render_ireal::{RenderOptions, render_svg};
let song = IrealSong::new();
let svg = render_svg(&song, &RenderOptions::default());
assert!(svg.starts_with("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"));
assert!(svg.contains("<svg "));Re-exports§
pub use chord_typography::ChordTypography;pub use chord_typography::SpanKind;pub use chord_typography::TypographySpan;pub use chord_typography::chord_to_typography;pub use layout::BarCoord;pub use layout::EmptyCell;pub use layout::Layout;pub use layout::compute_layout;pub use page::BAR_ROW_HEIGHT;pub use page::BARS_PER_ROW;pub use page::CHORD_FONT_SIZE_BASE;pub use page::CHORD_FONT_SIZE_BASE_SMALL;pub use page::CHORD_FONT_SIZE_SUPERSCRIPT;pub use page::GRID_TOP;pub use page::HEADER_BAND_HEIGHT;pub use page::MARGIN_X;pub use page::MARGIN_Y;pub use page::MAX_BARS;pub use page::MAX_CHORDS_PER_BAR;pub use page::MAX_SECTIONS;pub use page::PAGE_HEIGHT;pub use page::PAGE_WIDTH;
Modules§
- chord_
typography - Chord-name typography splitter.
- layout
- 4-bars-per-line grid layout engine.
- page
- Page-layout constants used by the SVG skeleton.
Structs§
- Render
Options - Caller-supplied render configuration.
Functions§
- render_
svg - Renders an iReal Pro chart as a fixed-size SVG document.
- version
- Returns the library version (the workspace
Cargo.tomlversionfield, baked in at compile time).