[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freetype-devel
Subject:    Re: Freetype for Python. AttributeError: module 'freetype' has no attribute 'Face'
From:       Hin-Tak Leung <htl10 () users ! sourceforge ! net>
Date:       2023-12-15 13:00:27
Message-ID: 1763252067.2836406.1702645227696 () mail ! yahoo ! com
[Download RAW message or body]

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  freetypeface  =  freetype.Face("Vera.ttf")face.set_char_size( 48*64  \
)face.load_char('S')bitmap  =  face.glyph.bitmapprint(bitmap.buffer)


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


[Attachment #3 (text/html)]

<html><head></head><body><div class="ydp36951ccbyahoo-style-wrap" style="font-family: \
Helvetica Neue, Helvetica, Arial, sans-serif; font-size: 16px;"><div \
style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif; font-size: \
16px;"></div>  <div><font face="Helvetica Neue, Helvetica, Arial, sans-serif"><span \
style="font-size: 16px;">Both comments from Alex are \
wrong...</span></font></div><div><font face="Helvetica Neue, Helvetica, Arial, \
sans-serif"><span style="font-size: 16px;"><br></span></font></div><div><font \
face="Helvetica Neue, Helvetica, Arial, sans-serif"><span style="font-size: \
16px;">&nbsp;freetype-py has its own versioning, it is confusing, but 2.4.0 is \
current: https://github.com/rougier/freetype-py/releases</span></font><span \
style="font-size: 16px; font-family: Helvetica Neue, Helvetica, Arial, \
sans-serif;">&nbsp;&nbsp;</span></div><div><span style="font-size: 16px; font-family: \
Helvetica Neue, Helvetica, Arial, sans-serif;"><br></span></div><div><span \
style="font-size: 16px; font-family: Helvetica Neue, Helvetica, Arial, \
sans-serif;">And has its init hook too: \
https://github.com/rougier/freetype-py/blob/master/freetype/__init__.py</span></div><div \
style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif; font-size: \
16px;"><br></div><div style="font-family: Helvetica Neue, Helvetica, Arial, \
sans-serif; font-size: 16px;">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.</div><div style="font-family: \
Helvetica Neue, Helvetica, Arial, sans-serif; font-size: 16px;"><br></div><div \
style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif; font-size: \
16px;"><br></div>  
        <div id="ydp36951ccbyahoo_quoted_3369092428" class="ydp36951ccbyahoo_quoted" \
                style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif; \
                font-size: 16px;">
            <div style="font-family:'Helvetica Neue', Helvetica, Arial, \
sans-serif;font-size:13px;color:#26282a;">  
                <div>
                    On Friday, 15 December 2023 at 02:50:03 GMT, Alexei \
Podtelezhnikov &lt;apodtele@gmail.com&gt; wrote:  </div>
                <div><br></div>
                <div><br></div>
                <div><div id="ydp36951ccbyiv9584013209"><div><div dir="ltr"><br \
clear="none"></div><blockquote type="cite"><div dir="ltr"><div \
style="font-family:Arial, sans-serif;font-size:14px;">I have bindings for freetype \
2.4.0 for Python. I dont understand why that:</div></div></blockquote><div><br \
clear="none"></div>Do you realize that this version is 13 years old? I recently saw a \
current FreeType version in the anaconda environment. Just saying…<div \
id="ydp36951ccbyiv9584013209yqtfd84968" \
class="ydp36951ccbyiv9584013209yqt8555235174"><br clear="none"></div><blockquote \
type="cite"><div dir="ltr"><div id="ydp36951ccbyiv9584013209yqtfd60111" \
class="ydp36951ccbyiv9584013209yqt8555235174"><div style="font-family:Arial, \
sans-serif;font-size:14px;"><br clear="none"></div><div style="font-family:Arial, \
sans-serif;font-size:14px;"><span>AttributeError: module 'freetype' has no attribute \
'Face'</span><br clear="none"></div><div style="font-family:Arial, \
sans-serif;font-size:14px;"><span><br clear="none"></span></div><div \
style="font-family:Arial, sans-serif;font-size:14px;"><span><b>is coming \
from:</b></span></div><div style="font-family:Arial, \
sans-serif;font-size:14px;"><span><b><br clear="none"></b></span></div></div><div \
style="font-family:Arial, sans-serif;font-size:14px;"><div \
id="ydp36951ccbyiv9584013209yqtfd85348" \
class="ydp36951ccbyiv9584013209yqt8555235174"><span><b></b></span><div \
style="font-family: Consolas, monospace; font-weight: normal; line-height: 19px; \
color: rgb(204, 204, 204); background-color: rgb(31, 31, 31);"><span><span \
style="color:rgb(197, 134, 192);">import</span><span>&nbsp;</span><span \
style="color:rgb(78, 201, 176);">freetype</span></span><div><span \
style="color:rgb(156, 220, 254);">face</span><span>&nbsp;</span><span \
style="color:rgb(212, 212, 212);">=</span><span>&nbsp;</span><span \
style="color:rgb(78, 201, 176);">freetype</span><span>.</span><span \
style="color:rgb(78, 201, 176);">Face</span><span>(</span><span style="color:rgb(206, \
145, 120);">"Vera.ttf"</span><span>)</span></div><div><span style="color:rgb(156, \
220, 254);">face</span><span>.</span><span style="color:rgb(220, 220, \
170);">set_char_size</span><span>( </span><span style="color:rgb(181, 206, \
168);">48</span><span style="color:rgb(212, 212, 212);">*</span><span \
style="color:rgb(181, 206, 168);">64</span><span>&nbsp;)</span></div><div><span \
style="color:rgb(156, 220, 254);">face</span><span>.</span><span \
style="color:rgb(220, 220, 170);">load_char</span><span>(</span><span \
style="color:rgb(206, 145, 120);">'S'</span><span>)</span></div><div><span \
style="color:rgb(156, 220, 254);">bitmap</span><span>&nbsp;</span><span \
style="color:rgb(212, 212, 212);">=</span><span>&nbsp;</span><span \
style="color:rgb(156, 220, 254);">face</span><span>.</span><span \
style="color:rgb(156, 220, 254);">glyph</span><span>.bitmap</span></div><span><span \
style="color:rgb(220, 220, 170);">print</span><span>(</span><span \
style="color:rgb(156, 220, \
254);">bitmap</span><span>.buffer)</span></span></div></div><br \
clear="none"></div><div style="font-family:Arial, \
sans-serif;font-size:14px;"><span><b><br \
clear="none"></b></span></div></div></blockquote><div>FreeType requires \
initialization (internal module loading). See if you can find some _init_ method that \
you might need to call first.</div></div></div></div>  </div>
        </div></div></body></html>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic