[reportlab-users] Problem using drawToFile() using PyCairo backend

Lele Gaifax lele at metapensiero.it
Mon Jun 12 04:11:15 EDT 2023


Hi all,

I tried upgrading one of my apps from RL 3.6.13 to latest 4.0.4, adding
the rl-accel and rlPyCairo extensions.

It almost worked without issue, with one particular exception: the app
comes with a Sphinx-based user manual, and its build procedure uses the
renderPM.drawToFile() function to dump a PNG of an output sample, and
that fails with the following traceback:

    Traceback (most recent call last):
      File ".../dump-layout.py", line 13, in <module>
        sys.exit(main())
                 ^^^^^^
      File ".../dump-layout.py", line 89, in main
        dump_default_layout(args.configuration, args.outline)
      File ".../dump-layout.py", line 75, in dump_default_layout
        renderPM.drawToFile(d, outline, 'PNG')
      File ".../lib/python3.11/site-packages/reportlab/graphics/renderPM.py", line 716, in drawToFile
        c = drawToPMCanvas(d, dpi=dpi, bg=bg, configPIL=configPIL, showBoundary=showBoundary,backend=backend)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File ".../lib/python3.11/site-packages/reportlab/graphics/renderPM.py", line 702, in drawToPMCanvas
        draw(d, c, 0, 0, showBoundary=showBoundary)
      File ".../lib/python3.11/site-packages/reportlab/graphics/renderPM.py", line 76, in draw
        R.draw(renderScaledDrawing(drawing), canvas, x, y, showBoundary=showBoundary)
      File ".../lib/python3.11/site-packages/reportlab/graphics/renderbase.py", line 186, in draw
        self.drawNode(drawing)
      File ".../lib/python3.11/site-packages/reportlab/graphics/renderPM.py", line 133, in drawNode
        self.drawNodeDispatcher(node)
      File ".../lib/python3.11/site-packages/reportlab/graphics/renderbase.py", line 267, in drawNodeDispatcher
        self.drawGroup(node)
      File ".../lib/python3.11/site-packages/reportlab/graphics/renderbase.py", line 298, in drawGroup
        self.drawNode(node)
      File ".../lib/python3.11/site-packages/reportlab/graphics/renderPM.py", line 133, in drawNode
        self.drawNodeDispatcher(node)
      File ".../lib/python3.11/site-packages/reportlab/graphics/renderbase.py", line 265, in drawNodeDispatcher
        self.drawString(node)
      File ".../lib/python3.11/site-packages/reportlab/graphics/renderPM.py", line 220, in drawString
        canv.drawString(x,y,text,_fontInfo=(fontName,fontSize))
      File ".../lib/python3.11/site-packages/reportlab/graphics/renderPM.py", line 546, in drawString
        gs.drawString(x,y,text)
      File ".../lib/python3.11/site-packages/rlPyCairo/gstate.py", line 219, in drawString
        for op in self._text2PathDescription(text, x, y):
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File ".../lib/python3.11/site-packages/rlPyCairo/gstate.py", line 58, in _text2PathDescription
        return _text2PathDescription(text, x, y)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File ".../lib/python3.11/site-packages/rlPyCairo/gstate.py", line 52, in _text2PathDescription
        return text2PathDescription(
               ^^^^^^^^^^^^^^^^^^^^^
      File ".../lib/python3.11/site-packages/reportlab/graphics/utils.py", line 170, in text2PathDescription
        P_extend(gs._text2Path(t,x=x,y=y,fontName=f.fontName,fontSize=fontSize, truncate=truncate,pathReverse=pathReverse))
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File ".../lib/python3.11/site-packages/reportlab/graphics/utils.py", line 134, in _text2Path
        face.glyph.outline.decompose(self, move_to=move_to, line_to=line_to, conic_to=conic_to, cubic_to=cubic_to)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    AttributeError: 'Outline' object has no attribute 'decompose'

I will try to distill a short script exhibiting the problem, but maybe
there's something I'm missing and the traceback above rings a bell to
you?

Thanks&bye, lele.
-- 
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
lele at metapensiero.it  |                 -- Fortunato Depero, 1929.



More information about the reportlab-users mailing list