aslanunal / googlefontdirectory

Automatically exported from code.google.com/p/googlefontdirectory
0 stars 0 forks source link

A few fonts (listed below) will not render with python's reportlab library. #85

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Install Python and ReportLab library
2. configure the attached script to point to the cloned googlefontdirectory 
directory
3. run the script (python generate_fonts.py)

What is the expected output? What do you see instead?
I expect to see all fonts listed by name in the font of that name in a PDF file.

For a small handful of the fonts: (These are only prefixes)
'Bevan', 'Lobster', 'DroidSans', 'Neucha', 'MavenProBlack', 'Maven', 'Astloch', 
'Chewy', 'Ubuntu', 'ComingSoon', 'PTSerif', 'PT', 'Arvo', 'Walter', 'Amaranth', 
'Crafty', 'Molengo', 'Reenie', 'Anton', 'Cherry', 'Dancing', 'Copse', 'Comfo', 
'GFSDi', 'OpenS', 'Chivo', 'NewsC', 'Calli', 'Ralew', 'Synco'

I get the following traceback:
Traceback (most recent call last):
  File "generate_fonts.py", line 117, in <module>
    doc.build(Story)
  File "/usr/lib/python2.7/dist-packages/reportlab/platypus/doctemplate.py", line 1117, in build
    BaseDocTemplate.build(self,flowables, canvasmaker=canvasmaker)
  File "/usr/lib/python2.7/dist-packages/reportlab/platypus/doctemplate.py", line 906, in build
    self._endBuild()
  File "/usr/lib/python2.7/dist-packages/reportlab/platypus/doctemplate.py", line 848, in _endBuild
    if getattr(self,'_doSave',1): self.canv.save()
  File "/usr/lib/python2.7/dist-packages/reportlab/pdfgen/canvas.py", line 1123, in save
    self._doc.SaveToFile(self._filename, self)
  File "/usr/lib/python2.7/dist-packages/reportlab/pdfbase/pdfdoc.py", line 235, in SaveToFile
    f.write(self.GetPDFData(canvas))
  File "/usr/lib/python2.7/dist-packages/reportlab/pdfbase/pdfdoc.py", line 247, in GetPDFData
    fnt.addObjects(self)
  File "/usr/lib/python2.7/dist-packages/reportlab/pdfbase/ttfonts.py", line 1126, in addObjects
    pdfFont.ToUnicode = doc.Reference(cmapStream, 'toUnicodeCMap:' + baseFontName)
  File "/usr/lib/python2.7/dist-packages/reportlab/pdfbase/pdfdoc.py", line 516, in Reference
    raise ValueError, "redefining named object: "+repr(name)
ValueError: redefining named object: 'toUnicodeCMap:AAAAAA+Amaranth-Bold'

What version of the product are you using? On what operating system?

mercurial trunk of googlefontdirectory, Ubuntu 11.04, Python 2.7.1+

Please provide any additional information below.

Feel free to use this script for automated testing if it helps.  Thanks for 
making google web fonts!

Original issue reported on code.google.com by charlesb...@gmail.com on 7 Oct 2011 at 3:44

Attachments:

GoogleCodeExporter commented 8 years ago
The problem with all of the fonts listed above is that there are duplicates 
found during the walk. Specifically, each of these was hinted with Visual 
TrueType, and has the relevant hinting file available in the 'src' 
subdirectory. The problem here is that the source format used by VTT is a fully 
loadable TTF file... and naturally, the directory walk finds both files, and 
can't load both into a single PDF.

Similarly, there are some '.ttf.orig' files that get picked up and should be 
ignored.

The easy solution is to simply ignore anything whose path name contains '/src/' 
or doesn't *end* in "ttf". This is simple enough to fix line 87:

{{{
if f[-4:] == '.ttf' and not re.search('/src/', f) and not re.search('\.hg', f) 
and not check_ignore(f, ignores):
}}}

The one remaining error comes from Comfortaa, and here, the problem is in the 
font itself. All three weights of that font have the Compatible Full Name 
field, which is used in PDF embedding, set to "Comfortaa".

Original comment by codeman38 on 7 Oct 2011 at 7:10

GoogleCodeExporter commented 8 years ago

Original comment by pathum...@gmail.com on 12 Aug 2014 at 10:55

GoogleCodeExporter commented 8 years ago
Charles, did codeman38's comment resolve the issue for you? :)

Original comment by dcrossland@google.com on 12 Aug 2014 at 11:42

GoogleCodeExporter commented 8 years ago
Yes it did! Thank you for the help!

Original comment by charlesb...@gmail.com on 12 Aug 2014 at 2:05