This file is indexed.

/usr/lib/python2.7/dist-packages/FontTools/fontTools/ttLib/tables/_a_v_a_r_test.py is in fonttools 3.0-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
from __future__ import print_function, division, absolute_import, unicode_literals
from fontTools.misc.py23 import *
from fontTools.misc.textTools import deHexStr
from fontTools.misc.xmlWriter import XMLWriter
from fontTools.ttLib import TTLibError
from fontTools.ttLib.tables._a_v_a_r import table__a_v_a_r
from fontTools.ttLib.tables._f_v_a_r import table__f_v_a_r, Axis
import collections
import unittest


TEST_DATA = deHexStr(
    "00 01 00 00 00 00 00 02 "
    "00 04 C0 00 C0 00 00 00 00 00 13 33 33 33 40 00 40 00 "
    "00 03 C0 00 C0 00 00 00 00 00 40 00 40 00")


class AxisVariationTableTest(unittest.TestCase):
    def test_compile(self):
        avar = table__a_v_a_r()
        avar.segments["wdth"] = {-1.0: -1.0, 0.0: 0.0, 0.3: 0.8, 1.0: 1.0}
        avar.segments["wght"] = {-1.0: -1.0, 0.0: 0.0, 1.0: 1.0}
        self.assertEqual(TEST_DATA, avar.compile(self.makeFont(["wdth", "wght"])))

    def test_decompile(self):
        avar = table__a_v_a_r()
        avar.decompile(TEST_DATA, self.makeFont(["wdth", "wght"]))
        self.assertEqual({
            "wdth": {-1.0: -1.0, 0.0: 0.0, 0.3: 0.8, 1.0: 1.0},
            "wght": {-1.0: -1.0, 0.0: 0.0, 1.0: 1.0}
        }, avar.segments)

    def test_decompile_unsupportedVersion(self):
        avar = table__a_v_a_r()
        font = self.makeFont(["wdth", "wght"])
        self.assertRaises(TTLibError, avar.decompile, deHexStr("02 01 03 06 00 00 00 00"), font)

    def test_toXML(self):
        avar = table__a_v_a_r()
        avar.segments["opsz"] = {-1.0: -1.0, 0.0: 0.0, 0.3: 0.8, 1.0: 1.0}
        writer = XMLWriter(BytesIO())
        avar.toXML(writer, self.makeFont(["opsz"]))
        self.assertEqual([
            '<segment axis="opsz">',
                '<mapping from="-1.0" to="-1.0"/>',
                '<mapping from="0.0" to="0.0"/>',
                '<mapping from="0.3" to="0.8"/>',
                '<mapping from="1.0" to="1.0"/>',
            '</segment>'
        ], self.xml_lines(writer))

    def test_fromXML(self):
        avar = table__a_v_a_r()
        avar.fromXML("segment", {"axis":"wdth"}, [
                ("mapping", {"from": "-1.0", "to": "-1.0"}, []),
                ("mapping", {"from": "0.0", "to": "0.0"}, []),
                ("mapping", {"from": "0.7", "to": "0.2"}, []),
                ("mapping", {"from": "1.0", "to": "1.0"}, [])
                ], ttFont=None)
        self.assertEqual({"wdth": {-1: -1, 0: 0, 0.7: 0.2, 1.0: 1.0}}, avar.segments)

    def test_fixupSegments(self):
        avar = table__a_v_a_r()
        avar.segments = {"wdth": {0.3: 0.8, 1.0: 0.7}}
        warnings = []
        avar.fixupSegments_(lambda w: warnings.append(w))
        self.assertEqual({"wdth": {-1.0: -1.0, 0.0: 0.0, 0.3: 0.8, 1.0: 1.0}}, avar.segments)
        self.assertEqual([
                "avar axis 'wdth' should map -1.0 to -1.0",
                "avar axis 'wdth' should map 0.0 to 0.0",
                "avar axis 'wdth' should map 1.0 to 1.0"
        ], warnings)

    @staticmethod
    def makeFont(axisTags):
        """['opsz', 'wdth'] --> ttFont"""
        fvar = table__f_v_a_r()
        for tag in axisTags:
            axis = Axis()
            axis.axisTag = tag
            fvar.axes.append(axis)
        return {"fvar": fvar}

    @staticmethod
    def xml_lines(writer):
        content = writer.file.getvalue().decode("utf-8")
        return [line.strip() for line in content.splitlines()][1:]


if __name__ == "__main__":
    unittest.main()