Exemplo n.º 1
0
 def __init__(self, posSize, glyphNamesToDisplay, verticalMode, fontsOrder,
              callback):
     super(SpacingMatrix, self).__init__(posSize)
     self.glyphNamesToDisplay = glyphNamesToDisplay
     self.fontsOrder = fontsOrder
     self.verticalMode = verticalMode
     self.callback = callback
     self.canvas = CanvasGroup((0, 0, 0, 0), delegate=self)
Exemplo n.º 2
0
 def __init__(self):
     self.dotSize = 10
     self.glyphs = None
     self.result = None
     self.pointer = None
     self.snap = 5 # snap distance
     self.snapped = None    # index of which point we're snapping on
     self.orientation = 0.3
     self.glyphScale = 0.18
     self.glyphs = [None, None, None]
     self.mGlyphs = None
     self.startDrag = None
     self.p1 = self.p2 = self.p3 = None
     s = 400
     self.w = vanilla.Window((s,s), "3nterpolation",minSize=(250,250))
     self.w.c = CanvasGroup((0,0,0,0), delegate=self)
     self.w.bind('resize', self.resize)
     self.w.open()
     self.resize()
     self.w.c.update()
Exemplo n.º 3
0
    def __init__(self, posSize, displayedWord, canvasScalingFactor, fontObj,
                 isKerningDisplayActive, areVerticalLettersDrawn,
                 areGroupsShown, areCollisionsShown, isSidebearingsActive,
                 isCorrectionActive, isMetricsActive, isColorsActive,
                 isSymmetricalEditingOn, isSwappedEditingOn, indexPair):

        super(WordDisplay, self).__init__(posSize)

        self.fontObj = fontObj
        self.displayedWord = displayedWord
        self.displayedPairs = buildPairsFromString(self.displayedWord,
                                                   self.fontObj)
        self.indexPair = indexPair

        if indexPair is not None:
            self.activePair = self.displayedPairs[self.indexPair]
        else:
            self.activePair = None

        self.canvasScalingFactor = canvasScalingFactor
        self.isKerningDisplayActive = isKerningDisplayActive
        self.areVerticalLettersDrawn = areVerticalLettersDrawn
        self.areGroupsShown = areGroupsShown
        self.areCollisionsShown = areCollisionsShown
        self.isSidebearingsActive = isSidebearingsActive
        self.isCorrectionActive = isCorrectionActive
        self.isMetricsActive = isMetricsActive
        self.isColorsActive = isColorsActive

        self.isSymmetricalEditingOn = isSymmetricalEditingOn
        self.isSwappedEditingOn = isSwappedEditingOn

        self.ctrlWidth, self.ctrlHeight = posSize[2], posSize[3]

        self.checkPairsQuality()
        self.wordCanvasGroup = CanvasGroup((0, 0, 0, 0), delegate=self)
    def addInterface(self, notification):
        self.window = notification['window']
        # self.cleanup(self.window)

        # CONTAINER
        xywh = (margin, -55, -margin, height)
        self.sbui = CanvasGroup(xywh, delegate=CanvasStuff(self.window))

        # LEFT
        x, y, w, h = xywh = (0, -height, dfltLwidth, height)
        this = self.sbui.L = Group(xywh)

        # text input
        xywh = (x, y + 3, width * 1.5, height * .75)
        this.Ltext = EditText(xywh,
                              placeholder='angledLeftMargin',
                              sizeStyle='mini',
                              continuous=False,
                              callback=self.setSB)
        # quick mod buttons
        xywh = (x + width * 1.5 + (gap * 1), y, width, height)
        this.Lminus = Button(xywh,
                             iconminus,
                             sizeStyle='mini',
                             callback=self.setLminus)
        this.Lminus.getNSButton().setToolTip_('Adjust LSB -' + str(unit))
        xywh = (x + width * 2.5 + (gap * 2), y, width, height)
        this.Lplus = Button(xywh,
                            iconplus,
                            sizeStyle='mini',
                            callback=self.setLplus)
        this.Lplus.getNSButton().setToolTip_('Adjust LSB +' + str(unit))
        xywh = (x + width * 3.5 + (gap * 3), y, width, height)
        this.Lround = Button(xywh,
                             iconround,
                             sizeStyle='mini',
                             callback=self.setLround)
        this.Lround.getNSButton().setToolTip_('Round LSB to ' + str(unit))
        xywh = (x + width * 4.5 + (gap * 4), y, width, height)
        this.Lright = Button(xywh,
                             iconcopyR,
                             sizeStyle='mini',
                             callback=self.setLright)
        this.Lright.getNSButton().setToolTip_('Copy Right Value')
        # stylize
        this.Ltext.getNSTextField().setBezeled_(False)
        this.Ltext.getNSTextField().setBackgroundColor_(NSColor.clearColor())
        self.flatButt(this.Lminus)
        self.flatButt(this.Lplus)
        self.flatButt(this.Lround)
        self.flatButt(this.Lright)

        # RIGHT
        x, y, w, h = xywh = (-dfltRwidth, y, dfltRwidth, h)
        this = self.sbui.R = Group(xywh)
        # text input
        xywh = (-x - width * 1.5, y + 3, width * 1.5, height * .75)
        this.Rtext = EditText(xywh,
                              placeholder='angledRightMargin',
                              sizeStyle='mini',
                              continuous=False,
                              callback=self.setSB)
        # quick mod buttons
        xywh = (-x - width * 5.5 - (gap * 4), y, width, height)
        this.Rleft = Button(xywh,
                            iconcopyL,
                            sizeStyle='mini',
                            callback=self.setRleft)
        this.Rleft.getNSButton().setToolTip_('Copy Left Value')
        xywh = (-x - width * 4.5 - (gap * 3), y, width, height)
        this.Rround = Button(xywh,
                             iconround,
                             sizeStyle='mini',
                             callback=self.setRround)
        this.Rround.getNSButton().setToolTip_('Round RSB to ' + str(unit))
        xywh = (-x - width * 3.5 - (gap * 2), y, width, height)
        this.Rminus = Button(xywh,
                             iconminus,
                             sizeStyle='mini',
                             callback=self.setRminus)
        this.Rminus.getNSButton().setToolTip_('Adjust RSB -' + str(unit))
        xywh = (-x - width * 2.5 - (gap * 1), y, width, height)
        this.Rplus = Button(xywh,
                            iconplus,
                            sizeStyle='mini',
                            callback=self.setRplus)
        this.Rplus.getNSButton().setToolTip_('Adjust RSB +' + str(unit))
        # stylize
        this.Rtext.getNSTextField().setBezeled_(False)
        this.Rtext.getNSTextField().setBackgroundColor_(NSColor.clearColor())
        this.Rtext.getNSTextField().setAlignment_(NSTextAlignmentRight)
        self.flatButt(this.Rminus)
        self.flatButt(this.Rplus)
        self.flatButt(this.Rround)
        self.flatButt(this.Rleft)

        # CENTER
        winX, winY, winW, winH = self.window.getVisibleRect()
        winW = winW - margin * 5
        x, y, w, h = xywh = ((winW / 2) - (dfltCwidth / 2), y, dfltCwidth, h)
        this = self.sbui.C = Group(xywh)
        x = 0

        # text input
        c = (dfltCwidth / 2)
        xywh = (c - (width * .75), y + 3, width * 1.5, height * .75)
        this.Ctext = EditText(xywh,
                              placeholder='width',
                              sizeStyle='mini',
                              continuous=False,
                              callback=self.setSB)
        # quick mod buttons
        xywh = (c - (width * .75) - width * 2 - (gap * 2), y, width, height)
        this.Ccenter = Button(xywh,
                              iconcenter,
                              sizeStyle='mini',
                              callback=self.setCcenter)
        this.Ccenter.getNSButton().setToolTip_('Center on Width')
        xywh = (c - (width * .75) - width - (gap * 1), y, width, height)
        this.Cround = Button(xywh,
                             iconround,
                             sizeStyle='mini',
                             callback=self.setCround)
        this.Cround.getNSButton().setToolTip_('Round Width to ' + str(unit))
        xywh = (c + (width * .75) + (gap * 1), y, width, height)
        this.Cminus = Button(xywh,
                             iconminus,
                             sizeStyle='mini',
                             callback=self.setCminus)
        this.Cminus.getNSButton().setToolTip_('Adjust Width -' + str(2 * unit))
        xywh = (c + (width * .75) + width + (gap * 2), y, width, height)
        this.Cplus = Button(xywh,
                            iconplus,
                            sizeStyle='mini',
                            callback=self.setCplus)
        this.Cplus.getNSButton().setToolTip_('Adjust Width +' + str(2 * unit))
        # stylize
        this.Ctext.getNSTextField().setBezeled_(False)
        this.Ctext.getNSTextField().setBackgroundColor_(NSColor.clearColor())
        this.Ctext.getNSTextField().setAlignment_(NSTextAlignmentCenter)
        self.flatButt(this.Cminus)
        self.flatButt(this.Cplus)
        self.flatButt(this.Cround)
        self.flatButt(this.Ccenter)

        # hide
        self.sbui.L.Lminus.show(False)
        self.sbui.L.Lround.show(False)
        self.sbui.L.Lplus.show(False)
        self.sbui.L.Lright.show(False)
        self.sbui.R.Rminus.show(False)
        self.sbui.R.Rround.show(False)
        self.sbui.R.Rplus.show(False)
        self.sbui.R.Rleft.show(False)
        self.sbui.C.Cminus.show(False)
        self.sbui.C.Cround.show(False)
        self.sbui.C.Ccenter.show(False)
        self.sbui.C.Cplus.show(False)

        # make it real
        self.sbWatcherInitialize()
        self.window.addGlyphEditorSubview(self.sbui)
        self.updateValues()
        self.buildMatchBase()
        windowViewManger[self.window] = self.sbui
