Update fontdb dependency to version 0.13
This commit is contained in:
parent
4ac5e1c6a6
commit
2c1d564d62
6 changed files with 24 additions and 11 deletions
|
|
@ -9,7 +9,7 @@ documentation = "https://docs.rs/cosmic-text/latest/cosmic_text/"
|
||||||
repository = "https://github.com/pop-os/cosmic-text"
|
repository = "https://github.com/pop-os/cosmic-text"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
fontdb = { version = "0.10.0", default-features = false }
|
fontdb = { version = "0.13.0", default-features = false }
|
||||||
libm = "0.2.6"
|
libm = "0.2.6"
|
||||||
log = "0.4.17"
|
log = "0.4.17"
|
||||||
ouroboros = "0.15.5"
|
ouroboros = "0.15.5"
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ impl<'a> FontFallbackIter<'a> {
|
||||||
"Failed to find preset fallback for {:?} locale '{}', used '{}': '{}'",
|
"Failed to find preset fallback for {:?} locale '{}', used '{}': '{}'",
|
||||||
self.scripts,
|
self.scripts,
|
||||||
self.locale,
|
self.locale,
|
||||||
font.info.family,
|
font.name(),
|
||||||
word
|
word
|
||||||
);
|
);
|
||||||
} else if !self.scripts.is_empty() && self.common_i > 0 {
|
} else if !self.scripts.is_empty() && self.common_i > 0 {
|
||||||
|
|
@ -95,7 +95,7 @@ impl<'a> Iterator for FontFallbackIter<'a> {
|
||||||
self.default_i += 1;
|
self.default_i += 1;
|
||||||
|
|
||||||
for font in self.fonts.iter() {
|
for font in self.fonts.iter() {
|
||||||
if font.info.family == default_family {
|
if font.contains_family(default_family) {
|
||||||
return Some(font);
|
return Some(font);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -109,7 +109,7 @@ impl<'a> Iterator for FontFallbackIter<'a> {
|
||||||
let script_family = script_families[self.script_i.1];
|
let script_family = script_families[self.script_i.1];
|
||||||
self.script_i.1 += 1;
|
self.script_i.1 += 1;
|
||||||
for font in self.fonts.iter() {
|
for font in self.fonts.iter() {
|
||||||
if font.info.family == script_family {
|
if font.contains_family(script_family) {
|
||||||
return Some(font);
|
return Some(font);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -130,7 +130,7 @@ impl<'a> Iterator for FontFallbackIter<'a> {
|
||||||
let common_family = common_families[self.common_i];
|
let common_family = common_families[self.common_i];
|
||||||
self.common_i += 1;
|
self.common_i += 1;
|
||||||
for font in self.fonts.iter() {
|
for font in self.fonts.iter() {
|
||||||
if font.info.family == common_family {
|
if font.contains_family(common_family) {
|
||||||
return Some(font);
|
return Some(font);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -143,7 +143,10 @@ impl<'a> Iterator for FontFallbackIter<'a> {
|
||||||
while self.other_i < self.fonts.len() {
|
while self.other_i < self.fonts.len() {
|
||||||
let font = &self.fonts[self.other_i];
|
let font = &self.fonts[self.other_i];
|
||||||
self.other_i += 1;
|
self.other_i += 1;
|
||||||
if !forbidden_families.contains(&font.info.family.as_str()) {
|
if forbidden_families
|
||||||
|
.iter()
|
||||||
|
.all(|family| !font.contains_family(family))
|
||||||
|
{
|
||||||
return Some(font);
|
return Some(font);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,18 @@ impl<'a> Font<'a> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn name(&self) -> &str {
|
||||||
|
if let Some((name, _)) = self.info.families.first() {
|
||||||
|
name
|
||||||
|
} else {
|
||||||
|
&self.info.post_script_name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn contains_family(&self, family: &str) -> bool {
|
||||||
|
self.info.families.iter().any(|(name, _)| name == family)
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(feature = "swash")]
|
#[cfg(feature = "swash")]
|
||||||
pub fn as_swash(&self) -> swash::FontRef {
|
pub fn as_swash(&self) -> swash::FontRef {
|
||||||
swash::FontRef {
|
swash::FontRef {
|
||||||
|
|
|
||||||
|
|
@ -44,8 +44,7 @@ impl FontSystem {
|
||||||
let now = std::time::Instant::now();
|
let now = std::time::Instant::now();
|
||||||
|
|
||||||
//TODO only do this on demand!
|
//TODO only do this on demand!
|
||||||
for i in 0..db.faces().len() {
|
for id in db.faces().map(|face| face.id).collect::<Vec<_>>() {
|
||||||
let id = db.faces()[i].id;
|
|
||||||
unsafe {
|
unsafe {
|
||||||
db.make_shared_face_data(id);
|
db.make_shared_face_data(id);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -75,8 +75,7 @@ impl FontSystem {
|
||||||
let now = std::time::Instant::now();
|
let now = std::time::Instant::now();
|
||||||
|
|
||||||
//TODO only do this on demand!
|
//TODO only do this on demand!
|
||||||
for i in 0..db.faces().len() {
|
for id in db.faces().map(|face| face.id).collect::<Vec<_>>() {
|
||||||
let id = db.faces()[i].id;
|
|
||||||
unsafe {
|
unsafe {
|
||||||
db.make_shared_face_data(id);
|
db.make_shared_face_data(id);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -149,7 +149,7 @@ fn shape_run(
|
||||||
None => break,
|
None => break,
|
||||||
};
|
};
|
||||||
|
|
||||||
log::trace!("Evaluating fallback with font '{}'", font.info.family);
|
log::trace!("Evaluating fallback with font '{}'", font.name());
|
||||||
let (mut fb_glyphs, fb_missing) =
|
let (mut fb_glyphs, fb_missing) =
|
||||||
shape_fallback(font, line, attrs_list, start_run, end_run, span_rtl);
|
shape_fallback(font, line, attrs_list, start_run, end_run, span_rtl);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue