Closed weiweihuanghuang closed 6 years ago
I would have expected this to work if you load TTFont with lazy=False at least, but I see that it’s still trying to call seek(0) method to rewind the stream. Maybe for now try to read all data into an in-memory BytesIO and pass that one to fonttools.
Is this a python23 problem?
Glyphsapp says I'm running fontTools 3.4.0 which seems crazy because the current is "3.32.1.dev0", https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/__init__.py#L7.
@schriftgestalt Are you supplying a custom version of fontTools for Glyphs?
I'm guessing when you install fontTools using this Glyphsapp menu:
It will install a custom fonttools to the system Python.
I can't replicate this issue with my version of fonttools.
Glyphs gets fonttools from this URL: https://github.com/behdad/fonttools/archive/master.zip
And by looking at that, I see that it is outdated. I’ll fix this.
I copied in the last fontTools I installed ("3.31.0") from /usr/local/lib/python2.7/site-packages/fontTools/
(some reason Glyphs app doesn't see this?) and I still get the same issue
the issue is in the current fonttools, and it's not a py23 issue. basically at some point (can't remember when but probably when behdad added support for writing collection fonts) the TTFont constructor started to call seek(0) on incoming file objects (rewinding them at the start offset), but some streams like the standard input or a zipfile like in your specific case are unseekable by definition. I would like to restore support for those at some point. I suggested a workaround.
@schriftgestalt I recommend you use pip (as a subprocess) to install/upgrade fonttools for Glyphs.app. It's not enough to download the tarball from github, unzip and run it. Some modules have extra dependencies now.
anyway, the canonical distribution is uploaded to the Python Package Index at each release. https://pypi.org/project/FontTools/#files
@schriftgestalt if you want to install third-party modules to some private directory in ~/Library/Application Support/Glyhps that is only in Glyphs' own PYTHONPATH -- you can use pip --target
option:
https://pip.pypa.io/en/stable/reference/pip_install/?highlight=target#cmdoption-t
pip doesn't support a programmatic API, can only be used as a script; they recommend calling it as a subprocess from other python code.
Thanks Cosimo!
My glyphsapp now has the same fonttools as everyone else. I will produce a workaround.
Alright, I'm closing this.
A fix has been implemented in 681da884830cb3229752d3135dbeb2e1352989ff. Regardless of whether the issue is in fontTools, the script should always run.
@weiweihuanghuang please repull and try again.
I'll keep an eye on the fonttools issue. Thanks everyone.
macOS 10.13.6 GA Version 2.5.2 (1176) fontTools "3.31.0"