Skip to content

Commit

Permalink
Auto detect generic when creating FamilyKey from str
Browse files Browse the repository at this point in the history
  • Loading branch information
declantsien committed Aug 31, 2023
1 parent 2be2a69 commit 5325841
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/layout/font/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,11 @@ pub enum FamilyKey<'a> {

impl<'a> From<&'a str> for FamilyKey<'a> {
fn from(name: &'a str) -> Self {
Self::Name(name)
if let Some(generic_family) = GenericFamily::parse(name) {
Self::Generic(generic_family)
} else {
Self::Name(name)
}
}
}

Expand Down

0 comments on commit 5325841

Please sign in to comment.