Esempio n. 1
0
    def fourStyleFamily(self, position, suffix=None):
        """
        Replaces the name table and certain OS/2 values with those that will make a four-style family.
        """
        f = self.f
        source = TTFont(fourStyleFamilySources[position])

        tf = tempfile.mkstemp()
        pathToXML = tf[1]
        source.saveXML(pathToXML, tables=['name'])
        os.close(tf[0])
        
        with open(pathToXML, "r") as temp:
            xml = temp.read()

        # make the changes
        if suffix:
            xml = xml.replace("Input", "Input" + suffix)

        # save the table
        with open(pathToXML, 'w') as temp:
            temp.write(xml)
            temp.write('\r')

        f['OS/2'].usWeightClass = source['OS/2'].usWeightClass
        f['OS/2'].fsType = source['OS/2'].fsType

        # write the table
        f['name'] = newTable('name')
        importXML(f, pathToXML)
    def fourStyleFamily(self, position, suffix=None):
        """
        Replaces the name table and certain OS/2 values with those that will make a four-style family.
        """
        f = self.f
        source = TTFont(fourStyleFamilySources[position])

        tf = tempfile.mkstemp()
        pathToXML = tf[1]
        source.saveXML(pathToXML, tables=['name'])
        os.close(tf[0])

        with open(pathToXML, "r") as temp:
            xml = temp.read()

        # make the changes
        if suffix:
            xml = xml.replace("Input", "Input" + suffix)

        # save the table
        with open(pathToXML, 'w') as temp:
            temp.write(xml)
            temp.write('\r')

        f['OS/2'].usWeightClass = source['OS/2'].usWeightClass
        f['OS/2'].fsType = source['OS/2'].fsType

        # write the table
        f['name'] = newTable('name')
        importXML(f, pathToXML)
    def changeNames(self, suffix=None):
        # this is a similar process to fourStyleFamily()

        tf = tempfile.mkstemp()
        pathToXML = tf[1]
        f.saveXML(pathToXML, tables=['name'])
        os.close(tf[0])

        with open(pathToXML, "r") as temp:
            xml = temp.read()

        # make the changes
        if suffix:
            xml = xml.replace("Input", "Input" + suffix)

        # save the table
        with open(pathToXML, 'w') as temp:
            temp.write(xml)
            temp.write('\r')

        # write the table
        f['name'] = newTable('name')
        importXML(f, pathToXML)
Esempio n. 4
0
    def changeNames(self, suffix=None):
        # this is a similar process to fourStyleFamily()
        
        tf = tempfile.mkstemp()
        pathToXML = tf[1]
        f.saveXML(pathToXML, tables=['name'])
        os.close(tf[0])
        
        with open(pathToXML, "r") as temp:
            xml = temp.read()

        # make the changes
        if suffix:
            xml = xml.replace("Input", "Input" + suffix)

        # save the table
        with open(pathToXML, 'w') as temp:
            temp.write(xml)
            temp.write('\r')
        
        # write the table
        f['name'] = newTable('name')
        importXML(f, pathToXML)