コード例 #1
0
for contour in glyph.contours:
    if contour.selected:
        for point in contour.bPoints:
            if point.selected:
                selectedPoints.append(point)
if len(selectedPoints) > 0:
    fl.SetUndo()
    
allPoints = []
pointIndexes = []
for i in selectedPoints:
	pointIndexes.append(i.index)

pt1 = min(pointIndexes)
pt2 = max(pointIndexes)

for contour in glyph.contours:
    if contour.selected:
        for point in contour.bPoints:
        	allPoints.append(point)

for point in allPoints:
	if point.index in range(pt1, pt2):
		selectedPoints.append(point)

for i in selectedPoints:
	i.select(state=True)

glyph.update()
コード例 #2
0
ファイル: angledMarginPen.py プロジェクト: vowapp/inter
def centerAngledMargins(glyph, font):
    """Center the glyph on angled margins."""
    pen = AngledMarginPen(font, glyph.width, font.info.italicAngle)
    g.draw(pen)
    isLeft, isRight = pen.margin
    setAngledLeftMargin(glyph, font, (isLeft + isRight) * .5)
    setAngledRightMargin(glyph, font, (isLeft + isRight) * .5)


def guessItalicOffset(glyph, font):
    """Guess the italic offset based on the margins of a symetric glyph.
		For instance H or I.
	"""
    l, r = getAngledMargins(glyph, font)
    return l - (l + r) * .5


if __name__ == "__main__":

    # example for FontLab, with a glyph open.
    from robofab.world import CurrentFont, CurrentGlyph
    g = CurrentGlyph()
    f = CurrentFont()

    print "margins!", getAngledMargins(g, f)
    # set the angled margin to a value
    m = 50
    setAngledLeftMargin(g, f, m)
    setAngledRightMargin(g, f, m)
    g.update()
コード例 #3
0
#FLM: Invert Selection

"""Invert the selected segments in the current glyph"""

from robofab.world import CurrentGlyph

glyph = CurrentGlyph()
for contour in glyph.contours:
	notSelected = []
	for segment in contour.segments:
		if not segment.selected:
			notSelected.append(segment.index)
	contour.selected = False
	for index in notSelected:
		contour[index].selected = True
glyph.update()
コード例 #4
0
ファイル: session2_07.py プロジェクト: anthrotype/robofab
myPen = g.getPen()

# myPen is a pen object of a type meant for
# constructing paths in a glyph.
# So rather than use this pen with the glyph's
# own draw() method, we're going to tell it 
# to do things ourselves. (Just like DrawBot!)
print myPen

myPen.moveTo((344, 645))
myPen.lineTo((647, 261))
myPen.lineTo((662, -32))
myPen.lineTo((648, -61))
myPen.lineTo((619, -61))
myPen.lineTo((352, 54))
myPen.lineTo((72, 446))
myPen.lineTo((117, 590))
myPen.lineTo((228, 665))
myPen.closePath()
myPen.moveTo((99, 451))
myPen.lineTo((365, 74))
myPen.curveTo((359, 122), (376, 178), (420, 206))
myPen.curveTo((422, 203), (142, 579), (142, 579))
myPen.closePath()
myPen.moveTo((631, -32))
myPen.lineTo((629, 103))
myPen.curveTo((556, 111), (524, 71), (508, 20))
myPen.closePath()

g.update()