Exemplo n.º 5
0
    def __init__(self, posSize, interface, sheet):
        super(DesignFrame, self).__init__(posSize)
        self.ui = interface
        self.s = sheet

        y = 10
        self.EM_Dimension_title = TextBox((10,y,200,20), 
                "EM Dimension (FU)", 
                sizeStyle = "small")
        self.EM_DimensionX_title = TextBox((145,y,20,20), 
                "X:", 
                sizeStyle = "small")
        self.EM_DimensionX_editText = EditText((160,y-3,45,20), 
                self.s.EM_Dimension_X, 
                callback = self.EM_DimensionX_editText_callback,
                sizeStyle = "small")
        self.EM_DimensionY_title = TextBox((235,y,20,20), 
                "Y:", 
                sizeStyle = "small")
        self.EM_DimensionY_editText = EditText((250,y-3,45,20), 
                self.s.EM_Dimension_Y,  
                callback = self.EM_DimensionY_editText_callback,
                sizeStyle = "small")
        y += 30
        self.characterFace_title = TextBox((10,y,200,20), 
                "Character Face (EM%)", 
                sizeStyle = "small")
        self.characterFacePercent_title = TextBox((208,y,30,20), 
                "%", 
                sizeStyle = "small")
        self.characterFace_editText = EditText((160,y-3,45,20), 
                self.s.characterFace,
                callback = self.characterFace_editText_callback,
                sizeStyle = "small")
        y += 30
        self.overshoot_title = TextBox((10,y,200,20), 
                "Overshoot (FU)", 
                sizeStyle = "small")
        self.overshootOutside_title = TextBox((110,y,70,20), 
                "Outside:", 
                sizeStyle = "small")
        self.overshootOutside_editText = EditText((160,y-3,45,20), 
                self.s.overshootOutsideValue, 
                callback = self.overshootOutside_editText_callback,
                sizeStyle = "small")
        self.overshootInside_title = TextBox((210,y,60,20), 
                "Inside:", 
                sizeStyle = "small")
        self.overshootInside_editText = EditText((250,y-3,45,20), 
                self.s.overshootInsideValue,  
                callback = self.overshootInside_editText_callback,
                sizeStyle = "small")
        y += 30
        self.horizontalLine_title = TextBox((10,y,140,20), 
                "Horizontal Line (EM%)", 
                sizeStyle = "small")
        self.horizontalLine_slider = Slider((160,y-3 ,135,20), 
                minValue = 0, maxValue = 50, value = 0, 
                sizeStyle = "small",
                callback = self._horizontalLine_slider_callback)
        y += 30
        self.verticalLine_title = TextBox((10,y,140,20), 
                "Vertical Line (EM%)", 
                sizeStyle = "small")
        self.verticalLine_slider = Slider((160,y-3 ,135,20), 
                minValue = 0, maxValue = 50, value = 0, 
                sizeStyle = "small",
                callback = self._verticalLine_slider_callback)
        y += 30
        self.customsFrames_title = TextBox((10,y,200,20), 
                "Customs Frames (EM%):", 
                sizeStyle = "small")
        y += 20
        slider = SliderListCell()

        self.customsFrames_list = List((10,y,285,-30),
                self.s.customsFrames,
                columnDescriptions = [{"title": "Name", "width" : 75}, 
                                    {"title": "Values", "width" : 200, "cell": slider}],
                editCallback = self._customsFrames_list_editCallback,
                drawFocusRing = False)  
        self.addCustomsFrames_button = Button((170,-28,62,-10),
                "+",
                callback = self._addCustomsFrames_button_callback,
                sizeStyle="small")
        self.removeCustomsFrames_button = Button((232,-28,62,-10),
                "-",
                callback = self._removeCustomsFrames_button_callback,
                sizeStyle="small")
        self.s.translateX,self.s.translateY = 0, 0
        self.canvas = CanvasGroup((-295,10,-10,-10), 
                delegate=ProjectCanvas(self.s, "DesignFrame", self))

        self.s.w.bind('close', self.windowWillClose)
        self.observer()
Exemplo n.º 6
0
    def __init__(self, willOpen=True):
        super(SidebearingsLinker, self).__init__()

        # collecting fonts
        self.allFonts = AllFonts()
        if self.allFonts != []:
            self.selectedFont = self.allFonts[0]

        # interface
        self.w = FloatingWindow((PLUGIN_WIDTH, PLUGIN_HEIGHT), PLUGIN_TITLE)

        jumpingY = MARGIN_VER
        self.w.fontPopUp = PopUpButton(
            (MARGIN_HOR, jumpingY, NET_WIDTH,
             vanillaControlsSize['PopUpButtonRegularHeight']),
            getNamesFrom(self.allFonts),
            callback=self.fontPopUpCallback)

        jumpingY += vanillaControlsSize['PopUpButtonRegularHeight'] + MARGIN_ROW
        self.w.canvas = CanvasGroup(
            (MARGIN_HOR, jumpingY, NET_WIDTH, CANVAS_HEIGHT), delegate=self)

        jumpingY += CANVAS_HEIGHT + MARGIN_ROW
        linksColumnDescriptions = [{
            "title": "left",
            'key': 'lft',
            'width': LIST_WIDE_COL
        }, {
            "title": "active",
            "cell": CheckBoxListCell(),
            'key': 'lftActive',
            'width': LIST_NARROW_COL
        }, {
            "title": "glyph",
            'key': 'servant',
            'width': LIST_WIDE_COL,
            "editable": False
        }, {
            "title": "active",
            "cell": CheckBoxListCell(),
            'key': 'rgtActive',
            'width': LIST_NARROW_COL
        }, {
            "title": "right",
            'key': 'rgt',
            'width': LIST_WIDE_COL
        }]

        if self.selectedFont is not None:
            links = loadLinksFromFont(self.selectedFont)
        else:
            links = []

        self.w.linksList = List(
            (MARGIN_HOR, jumpingY, NET_WIDTH, 200),
            links,
            showColumnTitles=False,
            allowsMultipleSelection=False,
            drawVerticalLines=True,
            columnDescriptions=linksColumnDescriptions,
            selectionCallback=self.selectionLinksListCallback,
            editCallback=self.editLinksListCallback)

        if self.selectedFont is not None:
            self.w.linksList.setSelection([0])
            self.currentRow = self.w.linksList[0]
            self.matchDisplayedSubscriptions()

        jumpingY += self.w.linksList.getPosSize()[3] + MARGIN_ROW
        buttonWidth = (NET_WIDTH - MARGIN_HOR) / 2
        self.w.linkAllButton = SquareButton(
            (MARGIN_HOR, jumpingY, buttonWidth,
             vanillaControlsSize['ButtonRegularHeight'] * 1.5),
            'Link All',
            callback=self.linkAllButtonCallback)

        self.w.unlockAllButton = SquareButton(
            (MARGIN_HOR * 2 + buttonWidth, jumpingY, buttonWidth,
             vanillaControlsSize['ButtonRegularHeight'] * 1.5),
            'Unlink All',
            callback=self.unlockAllButtonCallback)

        jumpingY += vanillaControlsSize[
            'ButtonRegularHeight'] * 1.5 + MARGIN_ROW
        self.w.separationLineOne = HorizontalLine(
            (MARGIN_HOR, jumpingY, NET_WIDTH,
             vanillaControlsSize['HorizontalLineThickness']))

        jumpingY += MARGIN_ROW
        self.w.pushIntoFontButton = SquareButton(
            (MARGIN_HOR, jumpingY, buttonWidth,
             vanillaControlsSize['ButtonRegularHeight'] * 1.5),
            'Push into font',
            callback=self.pushIntoFontButtonCallback)
        self.w.pushIntoFontButton.enable(False)

        self.w.clearLibsButton = SquareButton(
            (MARGIN_HOR * 2 + buttonWidth, jumpingY, buttonWidth,
             vanillaControlsSize['ButtonRegularHeight'] * 1.5),
            'Clear Libs',
            callback=self.clearLibsButtonCallback)

        jumpingY += vanillaControlsSize[
            'ButtonRegularHeight'] * 1.5 + MARGIN_ROW
        self.w.loadFromTable = SquareButton(
            (MARGIN_HOR, jumpingY, buttonWidth,
             vanillaControlsSize['ButtonRegularHeight'] * 1.5),
            'Load from table',
            callback=self.loadFromTableCallback)
        self.w.loadFromTable.enable(True)

        self.w.exportTable = SquareButton(
            (MARGIN_HOR * 2 + buttonWidth, jumpingY, buttonWidth,
             vanillaControlsSize['ButtonRegularHeight'] * 1.5),
            'Export table',
            callback=self.exportTableCallback)
        self.w.exportTable.enable(True)

        jumpingY += vanillaControlsSize[
            'ButtonRegularHeight'] * 1.5 + MARGIN_VER * 2
        self.w.resize(PLUGIN_WIDTH, jumpingY)

        self.setUpBaseWindowBehavior()

        if self.selectedFont is not None:
            self.matchSubscriptions()
            result = askYesNo('Warning',
                              'Do you want to align servants to masters?')
            if bool(result) is True:
                self._alignServantsToMasters()

        addObserver(self, "drawOnGlyphCanvas", "draw")
        addObserver(self, "drawOnGlyphCanvas", "drawInactive")
        addObserver(self, 'fontDidOpenCallback', 'fontDidOpen')
        addObserver(self, 'fontDidCloseCallback', 'fontDidClose')
        if willOpen is True:
            self.w.open()
