From b72a8da045e69ac6f933edffd79b935f9d2f4430 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 24 May 2023 13:21:33 -0600 Subject: [PATCH] [varStore] Adjust encoding overhead in optimize() Previously we were not accounting for the LOffset to VarData. --- Lib/fontTools/varLib/varStore.py | 4 ++-- Tests/varLib/varStore_test.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Lib/fontTools/varLib/varStore.py b/Lib/fontTools/varLib/varStore.py index 251805e3f..4d7becb70 100644 --- a/Lib/fontTools/varLib/varStore.py +++ b/Lib/fontTools/varLib/varStore.py @@ -406,7 +406,7 @@ class _Encoding(object): def _characteristic_overhead(chars): """Returns overhead in bytes of encoding this characteristic as a VarData.""" - c = 6 + c = 4 + 6 # 4 bytes for LOffset, 6 bytes for VarData header while chars: if chars & 0b1111: c += 2 @@ -485,7 +485,7 @@ def VarStore_optimize(self, use_NO_VARIATION_INDEX=True): # # Each encoding as such has a number of "active" (ie. non-zero) # columns. The overhead of encoding the characteristic bitmap - # is 6 bytes, plus 2 bytes per active column. + # is 10 bytes, plus 2 bytes per active column. # # When an encoding is merged into another one, if the characteristic # of the old encoding is a subset of the new one, then the overhead diff --git a/Tests/varLib/varStore_test.py b/Tests/varLib/varStore_test.py index b06ae0215..b78ce47f8 100644 --- a/Tests/varLib/varStore_test.py +++ b/Tests/varLib/varStore_test.py @@ -105,8 +105,8 @@ def buildAxis(axisTag): [10, 13, 0, 0, 20], {3: 300}, ], - 2, - 186, + 1, + 175, ), ( 5,