font = CurrentFont()

#Copy a glyph and then delete it

for glyph in font:
	# Only proceed if glyph has contours
	if len(glyph) != 0:

		#initialize counters
		glyphAnchors = 0
		copyAnchors = 0

		# Make the first copy
		newname = glyph.name
		newname += ".tmp1"
		copy = font.insertGlyph(glyph, newname)

		# Make the second copy
		newname = glyph.name
		newname += ".tmp2"
		copyTwo = font.insertGlyph(glyph, newname)

		#Decompose any composites in the copies
		for c in copy.components:
			counter = 0
			copy.components[counter].decompose()
			counter +=  1

		for c in copyTwo.components:
			counter = 0
			copyTwo.components[counter].decompose()
コード例 #2
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()
コード例 #3
0
ファイル: interpol_07.py プロジェクト: anthrotype/robofab
 
from robofab.world import CurrentFont
f = CurrentFont()
 
# glyphmath
a = f["A"]
b = f["B"]
 
# multiply works as scaling up
d = a * 2
# or
d = 2 * a
 
# note: as of robofab svn version 200,
# the "as" argument in insertGlyph has changed to "name"
f.insertGlyph(d, name="A.A_times_2")
 
# division works as scaling down
d = a / 2
f.insertGlyph(d, name="A.A_divide_2")
 
# addition: add coordinates of each point
d = a + b
f.insertGlyph(d, name="A.A_plus_B")
 
# subtraction: subtract coordinates of each point
d = a - b
f.insertGlyph(d, name="A.A_minus_B")
 
# combination: interpolation!
d = a + .5 * (b-a)
コード例 #4
0
# in the test font: two interpolatable, different glyphs
# on positions A and B.

from robofab.world import CurrentFont
f = CurrentFont()

# glyphmath
a = f["A"]
b = f["B"]

# multiply works as scaling up
d = a * 2
#or
d = 2 * a
# note: as of robofab svn version 200, the "as" argument in insertGlyph has changed to "name"
f.insertGlyph(d, name="A.A_times_2")

# division works as scaling down
d = a / 2
f.insertGlyph(d, name="A.A_divide_2")

# addition: add coordinates of each point
d = a + b
f.insertGlyph(d, name="A.A_plus_B")

# subtraction: subtract coordinates of each point
d = a - b
f.insertGlyph(d, name="A.A_minus_B")

# combination: interpolation!
d = a + .5 * (b - a)