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()
Metadata
Release files for ufo-gleaner 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ufo_gleaner-0.2.2-cp310-abi3-macosx_11_0_arm64.whl | CPython 3.10 | abi3 | macOS 11.0+ ARM64 | Details |
Release files / ufo_gleaner-0.2.2-cp310-abi3-macosx_11_0_arm64.whl
| Download URL | ufo_gleaner-0.2.2-cp310-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 365.9 kB |
| Tags | CPython 3.10 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
831a0aa38130835cfabca567e32d968b752b528f820788ea9dd4ef2216d3e0d5
|
|
BLAKE2b-256 checksum How to use checksums |
cb9afb2af08906fc33bcf7eec8dc6e700cc0049c3545780707cb547eab4b1485
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.9.3
|