Python extension for Windows DirectWrite shaping, modeled after uharfbuzz
Project description
Project
DWriteShapePy is a Python extension built using Cython. It provides streamlined bindings for the DirectWrite shaping engine. The model is similar to the model provided by uHarfBuzz but some differences because of differences in the API models between DirectWrite and HarfBuzz.
DWriteShapePy was initially developed to support a Python based font testing environment where similar tests are executed using both DirectWrite and HarfBuzz.
Example
import sys
import dwriteshapepy as dw
from pathlib import Path
with open(sys.argv[1], 'rb') as fontfile:
fontdata = fontfile.read()
text = sys.argv[2]
face = dw.Face(fontdata)
font = dw.Font(face)
upm = font.upem
print(upm)
buf = dw.Buffer()
buf.add_str(text)
features = {"kern": True, "liga": True}
dw.shape(font, buf, features)
glyph_names = [font.glyph_to_string(g.codepoint) for g in buf.glyph_infos]
infos = [(g.codepoint, g.cluster) for g in buf.glyph_infos]
print(glyph_names)
print(infos)
advance = [(adv.x_advance, adv.y_advance, adv.x_offset, adv.y_offset) for adv in buf.glyph_positions]
print(advance)
infos = buf.glyph_infos
positions = buf.glyph_positions
for info, pos in zip(infos, positions):
gid = info.codepoint
cluster = info.cluster
x_advance = pos.x_advance
x_offset = pos.x_offset
y_offset = pos.y_offset
print(f"gid{gid}={cluster}@{x_advance},{x_offset}+{y_offset}")
Trademarks
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dwriteshapepy-1.0.12.tar.gz.
File metadata
- Download URL: dwriteshapepy-1.0.12.tar.gz
- Upload date:
- Size: 115.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
05b44b1caa0d519e2bbb858a306fd9a8d0b65c5a1fd2af3d6ec6818cb743ba25
|
|
| MD5 |
25ff6bdbd216d722fe0b81358734abd8
|
|
| BLAKE2b-256 |
fad65858f57a1a9756262ddc37b9d99643a15048973fdd00cc26a7ecb94f6f31
|
Provenance
The following attestation bundles were made for dwriteshapepy-1.0.12.tar.gz:
Publisher:
pypi_publish.yml on microsoft/DWriteShapePy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dwriteshapepy-1.0.12.tar.gz -
Subject digest:
05b44b1caa0d519e2bbb858a306fd9a8d0b65c5a1fd2af3d6ec6818cb743ba25 - Sigstore transparency entry: 163018190
- Sigstore integration time:
-
Permalink:
microsoft/DWriteShapePy@19011e72d857cc32d4a7ed266effbb1a7870c20e -
Branch / Tag:
refs/tags/v1.0.12 - Owner: https://github.com/microsoft
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi_publish.yml@19011e72d857cc32d4a7ed266effbb1a7870c20e -
Trigger Event:
push
-
Statement type:
File details
Details for the file dwriteshapepy-1.0.12-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: dwriteshapepy-1.0.12-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 103.7 kB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5df7aebe98c6d777e65acbc44a3adfafda5ca8cf487322f21dfab1201b83a459
|
|
| MD5 |
ac5dbc6acb36278215927c7fc66fb579
|
|
| BLAKE2b-256 |
e17ca5e417c4a8af467f03910a0b2106e0dd2637c47bdb079670d30b0ae84734
|
Provenance
The following attestation bundles were made for dwriteshapepy-1.0.12-cp313-cp313-win_amd64.whl:
Publisher:
pypi_publish.yml on microsoft/DWriteShapePy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dwriteshapepy-1.0.12-cp313-cp313-win_amd64.whl -
Subject digest:
5df7aebe98c6d777e65acbc44a3adfafda5ca8cf487322f21dfab1201b83a459 - Sigstore transparency entry: 163018191
- Sigstore integration time:
-
Permalink:
microsoft/DWriteShapePy@19011e72d857cc32d4a7ed266effbb1a7870c20e -
Branch / Tag:
refs/tags/v1.0.12 - Owner: https://github.com/microsoft
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi_publish.yml@19011e72d857cc32d4a7ed266effbb1a7870c20e -
Trigger Event:
push
-
Statement type:
File details
Details for the file dwriteshapepy-1.0.12-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: dwriteshapepy-1.0.12-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 104.0 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03f6eea96bdbfea14dcf53759076edf3323e25841bf552a5b8b158eebef71418
|
|
| MD5 |
bb9ab2ca64e54e2c98840852a9bf1d39
|
|
| BLAKE2b-256 |
b266d4dede609a7a53b238a88ad73cbce323c250d5c89895f00e12f0d1be72a4
|
Provenance
The following attestation bundles were made for dwriteshapepy-1.0.12-cp312-cp312-win_amd64.whl:
Publisher:
pypi_publish.yml on microsoft/DWriteShapePy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dwriteshapepy-1.0.12-cp312-cp312-win_amd64.whl -
Subject digest:
03f6eea96bdbfea14dcf53759076edf3323e25841bf552a5b8b158eebef71418 - Sigstore transparency entry: 163018194
- Sigstore integration time:
-
Permalink:
microsoft/DWriteShapePy@19011e72d857cc32d4a7ed266effbb1a7870c20e -
Branch / Tag:
refs/tags/v1.0.12 - Owner: https://github.com/microsoft
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi_publish.yml@19011e72d857cc32d4a7ed266effbb1a7870c20e -
Trigger Event:
push
-
Statement type:
File details
Details for the file dwriteshapepy-1.0.12-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: dwriteshapepy-1.0.12-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 103.5 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e88c266d4401e22ca1febac9c8ff8a2d1613dd9b220e74c3582f0a36949fbb73
|
|
| MD5 |
4e6c1e83f68cf0cb9c1714450324395d
|
|
| BLAKE2b-256 |
35f8922ccdff382c4132835488d38c387960be021700d6dc8daa01578204a55c
|
Provenance
The following attestation bundles were made for dwriteshapepy-1.0.12-cp311-cp311-win_amd64.whl:
Publisher:
pypi_publish.yml on microsoft/DWriteShapePy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dwriteshapepy-1.0.12-cp311-cp311-win_amd64.whl -
Subject digest:
e88c266d4401e22ca1febac9c8ff8a2d1613dd9b220e74c3582f0a36949fbb73 - Sigstore transparency entry: 163018192
- Sigstore integration time:
-
Permalink:
microsoft/DWriteShapePy@19011e72d857cc32d4a7ed266effbb1a7870c20e -
Branch / Tag:
refs/tags/v1.0.12 - Owner: https://github.com/microsoft
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi_publish.yml@19011e72d857cc32d4a7ed266effbb1a7870c20e -
Trigger Event:
push
-
Statement type:
File details
Details for the file dwriteshapepy-1.0.12-cp310-cp310-win_amd64.whl.
File metadata
- Download URL: dwriteshapepy-1.0.12-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 103.5 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4880c85a807209744fa2c73306e7d8092b5eec499732ffe507b35f04b7d06b7b
|
|
| MD5 |
19a9d9b036a922968762f9311a5b0fc9
|
|
| BLAKE2b-256 |
3cb38ae56bacb421efcfef3910406c72ae25342661006383e89ddd17e889d3c9
|
Provenance
The following attestation bundles were made for dwriteshapepy-1.0.12-cp310-cp310-win_amd64.whl:
Publisher:
pypi_publish.yml on microsoft/DWriteShapePy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dwriteshapepy-1.0.12-cp310-cp310-win_amd64.whl -
Subject digest:
4880c85a807209744fa2c73306e7d8092b5eec499732ffe507b35f04b7d06b7b - Sigstore transparency entry: 163018197
- Sigstore integration time:
-
Permalink:
microsoft/DWriteShapePy@19011e72d857cc32d4a7ed266effbb1a7870c20e -
Branch / Tag:
refs/tags/v1.0.12 - Owner: https://github.com/microsoft
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi_publish.yml@19011e72d857cc32d4a7ed266effbb1a7870c20e -
Trigger Event:
push
-
Statement type:
File details
Details for the file dwriteshapepy-1.0.12-cp39-cp39-win_amd64.whl.
File metadata
- Download URL: dwriteshapepy-1.0.12-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 104.0 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
196e19bc68e179c58239b4085d0f18f19491c3c1b2e07c8defae4dc70bd48c31
|
|
| MD5 |
9b223152d84e68d8bfd39ca3f6c7c949
|
|
| BLAKE2b-256 |
777cba94b7d4186cfda169de410c4067b9566e0476cb7bb3597372d30efa8d82
|
Provenance
The following attestation bundles were made for dwriteshapepy-1.0.12-cp39-cp39-win_amd64.whl:
Publisher:
pypi_publish.yml on microsoft/DWriteShapePy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dwriteshapepy-1.0.12-cp39-cp39-win_amd64.whl -
Subject digest:
196e19bc68e179c58239b4085d0f18f19491c3c1b2e07c8defae4dc70bd48c31 - Sigstore transparency entry: 163018196
- Sigstore integration time:
-
Permalink:
microsoft/DWriteShapePy@19011e72d857cc32d4a7ed266effbb1a7870c20e -
Branch / Tag:
refs/tags/v1.0.12 - Owner: https://github.com/microsoft
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi_publish.yml@19011e72d857cc32d4a7ed266effbb1a7870c20e -
Trigger Event:
push
-
Statement type: