def __init__(self):    
     
     self.w = FloatingWindow((350, 110), "Angle Checker")
     y = 10
     self.w.desiredAngleText = TextBox((10, y, 140, 22), "Desired Angle:", alignment="right")
     self.w.desiredAngle = SliderEditIntStepper((160, y, -10, 22), 15.5, callback=self.changedCallback, minValue=0, maxValue=180)
     
     y += 30
     self.w.toleranceText = TextBox((10, y, 140, 22), "Tolerance +/-:", alignment="right")
     self.w.tolerance = SliderEditIntStepper((160, y, -10, 22), 1, callback=self.changedCallback, minValue=0, maxValue=15)
     
     y += 30
     self.w.rangeToCheckText = TextBox((10, y, 140, 22), "Range to check +/-:", alignment="right")
     self.w.rangeToCheck = SliderEditIntStepper((160, y, -10, 22), 12, callback=self.changedCallback, minValue=0, maxValue=45)
     
     # self.setUpBaseWindowBehavior()
     self.w.open()
     self.w.bind("close", self.windowCloseCallback)
     addObserver(self, "myDrawCallback", "draw")
     addObserver(self, "myDrawCallback", "drawInactive")
     # addObserver(self, "myDrawCallback", "spaceCenterDraw")
     addObserver(self, "myDrawCallback", "viewDidChangeGlyph")
     
     UpdateCurrentGlyphView()
     
     self.g = CurrentGlyph()
Ejemplo n.º 2
0
    def __init__(self, value, font1, font2, available_fonts):
        self.activateModule()

        # sets initial value
        # self.redBlink = False
        global redIsOn
        redIsOn = False

        x = 10
        y = 10
        lineHeight = 23

        self.value = value
        self.font1 = font1
        self.font2 = font2
        self.available_fonts = available_fonts

        # gname1
        if CurrentGlyph() != None:
            g = CurrentGlyph()
        else:
            g = gInit

        self.gname = g

        # use minSize to make window re-sizable
        self.w = vanilla.Window((400, 400),
                                'Delorean: Interpolation Preview',
                                minSize=(200, 200))

        # Figuring out what to display in the dropdown list
        styleNames_set = False
        familyNames_set = False
        familyNames_differ = False

        if all([f.info.styleName for f in self.available_fonts]):
            styleNames_set = True
        if all([f.info.familyName for f in self.available_fonts]):
            familyNames_set = True
            if len(set([f.info.familyName for f in self.available_fonts])) > 1:
                familyNames_differ = True

        if styleNames_set:
            # If style names are all set and family name is all the same
            # (or not set), display only the style name.
            # If family names are different, display family name & style name.
            if familyNames_set:
                if familyNames_differ:
                    fontList = [
                        '%s %s' % (f.info.familyName, f.info.styleName)
                        for f in self.available_fonts
                    ]
                else:
                    fontList = [f.info.styleName for f in self.available_fonts]
            else:
                fontList = [f.info.styleName for f in self.available_fonts]

        elif familyNames_set and familyNames_differ:
            # If for some reason only the family name is set, check if it is
            # different across UFOs. If it is, use it.
            fontList = [f.info.familyName for f in self.available_fonts]

        else:
            # Last resort (neither family nor style name are set), or the
            # family name is the same across UFOs (and no style name set):
            # Only display the UFO path.
            fontList = [os.path.basename(f.path) for f in self.available_fonts]

        # Dropdown menus
        w_width = self.w.getPosSize()[2]
        menu_width = w_width / 2 - 15
        # It would be nice to make the dropdown respond to a width change,
        # of the window, but that is for next time.

        self.w.leftList = vanilla.PopUpButton(
            (x, y, menu_width, lineHeight),
            fontList,
            callback=self.font1ChangeCallback)
        self.w.leftList.set(self.available_fonts.index(font1))

        self.w.rightList = vanilla.PopUpButton(
            (-menu_width - x, y, menu_width, lineHeight),
            fontList,
            callback=self.font2ChangeCallback)
        self.w.rightList.set(self.available_fonts.index(font2))

        # Line Return
        y += lineHeight

        # vanilla.TextBox (not interactive field)
        self.w.gnameTextBox = vanilla.TextBox((x, y, 200, lineHeight),
                                              'Glyph name')
        self.w.valueTextBox = vanilla.TextBox((x + 105, y, 200, lineHeight),
                                              'Interpolation %')

        # Line Return
        y += lineHeight

        # "Glyph name"
        self.w.gnameTextInput = vanilla.EditText(
            (x, y, 80, lineHeight),
            self.gname.name,
            callback=self.setterButtonCallback)

        # "Percentage" Slider
        # Value
        self.w.valueTextInput = SliderEditIntStepper(
            (x + 105, y, -10, 22),
            minValue=-200,
            maxValue=400,
            value=50,
            increment=10,
            callback=self.setterButtonCallback)

        y += lineHeight
        y += 15

        # -5 from bottom
        self.w.preview = GlyphPreview((0, y, -0, -5))

        # Report
        self.w.reportText = vanilla.TextBox((x, -27, 400, lineHeight), '')

        # generate instance
        self.w.generate = vanilla.Button((-35, -27, 27, lineHeight),
                                         u"⬇",
                                         callback=self.generateCallback)

        if CurrentGlyph() != None:
            g = CurrentGlyph()
        else:
            g = gInit

        gname = g.name
        self.interpSetGlyph(gname)

        self.w.box = vanilla.Box((0, (y - 9), -0, -30))
        self.setUpBaseWindowBehavior()
        self.w.open()
Ejemplo n.º 3
0
    def __init__(self, posSize):
        super(TTFAutoHintGroup, self).__init__(posSize)
        self.getNSView().setFrame_((((0, 0), (400, 400))))
        self.options = dict()

        updateWithDefaultValues(self.options, defaultOptions)

        column = 180
        gutter = 15

        y = 10

        self.hintRangeMininmumText = vanilla.TextBox((10, y+2, column, 22), "Hint Set Range Minimum:", alignment="right")
        self.hintRangeMinimum = SliderEditIntStepper((column + gutter, y, -10, 22), self.options["hintRangeMinimum"], callback=self.hintRangeMinimumMaximumCallback)

        y += 30
        self.hintRangeMaximumText = vanilla.TextBox((10, y+2, column, 22), "Hint Set Range Maximum:", alignment="right")
        self.hintRangeMaximum = SliderEditIntStepper((column + gutter, y, -10, 22), self.options["hintRangeMaximum"], callback=self.hintRangeMinimumMaximumCallback)

        y += 50

        self.hintingLimitText = vanilla.TextBox((10, y+2, column, 22), "Hinting Limit:", alignment="right")
        self.hintingLimit = SliderEditIntStepper((column + gutter, y, -10, 22), self.options["hintingLimit"])

        y += 28
        self.noHintingLimit = vanilla.CheckBox((column + gutter, y, -10, 22), "No Hinting Limit", callback=self.noHintingLimitCallback, sizeStyle="small")

        y += 30

        self.xHeightIncreaseLimitText = vanilla.TextBox((10, y+2, column, 22), "X Height Increase Limit:", alignment="right")
        self.xHeightIncreaseLimit = SliderEditIntStepper((column + gutter, y, -10, 22), self.options["xHeightIncreaseLimit"])

        y += 28
        self.noXHeightIncreaseLimit = vanilla.CheckBox((column + gutter, y, -10, 22), "No X Height Increase Limit", callback=self.noXHeightIncreaseLimitCallback, sizeStyle="small")

        y += 50

        self.fallbackScript = vanilla.CheckBox((column + gutter, y, -10, 22), "Fallback Script (Latin)", value=self.options["fallbackScript"])

        y += 50

        self.preHinting = vanilla.CheckBox((column + gutter, y, -10, 22), "Pre Hinted", value=self.options["preHinting"])

        y += 30
        self.symbolFont = vanilla.CheckBox((column + gutter, y, -10, 22), "Symbol Font", value=self.options["symbolFont"])

        y += 30
        self.addTTFAutoHintInfo = vanilla.CheckBox((column + gutter, y, -10, 22), "Add ttfautohint Info", value=self.options["addTTFAutoHintInfo"])

        y += 30
        self.overRideFontLicense = vanilla.CheckBox((column + gutter, y, -10, 22), "Override Font License Restrictions", value=self.options["overRideFontLicense"])

        y += 50

        self.stemWidthAndStemPos = vanilla.TextBox((0, y, column+10, 22), "Stem Width and Positioning:", alignment="right")

        self.grayScale = vanilla.CheckBox((column + gutter, y, -10, 22), "Gray Scale", value=self.options["grayScale"])

        y += 30
        self.gdiClearType = vanilla.CheckBox((column + gutter, y, -10, 22), "GDI ClearType", value=self.options["gdiClearType"])

        y += 30
        self.dwClearType = vanilla.CheckBox((column + gutter, y, -10, 22), "DW ClearType", value=self.options["dwClearType"])
Ejemplo n.º 4
0
class TTFAutoHintGroup(vanilla.Group):

    def __init__(self, posSize):
        super(TTFAutoHintGroup, self).__init__(posSize)
        self.getNSView().setFrame_((((0, 0), (400, 400))))
        self.options = dict()

        updateWithDefaultValues(self.options, defaultOptions)

        column = 180
        gutter = 15

        y = 10

        self.hintRangeMininmumText = vanilla.TextBox((10, y+2, column, 22), "Hint Set Range Minimum:", alignment="right")
        self.hintRangeMinimum = SliderEditIntStepper((column + gutter, y, -10, 22), self.options["hintRangeMinimum"], callback=self.hintRangeMinimumMaximumCallback)

        y += 30
        self.hintRangeMaximumText = vanilla.TextBox((10, y+2, column, 22), "Hint Set Range Maximum:", alignment="right")
        self.hintRangeMaximum = SliderEditIntStepper((column + gutter, y, -10, 22), self.options["hintRangeMaximum"], callback=self.hintRangeMinimumMaximumCallback)

        y += 50

        self.hintingLimitText = vanilla.TextBox((10, y+2, column, 22), "Hinting Limit:", alignment="right")
        self.hintingLimit = SliderEditIntStepper((column + gutter, y, -10, 22), self.options["hintingLimit"])

        y += 28
        self.noHintingLimit = vanilla.CheckBox((column + gutter, y, -10, 22), "No Hinting Limit", callback=self.noHintingLimitCallback, sizeStyle="small")

        y += 30

        self.xHeightIncreaseLimitText = vanilla.TextBox((10, y+2, column, 22), "X Height Increase Limit:", alignment="right")
        self.xHeightIncreaseLimit = SliderEditIntStepper((column + gutter, y, -10, 22), self.options["xHeightIncreaseLimit"])

        y += 28
        self.noXHeightIncreaseLimit = vanilla.CheckBox((column + gutter, y, -10, 22), "No X Height Increase Limit", callback=self.noXHeightIncreaseLimitCallback, sizeStyle="small")

        y += 50

        self.fallbackScript = vanilla.CheckBox((column + gutter, y, -10, 22), "Fallback Script (Latin)", value=self.options["fallbackScript"])

        y += 50

        self.preHinting = vanilla.CheckBox((column + gutter, y, -10, 22), "Pre Hinted", value=self.options["preHinting"])

        y += 30
        self.symbolFont = vanilla.CheckBox((column + gutter, y, -10, 22), "Symbol Font", value=self.options["symbolFont"])

        y += 30
        self.addTTFAutoHintInfo = vanilla.CheckBox((column + gutter, y, -10, 22), "Add ttfautohint Info", value=self.options["addTTFAutoHintInfo"])

        y += 30
        self.overRideFontLicense = vanilla.CheckBox((column + gutter, y, -10, 22), "Override Font License Restrictions", value=self.options["overRideFontLicense"])

        y += 50

        self.stemWidthAndStemPos = vanilla.TextBox((0, y, column+10, 22), "Stem Width and Positioning:", alignment="right")

        self.grayScale = vanilla.CheckBox((column + gutter, y, -10, 22), "Gray Scale", value=self.options["grayScale"])

        y += 30
        self.gdiClearType = vanilla.CheckBox((column + gutter, y, -10, 22), "GDI ClearType", value=self.options["gdiClearType"])

        y += 30
        self.dwClearType = vanilla.CheckBox((column + gutter, y, -10, 22), "DW ClearType", value=self.options["dwClearType"])

    def hintRangeMinimumMaximumCallback(self, sender):
        minValue = int(round(self.hintRangeMinimum.get()))
        maxValue = int(round(self.hintRangeMaximum.get()))

        if minValue > maxValue:
            self.hintRangeMaximum.set(minValue)

        if maxValue < minValue:
            self.hintRangeMinimum.set(maxValue)

    def noHintingLimitCallback(self, sender):
        self.hintingLimit.enable(not sender.get())

    def noXHeightIncreaseLimitCallback(self, sender):
        self.xHeightIncreaseLimit.enable(not sender.get())

    def get(self):
        return {
            "hintRangeMinimum": int(round(self.hintRangeMinimum.get())),
            "hintRangeMaximum": int(round(self.hintRangeMaximum.get())),

            "hintingLimit": int(round(self.hintingLimit.get())),
            "noHintingLimit": self.noHintingLimit.get(),

            "xHeightIncreaseLimit": int(round(self.xHeightIncreaseLimit.get())),
            "noXHeightIncreaseLimit": self.noXHeightIncreaseLimit.get(),

            "fallbackScript": self.fallbackScript.get(),

            "preHinting": self.preHinting.get(),
            "symbolFont": self.symbolFont.get(),
            "addTTFAutoHintInfo": self.addTTFAutoHintInfo.get(),
            "overRideFontLicense": self.overRideFontLicense.get(),

            "grayScale": self.grayScale.get(),
            "gdiClearType": self.gdiClearType.get(),
            "dwClearType": self.dwClearType.get(),
        }

    def set(self, options):
        if options is None:
            options = dict()
        updateWithDefaultValues(options, defaultOptions)

        self.hintRangeMinimum.set(options["hintRangeMinimum"])
        self.hintRangeMaximum.set(options["hintRangeMaximum"])

        self.hintingLimit.set(options["hintingLimit"])
        self.noHintingLimit.set(options["noHintingLimit"])
        self.noHintingLimitCallback(self.noHintingLimit)

        self.xHeightIncreaseLimit.set(options["xHeightIncreaseLimit"])
        self.noXHeightIncreaseLimit.set(options["noXHeightIncreaseLimit"])
        self.noXHeightIncreaseLimitCallback(self.noXHeightIncreaseLimit)

        self.fallbackScript.set(options["fallbackScript"])

        self.preHinting.set(options["preHinting"])
        self.symbolFont.set(options["symbolFont"])
        self.addTTFAutoHintInfo.set(options["addTTFAutoHintInfo"])
        self.overRideFontLicense.set(options["overRideFontLicense"])

        self.grayScale.set(options["grayScale"])
        self.gdiClearType.set(options["gdiClearType"])
        self.dwClearType.set(options["dwClearType"])