15 releases (9 breaking)
0.10.0 | Mar 17, 2023 |
---|---|
0.8.0 | Dec 5, 2022 |
0.7.0 | Mar 3, 2022 |
0.6.0 | Oct 21, 2021 |
0.0.1 | May 22, 2019 |
#201 in Text processing
1,678 downloads per month
Used in 4 crates
400KB
8K
SLoC
Norad
a Rust crate for working with Unified Font Object files.
A crate for reading, writing, and manipulating Unified Font Object files, a common font-design format.
lib.rs
:
Utilties for working with Unified Font Object files.
The types in this crate correspond to types described in the spec.
Basic Usage
Instantiate a UFO font object with a [Font
] struct like this:
use norad::Font;
let inpath = "RoflsExtraDim.ufo";
let mut font_obj = Font::load(inpath).expect("failed to load font");
# let layer = font_obj.default_layer();
# let glyph_a = layer.get_glyph("A").expect("missing glyph");
# assert_eq!(glyph_a.name().as_ref(), "A");
# let outpath = "RoflsSemiDim.ufo";
# font_obj.save(outpath);
The API may be used to access and modify data in the [Font
]:
# use norad::Font;
# let inpath = "RoflsExtraDim.ufo";
# let mut font_obj = Font::load(inpath).expect("failed to load font");
let layer = font_obj.default_layer();
let glyph_a = layer.get_glyph("A").expect("missing glyph");
assert_eq!(glyph_a.name().as_ref(), "A");
# let outpath = "RoflsSemiDim.ufo";
# font_obj.save(outpath);
Serialize the [Font
] to UFO files on disk with the [Font::save
] method:
# use norad::Font;
# let inpath = "RoflsExtraDim.ufo";
# let mut font_obj = Font::load(inpath).expect("failed to load font");
# let layer = font_obj.default_layer();
# let glyph_a = layer.get_glyph("A").expect("missing glyph");
# assert_eq!(glyph_a.name().as_ref(), "A");
let outpath = "RoflsSemiDim.ufo";
font_obj.save(outpath);
Refer to the examples
directory of the source repository
for additional source code examples.
API Documentation
Details on the full API for working with UFO fonts are available in these docs.
License
norad is licensed under the MIT and Apache v2.0 licenses.
Source
Source files are available at https://github.com/linebender/norad.
Dependencies
~3–15MB
~284K SLoC