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")
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)")
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)")
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)
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")