Skip to content

Commit

Permalink
Return ID in push_face_info
Browse files Browse the repository at this point in the history
  • Loading branch information
laurmaedje committed May 15, 2024
1 parent 0d181fb commit e2c2a43
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "fontdb"
version = "0.17.0"
version = "0.16.2" # downgraded so that the patch applies ...
authors = ["Yevhenii Reizner <[email protected]>"]
edition = "2018"
description = "A simple, in-memory font database with CSS-like queries."
Expand Down
10 changes: 6 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,9 @@ impl Database {
let n = ttf_parser::fonts_in_collection(data).unwrap_or(1);
for index in 0..n {
match parse_face_info(source.clone(), data, index) {
Ok(info) => self.push_face_info(info),
Ok(info) => {
self.push_face_info(info);
}
Err(e) => {
log::warn!(
"Failed to load a font face {} from '{}' cause {}.",
Expand Down Expand Up @@ -503,11 +505,11 @@ impl Database {
/// This method doesn't parse the `source` font.
///
/// The `id` field should be set to [`ID::dummy()`] and will be then overwritten by this method.
pub fn push_face_info(&mut self, mut info: FaceInfo) {
self.faces.insert_with_key(|k| {
pub fn push_face_info(&mut self, mut info: FaceInfo) -> ID {
ID(self.faces.insert_with_key(|k| {
info.id = ID(k);
info
});
}))
}

/// Removes a font face by `id` from the database.
Expand Down

0 comments on commit e2c2a43

Please sign in to comment.