From fb8a5eef25d4f70c25f8d1498d371eaafc6d51a6 Mon Sep 17 00:00:00 2001 From: Chad Brokaw Date: Sat, 20 Apr 2024 14:33:10 -0400 Subject: [PATCH] Don't track variations at default location (#38) 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. --- src/layout/data.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/layout/data.rs b/src/layout/data.rs index ac6ca617..640e88dd 100644 --- a/src/layout/data.rs +++ b/src/layout/data.rs @@ -248,7 +248,10 @@ impl LayoutData { 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,