# aishervin/termux-persian-font-injector architecture

> Architecture diagram of the GitHub repository aishervin/termux-persian-font-injector, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aishervin/termux-persian-font-injector
- Repository: https://github.com/aishervin/termux-persian-font-injector

## Overview

Termux-Persian-Font-Injector combines a native terminal wrapper and font-injection workflow with a browser-based workbench. In the terminal path, text enters shen-tty, is shaped and reordered, then rendered through the selected output mode; installation also builds the wrapper and installs fonts. The web path provides a live Persian terminal preview, glyph exploration, and repository browsing/download. The README documents installer, font-switching, and fallback-rendering capabilities. Some subsystem links rely on README statements because installer and font-generation internals were not sampled.

Main entry points: [`repo/src/shen_tty.c`](https://github.com/aishervin/termux-persian-font-injector/blob/main/repo/src/shen_tty.c) (PTY wrapper), [`install.sh`](https://github.com/aishervin/termux-persian-font-injector/blob/main/install.sh) (Installer), [`src/App.tsx`](https://github.com/aishervin/termux-persian-font-injector/blob/main/src/App.tsx) (Workbench interface), [`repo/src/persian_shaper.h`](https://github.com/aishervin/termux-persian-font-injector/blob/main/repo/src/persian_shaper.h) (Persian shaping)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_terminal["Terminal runtime"]
  node_shen_tty["PTY wrapper<br/>[shen_tty.c]"]
  node_shaper["Persian shaping<br/>[persian_shaper.h]"]
  node_bitmap["Bitmap glyphs<br/>[bitmap_font_8x16.h]"]
end

subgraph group_fonts["Font assets"]
  node_font_generator["Font generator<br/>[generate_font.py]"]
  node_font_assets["TTF font files"]
end

subgraph group_workbench["Web workbench"]
  node_web_entry["Web app entry<br/>[main.tsx]"]
  node_workbench_app["Workbench interface<br/>[App.tsx]"]
  node_persian_engine["Preview shaping<br/>[persianEngine.ts]"]
  node_repo_browser["Repository archive<br/>[tarBuilder.ts]"]
end

subgraph group_install["Installation"]
  node_installer["Installer<br/>[install.sh]"]
end

node_terminal_user(("Terminal user"))
node_terminal_output(("Terminal output"))
node_termux_font[("Termux font slot")]
node_web_user(("Workbench user"))
node_shell(("System shell"))

node_terminal_user -->|"runs"| node_shen_tty
node_shen_tty -->|"shapes text"| node_shaper
node_shen_tty -->|"uses glyphs"| node_bitmap
node_shaper -->|"reorders text"| node_terminal_output
node_shen_tty -->|"renders modes"| node_terminal_output
node_font_generator -->|"generates fonts"| node_font_assets
node_installer -->|"builds wrapper"| node_shen_tty
node_installer -->|"injects font"| node_termux_font
node_font_assets -->|"installs font"| node_termux_font
node_terminal_user -->|"installs"| node_installer
node_installer -->|"adds commands"| node_shell
node_web_user -->|"opens workbench"| node_web_entry
node_web_entry -->|"renders"| node_workbench_app
node_workbench_app -->|"previews text"| node_persian_engine
node_workbench_app -->|"browses and packs"| node_repo_browser
node_persian_engine -->|"reads glyph data"| node_bitmap

click node_shen_tty "https://github.com/aishervin/termux-persian-font-injector/blob/main/repo/src/shen_tty.c"
click node_shaper "https://github.com/aishervin/termux-persian-font-injector/blob/main/repo/src/persian_shaper.h"
click node_bitmap "https://github.com/aishervin/termux-persian-font-injector/blob/main/repo/src/bitmap_font_8x16.h"
click node_font_generator "https://github.com/aishervin/termux-persian-font-injector/blob/main/repo/scripts/generate_font.py"
click node_font_assets "https://github.com/aishervin/termux-persian-font-injector/tree/main/repo/assets"
click node_web_entry "https://github.com/aishervin/termux-persian-font-injector/blob/main/src/main.tsx"
click node_workbench_app "https://github.com/aishervin/termux-persian-font-injector/blob/main/src/App.tsx"
click node_persian_engine "https://github.com/aishervin/termux-persian-font-injector/blob/main/src/lib/persianEngine.ts"
click node_repo_browser "https://github.com/aishervin/termux-persian-font-injector/blob/main/src/lib/tarBuilder.ts"
click node_installer "https://github.com/aishervin/termux-persian-font-injector/blob/main/install.sh"

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_shen_tty,node_shaper,node_bitmap,node_terminal_user,node_web_user toneBlue
class node_font_generator,node_font_assets,node_termux_font toneAmber
class node_web_entry,node_workbench_app,node_persian_engine,node_repo_browser toneMint
class node_installer toneRose
class node_terminal_output,node_shell toneIndigo
```

## Components

### Terminal runtime

- [PTY wrapper](https://github.com/aishervin/termux-persian-font-injector/blob/main/repo/src/shen_tty.c): `repo/src/shen_tty.c`
- [Persian shaping](https://github.com/aishervin/termux-persian-font-injector/blob/main/repo/src/persian_shaper.h): `repo/src/persian_shaper.h`
- [Bitmap glyphs](https://github.com/aishervin/termux-persian-font-injector/blob/main/repo/src/bitmap_font_8x16.h): `repo/src/bitmap_font_8x16.h`

### Font assets

- [Font generator](https://github.com/aishervin/termux-persian-font-injector/blob/main/repo/scripts/generate_font.py): `repo/scripts/generate_font.py`
- [TTF font files](https://github.com/aishervin/termux-persian-font-injector/tree/main/repo/assets): `repo/assets`

### Web workbench

- [Web app entry](https://github.com/aishervin/termux-persian-font-injector/blob/main/src/main.tsx): `src/main.tsx`
- [Workbench interface](https://github.com/aishervin/termux-persian-font-injector/blob/main/src/App.tsx): `src/App.tsx`
- [Preview shaping](https://github.com/aishervin/termux-persian-font-injector/blob/main/src/lib/persianEngine.ts): `src/lib/persianEngine.ts`
- [Repository archive](https://github.com/aishervin/termux-persian-font-injector/blob/main/src/lib/tarBuilder.ts): `src/lib/tarBuilder.ts`

### Installation

- [Installer](https://github.com/aishervin/termux-persian-font-injector/blob/main/install.sh): `install.sh`

### Other components

- **Terminal user**
- **Terminal output**
- **Termux font slot**
- **Workbench user**
- **System shell**

## Connections

- Terminal user → PTY wrapper: runs (evidence: `README.md`)
- PTY wrapper → Persian shaping: shapes text (evidence: `repo/src/shen_tty.c`)
- PTY wrapper → Bitmap glyphs: uses glyphs (evidence: `repo/src/shen_tty.c`)
- Persian shaping → Terminal output: reorders text (evidence: `repo/src/persian_shaper.h`)
- PTY wrapper → Terminal output: renders modes (evidence: `README.md`)
- Font generator → TTF font files: generates fonts (evidence: `README.md`)
- Installer → PTY wrapper: builds wrapper (evidence: `README.md`)
- Installer → Termux font slot: injects font (evidence: `README.md`)
- TTF font files → Termux font slot: installs font (evidence: `README.md`)
- Terminal user → Installer: installs (evidence: `README.md`)
- Installer → System shell: adds commands (evidence: `README.md`)
- Workbench user → Web app entry: opens workbench (evidence: `README.md`)
- Web app entry → Workbench interface: renders (evidence: `src/main.tsx`)
- Workbench interface → Preview shaping: previews text (evidence: `src/App.tsx`)
- Workbench interface → Repository archive: browses and packs (evidence: `src/App.tsx`)
- Preview shaping → Bitmap glyphs: reads glyph data (evidence: `src/lib/persianEngine.ts`)
