Skip to content

Commit

Permalink
Make name-to-file-name conversion functions public
Browse files Browse the repository at this point in the history
  • Loading branch information
cmyr committed Nov 30, 2022
1 parent 9a2bfbc commit 6909612
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,5 @@ pub use identifier::Identifier;
pub use kerning::Kerning;
pub use layer::{Layer, LayerSet};
pub use shared_types::{Color, Plist};
pub use util::{default_file_name_for_glyph_name, default_file_name_for_layer_name};
pub use write::{QuoteChar, WriteOptions};
14 changes: 12 additions & 2 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,22 @@ pub(crate) fn recursive_sort_plist_keys(plist: &mut plist::Dictionary) {
}

/// Given a glyph `name`, return an appropriate file name.
pub(crate) fn default_file_name_for_glyph_name(name: &Name, existing: &HashSet<String>) -> PathBuf {
///
/// This name is computed via the [Common User Name to File Name Algorithm][algo]
/// defined in the UFO spec.
///
/// [algo]: https://unifiedfontobject.org/versions/ufo3/conventions/#common-user-name-to-file-name-algorithm
pub fn default_file_name_for_glyph_name(name: &Name, existing: &HashSet<String>) -> PathBuf {
user_name_to_file_name(name, "", ".glif", existing)
}

/// Given a layer `name`, return an appropriate file name.
pub(crate) fn default_file_name_for_layer_name(name: &Name, existing: &HashSet<String>) -> PathBuf {
///
/// This name is computed via the [Common User Name to File Name Algorithm][algo]
/// defined in the UFO spec.
///
/// [algo]: https://unifiedfontobject.org/versions/ufo3/conventions/#common-user-name-to-file-name-algorithm
pub fn default_file_name_for_layer_name(name: &Name, existing: &HashSet<String>) -> PathBuf {
user_name_to_file_name(name, "glyphs.", "", existing)
}

Expand Down

0 comments on commit 6909612

Please sign in to comment.