def performAlign(alignFunction):
    try:
        rfglyph = CurrentGlyph()
        if rfglyph is None:
            #raise Exception('No current font.')
            return

        rfglyph.prepareUndo("Align Glyph")


        glyph = TFSGlyph(rfglyph)
        glyphName = hex(glyph.unicode) if glyph.unicode is not None else '<None>'
        print 'processing', glyphName
        paths = glyph.getContours(setSelected=True)
        paths = alignFunction(paths)
        glyph.setContours(paths)

            #if index > 5:
            #    break
        glyph.update()
        font.update()

        ## tell the glyph you are done with your actions so it can handle the undo properly
        rfglyph.performUndo()

    except Exception, e:
        from robofab.interface.all.dialogs import Message as Dialog
        Dialog(e.message, title='Error')
示例#2
0
def selectEntireContours():
    glyph = CurrentGlyph()
    if glyph is None:
        raise Exception('No current glyph.')

    for contour in glyph:
        if isContourPartiallySelected(contour):
            selectContourPoints(contour)
def alignGlyphTangents(curvify, onlySelected):

    rfglyph = CurrentGlyph()
    if rfglyph is None:
        raise Exception('No current glyph.')

    rfglyph.prepareUndo("Align Tangents")

    glyph = TFSGlyph(rfglyph)
    glyphName = hex(glyph.unicode) if glyph.unicode is not None else '<None>'
    paths = glyph.getContours(setSelected=True)
    paths = processGlyph(glyph, glyphName, paths,
                         curvify=curvify,
                         onlySelected=onlySelected)
    glyph.setContours(paths)

    ## tell the glyph you are done with your actions so it can handle the undo properly
    rfglyph.performUndo()
示例#4
0
def getGlyphs(f):
    gNames = []
    cg = CurrentGlyph()
    if cg != None:
        gNames.append(cg.name)
    for g in f:
        if g.selected == True:
            if g.name not in gNames:
                gNames.append(g.name)
    return gNames
示例#5
0
def getGlyphs(f):
    from robofab.world import CurrentGlyph
    gNames = []
    cg = CurrentGlyph()
    if cg is not None:
        gNames.append(cg.name)
    for g in f:
        if g.selected == True:
            if g.name not in gNames:
                gNames.append(g.name)
    return gNames
示例#6
0
 def _globalExtremumTest(self, p1, p2, p3, p4):
     myRect = CurrentGlyph().box
     if not (pointInRect(p2, myRect) and pointInRect(p3, myRect)):
         points = getExtremaForCubic(p1, p2, p3, p4, h=True, v=True)
         for p in points:
             if p in self.errors:
                 self.errors[p].extend(
                     [RedArrowError(p4, "Bounding box extremum")])
             else:
                 self.errors[p] = [
                     RedArrowError(p4, "Bounding box extremum")
                 ]
示例#7
0
def performAlign(alignFunction):
    try:
        rfglyph = CurrentGlyph()
        if rfglyph is None:
            #raise Exception('No current font.')
            return

        rfglyph.prepareUndo("Align Glyph")

        glyph = TFSGlyph(rfglyph)
        glyphName = hex(
            glyph.unicode) if glyph.unicode is not None else '<None>'
        print 'processing', glyphName
        paths = glyph.getContours(setSelected=True)
        paths = alignFunction(paths)
        glyph.setContours(paths)

        #if index > 5:
        #    break
        glyph.update()
        font.update()

        ## tell the glyph you are done with your actions so it can handle the undo properly
        rfglyph.performUndo()

    except Exception, e:
        from robofab.interface.all.dialogs import Message as Dialog
        Dialog(e.message, title='Error')
示例#8
0
def copiaWidth(forigen, fdestino):
    g = CurrentGlyph()
    for glyph in fdestino:
        if glyph.selected:
            g = glyph.name
            anchoFinal = fdestino[g].width
            anchoActual = forigen[g].width
            anchoDif = anchoActual - anchoFinal
            if anchoFinal != anchoActual:
                fdestino[g].mark = 100
                fdestino[g].update()
                fdestino.update()
                print str(g)
                print str(forigen[g].width) + " > " + str(fdestino[g].width)
示例#9
0
# robothon06
# get a pen and draw something in the current glyph
# what will it draw? ha! run the script and find out!

