Python wrapper for ot-sanitizer
Project description
pyots (PYthon OT Sanitizer)
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 theversion
value insetup.cfg
under[download]
to specify a different version of OTS. You'll also need to change thesha256
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 onots
... - to build and install
pyots
after downloading OTS, you can runpython setup.py install
orpython -m pip install .
- while iterating changes, you will want to delete the temporary
build
andsrc/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 sanitizedmodified
Boolean indicating whether the file was modified* during sanitizationmessages
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 whensanitized
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. ignoringhead.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 thesanitize()
command and the sanitized file will be saved to that location - Use
quiet=True
forsanitize()
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file pyots-9.2.0.post1.tar.gz
.
File metadata
- Download URL: pyots-9.2.0.post1.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 054abcccf24a56bffbe0a2b26b8556a4f1bdd771c555114436ebb5693207f7d4 |
|
MD5 | 808d4a2d83d02df306545f32f0842d7a |
|
BLAKE2b-256 | 0dfa47a7e237c4ff1ff8cebeb1bef3584461eab4302ea5ca4fac6dcad3ba5d9d |
Provenance
The following attestation bundles were made for pyots-9.2.0.post1.tar.gz
:
Publisher:
release.yml
on adobe-type-tools/pyots
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
pyots-9.2.0.post1.tar.gz
- Subject digest:
054abcccf24a56bffbe0a2b26b8556a4f1bdd771c555114436ebb5693207f7d4
- Sigstore transparency entry: 150590802
- Sigstore integration time:
- Predicate type:
File details
Details for the file pyots-9.2.0.post1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: pyots-9.2.0.post1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 747.2 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 745188b33f64141d6de4e1290dcae1f0ef2806d8d744fb9a54a28c89f3d5d66c |
|
MD5 | 1eabf5ea806990c26c23e1e04cfbc9e3 |
|
BLAKE2b-256 | 07bf756791c0559395a0e69745421ec0844a6d5f282bd7b27eaddb952824a084 |
Provenance
The following attestation bundles were made for pyots-9.2.0.post1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
:
Publisher:
release.yml
on adobe-type-tools/pyots
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
pyots-9.2.0.post1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
- Subject digest:
745188b33f64141d6de4e1290dcae1f0ef2806d8d744fb9a54a28c89f3d5d66c
- Sigstore transparency entry: 150590807
- Sigstore integration time:
- Predicate type:
File details
Details for the file pyots-9.2.0.post1-cp312-cp312-macosx_11_0_arm64.whl
.
File metadata
- Download URL: pyots-9.2.0.post1-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 393.5 kB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 360bb4d149d6de2a9c2a15fbfd6b954624c4f7139500bc83dea62c36b5fd017d |
|
MD5 | ae14cfd1fb26e5337ae0629e64c05e70 |
|
BLAKE2b-256 | 32c6127925c9b4ecc3ff8fbf55e91207c547e733b99840e786f3e0d6241876d2 |
Provenance
The following attestation bundles were made for pyots-9.2.0.post1-cp312-cp312-macosx_11_0_arm64.whl
:
Publisher:
release.yml
on adobe-type-tools/pyots
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
pyots-9.2.0.post1-cp312-cp312-macosx_11_0_arm64.whl
- Subject digest:
360bb4d149d6de2a9c2a15fbfd6b954624c4f7139500bc83dea62c36b5fd017d
- Sigstore transparency entry: 150590823
- Sigstore integration time:
- Predicate type:
File details
Details for the file pyots-9.2.0.post1-cp312-cp312-macosx_10_13_x86_64.whl
.
File metadata
- Download URL: pyots-9.2.0.post1-cp312-cp312-macosx_10_13_x86_64.whl
- Upload date:
- Size: 409.5 kB
- Tags: CPython 3.12, macOS 10.13+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 40e2502027a65dd30067d96832603bf62cbcc064fe193a46a0f34444517eaec5 |
|
MD5 | 50ae0ad861bd4aaf751da59cee545726 |
|
BLAKE2b-256 | f3c39a4dee362fb22d71ec4632cb46bef0f8f321c4ef1693acf6cebc59b075f7 |
Provenance
The following attestation bundles were made for pyots-9.2.0.post1-cp312-cp312-macosx_10_13_x86_64.whl
:
Publisher:
release.yml
on adobe-type-tools/pyots
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
pyots-9.2.0.post1-cp312-cp312-macosx_10_13_x86_64.whl
- Subject digest:
40e2502027a65dd30067d96832603bf62cbcc064fe193a46a0f34444517eaec5
- Sigstore transparency entry: 150590840
- Sigstore integration time:
- Predicate type:
File details
Details for the file pyots-9.2.0.post1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: pyots-9.2.0.post1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 746.9 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0631ae84b0c47174b1e192d4ec4c609348ee51fdf6420eb50b804566ab4b07c9 |
|
MD5 | 84dc60c782791ecf484d9bfabeae12c8 |
|
BLAKE2b-256 | 8cfc1ab7435b38c63e965e13255105abfb27c99dff8af767488b7b68cbf02044 |
Provenance
The following attestation bundles were made for pyots-9.2.0.post1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
:
Publisher:
release.yml
on adobe-type-tools/pyots
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
pyots-9.2.0.post1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
- Subject digest:
0631ae84b0c47174b1e192d4ec4c609348ee51fdf6420eb50b804566ab4b07c9
- Sigstore transparency entry: 150590815
- Sigstore integration time:
- Predicate type:
File details
Details for the file pyots-9.2.0.post1-cp311-cp311-macosx_11_0_arm64.whl
.
File metadata
- Download URL: pyots-9.2.0.post1-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 393.4 kB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0cc44b96a37a37d132577a01605b30bdada9fd10e99001373987f2ffec58b1ab |
|
MD5 | 4e04d5781c827022658bfc8cdfc845da |
|
BLAKE2b-256 | 6d4d641e3a9cb91bbd4674e49e55bf10363ff04430b2c7aabedc130c9003a94f |
Provenance
The following attestation bundles were made for pyots-9.2.0.post1-cp311-cp311-macosx_11_0_arm64.whl
:
Publisher:
release.yml
on adobe-type-tools/pyots
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
pyots-9.2.0.post1-cp311-cp311-macosx_11_0_arm64.whl
- Subject digest:
0cc44b96a37a37d132577a01605b30bdada9fd10e99001373987f2ffec58b1ab
- Sigstore transparency entry: 150590826
- Sigstore integration time:
- Predicate type:
File details
Details for the file pyots-9.2.0.post1-cp311-cp311-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: pyots-9.2.0.post1-cp311-cp311-macosx_10_9_x86_64.whl
- Upload date:
- Size: 409.5 kB
- Tags: CPython 3.11, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 29d0096ddd7fdc9a7f6cce8c384caffd08137cec9f70e2eac40b2381e131d15e |
|
MD5 | 3ec869d5d5754c704f1e45135025a42d |
|
BLAKE2b-256 | 5325c9b5d9cded57d6d32ae4dd6cbf4015bcf29a7b6ed150e3691fecc97318a3 |
Provenance
The following attestation bundles were made for pyots-9.2.0.post1-cp311-cp311-macosx_10_9_x86_64.whl
:
Publisher:
release.yml
on adobe-type-tools/pyots
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
pyots-9.2.0.post1-cp311-cp311-macosx_10_9_x86_64.whl
- Subject digest:
29d0096ddd7fdc9a7f6cce8c384caffd08137cec9f70e2eac40b2381e131d15e
- Sigstore transparency entry: 150590837
- Sigstore integration time:
- Predicate type:
File details
Details for the file pyots-9.2.0.post1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: pyots-9.2.0.post1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 746.9 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4373a8778945504e43dec63c747bfcd2b66737d9521ed65ffa392112b0b0c2a8 |
|
MD5 | 6908dbf400c728ff92ac314418de045f |
|
BLAKE2b-256 | 31e3b698b7348c2cf2a40ba7a82e08735aaa63dc8cdad304d96477c3640b6fd2 |
Provenance
The following attestation bundles were made for pyots-9.2.0.post1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
:
Publisher:
release.yml
on adobe-type-tools/pyots
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
pyots-9.2.0.post1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
- Subject digest:
4373a8778945504e43dec63c747bfcd2b66737d9521ed65ffa392112b0b0c2a8
- Sigstore transparency entry: 150590805
- Sigstore integration time:
- Predicate type:
File details
Details for the file pyots-9.2.0.post1-cp310-cp310-macosx_11_0_arm64.whl
.
File metadata
- Download URL: pyots-9.2.0.post1-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 393.5 kB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2327938fbc81eb39a25b63b48e7b6255dbe5fbffd7fb033a38c86261d5d39caf |
|
MD5 | f0197d8669f50650d84f0799b4dae81f |
|
BLAKE2b-256 | 9b546bb3ea4fb559bc50eccc51dcd593e2dc3368a7ed0529940246ab0c492db4 |
Provenance
The following attestation bundles were made for pyots-9.2.0.post1-cp310-cp310-macosx_11_0_arm64.whl
:
Publisher:
release.yml
on adobe-type-tools/pyots
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
pyots-9.2.0.post1-cp310-cp310-macosx_11_0_arm64.whl
- Subject digest:
2327938fbc81eb39a25b63b48e7b6255dbe5fbffd7fb033a38c86261d5d39caf
- Sigstore transparency entry: 150590835
- Sigstore integration time:
- Predicate type:
File details
Details for the file pyots-9.2.0.post1-cp310-cp310-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: pyots-9.2.0.post1-cp310-cp310-macosx_10_9_x86_64.whl
- Upload date:
- Size: 409.5 kB
- Tags: CPython 3.10, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4295ecffdfe372d710e070ceecb49b200a13641e3d54e553481aaad735e2bd70 |
|
MD5 | 8953621283cb77819fb43fc5c3e35887 |
|
BLAKE2b-256 | 4bfe1722b1fe49b410e29db35b438920ed3fd2ca02e6f10167d321ac873d7fd5 |
Provenance
The following attestation bundles were made for pyots-9.2.0.post1-cp310-cp310-macosx_10_9_x86_64.whl
:
Publisher:
release.yml
on adobe-type-tools/pyots
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
pyots-9.2.0.post1-cp310-cp310-macosx_10_9_x86_64.whl
- Subject digest:
4295ecffdfe372d710e070ceecb49b200a13641e3d54e553481aaad735e2bd70
- Sigstore transparency entry: 150590836
- Sigstore integration time:
- Predicate type:
File details
Details for the file pyots-9.2.0.post1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: pyots-9.2.0.post1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 746.7 kB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 69b6d36909c1029c3611646395638581f8cf17bc170ab52b2e82416c74f33481 |
|
MD5 | c7210ee7f06622f4421a2ce685b21ea0 |
|
BLAKE2b-256 | 6b7cafc5603d31d4ef09a539669ac7606c5e19e896eb8011d946e3c82bc95833 |
Provenance
The following attestation bundles were made for pyots-9.2.0.post1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
:
Publisher:
release.yml
on adobe-type-tools/pyots
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
pyots-9.2.0.post1-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
- Subject digest:
69b6d36909c1029c3611646395638581f8cf17bc170ab52b2e82416c74f33481
- Sigstore transparency entry: 150590810
- Sigstore integration time:
- Predicate type:
File details
Details for the file pyots-9.2.0.post1-cp39-cp39-macosx_11_0_arm64.whl
.
File metadata
- Download URL: pyots-9.2.0.post1-cp39-cp39-macosx_11_0_arm64.whl
- Upload date:
- Size: 393.4 kB
- Tags: CPython 3.9, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 707211c75f602d637cc917d5dead9c3d4526d2ce48ea7c8553142deb71decb78 |
|
MD5 | e2dceb83e0e5cbdc60102455cba8d308 |
|
BLAKE2b-256 | 6beb5dd063820380da964436ce20d360841d7305ffbf452ce56f62bfb8f27596 |
Provenance
The following attestation bundles were made for pyots-9.2.0.post1-cp39-cp39-macosx_11_0_arm64.whl
:
Publisher:
release.yml
on adobe-type-tools/pyots
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
pyots-9.2.0.post1-cp39-cp39-macosx_11_0_arm64.whl
- Subject digest:
707211c75f602d637cc917d5dead9c3d4526d2ce48ea7c8553142deb71decb78
- Sigstore transparency entry: 150590829
- Sigstore integration time:
- Predicate type:
File details
Details for the file pyots-9.2.0.post1-cp39-cp39-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: pyots-9.2.0.post1-cp39-cp39-macosx_10_9_x86_64.whl
- Upload date:
- Size: 409.4 kB
- Tags: CPython 3.9, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cbdd3450807020030df60b4ea5afad081de688f94d78fcc2fa6cc7d1e56ce72d |
|
MD5 | a67380d6463a2037f6b265f6e1392372 |
|
BLAKE2b-256 | 8ec3f9a6d38979bd720492bc4f730ae769ac958ba89daceaf344b1673106a8a5 |
Provenance
The following attestation bundles were made for pyots-9.2.0.post1-cp39-cp39-macosx_10_9_x86_64.whl
:
Publisher:
release.yml
on adobe-type-tools/pyots
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
pyots-9.2.0.post1-cp39-cp39-macosx_10_9_x86_64.whl
- Subject digest:
cbdd3450807020030df60b4ea5afad081de688f94d78fcc2fa6cc7d1e56ce72d
- Sigstore transparency entry: 150590832
- Sigstore integration time:
- Predicate type: