Skip to content

Commit

Permalink
fix: strip start and end ' from font family
Browse files Browse the repository at this point in the history
  • Loading branch information
Brooooooklyn committed Aug 25, 2021
1 parent 92c60c1 commit 177e4f6
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/font.rs
Expand Up @@ -102,6 +102,13 @@ impl Font {
family: family
.split(',')
.map(|string| string.trim())
.map(|s| {
if s.starts_with('"') || s.starts_with('\'') {
unsafe { s.get_unchecked(1..s.len() - 1) }
} else {
s
}
})
.collect::<Vec<&str>>()
.join(","),
})
Expand Down Expand Up @@ -514,7 +521,15 @@ fn test_font_new() {
"50px \"Helvetica Neue\", sans-serif",
Font {
size: 50.0,
family: "\"Helvetica Neue\",sans-serif".to_owned(),
family: "Helvetica Neue,sans-serif".to_owned(),
..Default::default()
},
),
(
"100px 'Microsoft YaHei'",
Font {
size: 100.0,
family: "Microsoft YaHei".to_owned(),
..Default::default()
},
),
Expand Down

0 comments on commit 177e4f6

Please sign in to comment.