Skip to main content

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

From PyPI, recommended: pip install freetype-py. This will install the library with a bundled FreeType binary, so you’re ready to go on Windows, macOS and Linux (all with 32 and 64 bit x86 architecture support).

Do note: if you specify the –no-binary paramater to pip, or use a different architecture for which we don’t pre-compile binaries, the package will default to using an external FreeType library. Specify the environment variable FREETYPEPY_BUNDLE_FT=1 before calling pip to compile a binary yourself.

Installation with compiling FreeType from source

If you don’t want to or can’t use the pre-built binaries, build FreeType yourself: export FREETYPEPY_BUNDLE_FT=yesplease && pip install .. This will download and compile FreeType with Harfbuzz support as specified in setup-build-freetype.py. Set the environment variable PYTHON_ARCH to 32 or 64 to explicitly set an architecture, default is whatever your host machine uses. On macOS, we will always build a universal 32 and 64 bit Intel binary.

  • Windows: You need CMake and a C and C++ compiler, e.g. the Visual Code Community 2017 distribution with the desktop C++ workload.

  • macOS: You need CMake and the XCode tools (full IDE not necessary)

  • Linux: You need CMake, gcc and g++. For building a 32 bit library on a 64 bit machine, you need gcc-multilib and g++-multilib (Debian) or glibc-devel.i686 and libstdc++-devel.i686 (Fedora).

Installation with an external FreeType library (the default)

Install just the pure Python library and let it find a system-wide installed FreeType at runtime.

Mac users

Freetype should be already installed on your system. If not, either install it using homebrew 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 page for links. You can also compile the FreeType library from source yourself.

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.

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

echo %PATH%

Usage example

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.

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.

https://raw.githubusercontent.com/rougier/freetype-py/master/doc/_static/S.png 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.

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).

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 by Maxim Shemarev.

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

Project details


Download files

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

Source Distribution

freetype-py-2.1.0.post1.tar.gz (594.2 kB view details)

Uploaded Source

Built Distributions

freetype_py-2.1.0.post1-py2.py3-none-win_amd64.whl (666.2 kB view details)

Uploaded Python 2 Python 3 Windows x86-64

freetype_py-2.1.0.post1-py2.py3-none-win32.whl (574.4 kB view details)

Uploaded Python 2 Python 3 Windows x86

freetype_py-2.1.0.post1-py2.py3-none-manylinux1_x86_64.whl (883.6 kB view details)

Uploaded Python 2 Python 3

freetype_py-2.1.0.post1-py2.py3-none-manylinux1_i686.whl (866.2 kB view details)

Uploaded Python 2 Python 3

freetype_py-2.1.0.post1-py2.py3-none-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (1.6 MB view details)

Uploaded Python 2 Python 3 macOS 10.10+ intel macOS 10.10+ x86-64 macOS 10.6+ intel macOS 10.9+ intel macOS 10.9+ x86-64

