Exemplo n.º 1
0
    def drawRect(pen, x, y, size=50):
        pen.moveTo((x-.5*size, y-.5*size))
        pen.lineTo((x+.5*size, y-.5*size))
        pen.lineTo((x+.5*size, y+.5*size))
        pen.lineTo((x-.5*size, y+.5*size))
        pen.closePath()
 
    # the size of the raster unit
    resolution = 30
 
    # draw from top to bottom
    yValues = range(int(yMin), int(yMax), resolution)
    yValues.reverse()
 
    # go for it!
    for y in yValues:
        for x in range(int(xMin), int(xMax), resolution):
            # check the source glyph is white or black at x,y
            if source.pointInside((x, y)):
                drawRect(myPen, x, y, resolution-5)
        # update for each line if you like the animation
        # otherwise move the update() out of the loop
        dest.update()
        print dest
    
    source = f.newGlyph(sourceGlyph, clear=True)
    source.appendGlyph(dest)

f.removeGlyph('silly')
f.update()
listTemp = [] 
for i in listOne:
	listTemp.append(i + ".temp")

l = len(listOne)

def setGlyphNames(listA, listB):
	i = 0
	while i < l:
		g = f[listA[i]]
		g.name = listB[i]
		g.update()
		g.autoUnicodes()
		g.update()
		i = i+1
		
if len(listOne) == len(listTwo):
	setGlyphNames(listOne, listTemp) # a -> a.temp
	setGlyphNames(listTwo, listOne)  # A -> a
	setGlyphNames(listTemp, listTwo) # a.temp -> A
	f.update
	print 'Done! %d pairs of glyphs swapped.' % l
else:
	print "Can't run. Lists are not equal."

for i in listTwo:
    f.removeGlyph(i)
    
print ''
print 'Digested by Python.'
#exemption = 'zero.tzero'
		#Generate string from anchor points of contours in copy
		origBlob = "0"
		for contour in copy:
			for eachPoint in contour.bPoints:
				for eachAnchor in eachPoint.anchor:
					origBlob += `eachAnchor`
		oneHash = hash(origBlob)

		#Generate string from anchor points of contours in copyTwo
		copyBlob = "0"
		for contour in copyTwo:
			for eachPoint in contour.bPoints:
				for eachAnchor in eachPoint.anchor:
					copyBlob += `eachAnchor`
		#print blob
		twoHash = hash(copyBlob)

		#Mark glyph red if it contains overlaps
		if oneHash != twoHash:
			glyph.mark = 255

		#Delete the copies
		nameOne = copy.name
		nameTwo = copyTwo.name
		font.removeGlyph(nameOne)
		font.removeGlyph(nameTwo)

font.update()
print "Finished checking for and marking overlaps."
Exemplo n.º 4
0
# rename the selected glyphs
# in the current font to <glyphname>.sc
 
from robofab.world import CurrentFont
f = CurrentFont()
 
for g in f:
    if g.selected == 0:
        continue
    newName = g.name+".sc"
    print "moving", g.name, "to", newName
    f.insertGlyph(g, name=newName)
    f.removeGlyph(g.name)
    f.update()
Exemplo n.º 5
0
# http://github.com/typedev

from robofab.world import CurrentFont

s = 'space exclam quotesingle quotedbl numbersign dollar percent ampersand parenleft parenright asterisk plus comma hyphen period slash zero one two three four five six seven eight nine colon semicolon less equal greater question at A B C D E F G H I J K L M N O P Q R S T U V W X Y Z bracketleft backslash bracketright asciicircum underscore grave a b c d e f g h i j k l m n o p q r s t u v w x y z braceleft bar braceright asciitilde exclamdown cent sterling currency yen brokenbar section dieresis copyright ordfeminine guillemotleft logicalnot registered macron degree plusminus twosuperior threesuperior acute mu paragraph periodcentered cedilla onesuperior ordmasculine guillemotright onequarter onehalf threequarters questiondown Agrave Aacute Acircumflex Atilde Adieresis Aring AE Ccedilla Egrave Eacute Ecircumflex Edieresis Igrave Iacute Icircumflex Idieresis Eth Ntilde Ograve Oacute Ocircumflex Otilde Odieresis multiply Oslash Ugrave Uacute Ucircumflex Udieresis Yacute Thorn germandbls agrave aacute acircumflex atilde adieresis aring ae ccedilla egrave eacute ecircumflex edieresis igrave iacute icircumflex idieresis eth ntilde ograve oacute ocircumflex otilde odieresis divide oslash ugrave uacute ucircumflex udieresis yacute thorn ydieresis dotlessi circumflex caron breve dotaccent ring ogonek tilde hungarumlaut quoteleft quoteright minus u00A0|00A0 afii10017 afii10018 afii10019 afii10020 afii10021 afii10022 afii10023 afii10024 afii10025 afii10026 afii10027 afii10028 afii10029 afii10030 afii10031 afii10032 afii10033 afii10034 afii10035 afii10036 afii10037 afii10038 afii10039 afii10040 afii10041 afii10042 afii10043 afii10044 afii10045 afii10046 afii10047 afii10048 afii10049 afii10065 afii10066 afii10067 afii10068 afii10069 afii10070 afii10071 afii10072 afii10073 afii10074 afii10075 afii10076 afii10077 afii10078 afii10079 afii10080 afii10081 afii10082 afii10083 afii10084 afii10085 afii10086 afii10087 afii10088 afii10089 afii10090 afii10091 afii10092 afii10093 afii10094 afii10095 afii10096 afii10097 afii10051 afii10099 afii10050 afii10055 afii10052 afii10100 afii10103 afii10098 afii10057 afii10053 afii10101 afii10056 afii10104 afii10058 afii10106 afii10059 afii10107 afii10105 afii10054 afii10060 afii10108 afii10061 afii10109 afii10102 afii10062 afii10110 afii10145 afii10193 afii61352'

