From aeaf98a438dd3e9124ec7f8ae6c88cd6e8208558 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 24 May 2023 16:34:15 -0600 Subject: [PATCH] [varStore] Another fix and test --- Lib/fontTools/varLib/varStore.py | 2 +- Tests/varLib/varStore_test.py | 23 ++++++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/Lib/fontTools/varLib/varStore.py b/Lib/fontTools/varLib/varStore.py index 8321ef26b..9c0c68cec 100644 --- a/Lib/fontTools/varLib/varStore.py +++ b/Lib/fontTools/varLib/varStore.py @@ -382,7 +382,7 @@ class _Encoding(object): """Maximum possible byte gain from merging this into another characteristic.""" count = len(self.items) - return max(0, self.overhead - count * (self.width + 1)) + return max(0, self.overhead - count) def sort_key(self): return self.width, self.chars diff --git a/Tests/varLib/varStore_test.py b/Tests/varLib/varStore_test.py index 13153181b..37447c051 100644 --- a/Tests/varLib/varStore_test.py +++ b/Tests/varLib/varStore_test.py @@ -135,8 +135,29 @@ def buildAxis(axisTag): [10, 303, 0, 0, 20], [10, 304, 0, 0, 20], ], + 1, + 200, + ), + ( + 5, + [ + [0, 11, 12, 0, 20], + [0, 13, 12, 0, 20], + [0, 14, 12, 0, 20], + [0, 15, 12, 0, 20], + [0, 16, 12, 0, 20], + [0, 17, 12, 0, 20], + [0, 18, 12, 0, 20], + [0, 19, 12, 0, 20], + [0, 20, 12, 0, 20], + [10, 300, 0, 0, 20], + [10, 301, 0, 0, 20], + [10, 302, 0, 0, 20], + [10, 303, 0, 0, 20], + [10, 304, 0, 0, 20], + ], 2, - 206, + 218, ), ( 3,