# latex3/luaotfload architecture

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

- Interactive diagram: https://gitdiagram.com/latex3/luaotfload
- Repository: https://github.com/latex3/luaotfload

## Overview

Luaotfload adapts ConTeXt font loading for Plain and LaTeX: users request fonts by name or file and specify OpenType features; font metadata indexing supports name-based lookup. The README establishes these capabilities and the package entry points, but no source excerpts were provided, so internal calls and detailed shaping or resolution stages cannot be verified. The graph therefore shows only documented relationships.

Main entry points: [`src/luaotfload.lua`](https://github.com/latex3/luaotfload/blob/main/src/luaotfload.lua) (Luaotfload), [`src/luaotfload.sty`](https://github.com/latex3/luaotfload/blob/main/src/luaotfload.sty) (Plain entry), [`src/luaotfload-database.lua`](https://github.com/latex3/luaotfload/blob/main/src/luaotfload-database.lua) (Font metadata database), [`src/luaotfload-resolvers.lua`](https://github.com/latex3/luaotfload/blob/main/src/luaotfload-resolvers.lua) (Font name lookup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Package entry"]
  node_plainentry["Plain entry<br/>[luaotfload.sty]"]
  node_latexentry["LaTeX entry<br/>[luaotfload.sty]"]
  node_package["Luaotfload<br/>[luaotfload.lua]"]
end

subgraph group_resolution["Font resolution"]
  node_fontdb[("Font metadata database")]
  node_fontnames["Font name lookup"]
end

subgraph group_loading["Font loading"]
  node_fontfeatures["Feature requests"]
  node_fontloading["Font loading"]
end

subgraph group_engines["Engine integration"]
  node_luatex{{"LuaTeX"}}
  node_luahbtex{{"LuaHBTeX"}}
end

node_plainuser(("Plain user"))
node_latexuser(("LuaLaTeX user"))
node_fontspec["fontspec"]

node_plainuser -->|"loads with input"| node_plainentry
node_latexuser -->|"loads by default"| node_latexentry
node_plainentry -.->|"loads package"| node_package
node_latexentry -.->|"loads package"| node_package
node_package -->|"indexes metadata"| node_fontdb
node_fontdb -->|"enables name lookup"| node_fontnames
node_package -->|"provides feature syntax"| node_fontfeatures
node_package -->|"loads OpenType fonts"| node_fontloading
node_fontspec -->|"interfaces to"| node_package
node_luatex -->|"runs on"| node_package
node_luahbtex -->|"supports harfmode"| node_package

click node_plainentry "https://github.com/latex3/luaotfload/blob/main/src/luaotfload.sty"
click node_latexentry "https://github.com/latex3/luaotfload/blob/main/src/luaotfload.sty"
click node_package "https://github.com/latex3/luaotfload/blob/main/src/luaotfload.lua"
click node_fontdb "https://github.com/latex3/luaotfload/blob/main/src/luaotfload-database.lua"
click node_fontnames "https://github.com/latex3/luaotfload/blob/main/src/luaotfload-resolvers.lua"
click node_fontfeatures "https://github.com/latex3/luaotfload/blob/main/src/luaotfload-features.lua"
click node_fontloading "https://github.com/latex3/luaotfload/blob/main/src/luaotfload-loaders.lua"

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_plainentry,node_latexentry,node_package,node_plainuser,node_latexuser toneBlue
class node_fontdb,node_fontnames toneAmber
class node_fontfeatures,node_fontloading toneMint
class node_luatex,node_luahbtex toneRose
class node_fontspec toneIndigo
```

## Components

### Package entry

- [Plain entry](https://github.com/latex3/luaotfload/blob/main/src/luaotfload.sty): `src/luaotfload.sty`
- [LaTeX entry](https://github.com/latex3/luaotfload/blob/main/src/luaotfload.sty): `src/luaotfload.sty`
- [Luaotfload](https://github.com/latex3/luaotfload/blob/main/src/luaotfload.lua): `src/luaotfload.lua`

### Font resolution

- [Font metadata database](https://github.com/latex3/luaotfload/blob/main/src/luaotfload-database.lua): `src/luaotfload-database.lua`
- [Font name lookup](https://github.com/latex3/luaotfload/blob/main/src/luaotfload-resolvers.lua): `src/luaotfload-resolvers.lua`

### Font loading

- [Feature requests](https://github.com/latex3/luaotfload/blob/main/src/luaotfload-features.lua): `src/luaotfload-features.lua`
- [Font loading](https://github.com/latex3/luaotfload/blob/main/src/luaotfload-loaders.lua): `src/luaotfload-loaders.lua`

### Engine integration

- **LuaTeX**
- **LuaHBTeX**

### Other components

- **Plain user**
- **LuaLaTeX user**
- **fontspec**

## Connections

- Plain user → Plain entry: loads with input (evidence: `README.md`)
- LuaLaTeX user → LaTeX entry: loads by default (evidence: `README.md`)
- Plain entry → Luaotfload: loads package
- LaTeX entry → Luaotfload: loads package
- Luaotfload → Font metadata database: indexes metadata (evidence: `README.md`)
- Font metadata database → Font name lookup: enables name lookup (evidence: `README.md`)
- Luaotfload → Feature requests: provides feature syntax (evidence: `README.md`)
- Luaotfload → Font loading: loads OpenType fonts (evidence: `README.md`)
- fontspec → Luaotfload: interfaces to (evidence: `README.md`)
- LuaTeX → Luaotfload: runs on (evidence: `README.md`)
- LuaHBTeX → Luaotfload: supports harfmode (evidence: `README.md`)