freetype_py-2.1.0.post1-py2.py3-none-any.whl (69.3 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file freetype-py-2.1.0.post1.tar.gz.

File metadata

  • Download URL: freetype-py-2.1.0.post1.tar.gz
  • Upload date:
  • Size: 594.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.5.6

File hashes

Hashes for freetype-py-2.1.0.post1.tar.gz
Algorithm Hash digest
SHA256 76383bb3e59efa6ce0be1797ed70207d7d1e421611df3aceb269673c4a77c2cc
MD5 725a9d1c37da376cd538196d6e63b3ea
BLAKE2b-256 e30f30965bd690e1f35dfd50aa856fac006327e402d1a36d91e4e343f08e7b12

See more details on using hashes here.

File details

Details for the file freetype_py-2.1.0.post1-py2.py3-none-win_amd64.whl.

File metadata

  • Download URL: freetype_py-2.1.0.post1-py2.py3-none-win_amd64.whl
  • Upload date:
  • Size: 666.2 kB
  • Tags: Python 2, Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.8

File hashes

Hashes for freetype_py-2.1.0.post1-py2.py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 eda77d57acdfe74d1cf3958b5fb5aaea21a2866f4e8d7632c06123d6014f9e0c
MD5 7de00d15e147ebd8c2f4f9166ff41b1a
BLAKE2b-256 715f07aad120ca6e4339a5c127631341787bc6bc74add39a1f41223bda949721

See more details on using hashes here.

File details

Details for the file freetype_py-2.1.0.post1-py2.py3-none-win32.whl.

File metadata

  • Download URL: freetype_py-2.1.0.post1-py2.py3-none-win32.whl
  • Upload date:
  • Size: 574.4 kB
  • Tags: Python 2, Python 3, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.15

File hashes

Hashes for freetype_py-2.1.0.post1-py2.py3-none-win32.whl
Algorithm Hash digest
SHA256 d179759b245bb01f5603acd071aea99d97d993a28c4e71fdc4bd7530c49931f9
MD5 5b4d66fbf56273792653365455ce3675
BLAKE2b-256 83329170c919c489d2de18a15add5e86c3fbb82c015f073f31c64a7bcd0cdeb2

See more details on using hashes here.

File details

Details for the file freetype_py-2.1.0.post1-py2.py3-none-manylinux1_x86_64.whl.

File metadata

  • Download URL: freetype_py-2.1.0.post1-py2.py3-none-manylinux1_x86_64.whl
  • Upload date:
  • Size: 883.6 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.5.6

File hashes

Hashes for freetype_py-2.1.0.post1-py2.py3-none-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 84e9879bb5f87dc1eb5342230a13e7ea10f520aa06a4d1c7b298208bbac08110
MD5 d4b36ab1b9c3cb7cc297cb4609800a34
BLAKE2b-256 f2006f332e63b33d24dc3761916e6d51402a7a82dd43c6ca8a96e24dda32c6b5

See more details on using hashes here.

File details

Details for the file freetype_py-2.1.0.post1-py2.py3-none-manylinux1_i686.whl.

File metadata

  • Download URL: freetype_py-2.1.0.post1-py2.py3-none-manylinux1_i686.whl
  • Upload date:
  • Size: 866.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.5.6

File hashes

Hashes for freetype_py-2.1.0.post1-py2.py3-none-manylinux1_i686.whl
Algorithm Hash digest
SHA256 be7a97a964a23d41d7eed4fc834b243871845115728ef41390b9efede588e854
MD5 cc09e964491190ae7712f0b6bc830f10
BLAKE2b-256 b8eaadfbeb3762a03c1d1c1ff751101efb1fddb7aadffa991d39bdb486d0557e

See more details on using hashes here.

File details

Details for the file freetype_py-2.1.0.post1-py2.py3-none-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl.

File metadata

File hashes

Hashes for freetype_py-2.1.0.post1-py2.py3-none-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
Algorithm Hash digest
SHA256 2fa866dd3d8beb73d03f0cf6b7cc51d0cd0ab9c8674c1d8bee2a1b299ee0731c
MD5 39358c5513f1708b8e59baad597a9bf5
BLAKE2b-256 02c95414ba5fc8373a2c54e238f2e52c31b6b56b628449fcc114fc58c608d928

See more details on using hashes here.

File details

Details for the file freetype_py-2.1.0.post1-py2.py3-none-any.whl.

File metadata

  • Download URL: freetype_py-2.1.0.post1-py2.py3-none-any.whl
  • Upload date:
  • Size: 69.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.5.6

File hashes

Hashes for freetype_py-2.1.0.post1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 0f14ffc1715e3d0f01e7c9d07980b10b7143595d9322bb6da3fc74db5251fa8c
MD5 928566a75f1d5b90f8630bd60f5eb900
BLAKE2b-256 c09b1a402a9071bd6ef88c684bc83b1da90e8da4c27cc572be34178df4f84b30

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page