# yuru7/hackgen architecture

> Architecture diagram of the GitHub repository yuru7/hackgen, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/yuru7/hackgen
- Repository: https://github.com/yuru7/hackgen

## Overview

##### Project Type and Purpose
- This is a **build‐pipeline project** for a composite programming font (“HackGen”).
- It ingests two source fonts (Hack and GenJyuu‐Gothic derivation), applies custom modifications, hinting, and merges them into multiple output font families (normal, console, NerdFonts variants).

##### File Structure Analysis
- Top‐level scripts:
- `make_hackgen.sh`, `hackgen_generator.sh`, `cmap_patch.sh`, `os2_patch.sh`, `hinting_post_processing/...`, `little_scripts/...`
– These drive the build steps (patching, merging, hinting).
- `source/`: all source SFD font files and cmap format definitions, plus source licenses.
- `hinting_post_processing/`: control files for `ttfautohint`.
- `doc/`: design notes and migration aids.
- No server/client code—this is purely a **build architecture**.

##### README Insights
- Describes the **build environment** and external dependencies:
- fontforge (to load and export SFD/TTF)
- ttfautohint (for glyph hinting)
- fonttools (pyftmerge/ttx for merging/patching tables)
- Outlines the **font families** produced and the branching logic (standard vs. 3:5 width, console vs. normal, NerdFont variants).

a. Main Components
1. Source Inputs
– Hack SFD
– GenJyuu‐Gothic‐derived SFDs
– License text files
2. Build Scripts
– Patch scripts (`cmap_patch.sh`, `os2_patch.sh`)
– Main generator (`hackgen_generator.sh` / `make_hackgen.sh`)
– Hinting post‐processing (uses `ttfautohint` control files)
– Helper scripts (`little_scripts/`, `source/cmap_format_14_master`)
3. External Tools
– fontforge
– ttfautohint
– fonttools (`pyftmerge`, `ttx`)
4. Artifacts
– Intermediate patched TTFs
– Final TTF families (HackGen, HackGen Console, HackGen35, etc.)
– Release ZIP packages
5. Distribution Channels
– GitHub Releases
– Homebrew/CocoaTap*
– Chocolatey

b. Relationships & Data Flow
1. Source Inputs → Build Scripts
2. Build Scripts invoke fontforge to merge or patch glyph sets
3. Output from fontforge → ttfautohint (using `hinting_post_processing` controls)
4. Hinted TTFs → fonttools for table merges/patches (`pyftmerge`, `ttx`)
5. Final TTFs → packaged into ZIPs by scripts
6. Package → released to distribution channels

c. Architectural Patterns & Principles
- **Linear pipeline**: clear successive transformation stages
- **Separation of concerns**:
- Patching (cmap/OS2)
- Hinting
- Table merging
- Packaging
- **Reproducibility**: all steps scripted for automated rebuild

d. Key Technologies & Frameworks
- Scripting: Bash
- Font editing: fontforge CLI
- Hinting: ttfautohint
- Table tooling: fonttools (Python 2 pip installed)
- Packaging: standard zip utilities

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Source Inputs"
        SI_IDEO["Ideographic_Space.sfd"]:::input
        SI_FIXG["fix_GenJyuuGothicL-Monospace-Bold.sfd"]:::input
        SI_IMPB["improved_legibility-Bold.sfd"]:::input
        SI_IMPR["improved_legibility-Regular.sfd"]:::input
        SI_MAB["modify_arrow_Hack-Bold.sfd"]:::input
        SI_MAR["modify_arrow_Hack-Regular.sfd"]:::input
        SI_RWB["reiwa-Bold.sfd"]:::input
        SI_RWR["reiwa-Regular.sfd"]:::input
        SI_LG["LICENSE_GenJyuuGothic"]:::input
        SI_LH["LICENSE_Hack"]:::input
        SI_LN["LICENSE_NerdFonts"]:::input
        SI_CMAPM["cmap_format_14_master"]:::input
    end

    subgraph "Patching Module"
        PM_CMAP["cmap_patch.sh"]:::script
        PM_OS2["os2_patch.sh"]:::script
    end

    PatchedTTF["Intermediate Patched TTFs"]:::output

    subgraph "Hinting Module"
        HM_CTRL1["hackgen-regular-ctrl.txt"]:::script
        HM_CTRL2["hackgen-bold-ctrl.txt"]:::script
        HM_CTRL3["hackgen35-regular-ctrl.txt"]:::script
        HM_CTRL4["hackgen35-bold-ctrl.txt"]:::script
    end

    HintedTTF["Hinted TTFs"]:::output

    subgraph "Main Generator Module"
        MG_GEN["hackgen_generator.sh"]:::script
        MG_MAKE["make_hackgen.sh"]:::script
    end

    FinalTTF["Final TTF Families"]:::output

    subgraph "Packaging Module"
        PK_ZIP["Release ZIP Packages"]:::output
    end

    subgraph "Distribution Channels"
        DC_GH["GitHub Releases"]:::tool
        DC_HB["Homebrew/CocoaTap*"]:::tool
        DC_CH["Chocolatey"]:::tool
    end

    subgraph "Helper Scripts Module"
        HS_EXTRACT["extract_dakuon.sh"]:::script
    end

    subgraph "Documentation Module"
        DOC_IVS["ivs.txt"]:::input
        DOC_SFD["How_to_make_sfd.txt"]:::input
        DOC_MEMO["memo_DisplayOnMery.txt"]:::input
        DOC_MD["modify_arrow.md"]:::input
    end

    SI_IDEO & SI_FIXG & SI_IMPB & SI_IMPR & SI_MAB & SI_MAR & SI_RWB & SI_RWR & SI_LG & SI_LH & SI_LN & SI_CMAPM --> PM_CMAP
    SI_IDEO & SI_FIXG & SI_IMPB & SI_IMPR & SI_MAB & SI_MAR & SI_RWB & SI_RWR & SI_LG & SI_LH & SI_LN & SI_CMAPM --> PM_OS2
    PM_CMAP -->|"fontforge"| PatchedTTF
    PM_OS2 -->|"fontforge"| PatchedTTF
    PatchedTTF -->|"ttfautohint"| HM_CTRL1
    PatchedTTF -->|"ttfautohint"| HM_CTRL2
    PatchedTTF -->|"ttfautohint"| HM_CTRL3
    PatchedTTF -->|"ttfautohint"| HM_CTRL4
    HM_CTRL1 & HM_CTRL2 & HM_CTRL3 & HM_CTRL4 --> HintedTTF
    HintedTTF -->|"pyftmerge/ttx"| MG_GEN
    HintedTTF -->|"pyftmerge/ttx"| MG_MAKE
    HS_EXTRACT --> MG_GEN
    MG_GEN --> FinalTTF
    MG_MAKE --> FinalTTF
    FinalTTF --> PK_ZIP
    PK_ZIP --> DC_GH
    PK_ZIP --> DC_HB
    PK_ZIP --> DC_CH

    click SI_IDEO "https://github.com/yuru7/hackgen/blob/master/source/Ideographic_Space.sfd"
    click SI_FIXG "https://github.com/yuru7/hackgen/blob/master/source/fix_GenJyuuGothicL-Monospace-Bold.sfd"
    click SI_IMPB "https://github.com/yuru7/hackgen/blob/master/source/improved_legibility-Bold.sfd"
    click SI_IMPR "https://github.com/yuru7/hackgen/blob/master/source/improved_legibility-Regular.sfd"
    click SI_MAB "https://github.com/yuru7/hackgen/blob/master/source/modify_arrow_Hack-Bold.sfd"
    click SI_MAR "https://github.com/yuru7/hackgen/blob/master/source/modify_arrow_Hack-Regular.sfd"
    click SI_RWB "https://github.com/yuru7/hackgen/blob/master/source/reiwa-Bold.sfd"
    click SI_RWR "https://github.com/yuru7/hackgen/blob/master/source/reiwa-Regular.sfd"
    click SI_LG "https://github.com/yuru7/hackgen/tree/master/source/LICENSE_GenJyuuGothic"
    click SI_LH "https://github.com/yuru7/hackgen/tree/master/source/LICENSE_Hack"
    click SI_LN "https://github.com/yuru7/hackgen/tree/master/source/LICENSE_NerdFonts"
    click SI_CMAPM "https://github.com/yuru7/hackgen/tree/master/source/cmap_format_14_master"
    click PM_CMAP "https://github.com/yuru7/hackgen/blob/master/cmap_patch.sh"
    click PM_OS2 "https://github.com/yuru7/hackgen/blob/master/os2_patch.sh"
    click MG_GEN "https://github.com/yuru7/hackgen/blob/master/hackgen_generator.sh"
    click MG_MAKE "https://github.com/yuru7/hackgen/blob/master/make_hackgen.sh"
    click HM_CTRL1 "https://github.com/yuru7/hackgen/blob/master/hinting_post_processing/hackgen-regular-ctrl.txt"
    click HM_CTRL2 "https://github.com/yuru7/hackgen/blob/master/hinting_post_processing/hackgen-bold-ctrl.txt"
    click HM_CTRL3 "https://github.com/yuru7/hackgen/blob/master/hinting_post_processing/hackgen35-regular-ctrl.txt"
    click HM_CTRL4 "https://github.com/yuru7/hackgen/blob/master/hinting_post_processing/hackgen35-bold-ctrl.txt"
    click HS_EXTRACT "https://github.com/yuru7/hackgen/blob/master/little_scripts/extract_dakuon.sh"
    click DOC_IVS "https://github.com/yuru7/hackgen/blob/master/doc/ivs.txt"
    click DOC_SFD "https://github.com/yuru7/hackgen/blob/master/doc/note/How_to_make_sfd.txt"
    click DOC_MEMO "https://github.com/yuru7/hackgen/blob/master/doc/note/memo_DisplayOnMery.txt"
    click DOC_MD "https://github.com/yuru7/hackgen/blob/master/doc/note/modify_arrow.md"

    classDef input fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef script fill:#90EE90,stroke:#333,stroke-width:1px
    classDef tool fill:#FFA500,stroke:#333,stroke-width:1px
    classDef output fill:#FFFF99,stroke:#333,stroke-width:1px
```
