示例#1
0
    def test_width_class(self):
        ufo = defcon.Font()
        data = makeInstance("Condensed", width=("Condensed", 80))

        set_width_class(ufo, data)

        self.assertEqual(ufo.info.openTypeOS2WidthClass, 3)
        self.assertEqual(ufo.lib[WIDTH_CLASS_KEY], "Condensed")
示例#2
0
 def test_no_width_class(self):
     ufo = defcon.Font()
     # no explicit widthClass set, instance name doesn't matter
     set_width_class(ufo, makeInstance("Normal"))
     # the default OS/2 width class is set
     self.assertEqual(ufo.info.openTypeOS2WidthClass, 5)
     # non-empty value is stored in the UFO lib even if same as default
     self.assertEqual(ufo.lib[WIDTH_CLASS_KEY], "Medium (normal)")
示例#3
0
    def test_explicit_default_width(self):
        ufo = defcon.Font()
        data = makeInstance("Regular", width=("Medium (normal)", 100))

        set_width_class(ufo, data)
        # the default OS/2 width class is set
        self.assertEqual(ufo.info.openTypeOS2WidthClass, 5)
        # non-empty value is stored in the UFO lib even if same as default
        self.assertEqual(ufo.lib[WIDTH_CLASS_KEY], "Medium (normal)")
示例#4
0
 def test_no_width_class(self):
     ufo = defcon.Font()
     # no explicit widthClass set, instance name doesn't matter
     set_width_class(ufo, makeInstance("Normal"))
     # the default OS/2 width class is set
     self.assertEqual(ufo.info.openTypeOS2WidthClass, 5)
     # no value is stored in the UFO lib when instance in glyphs
     # source contains no `widthClass` (because same as default)
     self.assertTrue(WIDTH_CLASS_KEY not in ufo.lib)
示例#5
0
    def test_weight_and_width_class(self):
        ufo = defcon.Font()
        data = makeInstance("SemiCondensed ExtraBold",
                            weight=("ExtraBold", None, 160),
                            width=("SemiCondensed", 90))

        set_weight_class(ufo, data)
        set_width_class(ufo, data)

        self.assertEqual(ufo.info.openTypeOS2WeightClass, 800)
        self.assertEqual(ufo.lib[WEIGHT_CLASS_KEY], "ExtraBold")
        self.assertEqual(ufo.info.openTypeOS2WidthClass, 4)
        self.assertEqual(ufo.lib[WIDTH_CLASS_KEY], "SemiCondensed")