pydwshape
Windows-only. A DWriteCore-native per-lookup OpenType shaping tracer for BabelMap's OpenType test framework — the DirectWrite analogue of its HarfBuzz/HarfRust engines.
It shapes entirely with Microsoft DWriteCore (app-local, version-pinned)
and returns the babelsoft /api/opentype/shape result dict, including the
per-lookup glyph-mutation trace. No system dwrite.dll / TextShaping.dll is
loaded (no DLL-hijack surface), and no subprocess is spawned — the Rust engine
runs in-process via this PyO3 abi3 extension.
Requires
- Windows 10 1809+ (x64)
- CPython 3.9+ (any 3.9+ interpreter; wheel tag
cp39-abi3-win_amd64)
Importing on any other OS raises OSError.
Install
pip install pydwshape
Usage
from pydwshape import shape_with_dwrite
font = open("font.otf", "rb").read()
res = shape_with_dwrite(font, "ᠰᠠᠢᠬᠠᠨ") # script omitted -> auto-detected
res = shape_with_dwrite(font, "ᠰᠠᠢᠬᠠᠨ", script="mong") # explicit
# res = {upem, glyph_count, stages:[{m,glyphs,depth,effective}], final, messages, engine}
script may be omitted (auto/empty behave the same): the script number is
auto-detected from the text using DWriteCore's own Unicode script data
(Common/Inherited/combining marks inherit from context).
features is a {tag: bool} map (same convention as the HarfBuzz/harfrust
engines): optional features toggle ({"smcp": True}, {"liga": False} …);
script-required features (Mongolian/Arabic init/medi/fina/rclt …) are fixed
by DWriteCore and cannot be disabled.
Constraints
- Single-threaded by design: the per-lookup trace comes from a process-local hook that is installed per call and restored afterwards (the GIL serialises calls from Python, so repeated calls are safe).
- The hook is signature-locked to the bundled DWriteCore build (2.1.1.2605) with automatic relocation by prologue scan for newer builds.
Provenance / licensing
- Our Rust/Python code: MIT (see the source repository).
- Bundled
DWriteCore.dllis Microsoft software from the Windows App SDK (Microsoft.WindowsAppSDK.DWrite), redistributed under Microsoft's license terms for that component; the DLL is Microsoft-signed and unmodified.
Build (maintainers, Windows)
# stage the MS-signed DWriteCore.dll (from build/dwc_poc or the Windows App SDK NuGet)
Copy-Item build\dwc_poc\DWriteCore.dll python\pydwshape-wheel\python\pydwshape\DWriteCore.dll
cd python\pydwshape-wheel
python -m pip install maturin
python -m maturin build --release --interpreter <python> -o dist
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
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 pydwshape-0.2.0-cp39-abi3-win_amd64.whl.
File metadata
- Download URL: pydwshape-0.2.0-cp39-abi3-win_amd64.whl
- Upload date:
- Size: 1.6 MB
- Tags: CPython 3.9+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
382e6aefea0e3b43d023ae4649fbb9d3826871a3176a460c647bf31c38b6e9cd
|
|
| MD5 |
5104267ab315fa2419d5fed12b9f8712
|
|
| BLAKE2b-256 |
76a62c6f8aa6b09e68270379fb6438c39a4755c9eca27e1f31b60be21e5c0357
|
Provenance
The following attestation bundles were made for pydwshape-0.2.0-cp39-abi3-win_amd64.whl:
Publisher:
release.yml on Kushim-Jiang/pydwshape
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pydwshape-0.2.0-cp39-abi3-win_amd64.whl -
Subject digest:
382e6aefea0e3b43d023ae4649fbb9d3826871a3176a460c647bf31c38b6e9cd - Sigstore transparency entry: 2723546221
- Sigstore integration time:
-
Permalink:
Kushim-Jiang/pydwshape@a056aaaa43dd6cc0a565fecec9b8c843c8a5df87 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/Kushim-Jiang
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a056aaaa43dd6cc0a565fecec9b8c843c8a5df87 -
Trigger Event:
push
-
Statement type: