diff options
author | Rod S <rsheeter@google.com> | 2022-03-25 22:07:18 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2022-03-25 22:07:18 +0000 |
commit | 29956f91d34a6e7e114e9e04c4c22296e20b80c8 (patch) | |
tree | 98d81cb66669c50af608fd8a844e22039a00f5ae /Tests/ttLib/tables/TupleVariation_test.py | |
parent | ec30550b149d3ba5c81fc88f2f90dd171b3f4013 (diff) | |
parent | 3886b0a80e36b841df5bf1b790cfd2bb92764f15 (diff) | |
download | fonttools-29956f91d34a6e7e114e9e04c4c22296e20b80c8.tar.gz |
Update FontTools to 4.31.2 to gain access to iterSubTables. am: 0b59a54a78 am: 3e24ea754b am: 3886b0a80et_frc_odp_330442040t_frc_odp_330442000t_frc_ase_330444010android-13.0.0_r83android-13.0.0_r82android-13.0.0_r81android-13.0.0_r80android-13.0.0_r79android-13.0.0_r78android-13.0.0_r77android-13.0.0_r76android-13.0.0_r75android-13.0.0_r74android-13.0.0_r73android-13.0.0_r72android-13.0.0_r71android-13.0.0_r70android-13.0.0_r69android-13.0.0_r68android-13.0.0_r67android-13.0.0_r66android-13.0.0_r65android-13.0.0_r64android-13.0.0_r63android-13.0.0_r62android-13.0.0_r61android-13.0.0_r60android-13.0.0_r59android-13.0.0_r58android-13.0.0_r57android-13.0.0_r56android-13.0.0_r54android-13.0.0_r53android-13.0.0_r52android-13.0.0_r51android-13.0.0_r50android-13.0.0_r49android-13.0.0_r48android-13.0.0_r47android-13.0.0_r46android-13.0.0_r45android-13.0.0_r44android-13.0.0_r43android-13.0.0_r42android-13.0.0_r41android-13.0.0_r40android-13.0.0_r39android-13.0.0_r38android-13.0.0_r37android-13.0.0_r36android-13.0.0_r35android-13.0.0_r34android-13.0.0_r33android-13.0.0_r32android13-qpr3-s9-releaseandroid13-qpr3-s8-releaseandroid13-qpr3-s7-releaseandroid13-qpr3-s6-releaseandroid13-qpr3-s5-releaseandroid13-qpr3-s4-releaseandroid13-qpr3-s3-releaseandroid13-qpr3-s2-releaseandroid13-qpr3-s14-releaseandroid13-qpr3-s13-releaseandroid13-qpr3-s12-releaseandroid13-qpr3-s11-releaseandroid13-qpr3-s10-releaseandroid13-qpr3-s1-releaseandroid13-qpr3-releaseandroid13-qpr3-c-s8-releaseandroid13-qpr3-c-s7-releaseandroid13-qpr3-c-s6-releaseandroid13-qpr3-c-s5-releaseandroid13-qpr3-c-s4-releaseandroid13-qpr3-c-s3-releaseandroid13-qpr3-c-s2-releaseandroid13-qpr3-c-s12-releaseandroid13-qpr3-c-s11-releaseandroid13-qpr3-c-s10-releaseandroid13-qpr3-c-s1-releaseandroid13-qpr2-s9-releaseandroid13-qpr2-s8-releaseandroid13-qpr2-s7-releaseandroid13-qpr2-s6-releaseandroid13-qpr2-s5-releaseandroid13-qpr2-s3-releaseandroid13-qpr2-s2-releaseandroid13-qpr2-s12-releaseandroid13-qpr2-s11-releaseandroid13-qpr2-s10-releaseandroid13-qpr2-s1-releaseandroid13-qpr2-releaseandroid13-qpr2-b-s1-releaseandroid13-frc-odp-releaseandroid13-devandroid13-d4-s2-releaseandroid13-d4-s1-releaseandroid13-d4-releaseandroid13-d3-s1-release
Original change: https://android-review.googlesource.com/c/platform/external/fonttools/+/2043270
Change-Id: Ie02c14d6e2550eb53669c28030dcf2c938419d6e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
Diffstat (limited to 'Tests/ttLib/tables/TupleVariation_test.py')
-rw-r--r-- | Tests/ttLib/tables/TupleVariation_test.py | 80 |
1 files changed, 36 insertions, 44 deletions
diff --git a/Tests/ttLib/tables/TupleVariation_test.py b/Tests/ttLib/tables/TupleVariation_test.py index d7a0bc8a..99b94918 100644 --- a/Tests/ttLib/tables/TupleVariation_test.py +++ b/Tests/ttLib/tables/TupleVariation_test.py @@ -231,8 +231,7 @@ class TupleVariationTest(unittest.TestCase): [(7,4), (8,5), (9,6)]) axisTags = ["wght", "wdth"] sharedPeakIndices = { var.compileCoord(axisTags): 0x77 } - tup, deltas, _ = var.compile(axisTags, sharedPeakIndices, - sharedPoints={0,1,2}) + tup, deltas = var.compile(axisTags, sharedPeakIndices, pointData=b'') # len(deltas)=8; flags=None; tupleIndex=0x77 # embeddedPeaks=[]; intermediateCoord=[] self.assertEqual("00 08 00 77", hexencode(tup)) @@ -246,8 +245,7 @@ class TupleVariationTest(unittest.TestCase): [(7,4), (8,5), (9,6)]) axisTags = ["wght", "wdth"] sharedPeakIndices = { var.compileCoord(axisTags): 0x77 } - tup, deltas, _ = var.compile(axisTags, sharedPeakIndices, - sharedPoints={0,1,2}) + tup, deltas = var.compile(axisTags, sharedPeakIndices, pointData=b'') # len(deltas)=8; flags=INTERMEDIATE_REGION; tupleIndex=0x77 # embeddedPeak=[]; intermediateCoord=[(0.3, 0.1), (0.7, 0.9)] self.assertEqual("00 08 40 77 13 33 06 66 2C CD 39 9A", hexencode(tup)) @@ -261,8 +259,7 @@ class TupleVariationTest(unittest.TestCase): [(7,4), (8,5), (9,6)]) axisTags = ["wght", "wdth"] sharedPeakIndices = { var.compileCoord(axisTags): 0x77 } - tup, deltas, _ = var.compile(axisTags, sharedPeakIndices, - sharedPoints=None) + tup, deltas = var.compile(axisTags, sharedPeakIndices) # len(deltas)=9; flags=PRIVATE_POINT_NUMBERS; tupleIndex=0x77 # embeddedPeak=[]; intermediateCoord=[] self.assertEqual("00 09 20 77", hexencode(tup)) @@ -277,8 +274,7 @@ class TupleVariationTest(unittest.TestCase): [(7,4), (8,5), (9,6)]) axisTags = ["wght", "wdth"] sharedPeakIndices = { var.compileCoord(axisTags): 0x77 } - tuple, deltas, _ = var.compile(axisTags, - sharedPeakIndices, sharedPoints=None) + tuple, deltas = var.compile(axisTags, sharedPeakIndices) # len(deltas)=9; flags=PRIVATE_POINT_NUMBERS; tupleIndex=0x77 # embeddedPeak=[]; intermediateCoord=[(0.0, 0.0), (1.0, 1.0)] self.assertEqual("00 09 60 77 00 00 00 00 40 00 40 00", @@ -292,8 +288,7 @@ class TupleVariationTest(unittest.TestCase): var = TupleVariation( {"wght": (0.0, 0.5, 0.5), "wdth": (0.0, 0.8, 0.8)}, [(7,4), (8,5), (9,6)]) - tup, deltas, _ = var.compile(axisTags=["wght", "wdth"], - sharedCoordIndices={}, sharedPoints={0, 1, 2}) + tup, deltas = var.compile(axisTags=["wght", "wdth"], pointData=b'') # len(deltas)=8; flags=EMBEDDED_PEAK_TUPLE # embeddedPeak=[(0.5, 0.8)]; intermediateCoord=[] self.assertEqual("00 08 80 00 20 00 33 33", hexencode(tup)) @@ -305,8 +300,7 @@ class TupleVariationTest(unittest.TestCase): var = TupleVariation( {"wght": (0.0, 0.5, 0.5), "wdth": (0.0, 0.8, 0.8)}, [3, 1, 4]) - tup, deltas, _ = var.compile(axisTags=["wght", "wdth"], - sharedCoordIndices={}, sharedPoints={0, 1, 2}) + tup, deltas = var.compile(axisTags=["wght", "wdth"], pointData=b'') # len(deltas)=4; flags=EMBEDDED_PEAK_TUPLE # embeddedPeak=[(0.5, 0.8)]; intermediateCoord=[] self.assertEqual("00 04 80 00 20 00 33 33", hexencode(tup)) @@ -317,9 +311,7 @@ class TupleVariationTest(unittest.TestCase): var = TupleVariation( {"wght": (0.0, 0.5, 1.0), "wdth": (0.0, 0.8, 0.8)}, [(7,4), (8,5), (9,6)]) - tup, deltas, _ = var.compile(axisTags=["wght", "wdth"], - sharedCoordIndices={}, - sharedPoints={0, 1, 2}) + tup, deltas = var.compile(axisTags=["wght", "wdth"], pointData=b'') # len(deltas)=8; flags=EMBEDDED_PEAK_TUPLE # embeddedPeak=[(0.5, 0.8)]; intermediateCoord=[(0.0, 0.0), (1.0, 0.8)] self.assertEqual("00 08 C0 00 20 00 33 33 00 00 00 00 40 00 33 33", @@ -332,8 +324,7 @@ class TupleVariationTest(unittest.TestCase): var = TupleVariation( {"wght": (0.0, 0.5, 0.5), "wdth": (0.0, 0.8, 0.8)}, [(7,4), (8,5), (9,6)]) - tup, deltas, _ = var.compile( - axisTags=["wght", "wdth"], sharedCoordIndices={}, sharedPoints=None) + tup, deltas = var.compile(axisTags=["wght", "wdth"]) # len(deltas)=9; flags=PRIVATE_POINT_NUMBERS|EMBEDDED_PEAK_TUPLE # embeddedPeak=[(0.5, 0.8)]; intermediateCoord=[] self.assertEqual("00 09 A0 00 20 00 33 33", hexencode(tup)) @@ -346,8 +337,7 @@ class TupleVariationTest(unittest.TestCase): var = TupleVariation( {"wght": (0.0, 0.5, 0.5), "wdth": (0.0, 0.8, 0.8)}, [7, 8, 9]) - tup, deltas, _ = var.compile( - axisTags=["wght", "wdth"], sharedCoordIndices={}, sharedPoints=None) + tup, deltas = var.compile(axisTags=["wght", "wdth"]) # len(deltas)=5; flags=PRIVATE_POINT_NUMBERS|EMBEDDED_PEAK_TUPLE # embeddedPeak=[(0.5, 0.8)]; intermediateCoord=[] self.assertEqual("00 05 A0 00 20 00 33 33", hexencode(tup)) @@ -359,9 +349,7 @@ class TupleVariationTest(unittest.TestCase): var = TupleVariation( {"wght": (0.4, 0.5, 0.6), "wdth": (0.7, 0.8, 0.9)}, [(7,4), (8,5), (9,6)]) - tup, deltas, _ = var.compile( - axisTags = ["wght", "wdth"], - sharedCoordIndices={}, sharedPoints=None) + tup, deltas = var.compile(axisTags = ["wght", "wdth"]) # len(deltas)=9; # flags=PRIVATE_POINT_NUMBERS|INTERMEDIATE_REGION|EMBEDDED_PEAK_TUPLE # embeddedPeak=(0.5, 0.8); intermediateCoord=[(0.4, 0.7), (0.6, 0.9)] @@ -376,9 +364,7 @@ class TupleVariationTest(unittest.TestCase): var = TupleVariation( {"wght": (0.4, 0.5, 0.6), "wdth": (0.7, 0.8, 0.9)}, [7, 8, 9]) - tup, deltas, _ = var.compile( - axisTags = ["wght", "wdth"], - sharedCoordIndices={}, sharedPoints=None) + tup, deltas = var.compile(axisTags = ["wght", "wdth"]) # len(deltas)=5; # flags=PRIVATE_POINT_NUMBERS|INTERMEDIATE_REGION|EMBEDDED_PEAK_TUPLE # embeddedPeak=(0.5, 0.8); intermediateCoord=[(0.4, 0.7), (0.6, 0.9)] @@ -415,8 +401,8 @@ class TupleVariationTest(unittest.TestCase): self.assertEqual("7F B9 80 35", hexencode(var.compileCoord(["wght", "wdth"]))) def test_compilePoints(self): - compilePoints = lambda p: TupleVariation.compilePoints(set(p), numPointsInGlyph=999) - self.assertEqual("00", hexencode(compilePoints(range(999)))) # all points in glyph + compilePoints = lambda p: TupleVariation.compilePoints(set(p)) + self.assertEqual("00", hexencode(compilePoints(set()))) # all points in glyph self.assertEqual("01 00 07", hexencode(compilePoints([7]))) self.assertEqual("01 80 FF FF", hexencode(compilePoints([65535]))) self.assertEqual("02 01 09 06", hexencode(compilePoints([9, 15]))) @@ -488,7 +474,7 @@ class TupleVariationTest(unittest.TestCase): def test_decompilePoints_roundTrip(self): numPointsInGlyph = 500 # greater than 255, so we also exercise code path for 16-bit encoding - compile = lambda points: TupleVariation.compilePoints(points, numPointsInGlyph) + compile = lambda points: TupleVariation.compilePoints(points) decompile = lambda data: set(TupleVariation.decompilePoints_(numPointsInGlyph, data, 0, "gvar")[0]) for i in range(50): points = set(random.sample(range(numPointsInGlyph), 30)) @@ -496,18 +482,17 @@ class TupleVariationTest(unittest.TestCase): "failed round-trip decompile/compilePoints; points=%s" % points) allPoints = set(range(numPointsInGlyph)) self.assertSetEqual(allPoints, decompile(compile(allPoints))) + self.assertSetEqual(allPoints, decompile(compile(set()))) def test_compileDeltas_points(self): - var = TupleVariation({}, [(0,0), (1, 0), (2, 0), None, (4, 0), (5, 0)]) - points = {1, 2, 3, 4} + var = TupleVariation({}, [None, (1, 0), (2, 0), None, (4, 0), None]) # deltaX for points: [1, 2, 4]; deltaY for points: [0, 0, 0] - self.assertEqual("02 01 02 04 82", hexencode(var.compileDeltas(points))) + self.assertEqual("02 01 02 04 82", hexencode(var.compileDeltas())) def test_compileDeltas_constants(self): - var = TupleVariation({}, [0, 1, 2, None, 4, 5]) - cvts = {1, 2, 3, 4} + var = TupleVariation({}, [None, 1, 2, None, 4, None]) # delta for cvts: [1, 2, 4] - self.assertEqual("02 01 02 04", hexencode(var.compileDeltas(cvts))) + self.assertEqual("02 01 02 04", hexencode(var.compileDeltas())) def test_compileDeltaValues(self): compileDeltaValues = lambda values: hexencode(TupleVariation.compileDeltaValues_(values)) @@ -549,11 +534,6 @@ class TupleVariationTest(unittest.TestCase): # words, zeroes self.assertEqual("40 66 66 80", compileDeltaValues([0x6666, 0])) self.assertEqual("40 66 66 81", compileDeltaValues([0x6666, 0, 0])) - # bytes or words from floats - self.assertEqual("00 01", compileDeltaValues([1.1])) - self.assertEqual("00 02", compileDeltaValues([1.9])) - self.assertEqual("40 66 66", compileDeltaValues([0x6666 + 0.1])) - self.assertEqual("40 66 66", compileDeltaValues([0x6665 + 0.9])) def test_decompileDeltas(self): decompileDeltas = TupleVariation.decompileDeltas_ @@ -579,8 +559,12 @@ class TupleVariationTest(unittest.TestCase): self.assertListEqual(deltas, decompile(compile(deltas))) def test_compileSharedTuples(self): - # Below, the peak coordinate {"wght": 1.0, "wdth": 0.7} appears - # three times; {"wght": 1.0, "wdth": 0.8} appears twice. + # Below, the peak coordinate {"wght": 1.0, "wdth": 0.8} appears + # three times (most frequent sorted first); {"wght": 1.0, "wdth": 0.5} + # and {"wght": 1.0, "wdth": 0.7} both appears two times (tie) and + # are sorted alphanumerically to ensure determinism. + # The peak coordinate {"wght": 1.0, "wdth": 0.9} appears only once + # and is thus ignored. # Because the start and end of variation ranges is not encoded # into the shared pool, they should get ignored. deltas = [None] * 4 @@ -599,7 +583,7 @@ class TupleVariationTest(unittest.TestCase): }, deltas), TupleVariation({ "wght": (1.0, 1.0, 1.0), - "wdth": (0.3, 0.7, 1.0) + "wdth": (0.3, 0.5, 1.0) }, deltas), TupleVariation({ "wght": (1.0, 1.0, 1.0), @@ -608,11 +592,19 @@ class TupleVariationTest(unittest.TestCase): TupleVariation({ "wght": (1.0, 1.0, 1.0), "wdth": (0.3, 0.9, 1.0) - }, deltas) + }, deltas), + TupleVariation({ + "wght": (1.0, 1.0, 1.0), + "wdth": (0.4, 0.8, 1.0) + }, deltas), + TupleVariation({ + "wght": (1.0, 1.0, 1.0), + "wdth": (0.5, 0.5, 1.0) + }, deltas), ] result = compileSharedTuples(["wght", "wdth"], variations) self.assertEqual([hexencode(c) for c in result], - ["40 00 2C CD", "40 00 33 33"]) + ["40 00 33 33", "40 00 20 00", "40 00 2C CD"]) def test_decompileSharedTuples_Skia(self): sharedTuples = decompileSharedTuples( |