Skip to main content

Python wrapper for ot-sanitizer

Project description

pyots (PYthon OT Sanitizer)

Run Tests Build Python Wheels

PyPI PyPI

macOS ubuntu

Python wrapper for OpenType Sanitizer, also known as just "OTS". It is similar to and partially based on ots-python, but builds OTS as a Python C Extension (instead of as an executable and calling through subprocess as ots-python does).

NOTE: Although this package is similar to ots-python, it is not a drop-in replacement for it, as the Python API is different.

Requirements

The project builds pip-installable wheels for Python 3.9, 3.10, 3.11, or 3.12 under Mac or Linux. It is possible this project will build and run with other Pythons and other operating systems, but it has only been tested with the listed configurations.

Installation with pip

If you just want to use pyots, you can simply run python -m pip install -U pyots (in one of the supported platforms/Python versions) which will install pre-built, compiled, ready-to-use Python wheels. Then you can skip down to the Use section.

Installation/setup for developing pyots

If you'd like to tinker with the pyots code, you will want to get your local setup ready:

  • clone this repo
  • run python setup.py download to download the OTS source (which is not included in this project). You can modify the version value in setup.cfg under [download] to specify a different version of OTS. You'll also need to change the sha256 hash value that corresponds to the OTS tar.xz package. Note that this scheme has some limitations: OTS sources older than 8.1.3 might not build correctly since they used different build systems. Also, versions newer than the one specified in this repo might require adjustments in order to build correctly. What can we say, we're dependent on ots...
  • to build and install pyots after downloading OTS, you can run python setup.py install or python -m pip install .
  • while iterating changes, you will want to delete the temporary build and src/ots/build folders.

Testing

There is a test suite defined for exercising the Python extension. It makes use (and assumes the presence of) the downloaded OTS library source's test font data in src/ots so ensure you have run python setup.py download and have the ots folder under src. Invoke the tests with python -m pytest.

If you wish to run tests comparing results from ots-python against pyots, be sure to python -m pip install opentype-sanitizer first, otherwise that set of tests will be skipped.

Use

Simplest case:

import pyots
result = pyots.sanitize('/path/to/font/file.ttf')

result is an OTSResult object with 3 attributes:

  • sanitized Boolean indicating whether the file was successfully sanitized
  • modified Boolean indicating whether the file was modified* during sanitization
  • messages Tuple of message strings generated during sanitization (may be empty)
  • Note: currently the back-end OTS code can modify fonts that are successfully sanitized, even when no changes are performed. Thus modified can sometimes be True when sanitized is True. Usually the modification is only to the modification date and related checksums. Thus, it might be possible to devise a better detection of modification, i.e. ignoring head.modified and other inconsequential modifications, but that was out-of-scope for this work.

Example: sanitizing a folder of font files

# sanitize a folder of fonts. Print messages for any that were not successfully sanitized.
import pyots
from pathlib import Path

for filename in Path("src/ots/tests/fonts/good").rglob("*"):
    result = pyots.sanitize(filename.absolute())
    if not result.sanitized:
        print(f'{filename}:\n{", ".join([m for m in result.messages])}')

