Closed jeff5048 closed 6 years ago
Hi! If you want to run the code from IDLE, you probably need to specify the full path to a TTF you want to render, try e.g.
import freetype
face = freetype.Face(r'C:\Windows\Fonts\arial.ttf')
face.set_char_size( 48*64 )
face.load_char('S')
bitmap = face.glyph.bitmap
print (bitmap.buffer)
Note the r
in front of 'C:\Windows\Fonts\arial.ttf'
, this makes Windows paths work in Python.
Thank you madig. That did work! I was also able to get it to work by placing a ttf file in the directory with the example code file. It is outputting a bunch of comma delimited numbers to the Python 3.6.5 shell. The "r" before the path is a useful tip as I did not know that. Thx!
Hi,
I am new to Python programming. I don't know where else to post this issue. I installed freetype like this: python -m pip install --user freetype-py
It seemed to install okay.
There is an error when the following code is run in IDLE:
import freetype face = freetype.Face("Vera.ttf") face.set_char_size( 48*64 ) face.load_char('S') bitmap = face.glyph.bitmap print (bitmap.buffer)
I suspect there is no "Vera.ttf" file. The code doesn't work for common windows "ttf" files. Do fonts need to be moved to a specific directory?
Windows 10 Pro 64-bit OS and processor
The error is:
Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 17:00:18) [MSC v.1900 64 bit (AMD64)] on win32 Type "copyright", "credits" or "license()" for more information.