예제 #1
0
    def test_explicit_default_weight(self):
        ufo = defcon.Font()
        doc, data = makeInstanceDescriptor("Regular", weight=("Regular", None, 100))

        set_weight_class(ufo, doc, data)
        # the default OS/2 weight class is set
        self.assertEqual(ufo.info.openTypeOS2WeightClass, 400)
예제 #2
0
 def test_no_weight_class(self):
     ufo = self.ufo_module.Font()
     # name here says "Bold", however no explicit weightClass
     # is assigned
     doc, instance = makeInstanceDescriptor("Bold")
     set_weight_class(ufo, doc, instance)
     # the default OS/2 weight class is set
     self.assertEqual(ufo.info.openTypeOS2WeightClass, 400)
예제 #3
0
    def test_weight_and_width_class(self):
        ufo = defcon.Font()
        doc, data = makeInstanceDescriptor("SemiCondensed ExtraBold",
                                           weight=("ExtraBold", None, 160),
                                           width=("SemiCondensed", 4, 90))

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

        self.assertEqual(ufo.info.openTypeOS2WeightClass, 800)
        self.assertEqual(ufo.info.openTypeOS2WidthClass, 4)
예제 #4
0
    def test_unknown_weight_class(self):
        ufo = self.ufo_module.Font()
        # "DemiLight" is not among the predefined weight classes listed in
        # Glyphs.app/Contents/Frameworks/GlyphsCore.framework/Versions/A/
        # Resources/weights.plist
        # NOTE It is not possible from the user interface to set a custom
        # string as instance 'weightClass' since the choice is constrained
        # by a drop-down menu.
        doc, data = makeInstanceDescriptor("DemiLight Italic",
                                           weight=("DemiLight", None, 70))

        set_weight_class(ufo, doc, data)

        # the default OS/2 weight class is set
        self.assertEqual(ufo.info.openTypeOS2WeightClass, 400)
예제 #5
0
    def test_unknown_ui_string_but_defined_weight_class(self):
        ufo = self.ufo_module.Font()
        # "DemiLight" is not among the predefined weight classes listed in
        # Glyphs.app/Contents/Frameworks/GlyphsCore.framework/Versions/A/
        # Resources/weights.plist
        # NOTE It is not possible from the user interface to set a custom
        # string as instance 'weightClass' since the choice is constrained
        # by a drop-down menu.
        doc, data = makeInstanceDescriptor("DemiLight Italic",
                                           weight=("DemiLight", 350, 70))

        set_weight_class(ufo, doc, data)

        # Here we have set the weightClass to 350 so even though the string
        # is wrong, our value of 350 should be used.
        self.assertTrue(ufo.info.openTypeOS2WeightClass == 350)
예제 #6
0
    def test_weight_class(self):
        ufo = self.ufo_module.Font()
        doc, data = makeInstanceDescriptor("Bold", weight=("Bold", None, 150))

        set_weight_class(ufo, doc, data)
        self.assertEqual(ufo.info.openTypeOS2WeightClass, 700)