frederik

Forum Replies Created

Viewing 15 posts - 46 through 60 (of 531 total)
  • Author
    Posts
  • in reply to: Override a default shortcut #6165

    frederik
    Keymaster

    I would advise to subscribe to the notification fontDidSave and create a duplicate whenever that notification is been send.

    There is also a fontWillSave and fontWillAutoSave (in case you want to keep a version each 10 min)

    good luck

    in reply to: Odd progress bar window behaviour #6159

    frederik
    Keymaster

    Due to optimisations a text will not update directly cause it is receiving lots of updates in a short time.

    You will have to force the text view to update

    see https://github.com/typesupply/defconAppKit/blob/master/Lib/defconAppKit/windows/progressWindow.py#L27-L31

    instead of using the private _nsObject I would encourage you to use getNSTextField()

    good luck

    in reply to: Slant offset changes measurements on italic #6152

    frederik
    Keymaster

    this is already fixed in the beta and upcoming 1.7 release

    thanks for reporting!

    in reply to: Sorting contours #6147

    frederik
    Keymaster

    use:

    g = CurrentGlyph()
    
    contour = g[1]
    contour.selected = True
    g.update()
    
    in reply to: Getting the glyph and its font #6146

    frederik
    Keymaster

    Hi

    the mixed parents will be fixed in the next update, thanks for reporting

    one thing: a tool.getGlyph() method will always return a glyph from a glyph view, if you select a font window, it will send you a currentGlyphChanged notification, but the glyph will not actually change when using the tool.getGlyph(). To get the global current glyph use CurrentGlyph()

    the other weirdness: see https://github.com/typemytype/RoboFontExamples/blob/master/observers/eventObserver.py

    a tool can become active separately from a currentGlyphChanged or viewDidChangeGlyph

    in reply to: Sorting contours #6144

    frederik
    Keymaster

    the best thing todo is to draw the glyph into a pen store and process the data and draw it back into the glyph

    this should work :)

    enjoy

    from robofab.pens.pointPen import AbstractPointPen
    
    class SortingPen(AbstractPointPen):
        
        def __init__(self):
            self._contours = []
            
        def beginPath(self):
            self._contours.append([])
                           
        def addPoint(self, pt, segmentType=None, smooth=False, name=None, **kwargs):
            self._contours[-1].append((pt, segmentType, smooth, name, kwargs))
        
        def endPath(self):
            pass
    
        def addComponent(self, baseGlyph, transformation):
            pass   
                
        def drawPoints(self, pen):
            # sort by the len of oncurves and offcurvers for each contour
            sortable = []
            for contour in self._contours:
                oncurves = 0
                offcurves = 0
                for pt, segmentType, smooth, name, kwargs in contour:
                    if segmentType is None:
                        offcurves += 1
                    else:
                        oncurves += 1
                sortable.append((oncurves, offcurves, contour))
            sortable.sort()
    
            for oncurvers, offcurvers, contour in sortable:
                pen.beginPath()
                for pt, segmentType, smooth, name, kwargs in contour:
                    pen.addPoint(pt, 
                                smooth=smooth, 
                                segmentType=segmentType, 
                                name=name, 
                                **kwargs)
                pen.endPath()
            
         
    
    # get the current glyph
    g = CurrentGlyph()
    # get the pen
    sorting = SortingPen()
    # draw into that pen
    g.drawPoints(sorting)
    # clear the contours
    g.clearContours()
    # draw back into the glyph
    sorting.drawPoints(g.getPointPen())
    
    in reply to: Getting the glyph and its font #6139

    frederik
    Keymaster

    hi

    could you make an small example?

    I cannot reproduce this issue, with a quick test…

    thanks

    from mojo.events import BaseEventTool, installTool
    
    class TestTool(BaseEventTool):
        
        def currentGlyphChanged(self):
            g = self.getGlyph()
            f = g.getParent()
            print g.name, f
        
    installTool(TestTool())
    

    frederik
    Keymaster

    The font lib key will be com.typesupply.ufo2fdk.glyphOrderAndAliasDB and will also be used in Tal’s ufo2fdk package.


    frederik
    Keymaster

    Hi

    That lib key doest exists, it was just an example how it could be solved somehow.

    But if I was you I would just wait for the next update, there is an option to store the FDK Glyph Alias DB in the font.lib. That solve the issue of production glyph names vs real glyph names

    good luck

    in reply to: Storing/Loading settings of an extension #6135

    frederik
    Keymaster

    I would advice you to use getExtensionDefault(key, fallback) and setExtensionDefault(key, value)

    see http://doc.robofont.com/api/mojo/mojo-extensions/

    in reply to: Modify glyph copy/paste behavior for custom contexts? #6131

    frederik
    Keymaster

    He Nina

    Space Center already doest that, in all three input boxes. You could use that for Word-O-Mat… so it has support for pasting glif xml

    from lib.UI.spaceCenter.glyphSequenceEditText import GlyphSequenceEditText
    from vanilla import *
    
    class Test:
        
        def __init__(self):
            
            self.w = Window((200, 100))
            
            # the only tricky thing is that it is optimized for the lowerlevel defcon font object...
            self.w.input = GlyphSequenceEditText((10, 10, -10, 22), CurrentFont().naked(), callback=self.inputChangedCallback)
            self.w.open()
    
        def inputChangedCallback(self, sender):
            print sender.get()
    
    Test()
    

    FYI:

    RoboFont writes different representations to the pasteboard, any thing that is responding to a paste action can read their preferred representation.

    it is possible to add you’re own representations if you subscribe to the paste notification, just a add or rewrite whatever you like :)

    see https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/PasteboardGuide106/Introduction/Introduction.html#//apple_ref/doc/uid/TP40008100-SW1

    in reply to: Current glyph window size and position #6128

    frederik
    Keymaster

    He

    I don’t fully understand why but here is a script that is changing the size and position of the current window to the pervious current window

    from AppKit import NSApp
    # get all ordered windows
    windows = NSApp().orderedWindows()
    # get the size of the window
    (x, y), (w, h) =  windows[1].frame()
    # set the size of the window
    windows[0].setFrame_display_animate_(((x, y), (w, h)), True, False)
    

    good luck!

    in reply to: FAQ #5: Can I open .vfb files? #6127

    frederik
    Keymaster

    it should be living in /usr/local/bin/vfb2ufo

    it should also listen to which vfb2ufo in terminal, that is how RoboFont looks for it.

    And you probably have to restart RoboFont as the hasVFB2UFO flag is being set during start up

    good luck

    in reply to: Drawbot saveImage as gif #6122

    frederik
    Keymaster

    it should, just change the ext of the save image path to .gif or .mov

    if it not get generated: is there a traceback, does it export as pdf? with multiple pages?

    can you make an example?

    thanks

    in reply to: Subprocess module in Robofont #6120

    frederik
    Keymaster

    yep, using executeCommand solves your issue when shell is set to True

Viewing 15 posts - 46 through 60 (of 531 total)