コード例 #1
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')
コード例 #2
0
def selectEntireContours():
    glyph = CurrentGlyph()
    if glyph is None:
        raise Exception('No current glyph.')

    for contour in glyph:
        if isContourPartiallySelected(contour):
            selectContourPoints(contour)
コード例 #3
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
コード例 #4
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
コード例 #5
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")
                 ]
コード例 #6
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)
コード例 #7
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()
コード例 #8
0
from robofab.world import CurrentGlyph
from robofab.pens.filterPen import thresholdGlyph
d = 10
thresholdGlyph(CurrentGlyph(), d)
コード例 #9
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)
コード例 #10
0
ファイル: pen_00.py プロジェクト: jackjennings/roboFabDocs
# 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
コード例 #11
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()
コード例 #12
0
def cleanupCurrentGlyphContours():
    glyph = CurrentGlyph()
    if glyph is None:
        raise Exception('No current glyph.')
    cleanupGlyphContours(glyph)
コード例 #13
0
from robofab.world import CurrentGlyph
from robofab.pens.filterPen import halftoneGlyph

halftoneGlyph(CurrentGlyph())
コード例 #14
0
# open a glyph in FL first!
from robofab.world import CurrentGlyph
print CurrentGlyph()
コード例 #15
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()
コード例 #16
0
ファイル: pens_05.py プロジェクト: jackjennings/roboFabDocs
from robofab.world import CurrentGlyph
from robofab.pens.filterPen import spikeGlyph
segmentLength = 20
spikeLength = 100
spikeGlyph(CurrentGlyph(), segmentLength, spikeLength)
コード例 #17
0
ファイル: pens_03.py プロジェクト: jackjennings/roboFabDocs
from robofab.world import CurrentGlyph
from robofab.pens.filterPen import flattenGlyph
d = 10
flattenGlyph(CurrentGlyph(), d)
コード例 #18
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
コード例 #19
0
def mergeSelectedPointsInCurrentGlyph(updateControlPoints):
    glyph = CurrentGlyph()
    if glyph is None:
        raise Exception('No current glyph.')
    mergeSelectedPointsInGlyph(glyph, updateControlPoints)