If a custom font is set as the default font, trying to get its width in the future will cause it to crash, works only for fonts bundled like VeraMono and OpenSans
Code is in text.py, Just execute it with the line Text.default_font = 'consola.ttf' uncommented.
Result:
Traceback (most recent call last):
File "/home/burntranch/ursina/.venv/lib/python3.11/site-packages/ursina/text.py", line 479, in <module>
print('....', Text.get_width('yolo'))
^^^^^^^^^^^^^^^^^^^^^^
File "/home/burntranch/ursina/.venv/lib/python3.11/site-packages/ursina/text.py", line 429, in get_width
w = t.width
^^^^^^^
File "/home/burntranch/ursina/.venv/lib/python3.11/site-packages/ursina/text.py", line 278, in width
temp_text_node.setFont(self._font)
^^^^^^^^^^
AttributeError: 'Text' object has no attribute '_font'
If a custom font is set as the default font, trying to get its width in the future will cause it to crash, works only for fonts bundled like VeraMono and OpenSans
Code is in text.py, Just execute it with the line
Text.default_font = 'consola.ttf'
uncommented. Result: