Beispiel #1
0
def extractFontFromUFO(pathOrFile, destination, doGlyphs=True, doInfo=True, doKerning=True, doGroups=True, doFeatures=True, doLib=True, customFunctions=[]):
    source = UFOReader(pathOrFile)
    if doInfo:
        source.readInfo(destination.info)
    if doKerning:
        kerning = source.readKerning()
        destination.kerning.update(kerning)
    if doGroups:
        groups = source.readGroups()
        destination.groups.update(groups)
    if doFeatures:
        features = source.readFeatures()
        destination.features.text = features
    if doLib:
        lib = source.readLib()
        destination.lib.update(lib)
    if doGlyphs:
        glyphSet = source.getGlyphSet()
        for glyphName in glyphSet.keys():
            destination.newGlyph(glyphName)
            glyph = destination[glyphName]
            pointPen = glyph.getPointPen()
            glyphSet.readGlyph(glyphName=glyphName, glyphObject=glyph, pointPen=pointPen)
    for function in customFunctions:
        function(source, destination)
Beispiel #2
0
def extractFontFromUFO(pathOrFile,
                       destination,
                       doGlyphs=True,
                       doInfo=True,
                       doKerning=True,
                       doGroups=True,
                       doFeatures=True,
                       doLib=True,
                       customFunctions=[]):
    source = UFOReader(pathOrFile)
    if doInfo:
        source.readInfo(destination.info)
    if doKerning:
        kerning = source.readKerning()
        destination.kerning.update(kerning)
    if doGroups:
        groups = source.readGroups()
        destination.groups.update(groups)
    if doFeatures:
        features = source.readFeatures()
        destination.features.text = features
    if doLib:
        lib = source.readLib()
        destination.lib.update(lib)
    if doGlyphs:
        glyphSet = source.getGlyphSet()
        for glyphName in glyphSet.keys():
            destination.newGlyph(glyphName)
            glyph = destination[glyphName]
            pointPen = glyph.getPointPen()
            glyphSet.readGlyph(glyphName=glyphName,
                               glyphObject=glyph,
                               pointPen=pointPen)
    for function in customFunctions:
        function(source, destination)
Beispiel #3
0
	def _loadData(self, path):
		from robofab.ufoLib import UFOReader
		reader = UFOReader(path)
		fontLib = reader.readLib()
		# info
		reader.readInfo(self.info)
		# kerning
		self.kerning.update(reader.readKerning())
		self.kerning.setChanged(False)
		# groups
		self.groups.update(reader.readGroups())
		# features
		if reader.formatVersion == 1:
			# migrate features from the lib
			features = []
			classes = fontLib.get("org.robofab.opentype.classes")
			if classes is not None:
				del fontLib["org.robofab.opentype.classes"]
				features.append(classes)
			splitFeatures = fontLib.get("org.robofab.opentype.features")
			if splitFeatures is not None:
				order = fontLib.get("org.robofab.opentype.featureorder")
				if order is None:
					order = splitFeatures.keys()
					order.sort()
				else:
					del fontLib["org.robofab.opentype.featureorder"]
				del fontLib["org.robofab.opentype.features"]
				for tag in order:
					oneFeature = splitFeatures.get(tag)
					if oneFeature is not None:
						features.append(oneFeature)
			features = "\n".join(features)
		else:
			features = reader.readFeatures()
		self.features.text = features
		# hint data
		self.psHints = PostScriptFontHintValues(self)
		if postScriptHintDataLibKey in fontLib:
			del fontLib[postScriptHintDataLibKey]
		# lib
		self.lib.update(fontLib)
		# glyphs
		self._glyphSet = reader.getGlyphSet()
		self._hasNotChanged(doGlyphs=False)
Beispiel #4
0
 def _loadData(self, path):
     from robofab.ufoLib import UFOReader
     reader = UFOReader(path)
     fontLib = reader.readLib()
     # info
     reader.readInfo(self.info)
     # kerning
     self.kerning.update(reader.readKerning())
     self.kerning.setChanged(False)
     # groups
     self.groups.update(reader.readGroups())
     # features
     if reader.formatVersion == 1:
         # migrate features from the lib
         features = []
         classes = fontLib.get("org.robofab.opentype.classes")
         if classes is not None:
             del fontLib["org.robofab.opentype.classes"]
             features.append(classes)
         splitFeatures = fontLib.get("org.robofab.opentype.features")
         if splitFeatures is not None:
             order = fontLib.get("org.robofab.opentype.featureorder")
             if order is None:
                 order = splitFeatures.keys()
                 order.sort()
             else:
                 del fontLib["org.robofab.opentype.featureorder"]
             del fontLib["org.robofab.opentype.features"]
             for tag in order:
                 oneFeature = splitFeatures.get(tag)
                 if oneFeature is not None:
                     features.append(oneFeature)
         features = "\n".join(features)
     else:
         features = reader.readFeatures()
     self.features.text = features
     # hint data
     self.psHints = PostScriptFontHintValues(self)
     if postScriptHintDataLibKey in fontLib:
         del fontLib[postScriptHintDataLibKey]
     # lib
     self.lib.update(fontLib)
     # glyphs
     self._glyphSet = reader.getGlyphSet()
     self._hasNotChanged(doGlyphs=False)