示例#1
0
	def load(self):
		self.onOff = getExtensionDefault(onOffKey, self._fallbackOnOff)
		self.lineWidth = getExtensionDefault(lineWidthKey, self._fallbackStrokeWidth)
		self.lineColor = getExtensionDefaultColor(lineColorKey, self._fallbackStrokeColor)
		self.fillColor = getExtensionDefaultColor(fillColorKey, self._fallbackFillColor)
		self.lineRGBA = getExtensionDefault(lineRGBA, self._fallbackStrokeRGBA)
		self.fillRGBA = getExtensionDefault(fillRGBA, self._fallbackFillRGBA)
示例#2
0
    def becomeActive(self):
        """
        Boot up the dialog.
        """
        
        self.fillColor = getExtensionDefaultColor(self.DEFAULTKEY_FILLCOLOR, self.FALLBACK_FILLCOLOR)
        self.strokeColor = getExtensionDefaultColor(self.DEFAULTKEY_STROKECOLOR, self.FALLBACK_STROKECOLOR)
        
        self.w = FloatingWindow((260, 130), "Bounding Options", minSize=(100, 100), closable=False)

        self.w.viewOptions = RadioGroup((10, 10, 150, 20),
                                        ['Selection', 'Glyph'],
                                        callback=self.selectionCallback, isVertical=False, sizeStyle="small")
        self.w.viewOptions.set(getExtensionDefault(self.DEFAULTKEY_SELECTION, 0))
        
        self.w.useItalic = CheckBox((165, 10, 100, 20), "Use Italic", value=getExtensionDefault(self.DEFAULTKEY_USEITALIC, True), sizeStyle="small", callback=self.useItalicCallback)

        self.w.xLabel = TextBox((10, 40, 70, 20), "Divisions: X", sizeStyle="small")

        self.w.divisionsRadioX = Slider((80, 40, 70, 20),
        value=getExtensionDefault(self.DEFAULTKEY_DIVISIONSX, 1),
        minValue=1,
        maxValue=4,
        tickMarkCount=4,
        stopOnTickMarks=True,
        continuous=True,
        sizeStyle="small",
        callback=self.divisionsXCallback)

        self.w.yLabel = TextBox((160, 40, 70, 20), "Y", sizeStyle="small")
        self.w.divisionsRadioY = Slider((175, 40, 70, 20),
        value=getExtensionDefault(self.DEFAULTKEY_DIVISIONSY, 1),
        minValue=1,
        maxValue=4,
        tickMarkCount=4,
        stopOnTickMarks=True,
        continuous=True,
        sizeStyle="small",
         callback=self.divisionsYCallback)

        self.w.drawGuidesButton = Button((10, 100, 90, 20), 'Div Guides', callback=self.drawDivGuides, sizeStyle="small")
        self.w.drawBoxGuidesButton = Button((120, 100, 90, 20), 'Box Guides', callback=self.drawBoxGuides, sizeStyle="small",)
            

        x = 10
        y = 70
        self.w.showCoordinates = CheckBox((x, y, 90, 20), "Coordinates", value=getExtensionDefault(self.DEFAULTKEY_SHOWCOORDINATES, True), sizeStyle="small", callback=self.showCoordinatesCallback)
        x += 90
        self.w.showDimensions = CheckBox((x, y, 90, 20), "Dimensions", value=getExtensionDefault(self.DEFAULTKEY_SHOWDIMENSIONS, True), sizeStyle="small", callback=self.showDimensionsCallback)
            
        
        x += 90
        color = getExtensionDefaultColor(self.DEFAULTKEY_FILLCOLOR, self.FALLBACK_FILLCOLOR)
        self.w.color = ColorWell((x, y, 30, 22), 
                color=color,
                callback=self.colorCallback)

        self.setUpBaseWindowBehavior()
        self.w.open()
示例#3
0
 def load(self):
     self.fillColor = getExtensionDefaultColor(_fillColorDefaultKey,
                                               self._fallBackFillColor)
     self.strokeColor = getExtensionDefaultColor(_strokeColorDefaultKey,
                                                 self._fallBackStrokeColor)
     self.showPreview = getExtensionDefault(_showPreviewDefaultKey,
                                            self._fallbackShowPreview)
     self.data = getExtensionDefault(_dataDefaultKey, self._fallbackData)
示例#4
0
    def populateView(self):
        
        self.fillColor = getExtensionDefaultColor(self.DEFAULTKEY_FILLCOLOR, self.FALLBACK_FILLCOLOR)
        self.strokeColor = getExtensionDefaultColor(self.DEFAULTKEY_STROKECOLOR, self.FALLBACK_STROKECOLOR)

        doWindow = True
        if doWindow:
            view = self.getView()
            x = 10
            y = 10
            y += 30
            view.diacriticList = List((x, y, -10, -10), [],
                    columnDescriptions=[
                                    {"title": "Accent", "editable": False, 'enableDelete': True, 'typingSensitive': True}, 
                                    {"title": "Anchor", "editable": True, 'enableDelete': True, 'typingSensitive': True}, 
                                    ], 
                        doubleClickCallback=self.doubleClickCallback, 
                        #editCallback=self.modifyCallback,
                        selectionCallback=self.selectionCallback                  
                        )

            y-=30            
            view.glyphName = TextBox((x, y, 200, 25), '')

            x = -240
            view.guides = CheckBox((x, y, 60, 22), "Guides", sizeStyle="small", 
                #value=getExtensionDefault("%s.%s" %(self.DEFAULTKEY, "stroke"), False),
                value = True, 
                callback=self.updateView)
            x += 60            
            view.fill = CheckBox((x, y, 40, 22), "Fill", sizeStyle="small", 
                #value=getExtensionDefault("%s.%s" %(self.DEFAULTKEY, "fill"), True),
                value = True,
                callback=self.fillCallback)
            x += 40
            view.stroke = CheckBox((x, y, 60, 22), "Stroke", sizeStyle="small", 
                #value=getExtensionDefault("%s.%s" %(self.DEFAULTKEY, "stroke"), False),
                value = True, 
                callback=self.strokeCallback)
            x += 60
            color = getExtensionDefaultColor(self.DEFAULTKEY_FILLCOLOR, self.FALLBACK_FILLCOLOR)
            view.color = ColorWell((x, y, 30, 22), 
                color=color,
                callback=self.colorCallback)
            x += 40
            view.reset = Button((x, y, 30, 22), unichr(8634), callback=self.clearSelectionCallback)



          
            self.setUpBaseWindowBehavior()
        
        self.setShowAccents(self.current)

        UpdateCurrentGlyphView()
示例#5
0
 def _getColor(self, key, fallback):
     if key not in self._values:
         color = getExtensionDefaultColor(key)
         if color is None:
             color = NSColor.colorWithCalibratedRed_green_blue_alpha_(*fallback)
         self._values[key] = color
     return self._values[key]
 def __init__(self, constructions, font, parentWindow):
     
     self.font = font
     self.constructions = constructions
     
     self.w = Sheet((300, 120), parentWindow=parentWindow)
     
     getExtensionDefault, setExtensionDefault, getExtensionDefaultColor, setExtensionDefaultColor
     y = 15
     self.w.overWrite = CheckBox((15, y, 200, 22), "Overwrite Existing Glyphs", value=getExtensionDefault(self.overWriteKey, True))
     
     y += 35
     self.w.markGlyphs = CheckBox((15, y, 200, 22), "Mark Glyphs", value=getExtensionDefault(self.overWriteKey, True), callback=self.markGlyphsCallback) 
     self.w.markGlyphColor = ColorWell((130, y-5, 50, 30), color=getExtensionDefaultColor(self.markColorKey, NSColor.redColor()))
     
     self.w.markGlyphColor.enable(getExtensionDefault(self.overWriteKey, True))
             
     self.w.okButton = Button((-70, -30, -15, 20), "Build", callback=self.buildCallback, sizeStyle="small")
     self.w.setDefaultButton(self.w.okButton)
     
     self.w.closeButton = Button((-140, -30, -80, 20), "Cancel", callback=self.closeCallback, sizeStyle="small")
     self.w.closeButton.bind(".", ["command"])
     self.w.closeButton.bind(unichr(27), [])
     
     self.w.open() 
    def __init__(self):

        self.draw = False
        self.swap = True

        self.radius = getExtensionDefault(
            "%s.%s" % (WurstSchreiberDefaultKey, "radius"), 60)

        color = NSColor.colorWithCalibratedRed_green_blue_alpha_(1, 0, 0, .5)
        colorValue = getExtensionDefaultColor(
            "%s.%s" % (WurstSchreiberDefaultKey, "color"), color)

        self.w = FloatingWindow((150, 170), "WurstSchreiber")
        x = 15
        y = 15
        self.w.preview = CheckBox(
            (x, y, -x, 20),
            "Preview",
            callback=self.previewChanged,
            value=True)
        y+=30
        self.w.slider = SliderGroup(
            (x, y, -x, 22), 0, 100, self.radius, callback=self.sliderChanged)
        y+=35
        self.w.color = ColorWell(
            (x, y, -x, 40), callback=self.colorChanged, color=colorValue)
        y+=55
        self.w.button = Button(
            (x, y, -x, 20), "Trace!", callback=self.traceButton)
        addObserver(self, "drawWurst", "drawBackground")
        self.w.bind("close", self.closing)
        self.w.open()
示例#8
0
 def _getColor(self, key, fallback):
     if key not in self._values:
         color = getExtensionDefaultColor(key)
         if color is None:
             color = NSColor.colorWithCalibratedRed_green_blue_alpha_(
                 *fallback)
         self._values[key] = color
     return self._values[key]
示例#9
0
    def __init__(self, constructions, font, parentWindow):

        self.font = font
        self.constructions = constructions

        self.w = Sheet((300, 170), parentWindow=parentWindow)
        getExtensionDefault, setExtensionDefault, getExtensionDefaultColor, setExtensionDefaultColor
        y = 15
        self.w.overWrite = CheckBox(
            (15, y, 200, 22),
            "Overwrite Existing Glyphs",
            value=getExtensionDefault(self.overWriteKey, True))

        y += 35
        self.w.autoUnicodes = CheckBox((15, y, 200, 22),
                                       "Auto Unicodes",
                                       value=True)

        y += 35
        self.w.markGlyphs = CheckBox(
            (15, y, 200, 22),
            "Mark Glyphs",
            value=getExtensionDefault(self.overWriteKey, True),
            callback=self.markGlyphsCallback)
        self.w.markGlyphColor = ColorWell(
            (130, y - 5, 50, 30),
            color=getExtensionDefaultColor(self.markColorKey,
                                           NSColor.redColor()))

        self.w.markGlyphColor.enable(
            getExtensionDefault(self.overWriteKey, True))

        self.w.okButton = Button((-70, -30, -15, 20),
                                 "Build",
                                 callback=self.buildCallback,
                                 sizeStyle="small")
        self.w.setDefaultButton(self.w.okButton)

        self.w.closeButton = Button((-140, -30, -80, 20),
                                    "Cancel",
                                    callback=self.closeCallback,
                                    sizeStyle="small")
        self.w.closeButton.bind(".", ["command"])
        self.w.closeButton.bind(unichr(27), [])

        self.w.open()
示例#10
0
    def populateView(self):
        """
        The UI
        """
        self.fillColor = getExtensionDefaultColor(self.DEFAULTKEY_FILLCOLOR,
                                                  self.FALLBACK_FILLCOLOR)
        self.strokeColor = getExtensionDefaultColor(
            self.DEFAULTKEY_STROKECOLOR, self.FALLBACK_STROKECOLOR)
        self.contextBefore = self.contextAfter = ''

        # Populating the view can only happen after the view is attached to the window,
        # or else the relative widths go wrong.
        view = self.getView()
        view.add = Button((-40, 3, 30, 22), '+', callback=self.addCallback)
        view.reset = Button((-40, 30, 30, 22),
                            chr(8634),
                            callback=self.resetCallback)
        # Flag to see if the selection list click is in progress. We are resetting the selection
        # ourselves, using the list "buttons", but changing that selection will cause another
        # list update, that should be ignored.
        self._selectionChanging = False
        # Indicate that we are a drawing module
        self._canDraw = True

        self.sources = []

        x = y = 4

        view.fontList = List(
            (C.C2, y, 250, -65),
            self.getFontItems(),
            selectionCallback=self.fontListCallback,
            drawFocusRing=False,
            enableDelete=False,
            allowsMultipleSelection=False,
            allowsEmptySelection=True,
            drawHorizontalLines=True,
            showColumnTitles=False,
            columnDescriptions=self.getPathListDescriptor(),
            rowHeight=16,
        )
        view.viewEnabled = CheckBox((x, y, C.BUTTON_WIDTH, 22),
                                    "Show",
                                    callback=self.viewCallback,
                                    sizeStyle=C.STYLE_CHECKBOXSIZE,
                                    value=True)
        y += C.L
        view.fill = CheckBox(
            (x, y, 60, 22),
            "Fill",
            sizeStyle=C.STYLE_CHECKBOXSIZE,
            #value=getExtensionDefault("%s.%s" %(self.DEFAULTKEY, "fill"), True),
            value=True,
            callback=self.fillCallback)
        y += C.L
        color = getExtensionDefaultColor(self.DEFAULTKEY_FILLCOLOR,
                                         self.FALLBACK_FILLCOLOR)
        view.color = ColorWell((x, y, 60, 22),
                               color=color,
                               callback=self.colorCallback)
        y += C.L + 5
        view.stroke = CheckBox(
            (x, y, 60, 22),
            "Stroke",
            sizeStyle=C.STYLE_CHECKBOXSIZE,
            #value=getExtensionDefault("%s.%s" %(self.DEFAULTKEY, "stroke"), False),
            value=False,
            callback=self.strokeCallback)

        y += C.LL
        view.alignText = TextBox((x, y, 90, 50),
                                 'Alignment',
                                 sizeStyle=C.STYLE_LABELSIZE)
        y += C.L
        view.align = RadioGroup((x, y, 90, 50), ['Left', 'Center', 'Right'],
                                isVertical=True,
                                sizeStyle=C.STYLE_RADIOSIZE,
                                callback=self.alignCallback)
        view.align.set(0)

        #view.contextLabel = TextBox((C.C2, -58, 90, 50), 'Contexts', sizeStyle=C.STYLE_LABELSIZE)

        view.viewCurrent = CheckBox((C.C2, -60, 150, 22),
                                    "Always View Current",
                                    sizeStyle=C.STYLE_CHECKBOXSIZE,
                                    value=False,
                                    callback=self.contextEditCallback)

        #view.contextUandlc = CheckBox((C.C2+170, -60, 85, 22), "Match Case", sizeStyle=C.STYLE_CHECKBOXSIZE,
        #    value = False,
        #    callback=self.contextEditCallback)

        view.contextBefore = EditText((C.C2, -30, 85, 20),
                                      callback=self.contextEditCallback,
                                      continuous=True,
                                      sizeStyle="small",
                                      placeholder='Left Context')
        view.contextCurrent = EditText(
            (C.C2 + 95, -30, 60, 20),
            callback=self.contextCurrentEditCallback,
            continuous=True,
            sizeStyle="small")
        view.contextAfter = EditText((C.C2 + 165, -30, 85, 20),
                                     callback=self.contextEditCallback,
                                     continuous=True,
                                     sizeStyle="small",
                                     placeholder='Right Context')
        self.activateModule()
        self.setUpBaseWindowBehavior()
 def load(self):
     self.fillColor = getExtensionDefaultColor(_fillColorDefaultKey, self._fallBackFillColor)
     self.strokeColor = getExtensionDefaultColor(_strokeColorDefaultKey, self._fallBackStrokeColor)
     self.showPreview = getExtensionDefault(_showPreviewDefaultKey, self._fallbackShowPreview)
     self.data = getExtensionDefault(_dataDefaultKey, self._fallbackData)
    def __init__(self):

        self.w = FloatingWindow((300, 510), "Outline Palette")

        y = 5
        middle = 135
        textMiddle = middle - 27
        y += 10
        self.w._tickness = TextBox((0, y-3, textMiddle, 17), 'Thickness:', alignment="right")

        ticknessValue = getExtensionDefault("%s.%s" % (outlinePaletteDefaultKey, "thickness"), 10)

        self.w.tickness = Slider((middle, y, -50, 15),
                                 minValue=1,
                                 maxValue=200,
                                 callback=self.parametersChanged,
                                 value=ticknessValue)
        self.w.ticknessText = EditText((-40, y, -10, 17), ticknessValue,
                                       callback=self.parametersTextChanged,
                                       sizeStyle="small")
        y += 33
        self.w._contrast = TextBox((0, y-3, textMiddle, 17), 'Contrast:', alignment="right")

        contrastValue = getExtensionDefault("%s.%s" % (outlinePaletteDefaultKey, "contrast"), 0)

        self.w.contrast = Slider((middle, y, -50, 15),
                                 minValue=0,
                                 maxValue=200,
                                 callback=self.parametersChanged,
                                 value=contrastValue)
        self.w.contrastText = EditText((-40, y, -10, 17), contrastValue,
                                       callback=self.parametersTextChanged,
                                       sizeStyle="small")
        y += 33
        self.w._contrastAngle = TextBox((0, y-3, textMiddle, 17), 'Contrast Angle:', alignment="right")

        contrastAngleValue = getExtensionDefault("%s.%s" % (outlinePaletteDefaultKey, "contrastAngle"), 0)

        self.w.contrastAngle = Slider((middle, y-10, 30, 30),
                                 minValue=0,
                                 maxValue=360,
                                 callback=self.contrastAngleCallback,
                                 value=contrastValue)
        self.w.contrastAngle.getNSSlider().cell().setSliderType_(NSCircularSlider)
        self.w.contrastAngleText = EditText((-40, y, -10, 17), contrastAngleValue,
                                       callback=self.parametersTextChanged,
                                       sizeStyle="small")

        y += 33

        self.w._miterLimit = TextBox((0, y-3, textMiddle, 17), 'MiterLimit:', alignment="right")

        connectmiterLimitValue = getExtensionDefault("%s.%s" % (outlinePaletteDefaultKey, "connectmiterLimit"), True)

        self.w.connectmiterLimit = CheckBox((middle-22, y-3, 20, 17), "",
                                             callback=self.connectmiterLimit,
                                             value=connectmiterLimitValue)

        miterLimitValue = getExtensionDefault("%s.%s" % (outlinePaletteDefaultKey, "miterLimit"), 10)

        self.w.miterLimit = Slider((middle, y, -50, 15),
                                    minValue=1,
                                    maxValue=200,
                                    callback=self.parametersChanged,
                                    value=miterLimitValue)
        self.w.miterLimitText = EditText((-40, y, -10, 17), miterLimitValue,
                                          callback=self.parametersTextChanged,
                                          sizeStyle="small")

        self.w.miterLimit.enable(not connectmiterLimitValue)
        self.w.miterLimitText.enable(not connectmiterLimitValue)

        y += 30

        cornerAndCap = ["Square", "Round", "Butt"]

        self.w._corner = TextBox((0, y, textMiddle, 17), 'Corner:', alignment="right")
        self.w.corner = PopUpButton((middle-2, y-2, -48, 22), cornerAndCap, callback=self.parametersTextChanged)

        y += 30

        self.w._cap = TextBox((0, y, textMiddle, 17), 'Cap:', alignment="right")
        useCapValue = getExtensionDefault("%s.%s" % (outlinePaletteDefaultKey, "closeOpenPath"), False)
        self.w.useCap = CheckBox((middle-22, y, 20, 17), "",
                                             callback=self.useCapCallback,
                                             value=useCapValue)
        self.w.cap = PopUpButton((middle-2, y-2, -48, 22), cornerAndCap, callback=self.parametersTextChanged)
        self.w.cap.enable(useCapValue)

        cornerValue = getExtensionDefault("%s.%s" % (outlinePaletteDefaultKey, "corner"), "Square")
        if cornerValue in cornerAndCap:
            self.w.corner.set(cornerAndCap.index(cornerValue))

        capValue = getExtensionDefault("%s.%s" % (outlinePaletteDefaultKey, "cap"), "Square")
        if capValue in cornerAndCap:
            self.w.cap.set(cornerAndCap.index(capValue))

        y += 33

        self.w.keepBounds = CheckBox((middle-3, y, middle, 22), "Keep Bounds",
                                   value=getExtensionDefault("%s.%s" % (outlinePaletteDefaultKey, "keepBounds"), False),
                                   callback=self.parametersTextChanged)
        y += 30
        self.w.optimizeCurve = CheckBox((middle-3, y, middle, 22), "Optimize Curve",
                                   value=getExtensionDefault("%s.%s" % (outlinePaletteDefaultKey, "optimizeCurve"), False),
                                   callback=self.parametersTextChanged)
        y += 30                           
        self.w.addOriginal = CheckBox((middle-3, y, middle, 22), "Add Source",
                                   value=getExtensionDefault("%s.%s" % (outlinePaletteDefaultKey, "addOriginal"), False),
                                   callback=self.parametersTextChanged)
        y += 30
        self.w.addInner = CheckBox((middle-3, y, middle, 22), "Add Left",
                                   value=getExtensionDefault("%s.%s" % (outlinePaletteDefaultKey, "addLeft"), True),
                                   callback=self.parametersTextChanged)
        y += 30
        self.w.addOuter = CheckBox((middle-3, y, middle, 22), "Add Right",
                                   value=getExtensionDefault("%s.%s" % (outlinePaletteDefaultKey, "addRight"), True),
                                   callback=self.parametersTextChanged)

        y += 35

        self.w.preview = CheckBox((middle-3, y, middle, 22), "Preview",
                               value=getExtensionDefault("%s.%s" % (outlinePaletteDefaultKey, "preview"), True),
                               callback=self.previewCallback)
        y += 30
        self.w.fill = CheckBox((middle-3+10, y, middle, 22), "Fill",
                               value=getExtensionDefault("%s.%s" % (outlinePaletteDefaultKey, "fill"), False),
                               callback=self.fillCallback, sizeStyle="small")
        y += 25
        self.w.stroke = CheckBox((middle-3+10, y, middle, 22), "Stroke",
                               value=getExtensionDefault("%s.%s" % (outlinePaletteDefaultKey, "stroke"), True),
                               callback=self.strokeCallback, sizeStyle="small")

        color = NSColor.colorWithCalibratedRed_green_blue_alpha_(0, 1, 1, .8)

        self.w.color = ColorWell(((middle-5)*1.7, y-33, -10, 60),
                                 color=getExtensionDefaultColor("%s.%s" % (outlinePaletteDefaultKey, "color"), color),
                                 callback=self.colorCallback)

        self.previewCallback(self.w.preview)

        self.w.apply = Button((-70, -55, -10, 22), "Expand", self.expand, sizeStyle="small")
        self.w.applyNewFont = Button((-190, -55, -80, 22), "Expand Selection", self.expandSelection, sizeStyle="small")
        self.w.applySelection = Button((-290, -55, -200, 22), "Expand Font", self.expandFont, sizeStyle="small")

        self.w.preserveComponents = CheckBox((10, -25, -10, 22), "Preserve Components", sizeStyle="small",
                                value=getExtensionDefault("%s.%s" % (outlinePaletteDefaultKey, "preserveComponents"), False),
                                callback=self.parametersTextChanged)
        self.setUpBaseWindowBehavior()

        addObserver(self, "drawOutline", "drawBackground")
        self.parametersTextChanged
        self.w.open()
示例#13
0
 def __init__(self):
     
     # Preferences
     self._drawing = getExtensionDefault(self.DEFAULTKEY_DRAW, True)
     self._fill = getExtensionDefault(self.DEFAULTKEY_FILL, True)
     self._stroke = getExtensionDefault(self.DEFAULTKEY_STROKE, True)
     self._points = getExtensionDefault(self.DEFAULTKEY_POINTS, True)
     
     self._fillColor = getExtensionDefaultColor(self.DEFAULTKEY_FILLCOLOR, self.FALLBACK_FILLCOLOR)
     self._strokeColor = getExtensionDefaultColor(self.DEFAULTKEY_STROKECOLOR, self.FALLBACK_STROKECOLOR)
     self._pointsColor = getExtensionDefaultColor(self.DEFAULTKEY_POINTSCOLOR, self.FALLBACK_POINTSCOLOR)
     
     self._alignment = getExtensionDefault(self.DEFAULTKEY_ALIGNMENT, 0)
     self._kerning = getExtensionDefault(self.DEFAULTKEY_KERNING, 1)
     self._floating = getExtensionDefault(self.DEFAULTKEY_FLOATING, 1)
     
     # User preferences
     self._onCurvePointsSize = getDefault("glyphViewOncurvePointsSize") # typo, should be: OnCurve
     self._offCurvePointsSize = getDefault("glyphViewOffCurvePointsSize")
     self._strokeWidth = getDefault("glyphViewStrokeWidth")
     
     w, h = 400, 195
     x = y = 10
     
     self.initAllFonts()
     
     self.w = FloatingWindow((w, h), "Overlay UFOs")
     self.w.draw = CheckBox((x, y, 95, 18), "Draw", callback=self.drawCallback, value=self._drawing, sizeStyle="small")
     x += 60
     self.w.fill = CheckBox((x, y, 95, 18), "Fill", callback=self.fillCallback, value=self._fill, sizeStyle="small")
     x += 40
     self.w.fillColor = ColorWell((x, y, 45, 20), callback=self.fillColorCallback, color=self._fillColor)
     x += 60
     self.w.stroke = CheckBox((x, y, 95, 18), "Stroke", callback=self.strokeCallback, value=self._stroke, sizeStyle="small")
     x += 60
     self.w.strokeColor = ColorWell((x, y, 45, 20), callback=self.strokeColorCallback, color=self._strokeColor)
     x += 60
     self.w.points = CheckBox((x, y, 95, 18), "Points", callback=self.pointsCallback, value=self._points, sizeStyle="small")
     x += 60
     self.w.pointsColor = ColorWell((x, y, 45, 20), callback=self.pointsColorCallback, color=self._pointsColor)
     x, y = 10, 40
     self.w.alignText = TextBox((x, y, 250, 15), "Alignment:", sizeStyle="small")
     y += 18
     self.w.alignment = RadioGroup((x, y, 80, 55), ['Left', 'Center', 'Right'], isVertical=True, callback=self.alignmentCallback, sizeStyle="small")
     self.w.alignment.set(self._alignment)
     y += 62
     self.w.kerning = CheckBox((x, y, 100, 10), "Show kerning", callback=self.kerningCallback, value=self._kerning, sizeStyle="mini")
     y += 18
     self.w.floating = CheckBox((x, y, 100, 10), "Floating Window", callback=self.floatingCallback, value=self._floating, sizeStyle="mini")
     y += 25
     self.w.resetDefaults = Button((x, y, 85, 14), "Reset settings", callback=self.resetSettingsCallback, sizeStyle="mini")
     x, y = 110, 40
     self.w.fontList = List((x, y, 240, 55), self.getFontItems(), 
         columnDescriptions=self.getListDescriptor(), showColumnTitles=False,
         selectionCallback=None, doubleClickCallback=self.fontListCallback,
         allowsMultipleSelection=True, allowsEmptySelection=True,
         drawVerticalLines=False, drawHorizontalLines=True,
         drawFocusRing=False, rowHeight=16
     )
     y += 55
     self.w.hiddenFontList = List((x, y, 240, 55), self.getHiddenFontItems(), 
         columnDescriptions=self.getListDescriptor(), showColumnTitles=False,
         selectionCallback=None, doubleClickCallback=self.hiddenFontListCallback,
         allowsMultipleSelection=True, allowsEmptySelection=True,
         drawVerticalLines=False, drawHorizontalLines=True,
         drawFocusRing=False, rowHeight=16
     )
     self._selectionChanging = False
     self.w.fontList.setSelection([]) # unselect
     y += 65
     self.w.contextLeft = EditText((x, y, 90, 20), callback=self.contextCallback, continuous=True, placeholder="Left", sizeStyle="small")
     self.w.contextCurrent = EditText((x+95, y, 50, 20), callback=self.contextCallback, continuous=True, placeholder="?", sizeStyle="small")
     self.w.contextRight = EditText((x+150, y, 90, 20), callback=self.contextCallback, continuous=True, placeholder="Right", sizeStyle="small")
     x, y = 360, 100
     self.w.addFonts = Button((x, y, 30, 20), "+", callback=self.addHiddenFontsCallback, sizeStyle="regular")
     y += 25
     self.w.removeFonts = Button((x, y, 30, 20), unichr(8722), callback=self.removeHiddenFontsCallback, sizeStyle="regular")
             
     # Observers
     addObserver(self, "fontDidOpen", "fontDidOpen")
     addObserver(self, "fontWillClose", "fontWillClose") # fontDidClose?
     addObserver(self, "draw", "drawInactive")
     addObserver(self, "draw", "draw")
     
     # Prepare and open window
     self.setWindowLevel()
     self.setUpBaseWindowBehavior()
     self.w.open()
示例#14
0
    def __init__(self):

        self.w = FloatingWindow((300, 450), "Outline Palette")

        y = 5
        middle = 135
        textMiddle = middle - 27
        y += 10
        self.w._tickness = TextBox((0, y-3, textMiddle, 17), 'Thickness:', alignment="right")

        ticknessValue = getExtensionDefault("%s.%s" %(outlinePaletteDefaultKey, "thickness"), 10)

        self.w.tickness = Slider((middle, y, -50, 15),
                                 minValue=1,
                                 maxValue=200,
                                 callback=self.parametersChanged,
                                 value=ticknessValue)
        self.w.ticknessText = EditText((-40, y, -10, 17), ticknessValue,
                                       callback=self.parametersTextChanged,
                                       sizeStyle="small")
        y += 33
        self.w._contrast = TextBox((0, y-3, textMiddle, 17), 'Contrast:', alignment="right")

        contrastValue = getExtensionDefault("%s.%s" %(outlinePaletteDefaultKey, "contrast"), 0)

        self.w.contrast = Slider((middle, y, -50, 15),
                                 minValue=0,
                                 maxValue=200,
                                 callback=self.parametersChanged,
                                 value=contrastValue)
        self.w.contrastText = EditText((-40, y, -10, 17), contrastValue,
                                       callback=self.parametersTextChanged,
                                       sizeStyle="small")
        y += 33
        self.w._contrastAngle = TextBox((0, y-3, textMiddle, 17), 'Contrast Angle:', alignment="right")

        contrastAngleValue = getExtensionDefault("%s.%s" %(outlinePaletteDefaultKey, "contrastAngle"), 0)

        self.w.contrastAngle = Slider((middle, y-10, 30, 30),
                                 minValue=0,
                                 maxValue=360,
                                 callback=self.contrastAngleCallback,
                                 value=contrastValue)
        self.w.contrastAngle.getNSSlider().cell().setSliderType_(NSCircularSlider)
        self.w.contrastAngleText = EditText((-40, y, -10, 17), contrastAngleValue,
                                       callback=self.parametersTextChanged,
                                       sizeStyle="small")

        y += 33

        self.w._miterLimit = TextBox((0, y-3, textMiddle, 17), 'MiterLimit:', alignment="right")

        connectmiterLimitValue = getExtensionDefault("%s.%s" %(outlinePaletteDefaultKey, "connectmiterLimit"), True)

        self.w.connectmiterLimit = CheckBox((middle-22, y-3, 20, 17), "",
                                             callback=self.connectmiterLimit,
                                             value=connectmiterLimitValue)

        miterLimitValue = getExtensionDefault("%s.%s" %(outlinePaletteDefaultKey, "miterLimit"), 10)

        self.w.miterLimit = Slider((middle, y, -50, 15),
                                    minValue=1,
                                    maxValue=200,
                                    callback=self.parametersChanged,
                                    value=miterLimitValue)
        self.w.miterLimitText = EditText((-40, y, -10, 17), miterLimitValue,
                                          callback=self.parametersTextChanged,
                                          sizeStyle="small")

        self.w.miterLimit.enable(not connectmiterLimitValue)
        self.w.miterLimitText.enable(not connectmiterLimitValue)

        y += 30

        cornerAndCap = ["Square", "Round", "Butt"]

        self.w._corner = TextBox((0, y, textMiddle, 17), 'Corner:', alignment="right")
        self.w.corner = PopUpButton((middle-2, y-2, -48, 22), cornerAndCap, callback=self.parametersTextChanged)

        y += 30

        self.w._cap = TextBox((0, y, textMiddle, 17), 'Cap:', alignment="right")
        useCapValue = getExtensionDefault("%s.%s" %(outlinePaletteDefaultKey, "closeOpenPath"), False)
        self.w.useCap = CheckBox((middle-22, y, 20, 17), "",
                                             callback=self.useCapCallback,
                                             value=useCapValue)
        self.w.cap = PopUpButton((middle-2, y-2, -48, 22), cornerAndCap, callback=self.parametersTextChanged)
        self.w.cap.enable(useCapValue)

        cornerValue = getExtensionDefault("%s.%s" %(outlinePaletteDefaultKey, "corner"), "Square")
        if cornerValue in cornerAndCap:
            self.w.corner.set(cornerAndCap.index(cornerValue))

        capValue = getExtensionDefault("%s.%s" %(outlinePaletteDefaultKey, "cap"), "Square")
        if capValue in cornerAndCap:
            self.w.cap.set(cornerAndCap.index(capValue))

        y += 33

        self.w.addOriginal = CheckBox((middle-3, y, middle, 22), "Add Source",
                                      value=getExtensionDefault("%s.%s" %(outlinePaletteDefaultKey, "addOriginal"), False),
                                      callback=self.parametersTextChanged)
        y += 30
        self.w.addInner = CheckBox((middle-3, y, middle, 22), "Add Left",
                                   value=getExtensionDefault("%s.%s" %(outlinePaletteDefaultKey, "addLeft"), True),
                                   callback=self.parametersTextChanged)
        y += 30
        self.w.addOuter = CheckBox((middle-3, y, middle, 22), "Add Right",
                                   value=getExtensionDefault("%s.%s" %(outlinePaletteDefaultKey, "addRight"), True),
                                   callback=self.parametersTextChanged)

        y += 35



        self.w.preview = CheckBox((middle-3, y, middle, 22), "Preview",
                               value=getExtensionDefault("%s.%s" %(outlinePaletteDefaultKey, "preview"), True),
                               callback=self.previewCallback)
        y += 30
        self.w.fill = CheckBox((middle-3+10, y, middle, 22), "Fill",
                               value=getExtensionDefault("%s.%s" %(outlinePaletteDefaultKey, "fill"), False),
                               callback=self.fillCallback, sizeStyle="small")
        y += 25
        self.w.stroke = CheckBox((middle-3+10, y, middle, 22), "Stroke",
                               value=getExtensionDefault("%s.%s" %(outlinePaletteDefaultKey, "stroke"), True),
                               callback=self.strokeCallback, sizeStyle="small")

        color = NSColor.colorWithCalibratedRed_green_blue_alpha_(0, 1, 1, .8)

        self.w.color = ColorWell(((middle-5)*1.7, y-33, -10, 60),
                                 color=getExtensionDefaultColor("%s.%s" %(outlinePaletteDefaultKey, "color"), color),
                                 callback=self.colorCallback)

        self.previewCallback(self.w.preview)

        self.w.apply = Button((-70, -55, -10, 22), "Expand", self.expand, sizeStyle="small")
        self.w.applyNewFont = Button((-190, -55, -80, 22), "Expand Selection", self.expandSelection, sizeStyle="small")
        self.w.applySelection = Button((-290, -55, -200, 22), "Expand Font", self.expandFont, sizeStyle="small")
        
        self.w.preserveComponents = CheckBox((10, -25, -10, 22), "Preserve Components", sizeStyle="small",
                                value=getExtensionDefault("%s.%s" %(outlinePaletteDefaultKey, "preserveComponents"), False),
                                callback=self.parametersTextChanged)
        self.setUpBaseWindowBehavior()

        addObserver(self, "drawOutline", "drawBackground")
        self.parametersTextChanged
        self.w.open()
示例#15
0
    def becomeActive(self):
        """
        Boot up the dialog.
        """

        self.fillColor = getExtensionDefaultColor(self.DEFAULTKEY_FILLCOLOR,
                                                  self.FALLBACK_FILLCOLOR)
        self.strokeColor = getExtensionDefaultColor(
            self.DEFAULTKEY_STROKECOLOR, self.FALLBACK_STROKECOLOR)

        self.w = FloatingWindow((260, 130),
                                "Bounding Options",
                                minSize=(100, 100),
                                closable=False)

        self.w.viewOptions = RadioGroup((10, 10, 150, 20),
                                        ['Selection', 'Glyph'],
                                        callback=self.selectionCallback,
                                        isVertical=False,
                                        sizeStyle="small")
        self.w.viewOptions.set(
            getExtensionDefault(self.DEFAULTKEY_SELECTION, 0))

        self.w.useItalic = CheckBox(
            (165, 10, 100, 20),
            "Use Italic",
            value=getExtensionDefault(self.DEFAULTKEY_USEITALIC, True),
            sizeStyle="small",
            callback=self.useItalicCallback)

        self.w.xLabel = TextBox((10, 40, 70, 20),
                                "Divisions: X",
                                sizeStyle="small")

        self.w.divisionsRadioX = Slider(
            (80, 40, 70, 20),
            value=getExtensionDefault(self.DEFAULTKEY_DIVISIONSX, 1),
            minValue=1,
            maxValue=4,
            tickMarkCount=4,
            stopOnTickMarks=True,
            continuous=True,
            sizeStyle="small",
            callback=self.divisionsXCallback)

        self.w.yLabel = TextBox((160, 40, 70, 20), "Y", sizeStyle="small")
        self.w.divisionsRadioY = Slider(
            (175, 40, 70, 20),
            value=getExtensionDefault(self.DEFAULTKEY_DIVISIONSY, 1),
            minValue=1,
            maxValue=4,
            tickMarkCount=4,
            stopOnTickMarks=True,
            continuous=True,
            sizeStyle="small",
            callback=self.divisionsYCallback)

        self.w.drawGuidesButton = Button((10, 100, 90, 20),
                                         'Div Guides',
                                         callback=self.drawDivGuides,
                                         sizeStyle="small")
        self.w.drawBoxGuidesButton = Button(
            (120, 100, 90, 20),
            'Box Guides',
            callback=self.drawBoxGuides,
            sizeStyle="small",
        )

        x = 10
        y = 70
        self.w.showCoordinates = CheckBox(
            (x, y, 90, 20),
            "Coordinates",
            value=getExtensionDefault(self.DEFAULTKEY_SHOWCOORDINATES, True),
            sizeStyle="small",
            callback=self.showCoordinatesCallback)
        x += 90
        self.w.showDimensions = CheckBox(
            (x, y, 90, 20),
            "Dimensions",
            value=getExtensionDefault(self.DEFAULTKEY_SHOWDIMENSIONS, True),
            sizeStyle="small",
            callback=self.showDimensionsCallback)

        x += 90
        color = getExtensionDefaultColor(self.DEFAULTKEY_FILLCOLOR,
                                         self.FALLBACK_FILLCOLOR)
        self.w.color = ColorWell((x, y, 30, 22),
                                 color=color,
                                 callback=self.colorCallback)

        self.setUpBaseWindowBehavior()
        self.w.open()
示例#16
0
    def populateView(self):

        self.fillColor = getExtensionDefaultColor(self.DEFAULTKEY_FILLCOLOR,
                                                  self.FALLBACK_FILLCOLOR)
        self.strokeColor = getExtensionDefaultColor(
            self.DEFAULTKEY_STROKECOLOR, self.FALLBACK_STROKECOLOR)

        doWindow = True
        if doWindow:
            view = self.getView()
            x = 10
            y = 10
            y += 30
            view.diacriticList = List(
                (x, y, -10, -10),
                [],
                columnDescriptions=[
                    {
                        "title": "Accent",
                        "editable": False,
                        'enableDelete': True,
                        'typingSensitive': True
                    },
                    {
                        "title": "Anchor",
                        "editable": True,
                        'enableDelete': True,
                        'typingSensitive': True
                    },
                ],
                doubleClickCallback=self.doubleClickCallback,
                #editCallback=self.modifyCallback,
                selectionCallback=self.selectionCallback)

            y -= 30
            view.glyphName = TextBox((x, y, 200, 25), '')

            x = -240
            view.guides = CheckBox(
                (x, y, 60, 22),
                "Guides",
                sizeStyle="small",
                #value=getExtensionDefault("%s.%s" %(self.DEFAULTKEY, "stroke"), False),
                value=True,
                callback=self.updateView)
            x += 60
            view.fill = CheckBox(
                (x, y, 40, 22),
                "Fill",
                sizeStyle="small",
                #value=getExtensionDefault("%s.%s" %(self.DEFAULTKEY, "fill"), True),
                value=True,
                callback=self.fillCallback)
            x += 40
            view.stroke = CheckBox(
                (x, y, 60, 22),
                "Stroke",
                sizeStyle="small",
                #value=getExtensionDefault("%s.%s" %(self.DEFAULTKEY, "stroke"), False),
                value=True,
                callback=self.strokeCallback)
            x += 60
            color = getExtensionDefaultColor(self.DEFAULTKEY_FILLCOLOR,
                                             self.FALLBACK_FILLCOLOR)
            view.color = ColorWell((x, y, 30, 22),
                                   color=color,
                                   callback=self.colorCallback)
            x += 40
            view.reset = Button((x, y, 30, 22),
                                unichr(8634),
                                callback=self.clearSelectionCallback)

            self.setUpBaseWindowBehavior()

        self.setShowAccents(self.current)

        UpdateCurrentGlyphView()
示例#17
0
    def __init__(self):
        
        self.w = FloatingWindow((270, 340), "Outline Palette")
        
        y = 5
        middle = 110
        textMiddle = middle - 27
        y += 10
        self.w._tickness = TextBox((0, y-3, textMiddle, 17), 'Thickness:', alignment="right")
        
        ticknessValue = getExtensionDefault("%s.%s" %(outlinePaletteDefaultKey, "thickness"), 10)
        
        self.w.tickness = Slider((middle, y, -50, 15), 
                                 minValue=1, 
                                 maxValue=200, 
                                 callback=self.parametersChanged, 
                                 value=ticknessValue)
        self.w.ticknessText = EditText((-40, y, -10, 17), ticknessValue, 
                                       callback=self.parametersTextChanged, 
                                       sizeStyle="small")
        
        y += 33
        
        self.w._miterLimit = TextBox((0, y-3, textMiddle, 17), 'MiterLimit:', alignment="right")
        
        connectmiterLimitValue = getExtensionDefault("%s.%s" %(outlinePaletteDefaultKey, "connectmiterLimit"), True)
        
        self.w.connectmiterLimit = CheckBox((middle-22, y-3, 20, 17), "", 
                                             callback=self.connectmiterLimit, 
                                             value=connectmiterLimitValue)
        
        miterLimitValue = getExtensionDefault("%s.%s" %(outlinePaletteDefaultKey, "miterLimit"), 10)
        
        self.w.miterLimit = Slider((middle, y, -50, 15), 
                                    minValue=1, 
                                    maxValue=200, 
                                    callback=self.parametersChanged, 
                                    value=miterLimitValue)
        self.w.miterLimitText = EditText((-40, y, -10, 17), miterLimitValue, 
                                          callback=self.parametersTextChanged, 
                                          sizeStyle="small")
        
        self.w.miterLimit.enable(not connectmiterLimitValue)
        self.w.miterLimitText.enable(not connectmiterLimitValue)
        
        y += 30
        
        cornerAndCap = ["Square", "Round", "Butt"]
        
        self.w._corner = TextBox((0, y, textMiddle, 17), 'Corner:', alignment="right")
        self.w.corner = PopUpButton((middle-2, y-2, -48, 22), cornerAndCap, callback=self.parametersTextChanged)        
        
        y += 30
        
        self.w._cap = TextBox((0, y, textMiddle, 17), 'Cap:', alignment="right")
        useCapValue = getExtensionDefault("%s.%s" %(outlinePaletteDefaultKey, "closeOpenPath"), False)
        self.w.useCap = CheckBox((middle-22, y, 20, 17), "", 
                                             callback=self.useCapCallback, 
                                             value=useCapValue)
        self.w.cap = PopUpButton((middle-2, y-2, -48, 22), cornerAndCap, callback=self.parametersTextChanged) 
        self.w.cap.enable(useCapValue)       
        
        cornerValue = getExtensionDefault("%s.%s" %(outlinePaletteDefaultKey, "corner"), "Square")
        if cornerValue in cornerAndCap:
            self.w.corner.set(cornerAndCap.index(cornerValue))
        
        capValue = getExtensionDefault("%s.%s" %(outlinePaletteDefaultKey, "cap"), "Square")
        if capValue in cornerAndCap:
            self.w.cap.set(cornerAndCap.index(capValue))
            
        y += 33
        
        self.w.addOriginal = CheckBox((middle-3, y, middle, 22), "Add Source", 
                                      value=getExtensionDefault("%s.%s" %(outlinePaletteDefaultKey, "addOriginal"), False), 
                                      callback=self.parametersTextChanged)
        y += 30
        self.w.addInner = CheckBox((middle-3, y, middle, 22), "Add Left", 
                                   value=getExtensionDefault("%s.%s" %(outlinePaletteDefaultKey, "addLeft"), True), 
                                   callback=self.parametersTextChanged)
        y += 30
        self.w.addOuter = CheckBox((middle-3, y, middle, 22), "Add Right", 
                                   value=getExtensionDefault("%s.%s" %(outlinePaletteDefaultKey, "addRight"), True), 
                                   callback=self.parametersTextChanged)
        
        y += 35
        
        
        
        
        self.w.fill = CheckBox((middle-3, y, middle, 22), "Fill", 
                               value=getExtensionDefault("%s.%s" %(outlinePaletteDefaultKey, "fill"), False), 
                               callback=self.fillCallback)
        y += 30
        self.w.stroke = CheckBox((middle-3, y, middle, 22), "Stroke", 
                               value=getExtensionDefault("%s.%s" %(outlinePaletteDefaultKey, "stroke"), True), 
                               callback=self.strokeCallback)
        
        color = NSColor.colorWithCalibratedRed_green_blue_alpha_(0, 1, 1, .8)

        self.w.color = ColorWell(((middle-5)*1.7, y-33, -10, 60), 
                                 color=getExtensionDefaultColor("%s.%s" %(outlinePaletteDefaultKey, "color"), color),
                                 callback=self.colorCallback)
        
        self.w.apply = Button((-100, -30, -10, 22), "Expand", self.expand)
        self.w.applyAll = Button((-220, -30, -110, 22), "Expand Font", self.expandFont)
        self.setUpBaseWindowBehavior()
        
        addObserver(self, "drawOutline", "drawBackground")
        self.parametersTextChanged
        self.w.open()
示例#18
0
    def __init__(self):

        self.w = FloatingWindow((self._width + 2 * self._frame, self._height),
                                self._title)

        # ----------
        # text boxes
        # ----------

        textBoxY = self._padding

        self.w.steps_label = TextBox(
            (self._col_0, textBoxY, self._col_width, self._lineHeight),
            'Steps',
            alignment='right')
        if rfVersion >= 3.4:
            self.w.steps_text = NumberEditText(
                (self._col_1, textBoxY - 2, self._col_width, self._lineHeight),
                self.steps,
                callback=self.angleCallback,
                allowFloat=False,
                allowNegative=False,
                allowEmpty=False,
                minimum=1,
                decimals=0,
                continuous=True)
        else:
            self.w.steps_text = EditText(
                (self._col_1, textBoxY - 2, self._col_width, self._lineHeight),
                self.steps,
                callback=self.angleCallback,
                continuous=True)

        textBoxY += (self._row)

        self.w.xValue_label = TextBox(
            (self._col_0, textBoxY, self._col_width, self._lineHeight),
            'x',
            alignment='right')

        if rfVersion >= 3.4:
            self.w.xValue_text = NumberEditText(
                (self._col_1, textBoxY - 2, self._col_width, self._lineHeight),
                self.xValue,
                callback=self.xCallback,
                allowFloat=True,
                decimals=0)
        else:
            self.w.xValue_text = EditText(
                (self._col_1, textBoxY - 2, self._col_width, self._lineHeight),
                self.xValue,
                callback=self.xCallback)

        textBoxY += (self._row)

        self.w.yValue_label = TextBox(
            (self._col_0, textBoxY, self._col_width, self._lineHeight),
            'y',
            alignment='right')

        if rfVersion >= 3.4:
            self.w.yValue_text = NumberEditText(
                (self._col_1, textBoxY - 2, self._col_width, self._lineHeight),
                self.yValue,
                callback=self.yCallback,
                allowFloat=True,
                decimals=0)
        else:
            self.w.yValue_text = EditText(
                (self._col_1, textBoxY - 2, self._col_width, self._lineHeight),
                self.yValue,
                callback=self.yCallback)
        textBoxY += (self._row)

        self.w.angle_label = TextBox(
            (self._col_0, textBoxY, self._col_width, self._lineHeight),
            'Angle',
            alignment='right')
        self.w.angleResult = TextBox(
            (self._col_1, textBoxY, self._col_width, self._lineHeight),
            u'%s°' % self.niceAngleString(self.angle))
        textBoxY += (self._row)

        textBoxY += (self._row * .25)
        self.w.line = HorizontalLine(
            (self._gutter, textBoxY, -self._gutter, 0.5))
        textBoxY += (self._row * .25)

        self.w.lock_checkbox = CheckBox(
            (self._col_1 - 25, textBoxY, -self._gutter, self._lineHeight),
            'Lock Center',
            value=self.lock,
            callback=self.lockCallback)
        textBoxY += (self._row)

        self.w.rounding_checkbox = CheckBox(
            (self._col_1 - 25, textBoxY, -self._gutter, self._lineHeight),
            'Round Result',
            value=self.rounding,
            callback=self.roundingCallback)
        textBoxY += (self._row)

        # -------
        # buttons
        # -------

        self.w.color = ColorWell(
            (self._col_0, textBoxY, -self._gutter, 2 * self._lineHeight),
            color=getExtensionDefaultColor(
                '%s.%s' % (rotatorDefaults, 'color'), self._color),
            callback=self.colorCallback)
        textBoxY += (self._row)

        self.w.buttonRotate = Button(
            (self._col_0, -30, -self._gutter, self._lineHeight),
            'Rotate',
            callback=self.rotateCallback)

        self.setUpBaseWindowBehavior()
        addObserver(self, 'updateOrigin', 'mouseDragged')
        addObserver(self, 'drawRotationPreview', 'drawBackground')
        addObserver(self, 'drawSolidPreview', 'drawPreview')
        self.w.setDefaultButton(self.w.buttonRotate)
        self.w.open()
示例#19
0
    def populateView(self):
        """
        The UI
        """
        self.fillColor = getExtensionDefaultColor(self.DEFAULTKEY_FILLCOLOR, self.FALLBACK_FILLCOLOR)
        self.strokeColor = getExtensionDefaultColor(self.DEFAULTKEY_STROKECOLOR, self.FALLBACK_STROKECOLOR)
        self.contextBefore = self.contextAfter = ''
        
        # Populating the view can only happen after the view is attached to the window,
        # or else the relative widths go wrong.
        view = self.getView()
        view.add = Button((-40, 3, 30, 22), '+', callback=self.addCallback)
        view.reset = Button((-40, 30, 30, 22), chr(8634), callback=self.resetCallback)
        # Flag to see if the selection list click is in progress. We are resetting the selection
        # ourselves, using the list "buttons", but changing that selection will cause another
        # list update, that should be ignored.
        self._selectionChanging = False
        # Indicate that we are a drawing module
        self._canDraw = True
    
        self.sources = []

        x = y = 4

        view.fontList = List((C.C2, y, 250, -65), self.getFontItems(), 
            selectionCallback=self.fontListCallback,
            drawFocusRing=False, 
            enableDelete=False, 
            allowsMultipleSelection=False,
            allowsEmptySelection=True,
            drawHorizontalLines=True,
            showColumnTitles=False,
            columnDescriptions=self.getPathListDescriptor(),
            rowHeight=16,
        )         
        view.viewEnabled = CheckBox((x, y, C.BUTTON_WIDTH, 22), "Show", 
             callback=self.viewCallback, sizeStyle=C.STYLE_CHECKBOXSIZE, 
             value=True)
        y += C.L
        view.fill = CheckBox((x, y, 60, 22), "Fill", sizeStyle=C.STYLE_CHECKBOXSIZE, 
            #value=getExtensionDefault("%s.%s" %(self.DEFAULTKEY, "fill"), True),
            value = True,
            callback=self.fillCallback)
        y += C.L
        color = getExtensionDefaultColor(self.DEFAULTKEY_FILLCOLOR, self.FALLBACK_FILLCOLOR)
        view.color = ColorWell((x, y, 60, 22), 
            color=color,
            callback=self.colorCallback)
        y += C.L + 5
        view.stroke = CheckBox((x, y, 60, 22), "Stroke", sizeStyle=C.STYLE_CHECKBOXSIZE, 
            #value=getExtensionDefault("%s.%s" %(self.DEFAULTKEY, "stroke"), False),
            value = False, 
            callback=self.strokeCallback)

        y += C.LL
        view.alignText = TextBox((x, y, 90, 50), 'Alignment', sizeStyle=C.STYLE_LABELSIZE)
        y += C.L
        view.align = RadioGroup((x, y, 90, 50), ['Left', 'Center', 'Right'], isVertical=True, 
            sizeStyle=C.STYLE_RADIOSIZE, callback=self.alignCallback)
        view.align.set(0)
        
        #view.contextLabel = TextBox((C.C2, -58, 90, 50), 'Contexts', sizeStyle=C.STYLE_LABELSIZE)

        view.viewCurrent = CheckBox((C.C2, -60, 150, 22), "Always View Current", sizeStyle=C.STYLE_CHECKBOXSIZE,
            value = False,
            callback=self.contextEditCallback)

        #view.contextUandlc = CheckBox((C.C2+170, -60, 85, 22), "Match Case", sizeStyle=C.STYLE_CHECKBOXSIZE,
        #    value = False,
        #    callback=self.contextEditCallback)

        view.contextBefore = EditText((C.C2, -30, 85, 20), callback=self.contextEditCallback, continuous=True, sizeStyle="small", placeholder='Left Context')
        view.contextCurrent = EditText((C.C2+95, -30, 60, 20), callback=self.contextCurrentEditCallback, continuous=True, sizeStyle="small")
        view.contextAfter = EditText((C.C2+165, -30, 85, 20), callback=self.contextEditCallback, continuous=True, sizeStyle="small", placeholder='Right Context')
        self.activateModule()
        self.setUpBaseWindowBehavior()
    def generationSheet(self, sender):

        readableCoord = None
        incomingSpot = None

        if hasattr(sender, 'spot'):
            if hasattr(self.w, 'spotSheet'):
                self.w.spotSheet.close()
            incomingSpot = sender.spot
            ch, j = incomingSpot
            readableCoord = '%s%s'%(ch.upper(), j+1)

        hAxis, vAxis = self.axesGrid['horizontal'], self.axesGrid['vertical']
        self.w.generateSheet = Sheet((500, 275), self.w)
        generateSheet = self.w.generateSheet
        if incomingSpot is None:
            generateSheet.tabs = Tabs((15, 12, -15, -15), ['Instance(s)','Report'])
            instance = generateSheet.tabs[0]
            report = generateSheet.tabs[1]
        elif incomingSpot is not None:
            generateSheet.instance = Group((20, 20, -20, -20))
            instance = generateSheet.instance

        instance.guide = TextBox((10, 7, -10, 22),
            u'A1, B2, C4 — A, C (whole columns) — 1, 5 (whole lines) — * (everything)',
            sizeStyle='small'
            )
        instance.headerBar = HorizontalLine((10, 25, -10, 1))
        instance.spotsListTitle = TextBox((10, 40, 70, 17), 'Locations')
        instance.spots = EditText((100, 40, -10, 22))
        if readableCoord is not None:
            instance.spots.set(readableCoord)

        instance.sourceFontTitle = TextBox((10, 90, -280, 17), 'Source font (naming & groups)', sizeStyle='small')
        instance.sourceFontBar = HorizontalLine((10, 110, -280, 1))
        instance.sourceFont = PopUpButton((10, 120, -280, 22), [fontName(masterFont) for spot, masterFont in self.masters], sizeStyle='small')

        instance.interpolationOptions = TextBox((-250, 90, -10, 17), 'Interpolate', sizeStyle='small')
        instance.optionsBar = HorizontalLine((-250, 110, -10, 1))
        instance.glyphs = CheckBox((-240, 120, -10, 22), 'Glyphs', value=True, sizeStyle='small')
        instance.fontInfos = CheckBox((-240, 140, -10, 22), 'Font info', value=True, sizeStyle='small')
        instance.kerning = CheckBox((-120, 120, -10, 22), 'Kerning', value=True, sizeStyle='small')
        instance.groups = CheckBox((-120, 140, -10, 22), 'Copy Groups', value=True, sizeStyle='small')

        instance.openUI = CheckBox((10, -48, -10, 22), 'Open generated fonts', value=True, sizeStyle='small')
        instance.report = CheckBox((10, -28, -10, 22), 'Generation report', value=False, sizeStyle='small')

        instance.yes = Button((-170, -30, 160, 20), 'Generate Instance(s)', self.getGenerationInfo)
        instance.yes.id = 'instance'
        instance.no = Button((-250, -30, 75, 20), 'Cancel', callback=self.cancelGeneration)

        if incomingSpot is None:
            report.options = RadioGroup((10, 5, -10, 40), ['Report only', 'Report and mark glyphs'], isVertical=False)
            report.options.set(0)
            report.markColors = Group((10, 60, -10, -40))
            report.markColors.title = TextBox((0, 5, -10, 20), 'Mark glyphs', sizeStyle='small')
            report.markColors.bar = HorizontalLine((0, 25, 0, 1))
            report.markColors.compatibleTitle = TextBox((0, 35, 150, 20), 'Compatible')
            report.markColors.compatibleColor = ColorWell(
                (170, 35, -0, 20),
                color=getExtensionDefaultColor('interpolationMatrix.compatibleColor', fallback=NSColor.colorWithCalibratedRed_green_blue_alpha_(0.3,0.8,0,.9)))
            report.markColors.incompatibleTitle = TextBox((0, 60, 150, 20), 'Incompatible')
            report.markColors.incompatibleColor = ColorWell(
                (170, 60, -0, 20),
                color=getExtensionDefaultColor('interpolationMatrix.incompatibleColor', fallback=NSColor.colorWithCalibratedRed_green_blue_alpha_(0.9,0.1,0,1)))
            report.markColors.mixedTitle = TextBox((0, 85, 150, 20), 'Mixed compatibility')
            report.markColors.mixedColor = ColorWell(
                (170, 85, -0, 20),
                color=getExtensionDefaultColor('interpolationMatrix.mixedColor', fallback=NSColor.colorWithCalibratedRed_green_blue_alpha_(.6,.7,.3,.5)))
            report.yes = Button((-170, -30, 160, 20), 'Generate Report', self.getGenerationInfo)
            report.yes.id = 'report'
            report.no = Button((-250, -30, 75, 20), 'Cancel', callback=self.cancelGeneration)

        generateSheet.open()
示例#21
0
    def drawBackground(self, info):
        u"""Draw the background of defined glyphs and fonbts. 
        Scale is available as mouse.scale."""
        view = self.getView()
        if not view.viewEnabled.get():
            return
        fill = getExtensionDefault(self.DEFAULTKEY_FILL, True)
        stroke = getExtensionDefault(self.DEFAULTKEY_STROKE, True)
        fillcolor = getExtensionDefaultColor(self.DEFAULTKEY_FILLCOLOR,
                                             self.FALLBACK_FILLCOLOR)

        glyph = info.get('glyph')
        if glyph is not None:
            current = glyph.font
        else:
            current = self.tool.getCurrentFont()
        if glyph is None or current is None:
            return
        align = self.getAlignment()

        # Get the fonts from the list and see if they are selected.
        sourceItems = self.getSourceFonts()
        showFonts = []
        for item in sourceItems:
            if not item['status']:
                continue
            path = item['path']
            font = self.getHiddenFont(path)
            showFonts.append(font)

        if view.viewCurrent.get() and current not in showFonts:
            showFonts.append(current)

        for font in showFonts:
            self.fillColor.setFill()
            self.strokeColor.setStroke()

            contextBefore, contextCurrent, contextAfter = self.getContexts()

            if font is not None:
                contextBefore = splitText(contextBefore,
                                          TX.naked(font).unicodeData,
                                          TX.naked(font).groups)
                contextBefore = [
                    font[gname] for gname in contextBefore
                    if gname in font.keys()
                ]
                contextAfter = splitText(contextAfter,
                                         TX.naked(font).unicodeData,
                                         TX.naked(font).groups)
                contextAfter = [
                    font[gname] for gname in contextAfter
                    if gname in font.keys()
                ]
                contextCurrent = splitText(contextCurrent,
                                           TX.naked(font).unicodeData,
                                           TX.naked(font).groups)
                if len(contextCurrent) > 0:
                    contextCurrent = [
                        font[gname] for gname in [contextCurrent[0]]
                        if gname in font.keys()
                    ]
                    if len(contextCurrent) > 0:
                        sourceGlyph = contextCurrent[0]
                    else:
                        sourceGlyph = None
                elif glyph.name in font.keys():
                    sourceGlyph = font[glyph.name]
                else:
                    sourceGlyph = None
                """
                #There is an experimental feature that will change the case of the context characters based on the case of the current glyph. But I'm disabling that for now.
                
                if view.contextUandlc.get():
                    caseTransform = None
                    if self.isUpper(glyph):
                        caseTransform = FontTX.unicodes.getUpperFromLower
                    elif self.isLower(glyph):
                        caseTransform = FontTX.unicodes.getLowerFromUpper
                    if caseTransform:
                        for i, g in enumerate(contextBefore):
                            newG = caseTransform(g)
                            if newG is not None:
                                contextBefore[i] = newG
                        newG = caseTransform(sourceGlyph)
                        if newG is not None:
                            sourceGlyph = newG
                    if caseTransform:
                        for i, g in enumerate(contextAfter):
                            newG = caseTransform(g)
                            if newG is not None:
                                contextAfter[i] = newG  
                """

                scale(current.info.unitsPerEm / float(font.info.unitsPerEm))

                widthOffset = 0
                if sourceGlyph is not None:
                    if align == 'center':
                        destCenter = float(
                            glyph.width / 2) / current.info.unitsPerEm
                        sourceCenter = float(
                            sourceGlyph.width / 2) / font.info.unitsPerEm
                        widthOffset = (destCenter -
                                       sourceCenter) * font.info.unitsPerEm
                    elif align == 'right':
                        widthOffset = (
                            (glyph.width / glyph.font.info.unitsPerEm) -
                            (sourceGlyph.width /
                             sourceGlyph.font.info.unitsPerEm)
                        ) * font.info.unitsPerEm
                translate(widthOffset, 0)

                previousGlyph = sourceGlyph
                contextBefore.reverse()
                totalWidth = 0
                for i, cbGlyph in enumerate(contextBefore):
                    kernValue = 0
                    if previousGlyph is not None and previousGlyph.font == cbGlyph.font:
                        # Uncomment to activate kerning. Requires FontTX.
                        #kernValue += FontTX.kerning.getValue((previousGlyph.name, cbGlyph.name), font.kerning, font.groups)
                        kernValue += 0

                    translate(-cbGlyph.width - kernValue, 0)
                    totalWidth += cbGlyph.width + kernValue
                    drawGlyphPath = TX.naked(cbGlyph).getRepresentation(
                        "defconAppKit.NSBezierPath")
                    if view.fill.get():
                        drawGlyphPath.fill()
                    if view.stroke.get():
                        strokePixelPath(drawGlyphPath)
                    previousGlyph = cbGlyph
                translate(totalWidth, 0)

                totalWidth = 0
                contextCurrentAndAfter = [sourceGlyph] + contextAfter

                for i, cbGlyph in enumerate(contextCurrentAndAfter):
                    if cbGlyph is None:
                        cbGlyph = sourceGlyph
                    nextGlyph = None
                    if i + 1 < len(contextCurrentAndAfter):
                        nextGlyph = contextCurrentAndAfter[i + 1]
                    if (i == 0 and cbGlyph == glyph) or sourceGlyph is None:
                        pass
                    else:
                        drawGlyphPath = TX.naked(cbGlyph).getRepresentation(
                            "defconAppKit.NSBezierPath")
                        if view.fill.get():
                            drawGlyphPath.fill()
                        if view.stroke.get():
                            strokePixelPath(drawGlyphPath)
                    kernValue = 0

                    if cbGlyph is not None and nextGlyph is not None and nextGlyph.font == cbGlyph.font:
                        #kernValue = FontTX.kerning.getValue((cbGlyph.name, nextGlyph.name), font.kerning, font.groups)
                        # Uncomment to activate kerning. Requires FontTX.
                        kernValue = 0

                    width = 0
                    if cbGlyph is not None:
                        width = cbGlyph.width
                    translate(width + kernValue, 0)
                    totalWidth += width + kernValue
                    previousGlyph = cbGlyph

                translate(-totalWidth, 0)

                translate(-widthOffset, 0)
                scale(font.info.unitsPerEm / float(current.info.unitsPerEm))
    def generationSheet(self, sender):

        readableCoord = None
        incomingSpot = None

        if hasattr(sender, 'spot'):
            if hasattr(self.w, 'spotSheet'):
                self.w.spotSheet.close()
            incomingSpot = sender.spot
            ch, j = incomingSpot
            readableCoord = '%s%s'%(ch.upper(), j+1)

        hAxis, vAxis = self.axesGrid['horizontal'], self.axesGrid['vertical']
        self.w.generateSheet = Sheet((500, 275), self.w)
        generateSheet = self.w.generateSheet

        generateSheet.tabs = Tabs((15, 12, -15, -15), ['Fonts','Glyphs','Report'])
        font = generateSheet.tabs[0]
        glyph = generateSheet.tabs[1]
        report = generateSheet.tabs[2]

        font.guide = TextBox((10, 7, -10, 22),
            u'A1, B2, C4 — A, C (whole columns) — 1, 5 (whole lines) — * (everything)',
            sizeStyle='small')
        font.headerBar = HorizontalLine((10, 25, -10, 1))
        font.spotsListTitle = TextBox((10, 40, 70, 17), 'Locations')
        font.spots = EditText((100, 40, -10, 22))
        if readableCoord is not None:
            font.spots.set(readableCoord)

        font.sourceFontTitle = TextBox((10, 90, -280, 17), 'Source font (naming & groups)', sizeStyle='small')
        font.sourceFontBar = HorizontalLine((10, 110, -280, 1))
        font.sourceFont = PopUpButton((10, 120, -280, 22), [fontName(masterFont) for spot, masterFont in self.masters], sizeStyle='small')

        font.interpolationOptions = TextBox((-250, 90, -10, 17), 'Interpolate', sizeStyle='small')
        font.optionsBar = HorizontalLine((-250, 110, -10, 1))
        font.glyphs = CheckBox((-240, 120, -10, 22), 'Glyphs', value=True, sizeStyle='small')
        font.fontInfos = CheckBox((-240, 140, -10, 22), 'Font info', value=True, sizeStyle='small')
        font.kerning = CheckBox((-120, 120, -10, 22), 'Kerning', value=True, sizeStyle='small')
        font.groups = CheckBox((-120, 140, -10, 22), 'Copy Groups', value=True, sizeStyle='small')

        font.openUI = CheckBox((10, -48, -10, 22), 'Open generated fonts', value=True, sizeStyle='small')
        font.report = CheckBox((10, -28, -10, 22), 'Generation report', value=False, sizeStyle='small')

        font.yes = Button((-170, -30, 160, 20), 'Generate font(s)', self.getGenerationInfo)
        font.yes.id = 'font'
        font.no = Button((-250, -30, 75, 20), 'Cancel', callback=self.cancelGeneration)

        glyph.guide = TextBox((10, 7, -10, 22), u'A1, B2, C4, etc.', sizeStyle='small')
        glyph.headerBar = HorizontalLine((10, 25, -10, 1))
        glyph.spotsListTitle = TextBox((10, 40, 70, 17), 'Location')
        nCellsOnHorizontalAxis, nCellsOnVerticalAxis = self.axesGrid['horizontal'], self.axesGrid['vertical']
        glyph.spot = ComboBox((100, 40, 60, 22), ['%s%s'%(getKeyForValue(i).upper(), j+1) for i in range(nCellsOnHorizontalAxis) for j in range(nCellsOnVerticalAxis)])
        if readableCoord is not None:
            glyph.spot.set(readableCoord)
        glyph.glyphSetTitle = TextBox((10, 72, 70, 17), 'Glyphs')
        glyph.glyphSet = ComboBox(
            (100, 72, -10, 22),
            [
            'abcdefghijklmnopqrstuvwxyz',
            'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
            '01234567890'
            ])
        glyph.targetFontTitle = TextBox((10, 104, 70, 17), 'To font')
        fontList = [fontName(font) for font in AllFonts()]
        fontList.insert(0, 'New font')
        glyph.targetFont = PopUpButton((100, 104, -10, 22), fontList)
        glyph.suffixTile = TextBox((10, 140, 50, 20), 'Suffix')
        glyph.suffix = EditText((100, 136, 100, 22))

        glyph.yes = Button((-170, -30, 160, 20), 'Generate glyph(s)', self.generateGlyphSet)
        glyph.yes.id = 'glyph'
        if incomingSpot is not None:
            glyph.yes.spot = incomingSpot
        glyph.no = Button((-250, -30, 75, 20), 'Cancel', callback=self.cancelGeneration)

        report.options = RadioGroup((10, 5, -10, 40), ['Report only', 'Report and mark glyphs'], isVertical=False)
        report.options.set(0)
        report.markColors = Group((10, 60, -10, -40))
        report.markColors.title = TextBox((0, 5, -10, 20), 'Mark glyphs', sizeStyle='small')
        report.markColors.bar = HorizontalLine((0, 25, 0, 1))
        report.markColors.compatibleTitle = TextBox((0, 35, 150, 20), 'Compatible')
        report.markColors.compatibleColor = ColorWell(
            (170, 35, -0, 20),
            color=getExtensionDefaultColor('interpolationMatrix.compatibleColor', fallback=NSColor.colorWithCalibratedRed_green_blue_alpha_(0.3,0.8,0,.9)))
        report.markColors.incompatibleTitle = TextBox((0, 60, 150, 20), 'Incompatible')
        report.markColors.incompatibleColor = ColorWell(
            (170, 60, -0, 20),
            color=getExtensionDefaultColor('interpolationMatrix.incompatibleColor', fallback=NSColor.colorWithCalibratedRed_green_blue_alpha_(0.9,0.1,0,1)))
        report.markColors.mixedTitle = TextBox((0, 85, 150, 20), 'Mixed compatibility')
        report.markColors.mixedColor = ColorWell(
            (170, 85, -0, 20),
            color=getExtensionDefaultColor('interpolationMatrix.mixedColor', fallback=NSColor.colorWithCalibratedRed_green_blue_alpha_(.6,.7,.3,.5)))
        report.yes = Button((-170, -30, 160, 20), 'Generate Report', self.getGenerationInfo)
        report.yes.id = 'report'
        report.no = Button((-250, -30, 75, 20), 'Cancel', callback=self.cancelGeneration)

        generateSheet.open()
示例#23
0
    def drawBackground(self, info):
        u"""Draw the background of defined glyphs and fonbts. 
        Scale is available as mouse.scale."""        
        view = self.getView()
        if not view.viewEnabled.get():
            return
        fill = getExtensionDefault(self.DEFAULTKEY_FILL, True)
        stroke = getExtensionDefault(self.DEFAULTKEY_STROKE, True)
        fillcolor = getExtensionDefaultColor(self.DEFAULTKEY_FILLCOLOR, self.FALLBACK_FILLCOLOR)

        
        glyph = info.get('glyph')
        if glyph is not None:
            current = glyph.getParent()
        else:
            current = self.tool.getCurrentFont()
        if glyph is None or current is None:
            return 
        align = self.getAlignment()
        
        # Get the fonts from the list and see if they are selected.
        sourceItems = self.getSourceFonts()
        showFonts = []
        for item in sourceItems:
            if not item['status']:
                continue
            path = item['path']
            font = self.getHiddenFont(path)
            showFonts.append(font)
        
        if view.viewCurrent.get() and current not in showFonts:
            showFonts.append(current)
    
        for font in showFonts:
            self.fillColor.setFill()
            self.strokeColor.setStroke()
            
            contextBefore, contextCurrent, contextAfter = self.getContexts()
            
            if font is not None:   
                contextBefore = splitText(contextBefore, TX.naked(font).unicodeData, TX.naked(font).groups)
                contextBefore = [font[gname] for gname in contextBefore if gname in font.keys()]
                contextAfter = splitText(contextAfter, TX.naked(font).unicodeData, TX.naked(font).groups)
                contextAfter = [font[gname] for gname in contextAfter if gname in font.keys()]
                contextCurrent = splitText(contextCurrent, TX.naked(font).unicodeData, TX.naked(font).groups)
                if len(contextCurrent) > 0:
                    contextCurrent = [font[gname] for gname in [contextCurrent[0]] if gname in font.keys()]
                    if len(contextCurrent) > 0:
                        sourceGlyph = contextCurrent[0]
                    else:
                        sourceGlyph = None
                elif glyph.name in font.keys():
                    sourceGlyph = font[glyph.name]
                else:
                    sourceGlyph = None       
                
                """
                #There is an experimental feature that will change the case of the context characters based on the case of the current glyph. But I'm disabling that for now.
                
                if view.contextUandlc.get():
                    caseTransform = None
                    if self.isUpper(glyph):
                        caseTransform = FontTX.unicodes.getUpperFromLower
                    elif self.isLower(glyph):
                        caseTransform = FontTX.unicodes.getLowerFromUpper
                    if caseTransform:
                        for i, g in enumerate(contextBefore):
                            newG = caseTransform(g)
                            if newG is not None:
                                contextBefore[i] = newG
                        newG = caseTransform(sourceGlyph)
                        if newG is not None:
                            sourceGlyph = newG
                    if caseTransform:
                        for i, g in enumerate(contextAfter):
                            newG = caseTransform(g)
                            if newG is not None:
                                contextAfter[i] = newG  
                """                      
                                         
                scale(current.info.unitsPerEm/float(font.info.unitsPerEm))
                 
                widthOffset = 0
                if sourceGlyph is not None:
                    if align == 'center':
                        destCenter = float(glyph.width/2) / current.info.unitsPerEm
                        sourceCenter = float(sourceGlyph.width/2) / font.info.unitsPerEm
                        widthOffset = (destCenter-sourceCenter) * font.info.unitsPerEm
                    elif align == 'right':
                        widthOffset = ( (  glyph.width / glyph.getParent().info.unitsPerEm ) - (sourceGlyph.width / sourceGlyph.getParent().info.unitsPerEm ) ) * font.info.unitsPerEm
                translate(widthOffset, 0)
                
                previousGlyph = sourceGlyph
                contextBefore.reverse()
                totalWidth = 0
                for i, cbGlyph in enumerate(contextBefore):
                    kernValue = 0
                    if previousGlyph is not None and previousGlyph.getParent() == cbGlyph.getParent():
                        # Uncomment to activate kerning. Requires FontTX.
                        #kernValue += FontTX.kerning.getValue((previousGlyph.name, cbGlyph.name), font.kerning, font.groups)
                        kernValue += 0
                        
                    translate(-cbGlyph.width-kernValue, 0)
                    totalWidth += cbGlyph.width + kernValue
                    drawGlyphPath = TX.naked(cbGlyph).getRepresentation("defconAppKit.NSBezierPath")
                    if view.fill.get():
                        drawGlyphPath.fill()
                    if view.stroke.get():
                        strokePixelPath(drawGlyphPath)
                    previousGlyph = cbGlyph
                translate(totalWidth, 0)
                
                totalWidth = 0
                contextCurrentAndAfter = [sourceGlyph]+contextAfter

                for i, cbGlyph in enumerate(contextCurrentAndAfter):
                    if cbGlyph is None:
                        cbGlyph = sourceGlyph
                    nextGlyph = None
                    if i + 1 < len(contextCurrentAndAfter):
                        nextGlyph = contextCurrentAndAfter[i+1]
                    if (i == 0 and cbGlyph == glyph) or sourceGlyph is None:
                        pass
                    else:
                        drawGlyphPath = TX.naked(cbGlyph).getRepresentation("defconAppKit.NSBezierPath")
                        if view.fill.get():
                            drawGlyphPath.fill()
                        if view.stroke.get():
                            strokePixelPath(drawGlyphPath)
                    kernValue = 0
                    
                    if cbGlyph is not None and nextGlyph is not None and nextGlyph.getParent() == cbGlyph.getParent():
                        #kernValue = FontTX.kerning.getValue((cbGlyph.name, nextGlyph.name), font.kerning, font.groups)
                        # Uncomment to activate kerning. Requires FontTX.
                        kernValue = 0
                    
                    width = 0
                    if cbGlyph is not None:
                        width = cbGlyph.width
                    translate(width+kernValue, 0)
                    totalWidth += width + kernValue
                    previousGlyph = cbGlyph
                
                translate(-totalWidth, 0)
                
                translate(-widthOffset, 0)
                scale(font.info.unitsPerEm/float(current.info.unitsPerEm))
    def __init__(self):

        self.font = CurrentFont()
        if self.font is None:
            from vanilla.dialogs import message
            message("Oops!", "You need a font to use this tool.")
            return

        x = 10
        y = 10
        h = 40
        w = -10

        layers = self.font.layerOrder
        if len(layers) < 1:
            from vanilla.dialogs import message
            message("Oops!", "You need two layers to use this tool.")
            return

        lh = len(layers)*20+20

        self.layerName = layers[0]
        self.currentPen = None

        self.w = FloatingWindow((200, 330), "Broad Nib Background")


        stepValue = getExtensionDefault("%s.%s" %(BroadNibBackgroundDefaultKey, "step"), 20)
        self.w.step = SliderGroup((x, y, w, h), "Steps:", 0, 60, stepValue, callback=self.stepChanged)

        y+=h

        widthValue = getExtensionDefault("%s.%s" %(BroadNibBackgroundDefaultKey, "width"), 50)
        self.w.width = SliderGroup((x, y, w, h), "Width:", 0, 300, widthValue, callback=self.widthChanged)

        y+=h

        heightValue = getExtensionDefault("%s.%s" %(BroadNibBackgroundDefaultKey, "height"), 10)
        self.w.height = SliderGroup((x, y, w, h), "Height:", 0, 300, heightValue, callback=self.heightChanged)

        y+=h

        angleValue = getExtensionDefault("%s.%s" %(BroadNibBackgroundDefaultKey, "angle"), 30)
        self.w.angle = SliderGroup((x, y, w, h), "Angle:", 0, 360, angleValue, callback=self.angleChanged)
        self.w.angle.slider.getNSSlider().cell().setSliderType_(NSCircularSlider)
        self.w.angle.text.setPosSize((0, 15, -0, 20))
        self.w.angle.slider.setPosSize((60, 10, 30, 30))
        self.w.angle.slider._nsObject.cell().setControlSize_(NSRegularControlSize)

        y+=h + 20

        shapeValue = getExtensionDefault("%s.%s" %(BroadNibBackgroundDefaultKey, "shape"), 0)
        self.w.shapetext = TextBox((x, y, -0, 20), "Shape:")
        self.w.shape = RadioGroup((74, y, -0, 20), ["oval", "rect"], isVertical=False, callback=self.shapeChanged)
        self.w.shape.set(shapeValue)

        y+=h + 5

        color = NSColor.colorWithCalibratedRed_green_blue_alpha_(1, 0, 0, .5)
        colorValue = getExtensionDefaultColor("%s.%s" %(BroadNibBackgroundDefaultKey, "color"), color)
        self.w.colortext = TextBox((x, y, -0, 20), "Color:")
        self.w.color = ColorWell((70, y-5, w, 30), callback=self.colorChanged, color=colorValue)

        y+=h + 20

        self.w.layertext = TextBox((x, y-20, -0, 20), "Layer:")
        self.w.layer = List((x, y, w, lh), layers, allowsMultipleSelection=False, selectionCallback=self.layerChanged)

        y+=lh+15

        self.w.setPosSize((100, 100, 200, y))

        addObserver(self, "drawBroadNibBackground", "drawBackground")

        # needed for windowCloseCallback
        self.setUpBaseWindowBehavior()

        self.w.open()
    def __init__(self):

        self.font = CurrentFont()
        if self.font is None:
            from vanilla.dialogs import message
            message("Oops!", "You need a font to use this tool.")
            return

        x = 10
        y = 10
        h = 40
        w = -10

        layers = self.font.layerOrder
        if len(layers) < 1:
            from vanilla.dialogs import message
            message("Oops!", "You need two layers to use this tool.")
            return

        lh = len(layers)*20+20

        self.layerName = layers[0]
        self.currentPen = None

        self.w = FloatingWindow((200, 330), "Broad Nib Background")


        stepValue = getExtensionDefault("%s.%s" %(BroadNibBackgroundDefaultKey, "step"), 20)
        self.w.step = SliderGroup((x, y, w, h), "Steps:", 0, 60, stepValue, callback=self.stepChanged)

        y+=h

        widthValue = getExtensionDefault("%s.%s" %(BroadNibBackgroundDefaultKey, "width"), 50)
        self.w.width = SliderGroup((x, y, w, h), "Width:", 0, 300, widthValue, callback=self.widthChanged)

        y+=h

        heightValue = getExtensionDefault("%s.%s" %(BroadNibBackgroundDefaultKey, "height"), 10)
        self.w.height = SliderGroup((x, y, w, h), "Height:", 0, 300, heightValue, callback=self.heightChanged)

        y+=h

        angleValue = getExtensionDefault("%s.%s" %(BroadNibBackgroundDefaultKey, "angle"), 30)
        self.w.angle = SliderGroup((x, y, w, h), "Angle:", 0, 360, angleValue, callback=self.angleChanged)
        self.w.angle.slider.getNSSlider().cell().setSliderType_(NSCircularSlider)
        self.w.angle.text.setPosSize((0, 15, -0, 20))
        self.w.angle.slider.setPosSize((60, 10, 30, 30))
        self.w.angle.slider._nsObject.cell().setControlSize_(NSRegularControlSize)

        y+=h + 20

        shapeValue = getExtensionDefault("%s.%s" %(BroadNibBackgroundDefaultKey, "shape"), 0)
        self.w.shapetext = TextBox((x, y, -0, 20), "Shape:")
        self.w.shape = RadioGroup((74, y, -0, 20), ["oval", "rect"], isVertical=False, callback=self.shapeChanged)
        self.w.shape.set(shapeValue)

        y+=h + 5

        color = NSColor.colorWithCalibratedRed_green_blue_alpha_(1, 0, 0, .5)
        colorValue = getExtensionDefaultColor("%s.%s" %(BroadNibBackgroundDefaultKey, "color"), color)
        self.w.colortext = TextBox((x, y, -0, 20), "Color:")
        self.w.color = ColorWell((70, y-5, w, 30), callback=self.colorChanged, color=colorValue)

        y+=h + 20

        self.w.layertext = TextBox((x, y-20, -0, 20), "Layer:")
        self.w.layer = List((x, y, w, lh), layers, allowsMultipleSelection=False, selectionCallback=self.layerChanged)

        y+=lh+15

        self.w.setPosSize((100, 100, 200, y))

        addObserver(self, "drawBroadNibBackground", "drawBackground")

        # needed for windowCloseCallback
        self.setUpBaseWindowBehavior()

        self.w.open()