Exemplo n.º 7
0
    def __init__(self):
        self.w = FloatingWindow((400, 450), "Tracer", minSize=(400, 400))

        middle = 130
        gap = 15
        y = 10
        self.w.thresholdText = TextBox((10, y + 1, middle, 22),
                                       "Threshold:",
                                       alignment="right")
        self.w.threshold = Slider((middle + gap, y, -10, 22),
                                  minValue=0,
                                  maxValue=1,
                                  value=.2,
                                  continuous=False,
                                  callback=self.makePreview)

        y += 30
        self.w.blurText = TextBox((10, y + 1, middle, 22),
                                  "Blur:",
                                  alignment="right")
        self.w.blur = Slider((middle + gap, y, -10, 22),
                             minValue=0,
                             maxValue=30,
                             value=0,
                             continuous=False,
                             callback=self.makePreview)
        y += 30
        self.w.invert = CheckBox((middle + gap, y + 2, -10, 22),
                                 "Invert",
                                 callback=self.makePreview)
        y += 30
        self.w.turdsizeText = TextBox((10, y + 1, middle, 22),
                                      "Suppress Speckles:",
                                      alignment="right")
        self.w.turdsize = Slider((middle + gap, y, -10, 22),
                                 minValue=0,
                                 maxValue=30,
                                 value=2,
                                 continuous=False,
                                 callback=self.makePreview)
        y += 30
        self.w.opttoleranceText = TextBox((10, y + 1, middle, 22),
                                          "Tolerance:",
                                          alignment="right")
        self.w.opttolerance = Slider((middle + gap, y, -10, 22),
                                     minValue=0,
                                     maxValue=2,
                                     value=0.2,
                                     continuous=False,
                                     callback=self.makePreview)

        y += 25
        _y = -40
        self.w.preview = CanvasGroup((0, y, -0, _y), delegate=self)
        self._previewImage = None
        self._previewGlyph = None

        _y = -30
        self.w.trace = Button((-100, _y, -10, 22),
                              "Trace",
                              callback=self.trace)
        self.w.traceFont = Button((-210, _y, -110, 22),
                                  "Trace Font",
                                  callback=self.traceFont)
        self.w.update = Button((-300, _y, -220, 22),
                               "Update",
                               callback=self.makePreview)
        self.w.showPreview = CheckBox((10, _y, 100, 22),
                                      "Preview",
                                      value=True,
                                      callback=self.makePreview)

        self.w.setDefaultButton(self.w.trace)
        self.makePreview()
        self.w.open()
    def __init__(self, posSize, interface, sheet):
        super(ReferenceViewer, self).__init__(posSize)
        self.ui = interface
        self.s = sheet

        self.FontList_comboBox = ComboBox((10, 10, 130, 18),
                                          Global.fontsList.get(),
                                          sizeStyle='small')
        self.FontList_comboBox.set(Global.fontsList.get()[0])

        self.addReferenceFont_button = Button(
            (150, 9, 70, 20),
            "Add",
            sizeStyle="small",
            callback=self._addReferenceFont_button_callback)

        self.removeReference_button = Button(
            (225, 9, 70, 20),
            "Remove",
            sizeStyle="small",
            callback=self._removeReference_button_callback)

        self.s.reference_list_selection = []
        self.reference_list = List(
            (10, 35, 285, 125),
            self.s.referenceViewerList,
            columnDescriptions=[{
                "title": "Font"
            }],
            selectionCallback=self._reference_list_selectionCallback,
            drawFocusRing=False)

        self.settings = Group((10, 170, 295, -0))
        self.settings.show(0)

        y = 3

        self.settings.size_title = TextBox((0, y, 100, 20),
                                           "Size (FU)",
                                           sizeStyle="small")
        self.settings.size_editText = EditText(
            (-60, y - 3, -10, 20),
            "",
            sizeStyle="small",
            callback=self._size_editText_callback)

        self.settings.size_slider = Slider((90, y - 3, -65, 20),
                                           minValue=0,
                                           maxValue=1000,
                                           value=250,
                                           sizeStyle="small",
                                           callback=self._size_slider_callback)

        y += 30
        self.settings.color_title = TextBox((0, y, 100, 20),
                                            "Color (FU)",
                                            sizeStyle="small")
        self.settings.color_colorWell = ColorWell(
            (90, y - 3, -10, 20),
            callback=self._color_editText_callback,
            color=NSColor.grayColor())

        self.canvas = CanvasGroup(
            (-295, 10, -10, -10),
            delegate=ProjectCanvas(self.s, "ReferenceViewer", self))

        self.s.w.bind('close', self.windowWillClose)
        self.observer()