xxao/pero

SVG example fails because expected fonts are missing from OS

Opened this issue · 0 comments

I'm on Manjaro Linux and I think I don't have Arial or Helvetica.

Running this example:

import pero

# init size
width = 200
height = 200

# init canvas
canvas = pero.svg.SVGCanvas(width=width, height=height)

# draw graphics
canvas.line_color = "b"
canvas.fill_color = "w"
canvas.fill()
canvas.draw_circle(100, 100, 75)

# save to file
with open('test.svg', 'w', encoding='utf-8') as f:
    f.write(canvas.get_xml())

I get the following error:

Traceback (most recent call last):
  File "/home/villares/GitHub/sketch-a-day/2022/sketch_2022_12_12/sketch_2022_12_12.py", line 9, in <module>
    canvas = pero.svg.SVGCanvas(width=width, height=height)
  File "/home/villares/.local/lib/python3.10/site-packages/pero/backends/svg/canvas.py", line 56, in __init__
    self._update_text()
  File "/home/villares/.local/lib/python3.10/site-packages/pero/backends/svg/canvas.py", line 723, in _update_text
    font = self.get_font()
  File "/home/villares/.local/lib/python3.10/site-packages/pero/drawing/canvas.py", line 366, in get_font
    raise ValueError(message)
ValueError: Cannot initialize the font! -> Arial, arial, Arial, Helvetica