All Projects → rougier → Freetype Py

rougier / Freetype Py

Licence: other
Python binding for the freetype library

Programming Languages

python
139335 projects - #7 most used programming language

Labels

Projects that are alternatives of or similar to Freetype Py

Vsphere Automation Sdk Java
Java samples, language bindings, and API reference documentation for vSphere, VMC, and NSX-T using the VMware REST API
Stars: ✭ 132 (-36.84%)
Mutual labels:  bindings
Net Vips
.NET binding for libvips
Stars: ✭ 173 (-17.22%)
Mutual labels:  bindings
Vsphere Automation Sdk Rest
REST (Postman and JavaScript) samples and API reference documentation for vSphere using the VMware REST API
Stars: ✭ 182 (-12.92%)
Mutual labels:  bindings
Dotherside
C language library for creating bindings for the Qt QML language
Stars: ✭ 140 (-33.01%)
Mutual labels:  bindings
Python Sfml
Official binding of SFML for Python
Stars: ✭ 145 (-30.62%)
Mutual labels:  bindings
Cppsharp
Tools and libraries to glue C/C++ APIs to high-level languages
Stars: ✭ 2,221 (+962.68%)
Mutual labels:  bindings
Rust Gsl
A GSL (the GNU Scientific Library) binding for Rust
Stars: ✭ 125 (-40.19%)
Mutual labels:  bindings
Widgetkit
Compose native apps without a code using JSON and load them as NSBundle into another app dynamicly from local or remote locations.
Stars: ✭ 191 (-8.61%)
Mutual labels:  bindings
Piecash
Pythonic interface to GnuCash SQL documents
Stars: ✭ 172 (-17.7%)
Mutual labels:  bindings
Qt5.cr
Qt5 bindings for Crystal, based on Bindgen
Stars: ✭ 182 (-12.92%)
Mutual labels:  bindings
Gintro
High level GObject-Introspection based GTK3/GTK4 bindings for Nim language
Stars: ✭ 141 (-32.54%)
Mutual labels:  bindings
Xamarin.bindings
A list of existing Xamarin binding libraries.
Stars: ✭ 146 (-30.14%)
Mutual labels:  bindings
Tdl
Node.js bindings to TDLib.
Stars: ✭ 177 (-15.31%)
Mutual labels:  bindings
Wlroots Rs
Attempt at safe Rust bindings for wlroots
Stars: ✭ 135 (-35.41%)
Mutual labels:  bindings
Go Python3
Go bindings to the CPython-3 API
Stars: ✭ 185 (-11.48%)
Mutual labels:  bindings
Fftw.jl
Julia bindings to the FFTW library for fast Fourier transforms
Stars: ✭ 127 (-39.23%)
Mutual labels:  bindings
Node Webrtc
node-webrtc is a Node.js Native Addon that provides bindings to WebRTC M87
Stars: ✭ 2,258 (+980.38%)
Mutual labels:  bindings
Intercept
A C/C++ Binding Library for SQF and RV Engine Access Abstraction Layer
Stars: ✭ 191 (-8.61%)
Mutual labels:  bindings
Libvlc Go
Go bindings for libVLC and high-level media player interface
Stars: ✭ 188 (-10.05%)
Mutual labels:  bindings
Rust Bindgen
Automatically generates Rust FFI bindings to C (and some C++) libraries.
Stars: ✭ 2,453 (+1073.68%)
Mutual labels:  bindings

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

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].