def test_write_alignment_zone(self): zone = classes.GSAlignmentZone(23, 40) self.assertWritesValue(zone, '"{23, 40}"')
def test_write_font_master_attributes(self): """Test the writer on all GSFontMaster attributes""" master = classes.GSFontMaster() # List of properties from https://docu.glyphsapp.com/#gsfontmaster # id master.id = "MASTER-ID" # name # Cannot set the `name` attribute directly # master.name = "Hairline Megawide" master.customParameters['Master Name'] = "Hairline Megawide" # weight master.weight = "Thin" # width master.width = "Wide" # weightValue master.weightValue = 0.01 # widthValue master.widthValue = 0.99 # customValue # customName master.customName = "cuteness" # A value of 0.0 is not written to the file. master.customValue = 0.001 master.customName1 = "color" master.customValue1 = 0.1 master.customName2 = "depth" master.customValue2 = 0.2 master.customName3 = "surealism" master.customValue3 = 0.3 # ascender master.ascender = 234.5 # capHeight master.capHeight = 200.6 # xHeight master.xHeight = 59.1 # descender master.descender = -89.2 # italicAngle master.italicAngle = 12.2 # verticalStems master.verticalStems = [1, 2, 3] # horizontalStems master.horizontalStems = [4, 5, 6] # alignmentZones zone = classes.GSAlignmentZone(0, -30) master.alignmentZones = [ zone ] # blueValues: not handled because it is read-only # otherBlues: not handled because it is read-only # guides guide = classes.GSGuideLine() guide.name = "middle" master.guides.append(guide) # userData master.userData['rememberToMakeTea'] = True # customParameters master.customParameters['underlinePosition'] = -135 self.assertWrites(master, dedent("""\ { alignmentZones = ( "{0, -30}" ); ascender = 234.5; capHeight = 200.6; custom = cuteness; customValue = 0.001; custom1 = color; customValue1 = 0.1; custom2 = depth; customValue2 = 0.2; custom3 = surealism; customValue3 = 0.3; customParameters = ( { name = "Master Name"; value = "Hairline Megawide"; }, { name = underlinePosition; value = -135; } ); descender = -89.2; guideLines = ( { name = middle; } ); horizontalStems = ( 4, 5, 6 ); id = "MASTER-ID"; italicAngle = 12.2; name = "Hairline Megawide"; userData = { rememberToMakeTea = 1; }; verticalStems = ( 1, 2, 3 ); weight = Thin; weightValue = 0.01; width = Wide; widthValue = 0.99; xHeight = 59.1; } """)) # Write the capHeight and xHeight even if they are "0" master.xHeight = 0 master.capHeight = 0 written = test_helpers.write_to_lines(master) self.assertIn("xHeight = 0;", written) self.assertIn("capHeight = 0;", written)