mirror of
https://github.com/storytold/deckcraft.git
synced 2026-12-01 18:23:52 -06:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
11fec161cc |
@@ -1215,9 +1215,8 @@ impl FontDb {
|
|||||||
fn instance(&self, family: &str, style: &str) -> Option<Arc<FontFace>> {
|
fn instance(&self, family: &str, style: &str) -> Option<Arc<FontFace>> {
|
||||||
let open = style.find('{')?;
|
let open = style.find('{')?;
|
||||||
let base = self.find(family, style[..open].trim())?;
|
let base = self.find(family, style[..open].trim())?;
|
||||||
if base.skrifa().is_none_or(|f| f.axes().is_empty()) {
|
let Some(font) = base.skrifa().filter(|f| !f.axes().is_empty()) else { return Some(base) };
|
||||||
return Some(base);
|
let axis_tags: Vec<[u8; 4]> = font.axes().iter().map(|a| a.tag().to_be_bytes()).collect();
|
||||||
}
|
|
||||||
let mut coords = base.coords.clone();
|
let mut coords = base.coords.clone();
|
||||||
for kv in style[open + 1..].trim_end_matches('}').split(',') {
|
for kv in style[open + 1..].trim_end_matches('}').split(',') {
|
||||||
let (k, v) = kv.split_once(':')?;
|
let (k, v) = kv.split_once(':')?;
|
||||||
@@ -1227,6 +1226,11 @@ impl FontDb {
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
let tag = [k[0], k[1], k[2], k[3]];
|
let tag = [k[0], k[1], k[2], k[3]];
|
||||||
|
// A tag the font has no axis for changes nothing; keeping it would grow the list with
|
||||||
|
// every distinct tag in the style text.
|
||||||
|
if !axis_tags.contains(&tag) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
match coords.iter_mut().find(|(t, _)| *t == tag) {
|
match coords.iter_mut().find(|(t, _)| *t == tag) {
|
||||||
Some(c) => c.1 = v,
|
Some(c) => c.1 = v,
|
||||||
None => coords.push((tag, v)),
|
None => coords.push((tag, v)),
|
||||||
|
|||||||
Reference in New Issue
Block a user