Threshold Pen for Glyphs - Project Request

I've been using the Threshold Pen script (http://robofab.com/howto/usepens.html) from Robofab for many years happily via FontLab but my workflow has changed to Glyphs and I'd like to use the exact same script in Glyphs.

While I'm aware of similar tools for Glyphs, I'd like to hire somebody to port this expressly to Glyphs so I can run it on the entire font rather just individual characters.

I'm also happy to OpenSource it for the community since it's a great script and if there is interest by the developer and the community. Feel free to message me directly or reply to this thread.

Comments

  • Filip PaldiaFilip Paldia Posts: 43
    edited May 2018
    We might try that. How urgent is it?
  • Jens KutilekJens Kutilek Posts: 338
    Theoretically, RoboFab-based scripts should work as-is in Glyphs. Theoretically, because I just tried ThresholdPen and it failed ... (after I got it running, it only leaves empty glyphs in the font)
  • Georg SeifertGeorg Seifert Posts: 669
    And there is the "Delete Short Segments" filter: https://github.com/mekkablue/DeleteShortSegments
  • Georg SeifertGeorg Seifert Posts: 669
    And I fixed the `ThresholdPen`, at least the sample code from the robofab website works now.
  • AbrahamLeeAbrahamLee Posts: 262
    edited May 2018
    I apologize if this is too off-topic (I can certainly start a new thread), but speaking of RoboFab, does anyone here use the next generation of that code, called "fontParts"?
  • Many thanks All!

    @Georg Seifert - Yes I tried the Delete Short Segments script with Rainer but found it worked very differently and had a different result.

    That said, if I launch the Macro panel and paste the script in, it's not running but I'm not sure where to download the updated 'fix' from that does get it running. FWIW, Robofab is not currently installed on this machine, so I'm not sure what assets I need to install in order to run the entire script.
  • Georg SeifertGeorg Seifert Posts: 669
    The fix will come with the next update of Glyphs. 
  • Dave CrosslandDave Crossland Posts: 1,389
    Isn't there a convencecon installer in the glypglyph preferences window?
  • @Georg Seifert I just installed the 1141 update but was still unable to run the script. Kindly advise what I need to do in order to get it running, attached is the error.


  • Georg SeifertGeorg Seifert Posts: 669
    Do you have the latest version of robofab?
  • Stuart SandlerStuart Sandler Posts: 348
    edited May 2018
    @Georg Seifert To be clear, I don't have Robofab installed on this computer because I wasn't sure what I needed to install.

    The latest install instructions I found were from 2013 for OS X 10.7 and located here: 

    Since I'm on 10.12 and it seems Robofab has been replaced with FontParts, it's unclear to me what should be installed. http://robofont.com/documentation/building-tools/toolkit/robofab-fontparts/

    Any suggestions are welcome and I'm sure your answers to me will help other folks in the future who find this thread.
  • Georg SeifertGeorg Seifert Posts: 669
    You can try the "Install Modules" in Preference > Addons > Modules or do it manually like this: https://forum.glyphsapp.com/t/manually-installing-vanilla-module/8807 (the explanation is for vanilla but it works the same for robofab, too).
  • Thank you @Georg Seifert we're definitely getting close but I received the following errors, not sure what to do to fix them. Kindly advise as you're able and thank you for your ongoing assistance, I know this will help others.


  • Jens KutilekJens Kutilek Posts: 338
    You also need to install the FontTools Python module. RoboFab depends on it.
  • Thank you @Jens Kutilek that helped reduce the error reporting however it's not fully working yet. Kindly advise what else may be missing as you're able.


  • Jens KutilekJens Kutilek Posts: 338
    edited May 2018
    Hm, I get a different error:

    Traceback (most recent call last):
      File "<string>", line 8, in <module>
      File "/Library/Python/2.7/site-packages/robofab/pens/filterPen.py", line 126, in thresholdGlyph
        aGlyph.drawPoints(wrappedPen)
      File "/Library/Python/2.7/site-packages/robofab/objects/objectsBase.py", line 1507, in drawPoints
        c.drawPoints(pen)
      File "GlyphsApp/GlyphsApp/__init__.py", line 6796, in __GSPath__drawPoints__
        
      File "/Library/Python/2.7/site-packages/robofab/pens/pointPen.py", line 114, in endPath
        self._flushContour(segments)
      File "/Library/Python/2.7/site-packages/robofab/pens/adapterPens.py", line 104, in _flushContour
        assert 0, "illegal segmentType: %s" % segmentType
    AssertionError: illegal segmentType: offcurve
    Which build version of Glyphs are you using? Mine is 1146.
  • 1141
  • Simon CozensSimon Cozens Posts: 723
    You may need the latest GSPen and objectsGS. See https://forum.glyphsapp.com/t/robofab-getpen/2018/12
  • Jens KutilekJens Kutilek Posts: 338
    As far as I know, GSPen and objectsGS have been integrated into GlyphsApp some months ago and don't need to be installed separately.

    That said, if you have installed them in your scripts folder, maybe remove them so outdated versions are not used accidentally.

    I got the thresholdGlyph script to work now by changing some Glyphs Python API stuff. I submitted that to Georg and it will probably part of the next cutting edge build. Until then you could try this code:

    <p>from robofab.world import CurrentGlyph
    from robofab.pens.filterPen import thresholdGlyph
    
    GSOFFCURVE = "offcurve"
    
    GSLayer.drawPoints = DrawPointsWithPen
    
    def __GSPath__drawPoints__(self, pen):
    	'''draw the object with a fontTools pen'''
    	
    	pen.beginPath()
    	for i in range(len(self)):
    		Node = self.nodeAtIndex_(i-1)
    		node_type = Node.type
    		if Node.type == GSOFFCURVE:
    			node_type = None
    		pen.addPoint(Node.position, segmentType=node_type, smooth=Node.smooth, name=Node.name)
    	pen.endPath()
    
    GSPath.drawPoints = __GSPath__drawPoints__
    
    
    thresholdGlyph(CurrentGlyph(), 20)<br></p>

  • Thanks @Simon Cozens and @Jens Kutilek . . .

    I may have to wait until the next cutting edge build, but here's the error I'm now seeing regardless if I install the GSPen or objectGS scripts.

    Traceback (most recent call last):
      File "<string>", line 6, in <module>
    NameError: name 'DrawPointsWithPen' is not defined
  • Georg SeifertGeorg Seifert Posts: 669
    edited June 2018
    The thresholdGlyph example from the roboFab page should work fine as is in Glyphs version 1145.
    Maybe we should move this discussion to the Glyphs forum or the GlyphsSDK repository. 
Sign In or Register to comment.