Skip to content

Commit

Permalink
replace ctypes with subprocess
Browse files Browse the repository at this point in the history
We no longer wrap libttfautohint using ctypes, but prefer to run the ttfautohint executable as a subprocess. This is easier to maintain/update.
Fixes #15.
  • Loading branch information
anthrotype committed Nov 13, 2024
1 parent 36886f5 commit 81fdc0d
Show file tree
Hide file tree
Showing 21 changed files with 928 additions and 1,681 deletions.
10 changes: 2 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: "3.x"
Expand All @@ -41,7 +38,7 @@ jobs:
matrix:
os: [ "ubuntu-latest", "macos-13", "windows-latest" ]
env:
CIBW_ENVIRONMENT: TTFAUTOHINTPY_BUNDLE_DLL=1
CIBW_ENVIRONMENT: TTFAUTOHINTPY_BUNDLE_EXE=1
CIBW_BEFORE_ALL_LINUX: sh ci/docker-fixes.sh
CIBW_BEFORE_ALL_MACOS: sh ci/osx-fixes.sh
CIBW_ARCHS_LINUX: x86_64
Expand All @@ -58,9 +55,6 @@ jobs:
CIBW_TEST_COMMAND_WINDOWS: cd /d {project} && coverage run --parallel-mode -m pytest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: "Set up MSYS2 (Windows)"
uses: msys2/setup-msys2@v2
if: startsWith(matrix.os, 'windows')
Expand Down Expand Up @@ -115,7 +109,7 @@ jobs:
coverage xml
- name: Upload coverage to Codecov
if: ${{ !startsWith(matrix.os, 'ubuntu') }}
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@v4
with:
file: coverage.xml

Expand Down
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,14 @@ htmlcov/

# OSX Finder
.DS_Store

# autogenerated vesion file
src/python/ttfautohint/_version.py

# executable built in-place
src/python/ttfautohint/ttfautohint

# uncompressed source tarballs
src/c/ttfautohint/
src/c/freetype/
src/c/harfbuzz/
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
![CI Status](https://github.com/fonttools/ttfautohint-py/actions/workflows/ci.yml/badge.svg?branch=main)
# ttfautohint-py

`ttfautohint-py` is a Python wrapper for [ttfautohint](https://freetype.org/ttfautohint/), a free auto-hinter for TrueType fonts created by Werner Lemberg ([@lemzwerg](https://github.com/lemzwerg)).

As of v0.6, it runs the `ttfautohint` executable as a subprocess. Previous versions used [ctypes](https://docs.python.org/3/library/ctypes.html) to load the `libttfautohint` shared library, but that was hard to maintain and complicated to keep up to date with upstream `ttfautohint` hence we decided to switch to a simpler `subprocess` approach (cf. #15).

Binary "wheel" packages are available for Linux (`manylinux2014`), macOS and Windows, for Python 3.8+, with 32 and 64 bit architecture. They can be installed from the Python Package Index ([PyPI](https://pypi.python.org/pypi/ttfautohint-py)) using the pip installer.

$ pip install ttfautohint-py

The wheels include a precompiled `ttfautohint` executable which has no other dependency apart from system libraries. The [FreeType](https://www.freetype.org/) and the [HarfBuzz](https://github.com/harfbuzz/harfbuzz) libraries are compiled from source as static libraries and embedded in `ttfautohint`.

To compile the `ttfautohint-py` package from source on Windows, you need to install [MSYS2](http://www.msys2.org/) and the latest MinGW-w64 toolchain. This is because the `ttfautohint` build system is based on autotools and thus requires a Unix-like environment.

A `Makefile` is used to build the library and its static dependencies, thus the GNU [make](https://www.gnu.org/software/make/) executable must be on the `$PATH`, as this is called upon by the `setup.py` script.
49 changes: 0 additions & 49 deletions README.rst

This file was deleted.

8 changes: 8 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
[download]
freetype_version = 2.13.3
freetype_sha256 = 0550350666d427c74daeb85d5ac7bb353acba5f76956395995311a9c6f063289
harfbuzz_version = 8.5.0
harfbuzz_sha256 = 77e4f7f98f3d86bf8788b53e6832fb96279956e1c3961988ea3d4b7ca41ddc27
ttfautohint_version = 1.8.4
ttfautohint_sha256 = 8a876117fa6ebfd2ffe1b3682a9a98c802c0f47189f57d3db4b99774206832e1

[bdist_wheel]
universal = 1

Expand Down
Loading

0 comments on commit 81fdc0d

Please sign in to comment.