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 Sep 1, 2023
1 parent 0dd12fd commit d32eb19
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 d32eb19

Please sign in to comment.