On Lion and can’t get TTX to work anymore.

Primary tabs

16 posts / 0 new
Last post
Göran Söderström's picture
Joined: 15 Feb 2006 - 2:53am
On Lion and can’t get TTX to work anymore.
0

I just switch to a brand new computer and set up everything but can’t get TTX to work.

I see this when i type ttx in the terminal so I think it’s installed right?

---------------

TTX 2.3 -- From OpenType To XML And Back

If an input file is a TrueType or OpenType font file, it will be
dumped to an TTX file (an XML-based text format).
If an input file is a TTX file, it will be compiled to a TrueType
or OpenType font file.

etc ....

---------------

But when actually trying to work on a font file I get this:

---------------

File "/usr/local/bin/ttx", line 11, in
ttx.main(sys.argv[1:])
File "/Library/Python/2.7/site-packages/FontTools/fontTools/ttx.py", line 295, in main
process(jobs, options)
File "/Library/Python/2.7/site-packages/FontTools/fontTools/ttx.py", line 280, in process
action(input, output, options)
File "/Library/Python/2.7/site-packages/FontTools/fontTools/ttx.py", line 170, in ttDump
fontNumber=options.fontNumber)
File "/Library/Python/2.7/site-packages/FontTools/fontTools/ttLib/__init__.py", line 145, in __init__
if macUtils.getSFNTResIndices(file):
File "/Library/Python/2.7/site-packages/FontTools/fontTools/ttLib/macUtils.py", line 28, in getSFNTResIndices
resref = MyOpenResFile(path)
File "/Library/Python/2.7/site-packages/FontTools/fontTools/ttLib/macUtils.py", line 18, in MyOpenResFile
resref = Res.FSpOpenResFile(path, mode)
AttributeError: 'module' object has no attribute 'FSpOpenResFile'

---------------

On Lion with Python 2.7.

Any ideas what could be wrong? Would really appreciate it.

Michel Boyer's picture
Offline
Joined: 2 Jun 2007 - 1:01pm
0

I have not installed ttx2.3 on Lion. I am using ttx2.2 from AFDKO with no problem. Here are the differences between 2.2 and 2.3 according to the file changes.txt

TTX/FontTools Version 2.3


- TrueType Collection (TTC) support
- Python 2.6 support
- Update Unicode data to 5.2.0
- Couple of bug fixes

Maybe I should add that the AFDKO ttx comes with its own python, it does not rely on some pre-installed python.

Göran Söderström's picture
Joined: 15 Feb 2006 - 2:53am
0

This is the TTX that comes with Fonttools in the Robofab package.

So. it doesn't support Python 2.7 which came with the computer? Is that what you're meaning?

Michel Boyer's picture
Offline
Joined: 2 Jun 2007 - 1:01pm
0

Well, on my mac with Lion, there are three versions of python. If I type python2.5 I get python2.5, if I type python2.6, I get python 2.6. Here is a trace of execution:

% ls /usr/bin/python*
/usr/bin/python /usr/bin/python2.5 /usr/bin/python2.6 /usr/bin/python2.7 /usr/bin/pythonw /usr/bin/pythonw2.6
/usr/bin/python-config /usr/bin/python2.5-config /usr/bin/python2.6-config /usr/bin/python2.7-config /usr/bin/pythonw2.5 /usr/bin/pythonw2.7

You are not limited to python2.7 and to use the python fontforge module with a slightly modified mactools installation of fontforge, I have to use python2.6 (works on OS X 10.5 and OS X 10.7; have'nt tried yet on OS X 10.6). I know nothing of fontlab (don't want to pay just to answer questions on typophile).

Göran Söderström's picture
Joined: 15 Feb 2006 - 2:53am
0

Sorry, but I don‘t understand what to do. I just want TTX to work again. In the terminal. Nothing to do with FontLab.

Reynir Heiðberg Stefánsson's picture
Joined: 19 Nov 2010 - 11:15am
0

First, then, do the ls /usr/bin/python* thing. Also, if your machine has /usr/local/, try ls /usr/local/bin/python* in case there is a Python interpreter lurking there.

Assuming you found, say, /usr/bin/python2.5: Say python2.5 ttx foo.ttf to check if it runs to completion. If /usr/bin/python2.6 exists, try again with that.

Then, open the ttx script in a text editor and change the #! /usr/bin/env python (the sha-bang line) at the top to reflect the latest version that works. Save it, and you should be back to NERV's motto.

Göran Söderström's picture
Joined: 15 Feb 2006 - 2:53am
0

I’m with you through here:

ls /usr/bin/python*

and gets:

/usr/bin/python /usr/bin/python2.6 /usr/bin/pythonw
/usr/bin/python-config /usr/bin/python2.6-config /usr/bin/pythonw2.5
/usr/bin/python2.5 /usr/bin/python2.7 /usr/bin/pythonw2.6
/usr/bin/python2.5-config /usr/bin/python2.7-config /usr/bin/pythonw2.7

But, after that when I type:

python2.5 ttx foo.ttf

this happens:

python2.5: can't open file 'ttx': [Errno 2] No such file or directory

Same with 2.6.

Jens Kutílek's picture
Offline
Joined: 12 Sep 2007 - 7:55am
0

Hi Göran,

you need to edit one line in the fontTools source:

https://github.com/mcolyer/fonttools/commit/e732bd3ba63c51df9aed903eb214...

After that you need to run sudo ./setup.py install again in the fontTools folder.

Michel Boyer's picture
Offline
Joined: 2 Jun 2007 - 1:01pm
0

Jens

Does that solve all problems? I see that the deprecated calls FSpOpenResFile and FSpCreateResFile are also used in the files

./Lib/fontTools/fondLib.py ./Lib/fontTools/nfntLib.py ./Lib/fontTools/t1Lib.py ./Mac/TTX.py

Michel

Jens Kutílek's picture
Offline
Joined: 12 Sep 2007 - 7:55am
0

You're probably right, somebody should test fontTools thoroughly for stuff like this. As I understand it, it's a 64 bit issue, so the other way to avoid it is by switching Python to 32 bit by default:

defaults write com.apple.versioner.python Prefer-32-Bit -bool yes

Göran Söderström's picture
Joined: 15 Feb 2006 - 2:53am
0

Jens, do you know everything? :)

It worked! Thanks so much. Again.

Göran Söderström's picture
Joined: 15 Feb 2006 - 2:53am
0

Ok well. It worked to *create* the TTX but when going back to the TTF I get this:

Parsing 'GlyphOrder' table...
Parsing 'head' table...
Parsing 'hhea' table...
Parsing 'maxp' table...
Parsing 'OS/2' table...
Parsing 'hmtx' table...
Parsing 'cmap' table...
Parsing 'fpgm' table...
Parsing 'prep' table...
Parsing 'cvt ' table...
Parsing 'loca' table...
Parsing 'glyf' table...
Parsing 'kern' table...
Parsing 'name' table...
Parsing 'post' table...
Parsing 'gasp' table...
Parsing 'GPOS' table...
Parsing 'GSUB' table...
Traceback (most recent call last):
File "/usr/local/bin/ttx", line 11, in
ttx.main(sys.argv[1:])
File "/Library/Python/2.7/site-packages/FontTools/fontTools/ttx.py", line 295, in main
process(jobs, options)
File "/Library/Python/2.7/site-packages/FontTools/fontTools/ttx.py", line 280, in process
action(input, output, options)
File "/Library/Python/2.7/site-packages/FontTools/fontTools/ttx.py", line 186, in ttCompile
ttf.save(output)
File "/Library/Python/2.7/site-packages/FontTools/fontTools/ttLib/__init__.py", line 201, in save
self._writeTable(tag, writer, done)
File "/Library/Python/2.7/site-packages/FontTools/fontTools/ttLib/__init__.py", line 597, in _writeTable
tabledata = self.getTableData(tag)
File "/Library/Python/2.7/site-packages/FontTools/fontTools/ttLib/__init__.py", line 609, in getTableData
return self.tables[tag].compile(self)
File "/Library/Python/2.7/site-packages/FontTools/fontTools/ttLib/tables/otBase.py", line 73, in compile
self.table.compile(writer, font)
File "/Library/Python/2.7/site-packages/FontTools/fontTools/ttLib/tables/otBase.py", line 616, in compile
conv.write(writer, font, tableStack, value)
File "/Library/Python/2.7/site-packages/FontTools/fontTools/ttLib/tables/otConverters.py", line 185, in write
value.compile(subWriter, font, tableStack)
File "/Library/Python/2.7/site-packages/FontTools/fontTools/ttLib/tables/otBase.py", line 604, in compile
conv.write(writer, font, tableStack, value[i], i)
File "/Library/Python/2.7/site-packages/FontTools/fontTools/ttLib/tables/otConverters.py", line 185, in write
value.compile(subWriter, font, tableStack)
File "/Library/Python/2.7/site-packages/FontTools/fontTools/ttLib/tables/otBase.py", line 604, in compile
conv.write(writer, font, tableStack, value[i], i)
File "/Library/Python/2.7/site-packages/FontTools/fontTools/ttLib/tables/otConverters.py", line 185, in write
value.compile(subWriter, font, tableStack)
File "/Library/Python/2.7/site-packages/FontTools/fontTools/ttLib/tables/otBase.py", line 590, in compile
table = self.preWrite(font)
File "/Library/Python/2.7/site-packages/FontTools/fontTools/ttLib/tables/otTables.py", line 186, in preWrite
gidItems = [(getGlyphID(item[0]), getGlyphID(item[1])) for item in items]
File "/Library/Python/2.7/site-packages/FontTools/fontTools/ttLib/__init__.py", line 548, in getGlyphID
raise KeyError, glyphName
KeyError: 'glyph65535'

And it only seem to be happening on some fonts I now realized. Must be something wrong with the font perhaps? It’s a TTF generated from Fontlab 5.1.

Jens Kutílek's picture
Offline
Joined: 12 Sep 2007 - 7:55am
0

Jens, do you know everything? :)

I'm working on it ;)

KeyError: 'glyph65535'

65535 or 2¹⁶ − 1 is the maximum glyph index in OpenType fonts.

This error is usually because of a glyph being referenced in an OT feature but missing from the font. The error is in the GSUB table here, so I'd check the classes and substitution features for missing glyphs.

Michel Boyer's picture
Offline
Joined: 2 Jun 2007 - 1:01pm
0

That is due to the fact that the python that comes installed on the mac is ucs-2 and not ucs-4. Here is a trace of execution on my mac (python2.5, python2.6 and python2.7 in /usr/bin do the same):

501 % /usr/bin/python -c "import sys; print sys.maxunicode;"
65535
502 % /opt/local/bin/python -c "import sys; print sys.maxunicode;"
1114111
503 %

I installed a ucs-4 python (2.6) with macports to use with fontforge to handle glyphs above 0xFFFF.

Göran Söderström's picture
Joined: 15 Feb 2006 - 2:53am
0

Jens! Hero! You were right again!

For some reason the font could be generated even though a glyph was represented in the code (but not in the font).

I’m happy.

Beer’s on me.

Michel Boyer's picture
Offline
Joined: 2 Jun 2007 - 1:01pm
0

>   65535 or 2¹⁶ − 1 is the maximum glyph index in OpenType fonts
Sorry, I had misread your comment. GlyphID is indeed 16 bits.