Skip to content

Commit

Permalink
fix: do not split TextMetrics if theres nothing to split
Browse files Browse the repository at this point in the history
  • Loading branch information
zimond committed May 30, 2024
1 parent 2f2dcca commit e44deba
Show file tree
Hide file tree
Showing 2 changed files with 9 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 = "fontkit"
version = "0.6.0-beta.2"
version = "0.6.0-beta.3"
edition = "2021"
authors = ["Zimon Dai <[email protected]>"]
description = "A simple library for font loading and indexing"
Expand Down
12 changes: 8 additions & 4 deletions src/metrics/compose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -563,10 +563,14 @@ impl TextMetrics {
drop(positions);
// Split here, create a new span
let mut new_metrics = self.clone();
new_metrics.positions = {
let mut p = self.positions.write().unwrap();
Arc::new(RwLock::new(p.split_off(real_index)))
};
if real_index == 0 {
new_metrics.positions = Arc::new(RwLock::new(vec![]));
} else {
new_metrics.positions = {
let mut p = self.positions.write().unwrap();
Arc::new(RwLock::new(p.split_off(real_index)))
};
}
new_metrics
}
}

0 comments on commit e44deba

Please sign in to comment.