ufo-gleaner


Nameufo-gleaner JSON
Version 0.2.2 PyPI version JSON
download
home_pageNone
SummaryHigh-performance UFO/GLIF parser for Python written in Rust
upload_time2025-09-03 10:35:56
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseLICENSE
keywords font design ufo
VCS
bugtrack_url
requirements fontParts tqdm
Travis-CI No Travis.
coveralls test coverage
            # ufo-gleaner

[![PyPI - Version](https://img.shields.io/pypi/v/ufo-gleaner?logo=pypi&logoColor=white&style=for-the-badge)](https://pypi.org/project/ufo-gleaner/)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/ufo-gleaner?logo=python&logoColor=white&style=for-the-badge)](https://www.python.org)



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

## Usage

### Install

Install with pip:

```bash
python -m pip install ufo-gleaner
```

### Eager Gleaner

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

```python
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:

```python
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:

```python
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()
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "ufo-gleaner",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "font design, UFO",
    "author": null,
    "author_email": "Knut Nergaard <knut.nergaard@gmail.com>",
    "download_url": null,
    "platform": null,
    "description": "# ufo-gleaner\n\n[![PyPI - Version](https://img.shields.io/pypi/v/ufo-gleaner?logo=pypi&logoColor=white&style=for-the-badge)](https://pypi.org/project/ufo-gleaner/)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/ufo-gleaner?logo=python&logoColor=white&style=for-the-badge)](https://www.python.org)\n\n\n\nHigh-performance UFO/GLIF parser for Python written in Rust\n\n## Usage\n\n### Install\n\nInstall with pip:\n\n```bash\npython -m pip install ufo-gleaner\n```\n\n### Eager Gleaner\n\nParse all `.glif` files in one go as a dictionary mapping glyph names to their attributes:\n\n```python\nfrom ufo_gleaner import Gleaner, FileProvider\n\nprovider = FileProvider(\"/path/to/myfont.ufo\")\ngleaner = Gleaner(provider)\n\nglyphs = gleaner.glean()\nprint(glyphs[\"A\"][\"advance\"][\"width\"])\n```\n\n### Lazy Font Object Model\n\nTo minimize load time and memory footprint, `ufo-gleaner` provides a dictionary-like font\nobject with lazy parsing and on-demand access to GLIF files and their attributes:\n\n```python\nfrom ufo_gleaner import Font, FileProvider\n\nprovider = FileProvider(\"/path/to/myfont.ufo\")\nfont = Font(provider)\n\n# Access a single glyph by name\nglyph = font[\"A\"]\n\n# Access glyph attributes lazily\nanchors = glyph.anchors\n```\n\n### Custom Providers\n\n`Gleaner` can be used with any Python object that implements a `read(path: str) -> bytes` method,\nwhere `path` is relative to the UFO root. This lets you read from both `.ufo` directories and `.ufoz` \nZIP archives, for example:\n\n```python\nimport zipfile\nfrom ufo_gleaner import Gleaner\n\nclass UfozProvider:\n    def __init__(self, root):\n        self.zipfile = zipfile.ZipFile(root, \"r\")\n    \n    def read(self, path: str) -> bytes:\n        return self.zipfile.read(path)\n\nprovider = UfozProvider(\"/path/to/myfont.ufoz\")\ngleaner = Gleaner(provider)\n\nglyphs = gleaner.glean()\n```\n",
    "bugtrack_url": null,
    "license": "LICENSE",
    "summary": "High-performance UFO/GLIF parser for Python written in Rust",
    "version": "0.2.2",
    "project_urls": {
        "Homepage": "https://github.com/knutnergaard/SMufoLib"
    },
    "split_keywords": [
        "font design",
        " ufo"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "cb9afb2af08906fc33bcf7eec8dc6e700cc0049c3545780707cb547eab4b1485",
                "md5": "3c1f285f1da5a3ada1ce6c92f7bb09b1",
                "sha256": "831a0aa38130835cfabca567e32d968b752b528f820788ea9dd4ef2216d3e0d5"
            },
            "downloads": -1,
            "filename": "ufo_gleaner-0.2.2-cp310-abi3-macosx_11_0_arm64.whl",
            "has_sig": false,
            "md5_digest": "3c1f285f1da5a3ada1ce6c92f7bb09b1",
            "packagetype": "bdist_wheel",
            "python_version": "cp310",
            "requires_python": ">=3.10",
            "size": 365888,
            "upload_time": "2025-09-03T10:35:56",
            "upload_time_iso_8601": "2025-09-03T10:35:56.653825Z",
            "url": "https://files.pythonhosted.org/packages/cb/9a/fb2af08906fc33bcf7eec8dc6e700cc0049c3545780707cb547eab4b1485/ufo_gleaner-0.2.2-cp310-abi3-macosx_11_0_arm64.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-09-03 10:35:56",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "knutnergaard",
    "github_project": "SMufoLib",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "requirements": [
        {
            "name": "fontParts",
            "specs": [
                [
                    "==",
                    "0.12.5"
                ]
            ]
        },
        {
            "name": "tqdm",
            "specs": [
                [
                    "==",
                    "4.67.1"
                ]
            ]
        }
    ],
    "lcname": "ufo-gleaner"
}
        
Elapsed time: 1.22980s