Skip to content

Commit

Permalink
Merge pull request #94 from geieredgar/updates
Browse files Browse the repository at this point in the history
Update `fontdb` and `rustybuzz` dependency
  • Loading branch information
jackpot51 authored Mar 5, 2023
2 parents 28d8f59 + 81ecd49 commit 1bc198f
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ documentation = "https://docs.rs/cosmic-text/latest/cosmic_text/"
repository = "https://github.com/pop-os/cosmic-text"

[dependencies]
fontdb = { version = "0.10.0", default-features = false }
fontdb = { version = "0.13.0", default-features = false }
libm = "0.2.6"
log = "0.4.17"
ouroboros = "0.15.5"
rustybuzz = { version = "0.6.0", default-features = false, features = ["libm"] }
rustybuzz = { version = "0.7.0", default-features = false, features = ["libm"] }
swash = { version = "0.1.6", optional = true }
syntect = { version = "5.0.0", optional = true }
sys-locale = { version = "0.2.3", optional = true }
Expand Down
1 change: 1 addition & 0 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ allow = [
"Apache-2.0",
"Unicode-DFS-2016",
"BSD-2-Clause",
"Zlib",
#"Apache-2.0 WITH LLVM-exception",
]
# List of explicitly disallowed licenses
Expand Down
13 changes: 8 additions & 5 deletions src/font/fallback/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl<'a> FontFallbackIter<'a> {
"Failed to find preset fallback for {:?} locale '{}', used '{}': '{}'",
self.scripts,
self.locale,
font.info.family,
font.name(),
word
);
} else if !self.scripts.is_empty() && self.common_i > 0 {
Expand All @@ -95,7 +95,7 @@ impl<'a> Iterator for FontFallbackIter<'a> {
self.default_i += 1;

for font in self.fonts.iter() {
if font.info.family == default_family {
if font.contains_family(default_family) {
return Some(font);
}
}
Expand All @@ -109,7 +109,7 @@ impl<'a> Iterator for FontFallbackIter<'a> {
let script_family = script_families[self.script_i.1];
self.script_i.1 += 1;
for font in self.fonts.iter() {
if font.info.family == script_family {
if font.contains_family(script_family) {
return Some(font);
}
}
Expand All @@ -130,7 +130,7 @@ impl<'a> Iterator for FontFallbackIter<'a> {
let common_family = common_families[self.common_i];
self.common_i += 1;
for font in self.fonts.iter() {
if font.info.family == common_family {
if font.contains_family(common_family) {
return Some(font);
}
}
Expand All @@ -143,7 +143,10 @@ impl<'a> Iterator for FontFallbackIter<'a> {
while self.other_i < self.fonts.len() {
let font = &self.fonts[self.other_i];
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);
}
}
Expand Down
12 changes: 12 additions & 0 deletions src/font/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
pub fn as_swash(&self) -> swash::FontRef {
swash::FontRef {
Expand Down
3 changes: 1 addition & 2 deletions src/font/system/redox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ impl FontSystem {
let now = std::time::Instant::now();

//TODO only do this on demand!
for i in 0..db.faces().len() {
let id = db.faces()[i].id;
for id in db.faces().map(|face| face.id).collect::<Vec<_>>() {
unsafe {
db.make_shared_face_data(id);
}
Expand Down
3 changes: 1 addition & 2 deletions src/font/system/std.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ impl FontSystem {
let now = std::time::Instant::now();

//TODO only do this on demand!
for i in 0..db.faces().len() {
let id = db.faces()[i].id;
for id in db.faces().map(|face| face.id).collect::<Vec<_>>() {
unsafe {
db.make_shared_face_data(id);
}
Expand Down
2 changes: 1 addition & 1 deletion src/shape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ fn shape_run(
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) =
shape_fallback(font, line, attrs_list, start_run, end_run, span_rtl);

Expand Down

0 comments on commit 1bc198f

Please sign in to comment.