Пример #1
0
 def makeTestFont(self, number):
     from robofab.objects.objectsRF import RFont as _RFont
     f = _RFont()
     f.info.familyName = "TestFamily"
     f.info.styleName = "weight%d"%number
     f.info.postscriptFullName = "%s %s"%(f.info.familyName, f.info.styleName)
     # make some glyphs
     for name in ['A', 'B', 'C']:
         g = f.newGlyph(name)
         pen = g.getPen()
         pen.moveTo((0,0))
         pen.lineTo((500, 0))
         pen.lineTo((500, 800))
         pen.lineTo((0, 800))
         pen.closePath()
     return f
Пример #2
0
 def makeTestFont(self, number):
     from robofab.objects.objectsRF import RFont as _RFont
     f = _RFont()
     f.info.familyName = "TestFamily"
     f.info.styleName = "weight%d" % number
     f.info.postscriptFullName = "%s %s" % (f.info.familyName,
                                            f.info.styleName)
     # make some glyphs
     for name in ['A', 'B', 'C']:
         g = f.newGlyph(name)
         pen = g.getPen()
         pen.moveTo((0, 0))
         pen.lineTo((500, 0))
         pen.lineTo((500, 800))
         pen.lineTo((0, 800))
         pen.closePath()
     return f
Пример #3
0
			vfbDigest = self.vfb[name]._getDigest()
			if ufoDigest != vfbDigest:
				self.updateNames.append(name)
				self.w.list.set(self.updateNames)
				self.w.list.setSelection([-1])
	
	def updateGlyph(self, name):
		print "importing", name
		self.vfb[name].clear()
		self.vfb.insertGlyph(self.ufo[name], name=name)
		self.vfb[name].width = self.ufo[name].width
		self.vfb[name].note = self.ufo[name].note
		self.vfb[name].psHints.update(self.ufo[name].psHints)
		self.vfb[name].mark = 50
		self.vfb[name].update()


if __name__ == "__main__":
	
	
	f = CurrentFont()
	ufoPath = f.path.replace(".vfb", ".ufo")
	if os.path.exists(ufoPath):
		print "there is a ufo for this font at", ufoPath
		ufo = _RFont(ufoPath)
		UpdateFromUFODialogDialog(ufo, f)
	f.update()



	print "done"
Пример #4
0
        for name in names:
            print name
            ufoDigest = self.ufo[name]._getDigest()
            vfbDigest = self.vfb[name]._getDigest()
            if ufoDigest != vfbDigest:
                self.updateNames.append(name)
                self.w.list.set(self.updateNames)
                self.w.list.setSelection([-1])

    def updateGlyph(self, name):
        print "importing", name
        self.vfb[name].clear()
        self.vfb.insertGlyph(self.ufo[name], name=name)
        self.vfb[name].width = self.ufo[name].width
        self.vfb[name].note = self.ufo[name].note
        self.vfb[name].psHints.update(self.ufo[name].psHints)
        self.vfb[name].mark = 50
        self.vfb[name].update()


if __name__ == "__main__":

    f = CurrentFont()
    ufoPath = f.path.replace(".vfb", ".ufo")
    if os.path.exists(ufoPath):
        print "there is a ufo for this font at", ufoPath
        ufo = _RFont(ufoPath)
        UpdateFromUFODialogDialog(ufo, f)
    f.update()

    print "done"
Пример #5
0
        if isMethod:
            a = getattr(obj1, attrName)()
            b = getattr(obj2, attrName)()
        else:
            a = getattr(obj1, attrName)
            b = getattr(obj2, attrName)
        if a == b and a is not None and b is not None:
            print "\tattr %s ok" % attrName, a
            return True
        else:
            print "\t?\t%s error:" % attrName, "%s:" % obj1.__class__, a, "%s:" % obj2.__class__, b
            return False

    f = OpenFont(UFOPath)
    #f = OpenFont(SFDPath)
    ref = _RFont(UFOPath)

    if False:
        print
        print "test font attributes"
        compareAttr(f, ref, "path")

        a = Set(f.keys())
        b = Set(ref.keys())
        print "glyphs in ref, not in f", b.difference(a)
        print "glyphs in f, not in ref", a.difference(b)

        print "A" in f, "A" in ref
        print f.has_key("A"), ref.has_key("A")

        print
Пример #6
0
        if isMethod:
            a = getattr(obj1, attrName)()
            b = getattr(obj2, attrName)()
        else:
            a = getattr(obj1, attrName)
            b = getattr(obj2, attrName)
        if a == b and a is not None and b is not None:
            print "\tattr %s ok"%attrName, a
            return True
        else:
            print "\t?\t%s error:"%attrName, "%s:"%obj1.__class__, a, "%s:"%obj2.__class__, b
            return False

    f = OpenFont(UFOPath)
    #f = OpenFont(SFDPath)
    ref = _RFont(UFOPath)
    
    if False:
        print
        print "test font attributes"
        compareAttr(f, ref, "path")
    
        a = Set(f.keys())
        b = Set(ref.keys())
        print "glyphs in ref, not in f", b.difference(a)
        print "glyphs in f, not in ref", a.difference(b)
    
        print "A" in f, "A" in ref
        print f.has_key("A"),  ref.has_key("A")
    
        print
Пример #7
0
def makeGlyph(glyphList, font, message, mark, saveBackup):
	# Initialize the progress bar
	tickCount = len(glyphList)
	bar = ProgressBar(message, tickCount)
	tick = 0
	
	testingFont = _RFont()
	
	for item in glyphList:
		glyphName, advanceWidth, components = item
		
		# If the font has the glyph, lots of checking is required to see if changes have been made
		if font.has_key(glyphName):
			glyph = font[glyphName]
			
			#Build new glyph for comparisons
			testingFont.newGlyph(glyphName, clear=True)
			newGlyph = testingFont[glyphName]
			newGlyphCount = 0
			while newGlyphCount < len(components):
				component, x, y = components[newGlyphCount]
				newGlyph.appendComponent(component, offset=(x,y))
				newGlyphCount = newGlyphCount+1			
			newGlyph.width = advanceWidth
			newGlyph.round()
			
			# Make digest of the new glyph
			pointPen = DigestPointPen()
			newGlyph.drawPoints(pointPen)
			newDigest = pointPen.getDigest()
			
			# Make digest of the old glyph
			pointPen = DigestPointPen()
			glyph.drawPoints(pointPen)
			oldDigest = pointPen.getDigest()
			
			# Check the advance width
			if glyph.width != advanceWidth:
				glyph.width = advanceWidth
				if mark == 1:
					glyph.mark = 200
			
			# If the digests don't match, rebuild components
			if oldDigest != newDigest:
				if saveBackup == 1:
					backupName = glyph.name + '.bkup'
					font.insertGlyph(glyph, as=backupName)
					font[backupName].update()
				glyph.clearComponents()
				count = 0
				while count < len(components):
					component, x, y = components[count]
					glyph.appendComponent(component, offset=(x,y))
					count = count+1
				if mark == 1:
					glyph.mark = 200
			
			# Clean up things
			glyph.update()
			bar.tick(tick)
			tick = tick+1
		
		# If the glyph is not in the font, build a new glyph
		else:
			font.newGlyph(glyphName, clear=True)
			glyph = font[glyphName]
			glyph.width = advanceWidth
			count = 0
			while count < len(components):
				component, x, y = components[count]
				glyph.appendComponent(component, offset=(x,y))
				count = count+1
			if mark == 1:
				glyph.mark = 300
			glyph.update()
			bar.tick(tick)
			tick = tick+1
	
	font.update()
	testingFont.close()
	bar.close()