High-performance UFO/GLIF parser for Python written in Rust
Project description
ufo-gleaner
High-performance UFO/GLIF parser for Python written in Rust
Usage
Install
Install with pip:
python -m pip install ufo-gleaner
Eager Gleaner
Parse all .glif files in one go as a dictionary mapping glyph names to their attributes:
from ufo_gleaner import Gleaner, FileProvider
provider = FileProvider("/path/to/myfont.ufo")
gleaner = Gleaner(provider)
glyphs = gleaner.glean()
print(glyphs["A"]["advance"]["width"])
Lazy Font Object Model
To minimize load time and memory footprint, ufo-gleaner provides a dictionary-like font
object with lazy parsing and on-demand access to GLIF files and their attributes:
from ufo_gleaner import Font, FileProvider
provider = FileProvider("/path/to/myfont.ufo")
font = Font(provider)
# Access a single glyph by name
glyph = font["A"]
# Access glyph attributes lazily
anchors = glyph.anchors
Custom Providers
Gleaner can be used with any Python object that implements a read(path: str) -> bytes method,
where path is relative to the UFO root. This lets you read from both .ufo directories and .ufoz
ZIP archives, for example:
import zipfile
from ufo_gleaner import Gleaner
class UfozProvider:
def __init__(self, root):
self.zipfile = zipfile.ZipFile(root, "r")
def read(self, path: str) -> bytes:
return self.zipfile.read(path)
provider = UfozProvider("/path/to/myfont.ufoz")
gleaner = Gleaner(provider)
glyphs = gleaner.glean()
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 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 ufo_gleaner-0.2.0-cp310-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: ufo_gleaner-0.2.0-cp310-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 364.8 kB
- Tags: CPython 3.10+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ddb7c3a4c48f3f63fdf745984cc18467411ed22e17a39db599a8cf8c17530d83
|
|
| MD5 |
cff1ffc74a1ac5e1500a1ee44b61a606
|
|
| BLAKE2b-256 |
898e81c0fb1c56646ac5aea1ba37c1d12c2f74adc9bc620d220e4635c5117b4c
|