Skip to main content

High-performance UFO/GLIF parser for Python written in Rust

Project description

ufo-gleaner

PyPI - Version PyPI - Python Version

High-performance UFO/GLIF parser for Python written in Rust

Usage

Install

Install with pip:

python -m pip install ufo-gleaner

Quickstart

Parse all .glif files in one go as a dictionary mapping glyph names to their attributes:

from ufo_gleaner import UfoGleaner, FileProvider

provider = FileProvider("/path/to/myfont.ufo")
gleaner = UfoGleaner(provider)

glyphs = gleaner.glean()
print(glyphs["A"]["advance"]["width"])

Custom Providers

UfoGleaner 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 UfoGleaner

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 = UfoGleaner(provider)

glyphs = gleaner.glean()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ufo_gleaner-0.1.2-cp310-abi3-macosx_11_0_arm64.whl (328.3 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

File details

Details for the file ufo_gleaner-0.1.2-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ufo_gleaner-0.1.2-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3e08f4028c4882e3eaec5dbfefe6a1e2b4ac9b6a0949d5e8a0d364862ebdcf0c
MD5 f40033dceec16a928e14fd7cc05993d5
BLAKE2b-256 eaa54b91e836194021003f99295f91c735cc9e9b27bcff3e6be06490759960da

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page