1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//! Parse [SMuFL][smufl] (Standard Music Font Layout) metadata.
//!
//! SMuFL-compliant fonts can provide a metadata file in JSON format in their
//! distribution package. The metadata file allows the designer to provide
//! information that cannot easily (or in some cases at all) be encoded within
//! or retrieved from the font software itself, including recommendations for
//! how to draw the elements of music notation not provided directly by the font
//! itself (such as staff lines, barlines, hairpins, etc.) in a manner
//! complementary to the design of the font, and important glyph-specific
//! metrics, such as the precise coordinates at which a stem should connect to a
//! notehead.
//!
//! See the [SMuFL documentation][smufl-metadata] for more details.
//!
//! This crate supports [version 1.40][smufl-version-history] of the SMuFL
//! specification.
//!
//! The font metadata can be read into the [`Metadata`](crate::Metadata) struct:
//!
//! ```
//! use std::{fs::File, io::BufReader};
//!
//! use smufl::{Glyph, Metadata, StaffSpaces};
//!
//! # fn example() -> anyhow::Result<()> {
//! let file = File::open("../submodules/bravura/redist/bravura_metadata.json")?;
//! let reader = BufReader::new(file);
//! let metadata = Metadata::from_reader(reader)?;
//!
//! assert_eq!(metadata.font_name, "Bravura");
//! assert_eq!(
//! metadata.engraving_defaults.staff_line_thickness.unwrap(),
//! StaffSpaces(0.13)
//! );
//! assert_eq!(
//! metadata.advance_widths.get(Glyph::NoteheadWhole),
//! StaffSpaces(1.688)
//! );
//! assert_eq!(
//! metadata
//! .anchors
//! .get(Glyph::NoteheadBlack)
//! .stem_up_se
//! .unwrap()
//! .x(),
//! StaffSpaces(1.18)
//! );
//! assert_eq!(
//! metadata.bounding_boxes.get(Glyph::NoteheadBlack).ne.x(),
//! StaffSpaces(1.18)
//! );
//! # Ok(())
//! # }
//! # example().unwrap()
//! ```
//!
//! [smufl]: https://www.smufl.org/
//! [smufl-metadata]: https://w3c.github.io/smufl/latest/specification/font-specific-metadata.html
//! [smufl-version-history]: https://w3c.github.io/smufl/latest/preamble/version-history.html
pub use Anchors;
pub use BoundingBox;
pub use Coord;
pub use EngravingDefaults;
pub use Glyph;
pub use GlyphAdvanceWidths;
pub use GlyphAnchors;
pub use GlyphBoundingBoxes;
pub use GlyphData;
pub use Metadata;
pub use StaffSpaces;