freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Freetype for Python. AttributeError: module 'freetype' has no attrib


From: Hin-Tak Leung
Subject: Re: Freetype for Python. AttributeError: module 'freetype' has no attribute 'Face'
Date: Fri, 15 Dec 2023 13:00:27 +0000 (UTC)

Both comments from Alex are wrong...

 freetype-py has its own versioning, it is confusing, but 2.4.0 is current: https://github.com/rougier/freetype-py/releases  

And has its init hook too: https://github.com/rougier/freetype-py/blob/master/freetype/__init__.py

I think that the python load path of the initial poster is wrong. Ie. You are not loading freetype-py, but something else which happens to have a "freetype.py" file, for example. It could be his own code - if he has a file called freetype.py himself, that would be loaded instead of the (system-wide) freetype-py package. Quite a common mistake, to have all user code interacting with freetype-py in a new file called "freetype.py" (in the current directory), or a user file "skia.py" to interact with skia-python, etc.


On Friday, 15 December 2023 at 02:50:03 GMT, Alexei Podtelezhnikov <apodtele@gmail.com> wrote:



I have bindings for freetype 2.4.0 for Python. I dont understand why that:

Do you realize that this version is 13 years old? I recently saw a current FreeType version in the anaconda environment. Just saying…


AttributeError: module 'freetype' has no attribute 'Face'

is coming from:

import freetype
face = freetype.Face("Vera.ttf")
face.set_char_size( 48*64 )
face.load_char('S')
bitmap = face.glyph.bitmap
print(bitmap.buffer)


FreeType requires initialization (internal module loading). See if you can find some _init_ method that you might need to call first.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]