Skip to main content
Help us improve PyPI by participating in user testing. All experience levels needed!

Freetype python bindings

Project description

FreeType high-level python API
==============================

Freetype python provides bindings for the FreeType library. Only the high-level API is bound.

Documentation available at: http://freetype-py.readthedocs.org/en/latest/

Installation
============

To be able to use freetype python, you need the freetype library version 2
installed on your system.

Mac users
---------

Freetype should be already installed on your system. If not, either install it
using `homebrew <http://brew.sh>`_ or compile it and place the library binary
file in '/usr/local/lib'.

Linux users
-----------

Freetype should be already installed on your system. If not, either install
relevant package from your package manager or compile from sources and place
the library binary file in '/usr/local/lib'.

Window users
------------

There are no official Freetype binary releases available, but they offer some
links to precompiled Windows DLLs. Please see the `FreeType Downloads
<https://www.freetype.org/download.html>`_ page for links.
You can also compile the FreeType library from source.

32-Bit vs 64-Bit on Windows
~~~~~~~~~~~~~~~~~~~~~~~~~~~

If you are using freetype-py on Windows with a 32-Bit version of python, you
need the 32-Bit version of the Freetype binary. The same applies for a 64-Bit
version of python.

Installation on Windows
~~~~~~~~~~~~~~~~~~~~~~~

Because of the way Windows searches for dll files, make sure the resulting
file is named 'freetype.dll' (and not something like Freetype245.dll).
Windows expects the library in one of the directories listed in the $PATH
environment variable. As it is not recommended to place the dll in a Windows
system folder, you can choose one of the following ways to solve this:

* Place library in a folder of your choice and edit the $PATH user
environment variable
* Place library in a folder of your choice and edit the $PATH system
environment variable
* For development purpose, place the library in the working directory of
the application
* Place the library in one of the existing directories listed in $PATH

To get a complete list of all the directories in the $PATH
environment variable (user and system), open a command promt and type
.. code::
echo %PATH%

Usage example
=============

.. code:: python

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

Screenshots
===========

Screenshot below comes from the wordle.py example. No clever tricks here, just
brute force.

.. image:: https://raw.githubusercontent.com/rougier/freetype-py/master/doc/_static/wordle.png

Screenshots below comes from the glyph-vector.py and glyph-vectopr-2.py
examples showing how to access a glyph outline information and use it to draw
the glyph. Rendering (with Bézier curves) is done using matplotlib.

.. image:: https://raw.githubusercontent.com/rougier/freetype-py/master/doc/_static/S.png
.. image:: https://raw.githubusercontent.com/rougier/freetype-py/master/doc/_static/G.png


Screenshot below comes from the glyph-color.py showing how to draw and combine
a glyph outline with the regular glyph.

.. image:: https://raw.githubusercontent.com/rougier/freetype-py/master/doc/_static/outline.png

The screenshot below comes from the hello-world.py example showing how to draw
text in a bitmap (that has been zoomed in to show antialiasing).

.. image:: https://raw.githubusercontent.com/rougier/freetype-py/master/doc/_static/hello-world.png


The screenshot below comes from the agg-trick.py example showing an
implementation of ideas from the `Texts Rasterization Exposures
<http://agg.sourceforge.net/antigrain.com/research/font_rasterization/>`_ by
Maxim Shemarev.

.. image:: https://raw.githubusercontent.com/rougier/freetype-py/master/doc/_static/agg-trick.png


Contributors
============

* Titusz Pan (bug report)
* Ekkehard.Blanz (bug report)
* Jānis Lībeks (bug report)
* Frantisek Malina (typo)
* Tillmann Karras (bug report & fix)
* Matthew Sitton (bug report & fix)
* Tao Gong (bug report)
* Matthew Sitton (Remove raw interfaces from the __init__.py file)
* Daniel McCloy (Adde glyph_name function)

Project details


Release history Release notifications

This version
History Node

1.2.1

History Node

1.2

History Node

1.1

History Node

1.0.2

History Node

1.0.1

History Node

1.0

History Node

0.5.3

History Node

0.5.1

History Node

0.5.0

History Node

0.4.2

History Node

0.4.1

History Node

0.4

History Node

0.3.3

History Node

0.3.2

History Node

0.3.1

History Node

0.3.0

History Node

0.2.0

History Node

0.1.1

History Node

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
freetype-py-1.2.1.tar.gz (181.7 kB) Copy SHA256 hash SHA256 Source None Feb 24, 2018

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page