tags:

views:

200

answers:

1

I use python bindings for FontForge under Ubuntu. It constantly runs into crash without any clues about the reason, e.g. segmentation fault, memory mapping errors, etc.

All what I need is to read font file's (.ttf and .otf) meta data (font name, family name, version, unique id, copyright, license, designer, designer url, etc) and count the glyphs it has.

Are there any alternatives to fontforge which do above jobs in a more stable way? Any suggestions will be appreciated.

+1  A: 

Hi,

I had some issue with fontforge at my ubuntu x64 before too.

I am using it for adding opentype rules, but error sometimes happen, when I try to modify those metadata.

Latest svn is a lot better, I mean least crashing, I use following guide to install from svn.

http://openfontlibrary.org/wiki/How%5Fto%5Finstall%5FFontForge

Another option is you only need metadata right?

For that case, you could just save it to fontforge file as .sfd, and since it is text file, you can read it line by line from python.

FontName: -----
FullName: ------
FamilyName: ------
Weight: -----
...

Sorry for talking about fontforge only, because Its only the one I used as font editor before.

S.Mark
great, dumping to a .sfd file works. however, i need both metadata and unicode value of all glyphs. I saw there is something like "StartChar: numbersign Encoding: 35 35 6" in the .sfd file. How to convert "35 35 6" to its unicode number?
jack
may be like this? `unichr(int(re.search("Encoding: (\d+)",x).group(1)))` a bit dirty way though.
S.Mark
it works. do you know what the third value (6 in above case) stands for?
jack
I believe its the glyph index from the start, in fontforge UI menu, Encoding->Compact , you will only see glpyhs which is include in the font, first one is 0, then 1,2,3 etc, I think Its just for fontforge internal use
S.Mark