コード例 #1
0
 def testSaveAs(self):
     path = tempfile.mktemp(".ufo")
     try:
         keys1 = self.font.keys()
         self.font.save(path)
         keys2 = self.font.keys()
         keys1.sort()
         keys2.sort()
         self.assertEqual(keys1, keys2)
         self.assertEqual(self.font.path, path)
         font2 = RFont(path)
         keys3 = font2.keys()
         keys3.sort()
         self.assertEqual(keys1, keys3)
     finally:
         if os.path.exists(path):
             shutil.rmtree(path)
コード例 #2
0
ファイル: test_objectsUFO.py プロジェクト: SayCV/tools-FDK
	def testSaveAs(self):
		path = tempfile.mktemp(".ufo")
		try:
			keys1 = self.font.keys()
			self.font.save(path)
			keys2 = self.font.keys()
			keys1.sort()
			keys2.sort()
			self.assertEqual(keys1, keys2)
			self.assertEqual(self.font.path, path)
			font2 = RFont(path)
			keys3 = font2.keys()
			keys3.sort()
			self.assertEqual(keys1, keys3)
		finally:
			if os.path.exists(path):
				shutil.rmtree(path)
コード例 #3
0
 def afdko(self):
     import ufo2fdk
     from robofab.objects.objectsRF import RFont
     compiler = ufo2fdk.OTFCompiler()
     for infile in self.infiles:
         outfile = splitext(infile)[0] + '.otf'
         font = RFont(infile)
         compiler.compile(font, outfile, releaseMode=True)
コード例 #4
0
 def testSaveAs2(self):
     path = tempfile.mktemp(".ufo")
     # copy a glyph
     self.font["X"] = self.font["a"].copy()
     #		self.assertEqual(self.font["X"].name, "X")
     # remove a glyph
     self.font.removeGlyph("a")
     keys1 = self.font.keys()
     try:
         self.font.save(path)
         self.assertEqual(self.font.path, path)
         keys2 = self.font.keys()
         keys1.sort()
         keys2.sort()
         self.assertEqual(keys1, keys2)
         font2 = RFont(path)
         keys3 = font2.keys()
         keys3.sort()
         self.assertEqual(keys1, keys3)
     finally:
         if os.path.exists(path):
             shutil.rmtree(path)
コード例 #5
0
ファイル: test_objectsUFO.py プロジェクト: SayCV/tools-FDK
	def testSaveAs2(self):
		path = tempfile.mktemp(".ufo")
		# copy a glyph
		self.font["X"] = self.font["a"].copy()
#		self.assertEqual(self.font["X"].name, "X")
		# remove a glyph
		self.font.removeGlyph("a")
		keys1 = self.font.keys()
		try:
			self.font.save(path)
			self.assertEqual(self.font.path, path)
			keys2 = self.font.keys()
			keys1.sort()
			keys2.sort()
			self.assertEqual(keys1, keys2)
			font2 = RFont(path)
			keys3 = font2.keys()
			keys3.sort()
			self.assertEqual(keys1, keys3)
		finally:
			if os.path.exists(path):
				shutil.rmtree(path)
コード例 #6
0
def update_metadata(font):
    """
    The license bundled with the font is linewrapped. We don’t want these 
    linewraps in the metadata because font programs have dialog boxes that 
    might have another width.
    
    We leave the copyright statements in COPYING-OFL.txt as they are, but swap 
    the license text with an unlinewrapped version.
    
    README.txt is currently not linewrapped and can be embedded as is.
    """
    if exists(font):
        font_location = font
    else:
        font_location = join('..', font)

    font = RFont(font_location)

    information = contents('README.txt')
    # print information
    font.info.note = information

    f = contents('COPYING-OFL.txt')
    preamble = u"""The Open Baskerville font files are dual-licensed under the GNU GPL version 3 (GNU General Public License) and the SIL Open Font License (OFL). See 'COPYING-GPLv3.txt' and 'COPYING-OFL.txt' respectively. There is also a FAQ on the OFL (see 'COPYING-OFL-FAQ.txt').

What follows is the text of the SIL Open Font License.
___

"""
    copyright = f.split(
        '-----------------------------------------------------------')[0]
    ofl = contents('OFL-nolinewrap')
    license = preamble + copyright + ofl
    # print license
    font.info.openTypeNameLicense = license

    font.save()
コード例 #7
0
def update_metadata(font):
    """
    The license bundled with the font is linewrapped. We don’t want these 
    linewraps in the metadata because font programs have dialog boxes that 
    might have another width.
    
    We leave the copyright statements in COPYING-OFL.txt as they are, but swap 
    the license text with an unlinewrapped version.
    
    README.txt is currently not linewrapped and can be embedded as is.
    """
    if exists(font):
        font_location = font
    else:
        font_location = join('..',font)
        
    font = RFont(font_location)
    
    information = contents('README.txt')
    # print information
    font.info.note = information
    
    f = contents('COPYING-OFL.txt')
    preamble = u"""The Open Baskerville font files are dual-licensed under the GNU GPL version 3 (GNU General Public License) and the SIL Open Font License (OFL). See 'COPYING-GPLv3.txt' and 'COPYING-OFL.txt' respectively. There is also a FAQ on the OFL (see 'COPYING-OFL-FAQ.txt').

What follows is the text of the SIL Open Font License.
___

"""
    copyright = f   .split('-----------------------------------------------------------')[0]
    ofl = contents('OFL-nolinewrap')
    license = preamble + copyright + ofl
    # print license
    font.info.openTypeNameLicense = license
    
    font.save()
コード例 #8
0
ファイル: tthDupe.py プロジェクト: texervn/fontlab-scripts
def run(writeCoordinates=False):

    # Get the folder that contains the source hinting data,
    # and source font files:
    templateFolderPath = fl.GetPathName(
        "Select directory that contains the 'tthints' template file...")
    if not templateFolderPath:
        'Cancel was clicked or ESC was pressed'
        return

    tthintsFilePath = os.path.join(templateFolderPath, kTTHintsFileName)

    # Verify that the files tthints, font.pfa/ufo and font.ttf exist
    # in the folder provided:
    if not os.path.exists(tthintsFilePath):
        print "ERROR: Could not find %s file." % kTTHintsFileName
        return

    # Check if any of the possible template fonts exists -- PFA, TXT, or UFO:
    pfaFilePath = os.path.join(templateFolderPath, kPFAFileName)
    txtFilePath = os.path.join(templateFolderPath, kTXTFileName)
    ufoFilePath = os.path.join(templateFolderPath, kUFOFileName)

    if os.path.exists(pfaFilePath):
        pass
    elif os.path.exists(txtFilePath):
        pass
    elif os.path.exists(ufoFilePath):
        pass
    else:
        print "ERROR: Could not find any of the following font files: %s, %s or %s." % (
            kPFAFileName, kTXTFileName, kUFOFileName)
        return

    # Check if font.ttf exists in source folder:
    ttfFilePath = os.path.join(templateFolderPath, kTTFFileName)
    if not os.path.exists(ttfFilePath):
        print "ERROR: Could not find %s file." % kTTFFileName
        return

    # Get the (root) folder containingt the target font files:
    baseFolderPath = fl.GetPathName("Select top directory that contains the fonts to process ...")
    if not baseFolderPath:
        'Cancel was clicked or ESC key was pressed'
        return

    startTime = time.time()

    # Create a list of glyphs that have been hinted so it can be
    # used as a filter. The rawHintingDict contains a string of raw
    # hinting data for each glyph:
    glyphList, rawHintingDict = readTTHintsFile(tthintsFilePath)
    folderPathsList = getFolderPaths(baseFolderPath, templateFolderPath)

    if len(folderPathsList):
        delete_temporary_template_PFA = False
        print "Processing template files..."
        fl.Open(ttfFilePath)
        templateTTfont = fl[fl.ifont]
        if not os.path.exists(pfaFilePath) and os.path.exists(txtFilePath):
            delete_temporary_template_PFA = True
            makePFAfromTXT(txtFilePath, pfaFilePath)
        elif not os.path.exists(pfaFilePath) and os.path.exists(ufoFilePath):
            delete_temporary_template_PFA = True
            makePFAfromUFO(ufoFilePath, pfaFilePath, glyphList)
        fl.Open(pfaFilePath)
        templateT1font = fl[fl.ifont]

        # Make a Robofab font of the Type1 template font. This RB font is made
        # by copying each glyph. There does not seem to be a simpler method
        # that produces reliable results -- the challenge comes from having
        # to close the FL font downstream.
        templateT1RBfont = RFont()
        currentT1RBfont = CurrentFont()

        for gName in glyphList:
            g = currentT1RBfont[gName]
            templateT1RBfont.insertGlyph(g)

        hintedNodeDict, indexOnlyRawHintingDict, okToProcessTargetFonts = collectTemplateIndexes(
            templateTTfont, templateT1font, glyphList, rawHintingDict)
        closeAllOpenedFonts()

        if okToProcessTargetFonts:
            processTargetFonts(
                folderPathsList, templateT1RBfont, hintedNodeDict,
                glyphList, indexOnlyRawHintingDict, writeCoordinates)
        else:
            print "Can't process target fonts because of hinting errors found in template font."

        if delete_temporary_template_PFA:
            if os.path.exists(pfaFilePath):
                os.remove(pfaFilePath)

    else:
        print "Could not find suitable folders to process."

    endTime = time.time()
    elapsedSeconds = endTime-startTime

    if (elapsedSeconds/60) < 1:
        print '\nCompleted in %.1f seconds.\n' % elapsedSeconds
    else:
        print '\nCompleted in %s minutes and %s seconds.\n' % (
            elapsedSeconds/60, elapsedSeconds%60)
コード例 #9
0
 def setUp(self):
     self.font = RFont(getDemoFontPath())
コード例 #10
0
ファイル: compilers.py プロジェクト: skadisch/node-freetype2
 def afdko(self):
     import ufo2fdk
     from robofab.objects.objectsRF import RFont
     compiler = ufo2fdk.OTFCompiler()
     font = RFont(self.infile)
     compiler.compile(font, self.outfile, releaseMode=True)