from robofab.world import CurrentGlyph

g = CurrentGlyph()
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()
# FLM: Select between points

# Description:
# In your glyph windows select 2 nodes that are far appart
# The script will selec the intermediate ones
# Sometimes can be usefull to clean handwritting autotracing with lots of nodes
# But it's not perfect

# Credits:
# Josh at the Robofab discussion list
# https://groups.google.com/d/msg/robofab/tz-kCXMuJwc/GcDogqvXODwJ

from robofab.world import CurrentGlyph

glyph = CurrentGlyph()

selectedPoints = []

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)
示例#11
0
#FLM: 010 FontLab to RoboFab and Back

# In which an adventurous glyph of your choice
# makes a trip into RoboFab land,
# and returns safely home after various inspections
# and modifications.

from robofab.world import CurrentGlyph, CurrentFont

c = CurrentGlyph()
f = CurrentFont()

from robofab.objects.objectsRF import RGlyph
d = RGlyph()

# woa! d is now  a rf version of a fl glyph!
d.appendGlyph(c)
d.width = 100

c.printDump()
d.printDump()

e = f.newGlyph('copyTest')

# dump the rf glyph back to a fl glyph!
e.appendGlyph(d)

# see, it still takes its own kind as well
e.appendGlyph(f['a'])
e.printDump()
示例#12
0
		for index, pts in self.hits.items():
			unique = list(Set(pts))
			unique.sort()
			allHits[index] = unique
		return allHits
		
	def getAll(self):
		"""Get all the slices."""
		allHits = []
		for index, pts in self.hits.items():
			allHits.extend(pts)
		unique = list(Set(allHits))
		unique = list(unique)
		unique.sort()
		return unique
		
		
if __name__ == "__main__":

	from robofab.world import CurrentGlyph, CurrentFont
	f = CurrentFont()
	g = CurrentGlyph()

	pt = (74, 216)

	pen = MarginPen(f, pt[1], isHorizontal=False)
	g.draw(pen) 
	print 'glyph Y margins', pen.getMargins()
	print pen.getContourMargins()

示例#13
0
        allHits = {}
        for index, pts in self.hits.items():
            unique = list(Set(pts))
            unique.sort()
            allHits[index] = unique
        return allHits

    def getAll(self):
        """Get all the slices."""
        allHits = []
        for index, pts in self.hits.items():
            allHits.extend(pts)
        unique = list(Set(allHits))
        unique = list(unique)
        unique.sort()
        return unique


if __name__ == "__main__":

    from robofab.world import CurrentGlyph, CurrentFont
    f = CurrentFont()
    g = CurrentGlyph()

    pt = (74, 216)

    pen = MarginPen(f, pt[1], isHorizontal=False)
    g.draw(pen)
    print 'glyph Y margins', pen.getMargins()
    print pen.getContourMargins()
 def expand(self, sender):
     glyph = CurrentGlyph()
     
     defconGlyph = glyph.naked()
     
     glyph.prepareUndo("Outline")
     
     isQuad = curveConverter.isQuadratic(defconGlyph)
     
     if isQuad:
         curveConverter.quadratic2bezier(defconGlyph)
     
     outline = self.calculate(glyph)
     
     glyph.clear()
     outline.drawPoints(glyph.getPointPen())
     
     if isQuad:
         curveConverter.bezier2quadratic(defconGlyph)
     
     glyph.round()
     glyph.performUndo()
示例#15
0
# robofab manual
# Pen object
# usage examples

from robofab.world import CurrentGlyph

newGlyph = CurrentGlyph()

pen = newGlyph.getPen()

# do stuff with the pen to draw in this glyph
#FLM: Set 50 50 sidebearings

# Description:
# Set base sidebearings

# Credits:
# Pablo Impallari
# http://www.impallari.com

from robofab.world import CurrentFont,CurrentGlyph

f = CurrentFont()
g = CurrentGlyph()

g.leftMargin = 50
g.rightMargin = 50

f.update()

示例#17
0
import sys

sys.path.append('/Users/alexander/PycharmProjects/CustomControls')

import tdReport
from robofab.world import CurrentFont, CurrentGlyph
font = CurrentFont()
gselected = CurrentGlyph()

TOFL_MARK = (0.4, 1.0, 0.4, 1.0)
EXPORTED = (0.4, 1.0, 0.4, 0.1)
EXCEPT_MARK = (1.0, 0.8, 0.4, 1.0)

file_ext = 'toFl'
path_exp = font.path.replace('.ufo', '')
# filename = font.filename
report = tdReport.Report(file=path_exp,
                         ext='toFL',
                         process='Export selected glyphs to FontLab')
print 'Selected glyph: ', gselected.name, 'marked as', gselected.mark
names = []
for gf in CurrentFont():
    if gf.mark == gselected.mark:
        names.append(gf.name)
        report.add(gf.name)
print names
print 'Glyph list saved as: ' + path_exp + '.' + file_ext
report.save()
#FLM: Substract 1 Units to each side to current glyph

# Description:
# Substract current glyph sidebearings by 1 units on each side

# Credits:
# Pablo Impallari
# http://www.impallari.com

from robofab.world import CurrentFont,CurrentGlyph

f = CurrentFont()
g = CurrentGlyph()

OldLeft = g.leftMargin
OldRight = g.rightMargin 

g.leftMargin = OldLeft - 1
g.rightMargin = OldRight - 1

f.update()
示例#19
0
def cleanupCurrentGlyphContours():
    glyph = CurrentGlyph()
    if glyph is None:
        raise Exception('No current glyph.')
    cleanupGlyphContours(glyph)
示例#20
0
#FLM: Glyph Appender

"""Add a glyph to the current glyph"""

from robofab.world import CurrentFont, CurrentGlyph
from robofab.interface.all.dialogs import SelectGlyph

glyph = CurrentGlyph()
font = CurrentFont()

# select a glyph to add
selected = SelectGlyph(font)
# make sure that we are not trying add the current glyph to itself
if selected.name != glyph.name:
	# preserve the current state
	fl.SetUndo()
	# add the selected glyph to the current glyph
	glyph.appendGlyph(selected)
	# always update the glyph!
	glyph.update()
	# and, just to be safe, update the font... 
	font.update()
示例#21
0
#FLM: AT SBs from glyph

from robofab.world import CurrentFont,CurrentGlyph
from robofab.interface.all.dialogs import Message, ProgressBar, AskYesNoCancel, TwoChecks, AskString
import string

#Program
def check(font,name):
	result = False
	for g in font.glyphs:
		if g.name == name:
			result = True
	return result

font = CurrentFont()
cglyph = CurrentGlyph()
sb = AskString('SB values')
values = sb.split(',')



if check(font,values[0]):
	valueL=font[values[0]].leftMargin
else:
	valueL = cglyph.leftMargin
if check(font,values[1]):
	valueR=font[values[1]].rightMargin
else:
	valueL = cglyph.rightMargin

if valueL == 0:
示例#22
0
#FLM: Add 2 Units to each side to current glyph

# Description:
# Increase current glyph sidebearings by 2 units on each side

# Credits:
# Pablo Impallari
# http://www.impallari.com

from robofab.world import CurrentFont,CurrentGlyph

f = CurrentFont()
g = CurrentGlyph()

OldLeft = g.leftMargin
OldRight = g.rightMargin 

g.leftMargin = OldLeft + 2
g.rightMargin = OldRight + 2

f.update()

            self.randomize(bcp1),
            self.randomize(bcp2),
            self.randomize(pt)
        )
    
    def _closePath(self):
        self.writer_pen.closePath()
    
    def _endPath(self):
        self.writer_pen.endPath()
    
    def addComponent(self, baseGlyphName, transformation):
        pass


source = CurrentGlyph()

# Save the anchors from the original glyph in a list
anchors = [a for a in source.anchors]

# Remove all anchors from the glyph so they don't interfere with our processing
for a in anchors:
    source.removeAnchor(a)

# Temporary glyph to which the pen is writing
target = RGlyph()
target_pen = target.getPen()

source_pen = MyPen(CurrentFont(), target_pen, 10)
source.draw(source_pen)
示例#24
0
 def expand(self, sender):
     glyph = CurrentGlyph()
     preserveComponents = bool(self.w.preserveComponents.get())
     self.expandGlyph(glyph, preserveComponents)
     self.w.preview.set(False)
     self.previewCallback(self.w.preview)
示例#25
0
from robofab.world import CurrentGlyph
from robofab.pens.filterPen import flattenGlyph
d = 10
flattenGlyph(CurrentGlyph(), d)
示例#26
0
print font.lib['org.robofab']['A Dict']

# ...or we can avoid deeper nesting, and use our address as a
# key prefix:
font.lib['org.robofab.A'] = "A"
font.lib['org.robofab.B'] = "B"
font.lib['org.robofab.aList'] = [1, 2, 3]
print font.lib['org.robofab.A']
print font.lib['org.robofab.B']
print font.lib['org.robofab.aList']

# It is all sooo easy!

# Every glyph has it's very own lib as well
# and it works just like the font lib
glyph = CurrentGlyph()
glyph.lib['org.robofab'] = {'My glyph is totally': 'Awesome'}
print glyph.lib['org.robofab']['My glyph is totally']

# The type of data that can be stored in lib dictionaries is
# limited. Dictionary keys must be strings (or unicode strings),
# values may be dicts, lists, ints, floats, (unicode) strings and
# booleans. There is also a special type to store arbitrary binary
# data: robofab.plistlib.Data. Don't use plain strings for that!

# So, as you can see, this can be a very powerful thing
# to use and you are only limited by your imagination.
# Have fun!

# A Technical Note:
# You "under the hood" type folks out there may be
示例#27
0
def mergeSelectedPointsInCurrentGlyph(updateControlPoints):
    glyph = CurrentGlyph()
    if glyph is None:
        raise Exception('No current glyph.')
    mergeSelectedPointsInGlyph(glyph, updateControlPoints)
示例#28
0
# robothon 2009
# set guidelines on the average x, y of all selected points
# in the current glyph.
# useful for working on symetric glyphs.

from robofab.world import CurrentGlyph

g = CurrentGlyph()

# remove all old guides first
g.clearHGuides()
g.clearVGuides()

# this is where we'll be storing some data
guides = {}
average = {}

# iterate through the points, find the selected points
# and their associated off-curve points.
for c in g:
    for pt in c.bPoints:
        if pt.selected:
            average[(pt.anchor[0], pt.anchor[1])] = 1
            guides[(pt.anchor[0], pt.anchor[1])] = 1
            guides[(pt.anchor[0] + pt.bcpIn[0],
                    pt.anchor[1] + pt.bcpIn[1])] = 1
            guides[(pt.anchor[0] + pt.bcpOut[0],
                    pt.anchor[1] + pt.bcpOut[1])] = 1

# calculate an average position
x = None
#FLM: Set 50 50 sidebearings

# Description:
# Set base sidebearings

# Credits:
# Pablo Impallari
# http://www.impallari.com

from robofab.world import CurrentFont, CurrentGlyph

f = CurrentFont()
g = CurrentGlyph()

g.leftMargin = 50
g.rightMargin = 50

f.update()
示例#30
0
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()
示例#31
0
#FLM: Glyph Appender
"""Add a glyph to the current glyph"""

from robofab.world import CurrentFont, CurrentGlyph
from robofab.interface.all.dialogs import SelectGlyph

glyph = CurrentGlyph()
font = CurrentFont()

# select a glyph to add
selected = SelectGlyph(font)
# make sure that we are not trying add the current glyph to itself
if selected.name != glyph.name:
    # preserve the current state
    try:
        fl.SetUndo()
    except:
        pass
    # add the selected glyph to the current glyph
    glyph.appendGlyph(selected)
    # always update the glyph!
    glyph.update()
    # and, just to be safe, update the font...
    font.update()
#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()
#FLM: AT (?) Mask substract
from robofab.world import CurrentFont, CurrentGlyph

g = CurrentGlyph()

n = g.naked()
mask = n.mask

base = f["O"]
cutter = f["a"]
dest = g

dest.appendGlyph(base)
dest.naked().Bsubtract(cutter.naked())

dest.update()
示例#34
0
# robofab manual
#	Glyph object
#	attribute examples

from robofab.world import CurrentFont, CurrentGlyph
f = CurrentFont()

# create a glyph object by asking the font
g = f["Adieresis"]

# alternatively, create a glyph object for the current glyph
g = CurrentGlyph()

# get the width
print g.width

# get the name
print g.name

# a  list of unicode values for this glyph. Can be more than 1!
print g.unicodes

# set the width
g.width = 1000
print g.width

# get the number of contours in a glyph
# by getting  its length
print len(g)
示例#35
0
from robofab.world import CurrentGlyph
from robofab.pens.filterPen import halftoneGlyph

halftoneGlyph(CurrentGlyph())
                    y - radius * cos(phi + rho)
                )
            )
    else:
        for i in range(n - 1, 0, -1):
            rho = 2 * pi * i / n
            pen.lineTo(
                (
                    x - radius * sin(phi + rho),
                    y - radius * cos(phi + rho)
                )
            )
    
    # Close the path
    pen.closePath()


g = CurrentGlyph()
g.clear()
p = g.getPen()

diameter = 600
n = 8

for i in range(10):
    clockwise = i % 2
    phi = 1.2 * i * pi
    draw_polygon(p, (275, 216), diameter, n, phi, clockwise)
    #n -= 1
    diameter -= 50
示例#37
0
# robothon06
# get a pen and draw something in the current glyph
# what will it draw? ha! run the script and find out!

from robofab.world import CurrentGlyph

g = CurrentGlyph()
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()
示例#38
0
from robofab.world import CurrentGlyph
from robofab.pens.filterPen import spikeGlyph
segmentLength = 20
spikeLength = 100
spikeGlyph(CurrentGlyph(), segmentLength, spikeLength)
示例#39
0
 def quickModeSelectionCallback(self, sender):
     mode = self.quickModes[sender.getSelection()]
     if mode == quickMode_import_selectedFiles_everything:
         # import
         self.w.doImportCheckBox.set(True)
         self.w.saveVFBCheckBox.set(True)
         self.w.closeVFBCheckBox.set(True)
         # export
         self.w.doExportCheckBox.set(False)
         self.w.exportCurrentFontCheckBox.set(False)
         self.w.exportAllOpenFontsCheckBox.set(False)
         self.w.exportFormatVersion1CheckBox.set(False)
         self.w.exportFormatVersion2CheckBox.set(False)
         # destination
         self.w.destinationNewFilesCheckBox.set(True)
         self.w.destinationExistingFilesCheckBox.set(False)
         # parts
         self.w.doFontInfoCheckBox.set(True)
         self.w.doKerningCheckBox.set(True)
         self.w.doGroupsCheckBox.set(True)
         self.w.doLibCheckBox.set(True)
         self.w.doFeaturesCheckBox.set(True)
         self.w.doGlyphsText.set("")
         self.w.doGlyphMarksCheckBox.set(False)
         self.w.doGlyphMasksCheckBox.set(False)
         self.w.doGlyphHintsCheckBox.set(False)
         glyphs = None
     elif mode == quickMode_export_allFonts_everything:
         # import
         self.w.doImportCheckBox.set(False)
         self.w.saveVFBCheckBox.set(False)
         self.w.closeVFBCheckBox.set(False)
         # export
         self.w.doExportCheckBox.set(True)
         self.w.exportCurrentFontCheckBox.set(False)
         self.w.exportAllOpenFontsCheckBox.set(True)
         self.w.exportFormatVersion1CheckBox.set(False)
         self.w.exportFormatVersion2CheckBox.set(True)
         # destination
         self.w.destinationNewFilesCheckBox.set(True)
         self.w.destinationExistingFilesCheckBox.set(False)
         # parts
         self.w.doFontInfoCheckBox.set(True)
         self.w.doKerningCheckBox.set(True)
         self.w.doGroupsCheckBox.set(True)
         self.w.doLibCheckBox.set(True)
         self.w.doFeaturesCheckBox.set(True)
         self.w.doGlyphsText.set("")
         self.w.doGlyphMarksCheckBox.set(False)
         self.w.doGlyphMasksCheckBox.set(False)
         self.w.doGlyphHintsCheckBox.set(False)
         glyphs = None
     elif mode == quickMode_export_currentFont_selectedGlyphs:
         # import
         self.w.doImportCheckBox.set(False)
         self.w.saveVFBCheckBox.set(False)
         self.w.closeVFBCheckBox.set(False)
         # export
         self.w.doExportCheckBox.set(True)
         self.w.exportCurrentFontCheckBox.set(True)
         self.w.exportAllOpenFontsCheckBox.set(False)
         self.w.exportFormatVersion1CheckBox.set(False)
         self.w.exportFormatVersion2CheckBox.set(True)
         # destination
         self.w.destinationNewFilesCheckBox.set(False)
         self.w.destinationExistingFilesCheckBox.set(True)
         # parts
         self.w.doFontInfoCheckBox.set(False)
         self.w.doKerningCheckBox.set(False)
         self.w.doGroupsCheckBox.set(False)
         self.w.doLibCheckBox.set(False)
         self.w.doFeaturesCheckBox.set(False)
         self.w.doGlyphsText.set("")
         self.w.doGlyphMarksCheckBox.set(False)
         self.w.doGlyphMasksCheckBox.set(False)
         self.w.doGlyphHintsCheckBox.set(False)
         font = CurrentFont()
         if font is None:
             glyphs = None
         elif not len(font.selection):
             glyph = CurrentGlyph()
             if glyph is None:
                 glyphs = None
             else:
                 glyphs = [glyph.name]
         else:
             glyphs = font.selection
             glyphs.sort()
     else:
         return
     # update enabled states
     if self.w.doImportCheckBox.get():
         self.mode = "import"
     else:
         self.mode = "export"
     self._modeChange()
     # update glyph list
     self.glyphs = glyphs
     self._updateGlyphsText()
#MenuTitle: 02 Draw In Glyph
from robofab.world import CurrentGlyph

CurrentGlyph().clear()
p = CurrentGlyph().getPen()

# Draw a rectangle
p.moveTo((10, 0))
p.lineTo((540, 0))
p.lineTo((540, 432))
p.lineTo((10, 432))
p.closePath()
    
    def _lineTo(self, pt):
        self.writer_pen.lineTo(pt)
    
    def _curveToOne(self, bcp1, bcp2, pt):
        self.writer_pen.curveTo(bcp1, bcp2, pt)
    
    def _closePath(self):
        self.writer_pen.closePath()
    
    def _endPath(self):
        self.writer_pen.endPath()
    
    def addComponent(self, baseGlyphName, transformation):
        pass


source = CurrentGlyph()

# Temporary glyph to which the pen is writing
target = RGlyph()
target_pen = target.getPen()

source_pen = MyPen(CurrentFont(), target_pen)
source.draw(source_pen)

# Clear the original glyph and add the modfied outline
source.clear()
source.appendGlyph(target)

# You will notice any anchors are converted to stray points ...
#FLM: Add 1 Units to each side to current glyph

# Description:
# Increase current glyph sidebearings by 1 units on each side

# Credits:
# Pablo Impallari
# http://www.impallari.com

from robofab.world import CurrentFont,CurrentGlyph

f = CurrentFont()
g = CurrentGlyph()

OldLeft = g.leftMargin
OldRight = g.rightMargin 

g.leftMargin = OldLeft + 1
g.rightMargin = OldRight + 1

f.update()

示例#43
0
# robofab manual
# Glyph object
# attribute examples

from robofab.world import CurrentFont, CurrentGlyph
f = CurrentFont()

# create a glyph object by asking the font
g = f["Adieresis"]

# alternatively, create a glyph object for the current glyph
g = CurrentGlyph()

# get the width
print g.width

# get the name
print g.name

# a  list of unicode values for this glyph. Can be more than 1!
print g.unicodes

# set the width
g.width = 1000
print g.width

# get the number of contours in a glyph by getting its length
print len(g)
示例#44
0
	
	This script is useful when you're working on several interpolation
	masters as separate vfb source files.
	
	EvB 08	
"""


from robofab.glifLib import GlyphSet
from robofab.world import CurrentFont, CurrentGlyph, AllFonts
from robofab.interface.all.dialogs import Message, GetFolder
from robofab.tools.glyphNameSchemes import glyphNameToShortFileName
import os

f = CurrentFont()
g = CurrentGlyph()

f.save()

todo = f.selection
print "selection", todo
if g is not None:
	todo.append(g.name)
		
for f in AllFonts():
	ufoPath = None
	print "f.path", f, f.path
	if f.path is None:
		# huh, in case there is a ghost font.
		print "skipping", f
		continue
示例#45
0
from robofab.world import CurrentGlyph
from robofab.pens.filterPen import thresholdGlyph
d = 10
thresholdGlyph(CurrentGlyph(), d)