# hasanzakeri/harfrust-python architecture

> Architecture diagram of the GitHub repository hasanzakeri/harfrust-python, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hasanzakeri/harfrust-python
- Repository: https://github.com/hasanzakeri/harfrust-python

## Overview

harfrust-python exposes HarfRust text shaping to Python through a PyO3 extension, with both a one-shot CLI-compatible API and a configurable object API. The object workflow configures Unicode text and segment properties, loads/configures a font and shaping options, shapes the buffer, then provides positioned glyph data and serialization. Configuration types support script, direction, language, features, and variable-font variations. Edges reflect explicit calls in the sampled Rust source; the HarfRust engine and CLI helper are dependency APIs rather than repository modules.

Main entry points: [`src/font.rs`](https://github.com/hasanzakeri/harfrust-python/blob/main/src/font.rs) (Font and shaper), [`src/lib.rs`](https://github.com/hasanzakeri/harfrust-python/blob/main/src/lib.rs) (PyO3 extension), [`src/buffer.rs`](https://github.com/hasanzakeri/harfrust-python/blob/main/src/buffer.rs) (Text buffer), [`src/shape.rs`](https://github.com/hasanzakeri/harfrust-python/blob/main/src/shape.rs) (One-shot CLI API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Python API"]
  node_package["Public package<br/>[__init__.py]"]
  node_extension["PyO3 extension<br/>[lib.rs]"]
end

subgraph group_shaping["Shaping Workflow"]
  node_one_shot["One-shot CLI API<br/>[shape.rs]"]
  node_buffer["Text buffer<br/>[buffer.rs]"]
  node_font["Font and shaper<br/>[font.rs]"]
  node_glyphs["Glyph results<br/>[glyph.rs]"]
end

subgraph group_config["Configuration"]
  node_types["Configuration types<br/>[types.rs]"]
end

node_caller(("Python caller"))
node_harfrust["HarfRust engine"]
node_font_file["Font file"]

node_caller -->|"imports"| node_package
node_package -->|"re-exports"| node_extension
node_extension -->|"registers"| node_one_shot
node_extension -->|"registers"| node_buffer
node_extension -->|"registers"| node_font
node_extension -->|"registers"| node_glyphs
node_extension -->|"registers"| node_types
node_caller -->|"calls"| node_one_shot
node_caller -->|"builds text"| node_buffer
node_caller -->|"configures font"| node_font
node_buffer -->|"uses properties"| node_types
node_font -->|"consumes buffer"| node_buffer
node_font -->|"parses options"| node_types
node_font -->|"wraps output"| node_glyphs
node_font -->|"reads"| node_font_file
node_font -->|"shapes with"| node_harfrust
node_glyphs -->|"serializes with"| node_font
node_one_shot -->|"delegates shaping"| node_harfrust

click node_package "https://github.com/hasanzakeri/harfrust-python/blob/main/python/pyharfrust/__init__.py"
click node_extension "https://github.com/hasanzakeri/harfrust-python/blob/main/src/lib.rs"
click node_one_shot "https://github.com/hasanzakeri/harfrust-python/blob/main/src/shape.rs"
click node_buffer "https://github.com/hasanzakeri/harfrust-python/blob/main/src/buffer.rs"
click node_font "https://github.com/hasanzakeri/harfrust-python/blob/main/src/font.rs"
click node_glyphs "https://github.com/hasanzakeri/harfrust-python/blob/main/src/glyph.rs"
click node_types "https://github.com/hasanzakeri/harfrust-python/blob/main/src/types.rs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_package,node_extension toneBlue
class node_one_shot,node_buffer,node_font,node_glyphs toneAmber
class node_types toneMint
class node_caller,node_harfrust,node_font_file toneIndigo
```

## Components

### Python API

- [Public package](https://github.com/hasanzakeri/harfrust-python/blob/main/python/pyharfrust/__init__.py): `python/pyharfrust/__init__.py`
- [PyO3 extension](https://github.com/hasanzakeri/harfrust-python/blob/main/src/lib.rs): `src/lib.rs`

### Shaping Workflow

- [One-shot CLI API](https://github.com/hasanzakeri/harfrust-python/blob/main/src/shape.rs): `src/shape.rs`
- [Text buffer](https://github.com/hasanzakeri/harfrust-python/blob/main/src/buffer.rs): `src/buffer.rs`
- [Font and shaper](https://github.com/hasanzakeri/harfrust-python/blob/main/src/font.rs): `src/font.rs`
- [Glyph results](https://github.com/hasanzakeri/harfrust-python/blob/main/src/glyph.rs): `src/glyph.rs`

### Configuration

- [Configuration types](https://github.com/hasanzakeri/harfrust-python/blob/main/src/types.rs): `src/types.rs`

### Other components

- **Python caller**
- **HarfRust engine**
- **Font file**

## Connections

- Python caller → Public package: imports (evidence: `python/pyharfrust/__init__.py`)
- Public package → PyO3 extension: re-exports (evidence: `python/pyharfrust/__init__.py`)
- PyO3 extension → One-shot CLI API: registers (evidence: `src/lib.rs`)
- PyO3 extension → Text buffer: registers (evidence: `src/lib.rs`)
- PyO3 extension → Font and shaper: registers (evidence: `src/lib.rs`)
- PyO3 extension → Glyph results: registers (evidence: `src/lib.rs`)
- PyO3 extension → Configuration types: registers (evidence: `src/lib.rs`)
- Python caller → One-shot CLI API: calls (evidence: `README.md`)
- Python caller → Text buffer: builds text (evidence: `README.md`)
- Python caller → Font and shaper: configures font (evidence: `README.md`)
- Text buffer → Configuration types: uses properties (evidence: `src/buffer.rs`)
- Font and shaper → Text buffer: consumes buffer (evidence: `src/font.rs`)
- Font and shaper → Configuration types: parses options (evidence: `src/font.rs`)
- Font and shaper → Glyph results: wraps output (evidence: `src/font.rs`)
- Font and shaper → Font file: reads (evidence: `src/font.rs`)
- Font and shaper → HarfRust engine: shapes with (evidence: `src/font.rs`)
- Glyph results → Font and shaper: serializes with (evidence: `src/glyph.rs`)
- One-shot CLI API → HarfRust engine: delegates shaping (evidence: `src/shape.rs`)
