Skip to content

Commit

Permalink
Merge 446f566 into b2fb04a
Browse files Browse the repository at this point in the history
  • Loading branch information
madig committed Mar 16, 2022
2 parents b2fb04a + 446f566 commit cf645da
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ impl LayerSet {
/// reducing memory use.
pub(crate) fn load(base_dir: &Path, glyph_names: &NameList) -> Result<LayerSet, FontLoadError> {
let layer_contents_path = base_dir.join(LAYER_CONTENTS_FILE);
let to_load: Vec<(Name, PathBuf)> = if layer_contents_path.exists() {
let to_load: Vec<(Name, String)> = if layer_contents_path.exists() {
plist::from_file(&layer_contents_path)
.map_err(|source| FontLoadError::ParsePlist { name: LAYER_CONTENTS_FILE, source })?
} else {
vec![(Name::new_raw(DEFAULT_LAYER_NAME), PathBuf::from(DEFAULT_GLYPHS_DIRNAME))]
vec![(Name::new_raw(DEFAULT_LAYER_NAME), DEFAULT_GLYPHS_DIRNAME.into())]
};

let mut layers: Vec<_> = to_load
.into_iter()
.iter()
.map(|(name, path)| {
let layer_path = base_dir.join(&path);
Layer::load_impl(&layer_path, name.clone(), glyph_names).map_err(|source| {
Expand All @@ -70,7 +70,12 @@ impl LayerSet {
.ok_or(FontLoadError::MissingDefaultLayer)?;
layers.rotate_left(default_idx);

Ok(LayerSet { layers, path_set: HashSet::new() })
Ok(LayerSet {
layers,
path_set: HashSet::from_iter(
to_load.iter().filter(|(_, path)| path != "glyphs").map(|(_, path)| path.into()),
),
})
}

/// Returns the number of layers in the set.
Expand Down

0 comments on commit cf645da

Please sign in to comment.