freetype-py


Namefreetype-py JSON
Version 2.5.1 PyPI version JSON
download
home_pagehttps://github.com/rougier/freetype-py
SummaryFreetype python bindings
upload_time2024-08-29 18:32:26
maintainerNone
docs_urlNone
authorNicolas P. Rougier
requires_python>=3.7
licenseNone
keywords freetype font
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            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-vector-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


Freezing apps
=============

Freetype implements a hook for PyInstaller to help simplify the freezing process
(it e.g. ensures that the freetype DLL is included). This hook requires
PyInstaller version 4+.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/rougier/freetype-py",
    "name": "freetype-py",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "freetype, font",
    "author": "Nicolas P. Rougier",
    "author_email": "Nicolas.Rougier@inria.fr",
    "download_url": "https://files.pythonhosted.org/packages/d0/9c/61ba17f846b922c2d6d101cc886b0e8fb597c109cedfcb39b8c5d2304b54/freetype-py-2.5.1.zip",
    "platform": null,
    "description": "FreeType (high-level Python API)\n================================\n\nFreetype Python provides bindings for the FreeType library. Only the\nhigh-level API is bound.\n\nDocumentation available at: http://freetype-py.readthedocs.org/en/latest/\n\nInstallation\n============\n\n**From PyPI, recommended**: `pip install freetype-py`. This will install the\nlibrary with a bundled FreeType binary, so you're ready to go on Windows,\nmacOS and Linux (all with 32 and 64 bit x86 architecture support).\n\nDo note: if you specify the `--no-binary` paramater to pip, or use a different\narchitecture for which we don't pre-compile binaries, the package will default\nto using an external FreeType library. Specify the environment variable\n`FREETYPEPY_BUNDLE_FT=1` before calling pip to compile a binary yourself.\n\nInstallation with compiling FreeType from source\n------------------------------------------------\n\nIf you don't want to or can't use the pre-built binaries, build FreeType\nyourself: `export FREETYPEPY_BUNDLE_FT=yesplease && pip install .`.\nThis will download and compile FreeType with Harfbuzz support as specified in\n`setup-build-freetype.py`. Set the environment variable `PYTHON_ARCH` to 32 or\n64 to explicitly set an architecture, default is whatever your host machine\nuses. On macOS, we will always build a universal 32 and 64 bit Intel binary.\n\n- Windows: You need CMake and a C and C++ compiler, e.g. the Visual Code\n  Community 2017 distribution with the desktop C++ workload.\n- macOS: You need CMake and the XCode tools (full IDE not necessary)\n- Linux: You need CMake, gcc and g++. For building a 32 bit library on a\n  64 bit machine, you need gcc-multilib and g++-multilib (Debian) or\n  glibc-devel.i686 and libstdc++-devel.i686 (Fedora).\n\nInstallation with an external FreeType library (the default)\n------------------------------------------------------------\n\nInstall just the pure Python library and let it find a system-wide installed\nFreeType at runtime.\n\nMac users\n~~~~~~~~~\n\nFreetype should be already installed on your system. If not, either install it\nusing `homebrew <http://brew.sh>`_ or compile it and place the library binary\nfile in '/usr/local/lib'.\n\nLinux users\n~~~~~~~~~~~\n\nFreetype should be already installed on your system. If not, either install\nrelevant package from your package manager or compile from sources and place\nthe library binary file in '/usr/local/lib'.\n\nWindow users\n~~~~~~~~~~~~\n\nThere are no official Freetype binary releases available, but they offer some\nlinks to precompiled Windows DLLs. Please see the `FreeType Downloads\n<https://www.freetype.org/download.html>`_ page for links.\nYou can also compile the FreeType library from source yourself.\n\nIf you are using freetype-py on Windows with a 32-Bit version of Python, you\nneed the 32-Bit version of the Freetype binary. The same applies for a 64-Bit\nversion of Python.\n\nBecause of the way Windows searches for dll files, make sure the resulting\nfile is named 'freetype.dll' (and not something like Freetype245.dll).\nWindows expects the library in one of the directories listed in the $PATH\nenvironment variable. As it is not recommended to place the dll in a Windows\nsystem folder, you can choose one of the following ways to solve this:\n\n* Place library in a folder of your choice and edit the $PATH user\n  environment variable\n* Place library in a folder of your choice and edit the $PATH system\n  environment variable\n* For development purpose, place the library in the working directory of\n  the application\n* Place the library in one of the existing directories listed in $PATH\n\nTo get a complete list of all the directories in the $PATH\nenvironment variable (user and system), open a command promt and type\n\n.. code::\n\n   echo %PATH%\n\nUsage example\n=============\n\n.. code:: python\n\n   import freetype\n   face = freetype.Face(\"Vera.ttf\")\n   face.set_char_size( 48*64 )\n   face.load_char('S')\n   bitmap = face.glyph.bitmap\n   print(bitmap.buffer)\n\nScreenshots\n===========\n\nScreenshot below comes from the wordle.py example. No clever tricks here, just\nbrute force.\n\n.. image:: https://raw.githubusercontent.com/rougier/freetype-py/master/doc/_static/wordle.png\n\nScreenshots below comes from the glyph-vector.py and glyph-vector-2.py\nexamples showing how to access a glyph outline information and use it to draw\nthe glyph. Rendering (with B\u00e9zier curves) is done using matplotlib.\n\n.. image:: https://raw.githubusercontent.com/rougier/freetype-py/master/doc/_static/S.png\n.. image:: https://raw.githubusercontent.com/rougier/freetype-py/master/doc/_static/G.png\n\n\nScreenshot below comes from the glyph-color.py showing how to draw and combine\na glyph outline with the regular glyph.\n\n.. image:: https://raw.githubusercontent.com/rougier/freetype-py/master/doc/_static/outline.png\n\nThe screenshot below comes from the hello-world.py example showing how to draw\ntext in a bitmap (that has been zoomed in to show antialiasing).\n\n.. image:: https://raw.githubusercontent.com/rougier/freetype-py/master/doc/_static/hello-world.png\n\n\nThe screenshot below comes from the agg-trick.py example showing an\nimplementation of ideas from the `Texts Rasterization Exposures\n<http://agg.sourceforge.net/antigrain.com/research/font_rasterization/>`_ by\nMaxim Shemarev.\n\n.. image:: https://raw.githubusercontent.com/rougier/freetype-py/master/doc/_static/agg-trick.png\n\n\nFreezing apps\n=============\n\nFreetype implements a hook for PyInstaller to help simplify the freezing process\n(it e.g. ensures that the freetype DLL is included). This hook requires\nPyInstaller version 4+.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Freetype python bindings",
    "version": "2.5.1",
    "project_urls": {
        "Homepage": "https://github.com/rougier/freetype-py"
    },
    "split_keywords": [
        "freetype",
        " font"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "38a8258dd138ebe60c79cd8cfaa6d021599208a33f0175a5e29b01f60c9ab2c7",
                "md5": "743796b402fa68bbe1e085e6de45962f",
                "sha256": "d01ded2557694f06aa0413f3400c0c0b2b5ebcaabeef7aaf3d756be44f51e90b"
            },
            "downloads": -1,
            "filename": "freetype_py-2.5.1-py3-none-macosx_10_9_universal2.whl",
            "has_sig": false,
            "md5_digest": "743796b402fa68bbe1e085e6de45962f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 1747885,
            "upload_time": "2024-08-29T18:32:17",
            "upload_time_iso_8601": "2024-08-29T18:32:17.604250Z",
            "url": "https://files.pythonhosted.org/packages/38/a8/258dd138ebe60c79cd8cfaa6d021599208a33f0175a5e29b01f60c9ab2c7/freetype_py-2.5.1-py3-none-macosx_10_9_universal2.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a293280ad06dc944e40789b0a641492321a2792db82edda485369cbc59d14366",
                "md5": "a4f4eb173a071d86b4ca2d170bb36fd9",
                "sha256": "5d2f6b3d68496797da23204b3b9c4e77e67559c80390fc0dc8b3f454ae1cd819"
            },
            "downloads": -1,
            "filename": "freetype_py-2.5.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
            "has_sig": false,
            "md5_digest": "a4f4eb173a071d86b4ca2d170bb36fd9",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 1051055,
            "upload_time": "2024-08-29T18:32:19",
            "upload_time_iso_8601": "2024-08-29T18:32:19.153424Z",
            "url": "https://files.pythonhosted.org/packages/a2/93/280ad06dc944e40789b0a641492321a2792db82edda485369cbc59d14366/freetype_py-2.5.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b636853cad240ec63e21a37a512ee19c896b655ce1772d803a3dd80fccfe63fe",
                "md5": "d33c3ee0b9c9c912eeefbff58e8b554c",
                "sha256": "289b443547e03a4f85302e3ac91376838e0d11636050166662a4f75e3087ed0b"
            },
            "downloads": -1,
            "filename": "freetype_py-2.5.1-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl",
            "has_sig": false,
            "md5_digest": "d33c3ee0b9c9c912eeefbff58e8b554c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 1043856,
            "upload_time": "2024-08-29T18:32:20",
            "upload_time_iso_8601": "2024-08-29T18:32:20.565533Z",
            "url": "https://files.pythonhosted.org/packages/b6/36/853cad240ec63e21a37a512ee19c896b655ce1772d803a3dd80fccfe63fe/freetype_py-2.5.1-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "936ffcc1789e42b8c6617c3112196d68e87bfe7d957d80812d3c24d639782dcb",
                "md5": "f71ba43ed224a105e20212520e504558",
                "sha256": "cd3bfdbb7e1a84818cfbc8025fca3096f4f2afcd5d4641184bf0a3a2e6f97bbf"
            },
            "downloads": -1,
            "filename": "freetype_py-2.5.1-py3-none-musllinux_1_1_aarch64.whl",
            "has_sig": false,
            "md5_digest": "f71ba43ed224a105e20212520e504558",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 1108180,
            "upload_time": "2024-08-29T18:32:21",
            "upload_time_iso_8601": "2024-08-29T18:32:21.871623Z",
            "url": "https://files.pythonhosted.org/packages/93/6f/fcc1789e42b8c6617c3112196d68e87bfe7d957d80812d3c24d639782dcb/freetype_py-2.5.1-py3-none-musllinux_1_1_aarch64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2a1b161d3a6244b8a820aef188e4397a750d4a8196316809576d015f26594296",
                "md5": "497df819873fe2b5e8aee8ae1fc731b5",
                "sha256": "3c1aefc4f0d5b7425f014daccc5fdc7c6f914fb7d6a695cc684f1c09cd8c1660"
            },
            "downloads": -1,
            "filename": "freetype_py-2.5.1-py3-none-musllinux_1_1_x86_64.whl",
            "has_sig": false,
            "md5_digest": "497df819873fe2b5e8aee8ae1fc731b5",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 1106792,
            "upload_time": "2024-08-29T18:32:23",
            "upload_time_iso_8601": "2024-08-29T18:32:23.134563Z",
            "url": "https://files.pythonhosted.org/packages/2a/1b/161d3a6244b8a820aef188e4397a750d4a8196316809576d015f26594296/freetype_py-2.5.1-py3-none-musllinux_1_1_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "936ebd7fbfacca077bc6f34f1a1109800a2c41ab50f4704d3a0507ba41009915",
                "md5": "e8f3eb7063960cc92c733dcdf9548337",
                "sha256": "0b7f8e0342779f65ca13ef8bc103938366fecade23e6bb37cb671c2b8ad7f124"
            },
            "downloads": -1,
            "filename": "freetype_py-2.5.1-py3-none-win_amd64.whl",
            "has_sig": false,
            "md5_digest": "e8f3eb7063960cc92c733dcdf9548337",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 814608,
            "upload_time": "2024-08-29T18:32:24",
            "upload_time_iso_8601": "2024-08-29T18:32:24.648669Z",
            "url": "https://files.pythonhosted.org/packages/93/6e/bd7fbfacca077bc6f34f1a1109800a2c41ab50f4704d3a0507ba41009915/freetype_py-2.5.1-py3-none-win_amd64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d09c61ba17f846b922c2d6d101cc886b0e8fb597c109cedfcb39b8c5d2304b54",
                "md5": "ac44c802ce82b123721b53104b6a8932",
                "sha256": "cfe2686a174d0dd3d71a9d8ee9bf6a2c23f5872385cf8ce9f24af83d076e2fbd"
            },
            "downloads": -1,
            "filename": "freetype-py-2.5.1.zip",
            "has_sig": false,
            "md5_digest": "ac44c802ce82b123721b53104b6a8932",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 851738,
            "upload_time": "2024-08-29T18:32:26",
            "upload_time_iso_8601": "2024-08-29T18:32:26.370899Z",
            "url": "https://files.pythonhosted.org/packages/d0/9c/61ba17f846b922c2d6d101cc886b0e8fb597c109cedfcb39b8c5d2304b54/freetype-py-2.5.1.zip",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-29 18:32:26",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "rougier",
    "github_project": "freetype-py",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "freetype-py"
}
        
Elapsed time: 0.80361s