Skip to content

Commit

Permalink
fix: consistently use family_name / font_name
Browse files Browse the repository at this point in the history
  • Loading branch information
tomcur committed Jul 24, 2024
1 parent 8500e14 commit 7741983
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions font-enumeration/src/core_text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ pub fn all_fonts() -> Result<Box<[OwnedFont]>, Error> {
.iter()
.filter_map(|font| {
Some(OwnedFont {
family: font.family_name(),
name: font.font_name(),
family_name: font.family_name(),
font_name: font.font_name(),
path: font.font_path()?,
})
})
Expand Down
4 changes: 2 additions & 2 deletions font-enumeration/src/fontconfig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ pub fn all_fonts() -> Result<Box<[OwnedFont]>, Error> {
let path = font.get_string(fontconfig::FC_FILE)?;

Some(OwnedFont {
family: family.to_owned(),
name: name.to_owned(),
family_name: family.to_owned(),
font_name: name.to_owned(),
path: PathBuf::from(path),
})
})
Expand Down
16 changes: 8 additions & 8 deletions font-enumeration/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,18 @@ impl Collection {

pub fn all<'c>(&'c self) -> impl Iterator<Item = Font<'c>> {
self.all_fonts.iter().map(move |font| Font {
family: &font.family,
name: &font.name,
family_name: &font.family_name,
font_name: &font.font_name,
path: &font.path,
})
}

pub fn by_family<'c, 'f>(&'c self, family: &'f str) -> impl Iterator<Item = Font<'c>> + 'f
pub fn by_family<'c, 'f>(&'c self, family_name: &'f str) -> impl Iterator<Item = Font<'c>> + 'f
where
'c: 'f,
{
self.all()
.filter(|font| utils::case_insensitive_match(font.family, family))
.filter(|font| utils::case_insensitive_match(font.family_name, family_name))
}

pub fn take(self) -> Vec<OwnedFont> {
Expand All @@ -57,15 +57,15 @@ impl Collection {

#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct Font<'c> {
pub family: &'c str,
pub name: &'c str,
pub family_name: &'c str,
pub font_name: &'c str,
pub path: &'c Path,
}

#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct OwnedFont {
family: String,
name: String,
family_name: String,
font_name: String,
path: PathBuf,
}

Expand Down

0 comments on commit 7741983

Please sign in to comment.