googlefonts / pyfontaine

Python tool to check font files for language/character set support
https://github.com/googlefonts/pyfontaine
GNU General Public License v3.0
104 stars 20 forks source link

error reading .ttc file #57

Closed zxytim closed 9 years ago

zxytim commented 9 years ago

when reading .ttc file:

$ pyfontaine simsun.ttc                                                                                              
Traceback (most recent call last):
  File "/home/zxytim/.local/bin/pyfontaine", line 266, in <module>
    main()
  File "/home/zxytim/.local/bin/pyfontaine", line 193, in main
    tree = director.construct_tree(fonts)
  File "/home/zxytim/.local/lib/python2.7/site-packages/fontaine/builder.py", line 118, in construct_tree
    font = FontFactory.openfont(font_filename, charmaps=self.charmaps)
  File "/home/zxytim/.local/lib/python2.7/site-packages/fontaine/font.py", line 124, in openfont
    return TTFont(fontfile, charmaps)
  File "/home/zxytim/.local/lib/python2.7/site-packages/fontaine/font.py", line 130, in __init__
    self._fontFace = FontFace(fontfile)
  File "/home/zxytim/.local/lib/python2.7/site-packages/fontaine/font.py", line 45, in __init__
    self.ttf = ttLib.TTFont(open(fontfile))
  File "/home/zxytim/.local/lib/python2.7/site-packages/FontTools/fontTools/ttLib/__init__.py", line 156, in __init__
    self.reader = sfnt.SFNTReader(file, checkChecksums, fontNumber=fontNumber)
  File "/home/zxytim/.local/lib/python2.7/site-packages/FontTools/fontTools/ttLib/sfnt.py", line 36, in __init__
    raise ttLib.TTLibError, "specify a font number between 0 and %d (inclusive)" % (self.numFonts - 1)
fontTools.ttLib.TTLibError: specify a font number between 0 and 1 (inclusive)

As I have a check at your code, I found the problem lies in that all fontaine.font.{FontFactory, TTFont, FontFace} does not handle fontNumber needed by fontTools.

davelab6 commented 9 years ago

Thanks! @vitalyvolkov please resolve :)

davelab6 commented 9 years ago

@zxytim can this be closed?

$ pyfontaine /Library/Fonts/PTSans.ttc 
Fonts
  Font:
    Filename: PTSans.ttc
    Common name: PT Sans
    Sub family: Italic
    Style: italic
    Weight: normal
    Fixed width: no
    Fixed sizes: no
    Copyright: Copyright © 2009 ParaType Ltd. All rights reserved.
    License: ParaType Ltd grants you the right to use, copy, modify this font and distribute modified and unmodified copies of the font by any means, including placing on Web servers for free downloading, embedding in documents and Web pages, bundling with commercial and non commercial products, if it does not conflict with the ParaType Free Font License placed on www.paratype.com/public/pt_openlicense_eng.asp.
    License url: http://www.paratype.com/public/pt_openlicense_eng.asp
    Version: 10.0d1e1
    Vendor: ParaType Ltd
    Vendor url: http://www.paratype.com
    Designer: A.Korolkova, O.Umpeleva, V.Yefimov
    Designer url: http://www.paratype.com/help/designers/
    Glyph count: 719
    Orthographies:
        Orthography:
          Common name: GlyphOrderAndAliasDB
          Support level: fragmentary
          Percent coverage: 36
          Coverage: 719
          Set total: 266
        Orthography:
          Common name: Unencoded Glyphs
          Support level: fragmentary
          Percent coverage: 36
          Coverage: 719
          Set total: 266
$