Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to run on windows: OSError: cannot load font (no text renderer) #96

Closed
matiasba opened this issue Jul 11, 2024 · 3 comments
Closed

Comments

@matiasba
Copy link

I'm unable to use the library on a windows system with a venv created via pycharm

The install goes ok

(.venv5) PS C:\Users\matia\PycharmProjects\test> pip install aggdraw
Collecting aggdraw
  Obtaining dependency information for aggdraw from https://files.pythonhosted.org/packages/5d/2d/faeee5134f899b73581b041799417ec53b9487a37e9b34d1f9c8d317f988/aggdraw-1.3.18.post0-cp310-cp310-win_amd64.whl.metadata
  Using cached aggdraw-1.3.18.post0-cp310-cp310-win_amd64.whl.metadata (679 bytes)
Using cached aggdraw-1.3.18.post0-cp310-cp310-win_amd64.whl (44 kB)
Installing collected packages: aggdraw
Successfully installed aggdraw-1.3.18.post0

It gives the following error when I try yo use it.

(.venv5) PS C:\Users\matia\PycharmProjects\test> python
Python 3.10.11 (tags/v3.10.11:7d4cc5a, Apr  5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import aggdraw
>>> aggdraw.Font('black', 'Vera.ttf')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OSError: cannot load font (no text renderer)

It works with no problems in a venv created inside a linux WSL
There is a similar non resolved issue here #74 but that one is not on windows.
I think that i may be missing some system dependency, can someone help me?
Many thanks

@djhoese
Copy link
Member

djhoese commented Jul 11, 2024

To use fonts you will need the C/C++ library "freetype" installed. I am not up to date on the easiest way to do that on Windows. If you were using a conda environment then it would be easily installable from that. There are other solutions too, but I'm just not familiar with them.

@matiasba
Copy link
Author

I did some digging and I cant find any good explanation on how to install freetype on windows. There is a python package called freetype-py which seems to work on windows but I cant find a way to make aggdraw use those binaries. Do you know if there is a way to make that work?

@djhoese
Copy link
Member

djhoese commented Sep 11, 2024

Sorry I didn't answer this. The notification must have fallen through the cracks. The freetype-py package would be a good start, except if I remember correctly it doesn't bundle Windows binaries in its wheels any more. Or rather it doesn't have Windows wheels. If you do install it and it includes freetype in it, then installing aggdraw from source should automatically find them. Otherwise you can force it using AGGDRAW_FREETYPE_ROOT:

FREETYPE_ROOT = os.getenv('AGGDRAW_FREETYPE_ROOT')

@djhoese djhoese closed this as completed Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants