本文整理汇总了Python中fontTools.ttLib.tables.TupleVariation.TupleVariation.compileDeltaValues_方法的典型用法代码示例。如果您正苦于以下问题:Python TupleVariation.compileDeltaValues_方法的具体用法?Python TupleVariation.compileDeltaValues_怎么用?Python TupleVariation.compileDeltaValues_使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fontTools.ttLib.tables.TupleVariation.TupleVariation
的用法示例。
在下文中一共展示了TupleVariation.compileDeltaValues_方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_compileDeltaValues
# 需要导入模块: from fontTools.ttLib.tables.TupleVariation import TupleVariation [as 别名]
# 或者: from fontTools.ttLib.tables.TupleVariation.TupleVariation import compileDeltaValues_ [as 别名]
def test_compileDeltaValues(self):
compileDeltaValues = lambda values: hexencode(TupleVariation.compileDeltaValues_(values))
# zeroes
self.assertEqual("80", compileDeltaValues([0]))
self.assertEqual("BF", compileDeltaValues([0] * 64))
self.assertEqual("BF 80", compileDeltaValues([0] * 65))
self.assertEqual("BF A3", compileDeltaValues([0] * 100))
self.assertEqual("BF BF BF BF", compileDeltaValues([0] * 256))
# bytes
self.assertEqual("00 01", compileDeltaValues([1]))
self.assertEqual("06 01 02 03 7F 80 FF FE", compileDeltaValues([1, 2, 3, 127, -128, -1, -2]))
self.assertEqual("3F" + (64 * " 7F"), compileDeltaValues([127] * 64))
self.assertEqual("3F" + (64 * " 7F") + " 00 7F", compileDeltaValues([127] * 65))
# words
self.assertEqual("40 66 66", compileDeltaValues([0x6666]))
self.assertEqual("43 66 66 7F FF FF FF 80 00", compileDeltaValues([0x6666, 32767, -1, -32768]))
self.assertEqual("7F" + (64 * " 11 22"), compileDeltaValues([0x1122] * 64))
self.assertEqual("7F" + (64 * " 11 22") + " 40 11 22", compileDeltaValues([0x1122] * 65))
# bytes, zeroes, bytes: a single zero is more compact when encoded as part of the bytes run
self.assertEqual("04 7F 7F 00 7F 7F", compileDeltaValues([127, 127, 0, 127, 127]))
self.assertEqual("01 7F 7F 81 01 7F 7F", compileDeltaValues([127, 127, 0, 0, 127, 127]))
self.assertEqual("01 7F 7F 82 01 7F 7F", compileDeltaValues([127, 127, 0, 0, 0, 127, 127]))
self.assertEqual("01 7F 7F 83 01 7F 7F", compileDeltaValues([127, 127, 0, 0, 0, 0, 127, 127]))
# bytes, zeroes
self.assertEqual("01 01 00", compileDeltaValues([1, 0]))
self.assertEqual("00 01 81", compileDeltaValues([1, 0, 0]))
# words, bytes, words: a single byte is more compact when encoded as part of the words run
self.assertEqual("42 66 66 00 02 77 77", compileDeltaValues([0x6666, 2, 0x7777]))
self.assertEqual("40 66 66 01 02 02 40 77 77", compileDeltaValues([0x6666, 2, 2, 0x7777]))
# words, zeroes, words
self.assertEqual("40 66 66 80 40 77 77", compileDeltaValues([0x6666, 0, 0x7777]))
self.assertEqual("40 66 66 81 40 77 77", compileDeltaValues([0x6666, 0, 0, 0x7777]))
self.assertEqual("40 66 66 82 40 77 77", compileDeltaValues([0x6666, 0, 0, 0, 0x7777]))
# words, zeroes, bytes
self.assertEqual("40 66 66 80 02 01 02 03", compileDeltaValues([0x6666, 0, 1, 2, 3]))
self.assertEqual("40 66 66 81 02 01 02 03", compileDeltaValues([0x6666, 0, 0, 1, 2, 3]))
self.assertEqual("40 66 66 82 02 01 02 03", compileDeltaValues([0x6666, 0, 0, 0, 1, 2, 3]))
# 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]))