renderPM can't set font

Bug #1918107 reported by Christophe Monniez
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-reportlab (Ubuntu)
New
Undecided
Unassigned

Bug Description

Since the `gsfonts` dependency was removed in bug #1862641, some reportlab functionalities are failing.

It can be reproduced with a simple example. First, ensure that `gsfonts` package is not installed.

In python3:

```
from reportlab.graphics.barcode import createBarcodeDrawing
barcode = createBarcodeDrawing('EAN13', value='1234')
barcode.asString('png')
```

This leads to the following traceback:
```
Warn: Can't find .pfb for face 'Times-Roman'
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/reportlab/graphics/renderPM.py", line 242, in _setFont
    gs.setFont(fontName,fontSize)
ValueError: _renderPM.gstate_setFont: Can't find font!

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/reportlab/graphics/renderPM.py", line 248, in _setFont
    _renderPM.makeT1Font(fontName,f.face.findT1File(),f.encoding.vector,open_and_read)
TypeError: makeT1Font() argument 2 must be str, not None

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/reportlab/graphics/shapes.py", line 854, in asString
    return renderPM.drawToString(self, fmt=format,showBoundary=getattr(self,'showBorder',
  File "/usr/lib/python3/dist-packages/reportlab/graphics/renderPM.py", line 685, in drawToString
    drawToFile(d,s,fmt=fmt, dpi=dpi, bg=bg, configPIL=configPIL)
  File "/usr/lib/python3/dist-packages/reportlab/graphics/renderPM.py", line 680, in drawToFile
    c = drawToPMCanvas(d, dpi=dpi, bg=bg, configPIL=configPIL, showBoundary=showBoundary)
  File "/usr/lib/python3/dist-packages/reportlab/graphics/renderPM.py", line 666, in drawToPMCanvas
    draw(d, c, 0, 0, showBoundary=showBoundary)
  File "/usr/lib/python3/dist-packages/reportlab/graphics/renderPM.py", line 51, in draw
    R.draw(renderScaledDrawing(drawing), canvas, x, y, showBoundary=showBoundary)
  File "/usr/lib/python3/dist-packages/reportlab/graphics/renderbase.py", line 204, in draw
    self.initState(x,y) #this is the push()
  File "/usr/lib/python3/dist-packages/reportlab/graphics/renderPM.py", line 98, in initState
    self.applyState()
  File "/usr/lib/python3/dist-packages/reportlab/graphics/renderPM.py", line 92, in applyState
    self._canvas.setFont(s['fontName'], s['fontSize'])
  File "/usr/lib/python3/dist-packages/reportlab/graphics/renderPM.py", line 399, in setFont
    _setFont(self._gs,fontName,fontSize)
  File "/usr/lib/python3/dist-packages/reportlab/graphics/renderPM.py", line 251, in _setFont
    raise RenderPMError("Can't setFont(%s) missing the T1 files?\nOriginally %s: %s" % (fontName,s1,s2))
reportlab.graphics.renderPM.RenderPMError: Can't setFont(Times-Roman) missing the T1 files?
Originally <class 'TypeError'>: makeT1Font() argument 2 must be str, not None
```

After installing the `gsfonts` package, the traceback does not occurs and the code works as expected.

lsb release: Ubuntu 20.04.1 LTS
python3-renderpm:amd64 3.5.34-1ubuntu1

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.