Options for sanitize()

  • Specify keyword output=<path_to_output_file> to the sanitize() command and the sanitized file will be saved to that location
  • Use quiet=True for sanitize() to suppress messages
  • Specify font_index=<index_in_TTC> when sanitizing a Collection (OTC/TTC) file and you want to sanitize only a particular index within the Collection (otherwise all will be sanitized per OTS's default behavior)

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

pyots-9.2.0.post2.tar.gz (19.5 kB view details)

Uploaded Source

Built Distributions

pyots-9.2.0.post2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (747.2 kB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

pyots-9.2.0.post2-cp312-cp312-macosx_11_0_arm64.whl (393.5 kB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

pyots-9.2.0.post2-cp312-cp312-macosx_10_13_x86_64.whl (409.5 kB view details)

Uploaded CPython 3.12 macOS 10.13+ x86-64

pyots-9.2.0.post2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (746.9 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

pyots-9.2.0.post2-cp311-cp311-macosx_11_0_arm64.whl (393.4 kB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

pyots-9.2.0.post2-cp311-cp311-macosx_10_9_x86_64.whl (409.5 kB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

pyots-9.2.0.post2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (746.9 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

pyots-9.2.0.post2-cp310-cp310-macosx_11_0_arm64.whl (393.5 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

pyots-9.2.0.post2-cp310-cp310-macosx_10_9_x86_64.whl (409.5 kB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

pyots-9.2.0.post2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (746.7 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

pyots-9.2.0.post2-cp39-cp39-macosx_11_0_arm64.whl (393.4 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

pyots-9.2.0.post2-cp39-cp39-macosx_10_9_x86_64.whl (409.4 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

File details

Details for the file pyots-9.2.0.post2.tar.gz.

File metadata

  • Download URL: pyots-9.2.0.post2.tar.gz
  • Upload date:
  • Size: 19.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for pyots-9.2.0.post2.tar.gz
Algorithm Hash digest
SHA256 386b9f47af20d5eab5f53dc77ff6a192d52e75e9c3c1748cb69c4e6632b5e549
MD5 f938b462a211ffa29d13fdd2008ecfa6
BLAKE2b-256 830d6c59cf7a189a609165d1774ef9cc0e821b4acf26200323d89bcf5c42a863

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyots-9.2.0.post2.tar.gz:

Publisher: release.yml on adobe-type-tools/pyots

Attestations:

File details

Details for the file pyots-9.2.0.post2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyots-9.2.0.post2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 45f01106d5e6cce983cfed8905f4f72198ef5ad7c283920279e8c8081e9e8271
MD5 be002b195de7698063867d77d8245fd5
BLAKE2b-256 2840c966136eb49c0b3d1199806b101bb3ba3ace935a4c46656fa4f0d8033dca

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyots-9.2.0.post2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on adobe-type-tools/pyots

Attestations:

File details

Details for the file pyots-9.2.0.post2-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyots-9.2.0.post2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d0a22b1ad584d4c8ca27f3e0e15d9a2f839e1cb47e64fec0f8693c37239aa936
MD5 b094c402b177c401d643f7b5c1c15bca
BLAKE2b-256 b2f6a8a8dcba769349d55d6bf3a17cfbb1ebbc3767f4025cacd1e54fb4205dfb

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyots-9.2.0.post2-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: release.yml on adobe-type-tools/pyots

Attestations:

File details

Details for the file pyots-9.2.0.post2-cp312-cp312-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for pyots-9.2.0.post2-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 15accd390f9f8a1aafc9a871dc5c4566cdf4684957711c48590e1de1c4e8c0a7
MD5 c534a0010f682057eb725bbe8833b998
BLAKE2b-256 d6b21b089d6ef7e026570859de6e50128d423b7d4afc31e98f3e4276cea97456

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyots-9.2.0.post2-cp312-cp312-macosx_10_13_x86_64.whl:

Publisher: release.yml on adobe-type-tools/pyots

Attestations:

File details

Details for the file pyots-9.2.0.post2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyots-9.2.0.post2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f0410620c502fe6cbadb09fcf01c9e6728d57c782a5f97fe5b71b2a98eadad67
MD5 905eb5899f5949496d98033e50bfb1bd
BLAKE2b-256 f73ece97a38df357be3985c44bbcc8d5c1a4f3f159c092536760ec08ca409617

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyots-9.2.0.post2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on adobe-type-tools/pyots

Attestations:

File details

Details for the file pyots-9.2.0.post2-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyots-9.2.0.post2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8f25bb7ad3864c7c7c1599a1febd6d824befed40a17e13ce1633128465f51bfa
MD5 3091fcfe19a6a7f0ef691f63c8d8a9b2
BLAKE2b-256 8d6b0b831186a2b9cd6372e80005849b70ae5c59bc08bfe870cd9bb319ee627d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyots-9.2.0.post2-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: release.yml on adobe-type-tools/pyots

Attestations:

File details

Details for the file pyots-9.2.0.post2-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pyots-9.2.0.post2-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 5d7c58ee94029ff97e145dc1660e52c77268b3c8da7d5a9fefcf00125e2ae0fd
MD5 9c3a3d75784fbf2a66a9f539b13c2acb
BLAKE2b-256 990e577492619073f7b9ccaba8b73e4f196069ef5a8fc6d47f3aa4202028ee51

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyots-9.2.0.post2-cp311-cp311-macosx_10_9_x86_64.whl:

Publisher: release.yml on adobe-type-tools/pyots

Attestations:

File details

Details for the file pyots-9.2.0.post2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyots-9.2.0.post2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0d50d85816048aafe4389b8f85bb97f1da8282919c3e54df837614789d0451aa
MD5 21f3cd16525dd08df4f086f9d057b458
BLAKE2b-256 69123d22b7c63d967364dde2d39d94855a660418b75928d64196a40c7efc8990

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyots-9.2.0.post2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on adobe-type-tools/pyots

Attestations:

File details

Details for the file pyots-9.2.0.post2-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyots-9.2.0.post2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5b28311b9b327ed9be91e41153ab3e53a321f8f37b5087ce2bc4b962ab1156e6
MD5 5787caf61b0248568505cda12c526047
BLAKE2b-256 beccb3ced931dd69163f0b6d5869e2cd37cb887d2a2f5c9bd2e7d4c62734da5f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyots-9.2.0.post2-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: release.yml on adobe-type-tools/pyots

Attestations:

File details

Details for the file pyots-9.2.0.post2-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pyots-9.2.0.post2-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 42b462abfc548176f2be75130707368a93db534a04186d1221be21a217bca76c
MD5 1e70e3820187997e7f61029e1a8c07cf
BLAKE2b-256 06173ef231667cb23b0ac6c44b1f32e808240fdbc6d5a6cace3514e9ddd63a5b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyots-9.2.0.post2-cp310-cp310-macosx_10_9_x86_64.whl:

Publisher: release.yml on adobe-type-tools/pyots

Attestations:

File details

Details for the file pyots-9.2.0.post2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyots-9.2.0.post2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fec4deec42fbe638b119eeaba4c53c1bd158917de602c7c6f4c27d2c11c2fc07
MD5 49c2cf410ca803cff871611ac7925f56
BLAKE2b-256 660f98ba7dd06a60a9b59d3b3af84e39e8886353f20ca427f91d9f0757b8e396

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyots-9.2.0.post2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on adobe-type-tools/pyots

Attestations:

File details

Details for the file pyots-9.2.0.post2-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyots-9.2.0.post2-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 aa24b8fa591db919ffa9b7c3bf446e0ecced759f810955f23de48fc3d7a64cab
MD5 f09f46c9b0992ba4e12fdc9dc2a9a911
BLAKE2b-256 9c1f77022dd2e03aa674d76315f31e2cc196ad262872c545da44d4e8130cb6dc

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyots-9.2.0.post2-cp39-cp39-macosx_11_0_arm64.whl:

Publisher: release.yml on adobe-type-tools/pyots

Attestations:

File details

Details for the file pyots-9.2.0.post2-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pyots-9.2.0.post2-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 559bf7a4e87b9a11b60faca8e526b6ffe6bc61d4d18cb16048550fe368bef8d6
MD5 1a43c1ecd097a77a5a024b4ced1a7f02
BLAKE2b-256 605837325cb888093fd0520be383f58a6a87ee6d6f5e37cb895c80f0b896bf37

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyots-9.2.0.post2-cp39-cp39-macosx_10_9_x86_64.whl:

Publisher: release.yml on adobe-type-tools/pyots

Attestations:

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