ng = s.split(' ')

font = CurrentFont()

for gname in ng:
    if gname not in font.keys():
        d = RGlyph()
        font[gname] = d
        missglyph = font[gname]
        missglyph.width = 0
        missglyph.update()

font.update()

font.testInstall()

glyphOrder = font.glyphOrder

for gname in ng:
    if font[gname].width == 0:
        font.removeGlyph(gname)

font.glyphOrder = glyphOrder
font.update()
from robofab.world import CurrentFont


s = 'space exclam quotesingle quotedbl numbersign dollar percent ampersand parenleft parenright asterisk plus comma hyphen period slash zero one two three four five six seven eight nine colon semicolon less equal greater question at A B C D E F G H I J K L M N O P Q R S T U V W X Y Z bracketleft backslash bracketright asciicircum underscore grave a b c d e f g h i j k l m n o p q r s t u v w x y z braceleft bar braceright asciitilde exclamdown cent sterling currency yen brokenbar section dieresis copyright ordfeminine guillemotleft logicalnot registered macron degree plusminus twosuperior threesuperior acute mu paragraph periodcentered cedilla onesuperior ordmasculine guillemotright onequarter onehalf threequarters questiondown Agrave Aacute Acircumflex Atilde Adieresis Aring AE Ccedilla Egrave Eacute Ecircumflex Edieresis Igrave Iacute Icircumflex Idieresis Eth Ntilde Ograve Oacute Ocircumflex Otilde Odieresis multiply Oslash Ugrave Uacute Ucircumflex Udieresis Yacute Thorn germandbls agrave aacute acircumflex atilde adieresis aring ae ccedilla egrave eacute ecircumflex edieresis igrave iacute icircumflex idieresis eth ntilde ograve oacute ocircumflex otilde odieresis divide oslash ugrave uacute ucircumflex udieresis yacute thorn ydieresis dotlessi circumflex caron breve dotaccent ring ogonek tilde hungarumlaut quoteleft quoteright minus u00A0|00A0 afii10017 afii10018 afii10019 afii10020 afii10021 afii10022 afii10023 afii10024 afii10025 afii10026 afii10027 afii10028 afii10029 afii10030 afii10031 afii10032 afii10033 afii10034 afii10035 afii10036 afii10037 afii10038 afii10039 afii10040 afii10041 afii10042 afii10043 afii10044 afii10045 afii10046 afii10047 afii10048 afii10049 afii10065 afii10066 afii10067 afii10068 afii10069 afii10070 afii10071 afii10072 afii10073 afii10074 afii10075 afii10076 afii10077 afii10078 afii10079 afii10080 afii10081 afii10082 afii10083 afii10084 afii10085 afii10086 afii10087 afii10088 afii10089 afii10090 afii10091 afii10092 afii10093 afii10094 afii10095 afii10096 afii10097 afii10051 afii10099 afii10050 afii10055 afii10052 afii10100 afii10103 afii10098 afii10057 afii10053 afii10101 afii10056 afii10104 afii10058 afii10106 afii10059 afii10107 afii10105 afii10054 afii10060 afii10108 afii10061 afii10109 afii10102 afii10062 afii10110 afii10145 afii10193 afii61352'

ng = s.split(' ')

font = CurrentFont()

for gname in ng:
    if gname not in font.keys():
        d = RGlyph()
        font[gname] = d
        missglyph = font[gname]
        missglyph.width = 0
        missglyph.update()

font.update()

font.testInstall()

glyphOrder = font.glyphOrder

for gname in ng:
    if font[gname].width == 0:
         font.removeGlyph(gname)
         
font.glyphOrder = glyphOrder                
font.update()