gd_engrave¶
Native music engraving: a score becomes positioned marks, then self-contained SVG. Fonts are explicit immutable tables; one reusable Engraver belongs to one thread.
Structs
- pub struct gd_engrave::BreakPoint¶
-
A legal measure boundary; the first and last entries delimit the complete score.
Fields
- pub gap: usize¶
-
Gap index at this boundary.
- pub measure: u32¶
-
Printed number of the following measure.
- pub penalty: i32¶
-
Preferred break penalty; a negative value rewards this boundary.
- pub forced: bool¶
-
No candidate may cross this boundary.
- pub forbidden: bool¶
-
No candidate may end here, except the final score boundary.
- pub prefix: f64¶
-
Clef, signatures and instrument-name width at a line starting here.
- pub indent: f64¶
-
Instrument-name indent before the staff lines begin.
- pub suffix: f64¶
-
Courtesy signatures before a line ending here.
- pub struct gd_engrave::Line¶
-
One line in the chosen optimal breaking within the bounded candidate window.
Fields
- pub first: usize¶
-
Starting breakpoint index.
- pub last: usize¶
-
Ending breakpoint index.
- pub stretch: f64¶
-
Selected proportional stretch.
- pub width: f64¶
-
Actual width including prefatory and courtesy matter.
- pub overfull: bool¶
-
Whether a minimum-clearance line exceeds its available width.
- pub struct gd_engrave::FaceData<'f>¶
-
One borrowed OpenType face; a collection needs its explicit face index.
Fields
- pub data: &'f [u8]¶
-
Original font or collection bytes.
- pub index: u32¶
-
Face index; zero is the common single-font case.
- pub source: Option<&'f dyn FaceSource>¶
-
Optional lazy source; when present it supplies bytes instead of data.
Trait Implementations
- impl fmt::Debug for FaceData<'_>
-
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
- pub struct gd_engrave::FontOptions<'f>¶
-
Borrowed text faces, in fallback order; fonts outlive the returned tables.
Fields
- pub struct gd_engrave::Fonts<'f>¶
-
Explicit immutable font tables, safe to share between engraving threads.
Implementations
- impl Fonts<'_>
Trait Implementations
- impl fmt::Debug for Fonts<'_>
-
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
- pub struct gd_engrave::Glyph(pub u16)¶
-
A Bravura glyph identifier, independent of its name in SMuFL metadata.
- pub struct gd_engrave::GlyphData¶
-
One immutable music glyph, in staff spaces with upward font coordinates.
Fields
- pub advance: f64¶
-
Horizontal advance in staff spaces.
- pub struct gd_engrave::Bezier¶
-
A cubic Bezier curve with its two control points.
Fields
Implementations
- pub struct gd_engrave::Point¶
-
A point in staff spaces during layout and in points in the public display list.
Fields
- pub x: f64¶
-
Horizontal coordinate, increasing to the right.
- pub y: f64¶
-
Vertical coordinate, increasing downwards.
- pub struct gd_engrave::Rect¶
-
An axis-aligned rectangle in the same units as its associated marks.
Fields
- pub left: f64¶
-
Minimum horizontal coordinate.
- pub top: f64¶
-
Minimum vertical coordinate.
- pub right: f64¶
-
Maximum horizontal coordinate.
- pub bottom: f64¶
-
Maximum vertical coordinate.
Implementations
- impl Rect
-
- pub fn translated(self, x: f64, y: f64) -> Self¶
-
Returns a translated rectangle, borrowing no state and performing no allocation.
- pub fn union(self, other: Self) -> Self¶
-
Returns the smallest rectangle enclosing both inputs.
- pub fn overlaps(self, other: Self, tolerance: f64) -> bool¶
-
Returns whether the interiors overlap beyond a nonnegative tolerance.
- pub struct gd_engrave::Engraver¶
-
Reusable per-thread layout buffers. No process-global state or hidden font policy.
Implementations
- pub struct gd_engrave::Limits¶
-
Explicit bounds on layout work, output size and system count.
Fields
- pub events: usize¶
-
Maximum input event count.
- pub measures_per_line: usize¶
-
Maximum line-breaking candidate window in measures.
- pub systems: usize¶
-
Maximum systems in one drawing.
- pub height: f64¶
-
Maximum height in points.
- pub work: usize¶
-
Charged candidate gaps, comparisons and curve samples.
- pub marks: usize¶
-
Maximum positioned marks across every system.
- pub svg_bytes: usize¶
-
Maximum serialized SVG bytes, including outlines.
Trait Implementations
- pub struct gd_engrave::Options<'a>¶
-
Plain layout options; dimensions are points. The default staff is 18 points high.
Fields
- pub line_width: f64¶
-
Available system width.
- pub staff_size: f64¶
-
Height of a five-line staff.
- pub optical_adjustment: f64¶
-
Optical gap adjustment between opposite stem directions, in staff spaces.
- pub scratch: crate::Scratch<'a>¶
-
Scoped reservations for short-lived spacing and skyline buffers.
Trait Implementations
- impl fmt::Debug for Options<'_>
-
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
- pub struct gd_engrave::Engraving¶
-
A complete immutable drawing, independent of input syntax and borrowed font bytes.
Fields
- pub width: f64¶
-
Natural output width in points.
- pub height: f64¶
-
Complete output height in points.
- pub struct gd_engrave::PositionedMark¶
-
Source-independent grouping and ink bounds for one positioned instruction.
Fields
- pub measure: u32¶
-
Printed measure number; zero for shared system furniture.
- pub struct gd_engrave::Summary¶
-
Facts used by an adapter to word an accessible description in the page’s language.
Fields
- pub staves: u32¶
-
Number of staves.
- pub measures: (u32, u32)¶
-
Inclusive first and last printed measure numbers.
- pub lyrics: bool¶
-
Whether any verse has syllables.
- pub struct gd_engrave::System¶
-
One system’s positioned geometry and vertical extent.
Fields
- pub width: f64¶
-
Actual system ink width in points; zero uses the complete engraving width.
- pub top: f64¶
-
Top in points from the complete drawing’s origin.
- pub height: f64¶
-
Height in points, including lyrics and outside marks.
- pub first_measure: u32¶
-
Printed first measure number.
- pub last_measure: u32¶
-
Printed last measure number.
- pub marks: Vec<PositionedMark>¶
-
Geometry with staff and measure identities for SVG grouping.
- pub struct gd_engrave::Scratch<'a>¶
-
Borrowed memory callbacks for transient layout buffers; empty by default. They are
Fn, notFnMutlikecrate::Reserve, because several reservations are live at once and each releases its own bytes when dropped.Fields
- pub reserve: Option<&'a dyn Fn(usize) -> bool>¶
-
Reserves bytes before allocation; false stops the layout with a limit error.
- pub release: Option<&'a dyn Fn(usize)>¶
-
Returns successfully reserved bytes when the temporary buffer is freed. Without this callback the caller conservatively retains the charge.
Trait Implementations
- impl fmt::Debug for Scratch<'_>
-
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
- pub struct gd_engrave::Rod¶
-
A clearance constraint spanning one or more adjacent gaps.
Fields
- pub first: usize¶
-
First gap, inclusive.
- pub last: usize¶
-
Last gap, exclusive.
- pub minimum: f64¶
-
Required sum of those gaps.
- pub struct gd_engrave::Solution¶
-
The unique spring-energy minimizer after conservative spanning-rod conversion.
Fields
- pub gaps: Vec<f64>¶
-
Nonnegative gap lengths satisfying every original rod.
- pub stretch: f64¶
-
Proportional spring stretch; zero on an overfull line.
- pub overfull: bool¶
-
Whether the minimum width exceeds the requested width.
- pub minimum: f64¶
-
Sum of converted minimum clearances.
- pub natural: f64¶
-
Sum at stretch one, including bound rods.
- pub struct gd_engrave::Spring¶
-
One gap’s preferred length and non-negotiable collision clearance.
Fields
- pub ideal: f64¶
-
Positive preferred length in staff spaces.
- pub minimum: f64¶
-
Nonnegative minimum length in staff spaces.
- pub struct gd_engrave::SvgOptions<'a>¶
-
Standalone SVG export policy. The default selects every system and black ink.
Fields
- pub title: &'a str¶
-
Accessible title, escaped as XML text.
- pub description: &'a str¶
-
Accessible musical description, escaped as XML text.
- pub adaptive: bool¶
-
Add screen-only dark-theme ink rules; PDF and PNG use false.
- pub max_bytes: usize¶
-
Maximum complete SVG bytes, excluding an existing caller buffer prefix.
Trait Implementations
- impl Default for SvgOptions<'_>
-
- fn default() -> Self
- pub struct gd_engrave::TextGlyph¶
-
One outlined text glyph in points, relative to its run’s baseline.
Fields
- pub x: f64¶
-
Horizontal placement in points.
- pub y: f64¶
-
Downward vertical placement in points.
- pub struct gd_engrave::TextRun¶
-
Shaped text with real ink geometry; export never depends on browser fonts.
Fields
- pub advance: f64¶
-
Shaped horizontal advance in points, including spaces.
- pub ascent: f64¶
-
Face ascent in points.
- pub descent: f64¶
-
Positive face descent in points.
- pub word_space: f64¶
-
Largest word-space advance among the selected faces, in points.
Enums
- pub enum gd_engrave::Justify¶
-
Last-line and single-line justification policy.
Variants
- Auto¶
-
Leave a short final line at its natural width.
- All¶
-
Stretch every line to the available measure.
- None¶
-
Compress when needed but never stretch beyond natural width.
- pub enum gd_engrave::Mark¶
-
One self-contained geometry instruction in points, using downward y coordinates.
Variants
- Glyph { glyph: Glyph, x: f64, y: f64, size: f64, role: Role }¶
-
A music-font glyph, scaled from staff spaces to points.
- x: f64¶
-
Horizontal origin.
- y: f64¶
-
Vertical origin.
- size: f64¶
-
Points per font staff space.
- Line { from: Point, to: Point, thickness: f64, role: Role }¶
-
A straight, solid segment.
- thickness: f64¶
-
Stroke width.
- Text { run: TextRun, x: f64, y: f64, role: Role }¶
-
Outlined text with its shaped advance and ink bounds.
- x: f64¶
-
Horizontal baseline origin.
- y: f64¶
-
Vertical baseline origin.
Implementations
- pub enum gd_engrave::Role¶
-
A mark’s semantic role, used by SVG classes and collision audits.
Variants
- Staff¶
-
Staff line.
- Clef¶
-
Clef.
- Signature¶
-
Key or time signature.
- Notehead¶
-
Pitched notehead.
- Fret¶
-
Fret number on a tablature string.
- Ledger¶
-
Ledger line through an outside note.
- Stem¶
-
Stem.
- Flag¶
-
Flag.
- Beam¶
-
Beam.
- Accidental¶
-
Accidental or cautionary parentheses.
- Dot¶
-
Augmentation dot.
- Rest¶
-
Rest or multi-measure rest bar.
- Bar¶
-
Bar line or repeat dots.
- Tie¶
-
Tie.
- Slur¶
-
Legato or phrasing slur.
- Tuplet¶
-
Tuplet number or bracket.
- Articulation¶
-
Articulation or fingering.
- Fingering¶
-
Fingering digit.
- Tempo¶
-
Tempo instruction.
- Rehearsal¶
-
Rehearsal label.
- Dynamic¶
-
Dynamic or hairpin.
- Lyric¶
-
Lyric syllable, hyphen or extender.
- Instrument¶
-
Instrument name or group delimiter.
- Script¶
-
Text script, tempo or rehearsal mark.
- ChordName¶
-
Chord symbol.
- Volta¶
-
Repeat ending bracket and label.
- MeasureNumber¶
-
Measure number.
Implementations
Traits
- pub trait gd_engrave::FaceSource: Sync¶
-
A build-owned immutable font source, loaded only when its coverage is needed.
- fn data(&self) -> Result<&[u8], Error>¶
-
Borrows original bytes for the lifetime of this source, or reports a load failure.
- fn covers(&self, _character: char) -> bool¶
-
Tests discovered coverage before loading bytes. True may be provisional.
Functions
- pub fn gd_engrave::break_lines(springs: &[Spring], rods: &[Rod], breaks: &[BreakPoint], width: f64, justify: Justify, limits: &Limits) -> Result<Vec<Line>, Error>¶
-
Borrows a spacing problem and returns its optimal bounded measure breaking. Fails for invalid boundaries, exhausted work or system limits, or contradictory breaks.
- pub fn gd_engrave::load_fonts<'f>(options: &FontOptions<'f>) -> Result<Fonts<'f>, Error>¶
-
Loads unmodified embedded music data and borrows the supplied text faces. No global state or filesystem is consulted. Fails for malformed fonts or metadata.
- pub fn gd_engrave::engrave_svg(score: &Score, fonts: &Fonts<'_>, options: &mut Options<'_>) -> Result<String, Error>¶
-
One-call SVG engraving with fresh workspace buffers and default non-adaptive export. Borrows score, fonts and options; fails like Engraver::engrave_score or write_svg.
- pub fn gd_engrave::solve_spacing(springs: &[Spring], rods: &[Rod], width: f64) -> Result<Solution, Error>¶
-
Borrows gaps and rods and solves for a positive finite width. Fails for invalid dimensions, rod indices, memory refusal or the default work limit.
- pub fn gd_engrave::write_svg(out: &mut String, engraving: &Engraving, options: &SvgOptions<'_>, reserve: Option<&mut Reserve<'_>>) -> Result<(), Error>¶
-
Appends self-contained SVG to a caller’s buffer, borrowing all inputs for this call. Fails on invalid systems or dimensions, allocation refusal or size limits. A failure restores the caller’s original buffer length.
Type Aliases
- pub type gd_engrave::Reserve<'a> = dyn FnMut(usize) -> bool + 'a¶
-
A caller-owned memory ledger, consulted before each buffer grows.