[Bug 1918107] [NEW] renderPM can't set font
Christophe Monniez
1918107 at bugs.launchpad.net
Mon Mar 8 09:55:17 UTC 2021
Public bug reported:
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
** Affects: python-reportlab (Ubuntu)
Importance: Undecided
Status: New
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to python-reportlab in Ubuntu.
https://bugs.launchpad.net/bugs/1918107
Title:
renderPM can't set font
Status in python-reportlab package in Ubuntu:
New
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 manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/python-reportlab/+bug/1918107/+subscriptions
More information about the foundations-bugs
mailing list