Guidedog मैनुअल 1.0.0-beta.16
भाषा
इस पृष्ठ पर
Guidedog / दस्तावेज़ 1.0.0-beta.16

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 regular: Vec<FaceData<'f>>

Regular text faces.

pub bold: Vec<FaceData<'f>>

Bold text faces, falling back to regular when empty.

pub italic: Vec<FaceData<'f>>

Italic text faces, falling back to regular when empty.

pub bold_italic: Vec<FaceData<'f>>

Bold italic text faces, falling back to bold, italic, then regular when empty.

pub struct gd_engrave::Fonts<'f>

Explicit immutable font tables, safe to share between engraving threads.

Implementations

impl Fonts<'_>
pub fn glyph(&self, name: &str) -> Result<Glyph, Error>

Finds a named SMuFL glyph. Fails if the vendored font lacks its outline or metadata.

pub fn glyph_data(&self, glyph: Glyph) -> Option<&GlyphData>

Borrows one loaded glyph’s path, bounds and anchors, or None for a foreign id.

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 name: String

Stable SMuFL glyph name.

pub outline: String

SVG path in staff-space units, with upward y.

pub bounds: Rect

Ink bounds in the display list’s downward-y coordinates.

pub anchors: BTreeMap<String, Point>

SMuFL anchors and cut-outs in upward-y font coordinates.

pub advance: f64

Horizontal advance in staff spaces.

pub struct gd_engrave::Bezier

A cubic Bezier curve with its two control points.

Fields

pub from: Point

Start.

pub first: Point

First control point.

pub second: Point

Second control point.

pub to: Point

End.

Implementations

impl Bezier
pub fn point(self, t: f64) -> Point

Evaluates the polynomial at t; callers use t in the closed interval 0..=1.

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

impl Engraver
pub fn engrave_score(&mut self, score: &Score, fonts: &Fonts<'_>, options: &mut Options<'_>) -> Result<Engraving, Error>

Borrows a score and immutable fonts and produces owned systems of geometry. Fails for invalid notation, dimensions, fonts, work bounds or memory refusal.

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

impl Default for Limits
fn default() -> Self
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 justify: Justify

Last-line and single-line spacing policy.

pub optical_adjustment: f64

Optical gap adjustment between opposite stem directions, in staff spaces.

pub limits: Limits

Finite work and size bounds.

pub reserve: Option<&'a mut Reserve<'a>>

Optional caller-owned buffer-growth ledger.

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
impl Default for Options<'_>
fn default() -> Self
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 systems: Vec<System>

Systems in reading order.

pub glyphs: BTreeMap<Glyph, GlyphData>

Only music glyphs used by this drawing, with outlines for standalone export.

pub summary: Summary

Accessible musical facts.

pub warnings: Vec<Error>

Recoverable layout and missing-text-glyph diagnostics.

pub struct gd_engrave::PositionedMark

Source-independent grouping and ink bounds for one positioned instruction.

Fields

pub mark: Mark

Instruction in points relative to its system’s top.

pub staff: StaffId

Owning staff.

pub measure: u32

Printed measure number; zero for shared system furniture.

pub bounds: Rect

Conservative ink bounds used by audits and vertical placement.

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 instruments: Vec<String>

Named instruments, in staff order.

pub key: Option<Key>

Initial key when supplied.

pub meter: Option<Meter>

Initial meter when supplied.

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, not FnMut like crate::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 systems: Option<Range<usize>>

Selected system indices, or all systems.

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 outline: String

SVG path with upward font y, already scaled to points.

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 glyphs: Vec<TextGlyph>

Glyph outlines in visual order.

pub advance: f64

Shaped horizontal advance in points, including spaces.

pub bounds: Rect

Composite ink bounds relative to the run’s baseline.

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.

pub sources: Vec<String>

Opaque identities of the text font sources actually selected during shaping.

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.

glyph: Glyph

Glyph definition in Engraving::glyphs.

x: f64

Horizontal origin.

y: f64

Vertical origin.

size: f64

Points per font staff space.

role: Role

Semantic role.

Line { from: Point, to: Point, thickness: f64, role: Role }

A straight, solid segment.

from: Point

First endpoint.

to: Point

Last endpoint.

thickness: f64

Stroke width.

role: Role

Semantic role.

Polygon { points: [Point; 4], role: Role }

A filled quadrilateral, usually a beam.

points: [Point; 4]

Vertices in perimeter order.

role: Role

Semantic role.

Curve { outer: Bezier, inner: Bezier, role: Role }

A filled bow bounded by two cubic curves.

outer: Bezier

Outer boundary, from left to right.

inner: Bezier

Inner boundary, from left to right.

role: Role

Semantic role.

Text { run: TextRun, x: f64, y: f64, role: Role }

Outlined text with its shaped advance and ink bounds.

run: TextRun

Positioned text outlines, relative to the baseline origin.

x: f64

Horizontal baseline origin.

y: f64

Vertical baseline origin.

role: Role

Semantic role.

Implementations

impl Mark
pub fn role(&self) -> Role

Returns the role shared by every geometry variant.

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

impl Role
pub fn name(self) -> &'static str

Returns a stable ASCII class name without allocating.

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.

fn id(&self) -> Option<&str>

Borrows an optional opaque dependency identity for the adapter to observe.

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.