Skip to content

Commit

Permalink
Don't track variations at default location (#38)
Browse files Browse the repository at this point in the history
For variable fonts, when all normalized coordinates are equal to 0, that is equivalent to the default location in variation space and all variation processing can be disabled.

Detect this when pushing a new shaped run and don't store the unnecessary coordinates.
  • Loading branch information
dfrg authored Apr 20, 2024
1 parent 75199b2 commit fb8a5ee
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/layout/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,10 @@ impl<B: Brush> LayoutData<B> {
let metrics = shaper.metrics();
let cluster_range = self.clusters.len()..self.clusters.len();
let coords_start = self.coords.len();
self.coords.extend_from_slice(shaper.normalized_coords());
let coords = shaper.normalized_coords();
if coords.iter().any(|coord| *coord != 0) {
self.coords.extend_from_slice(coords);
}
let coords_end = self.coords.len();
let mut run = RunData {
font_index,
Expand Down

0 comments on commit fb8a5ee

Please sign in to comment.