# sightem/libtexce architecture

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

- Interactive diagram: https://gitdiagram.com/sightem/libtexce
- Repository: https://github.com/sightem/libtexce

## Overview

libtexce is a C LaTeX-like renderer for TI-84 Plus CE, also usable in native/browser development builds. Its main workflow borrows immutable source and font data, formats the document into height and sparse checkpoints, then reparses visible windows and draws them through a renderer. The graph focuses on parsing, layout, font metrics, and rendering; unsampled details are omitted where the available references do not establish calls.

Main entry points: [`src/tex/tex_layout.c`](https://github.com/sightem/libtexce/blob/master/src/tex/tex_layout.c) (Format API), [`src/tex/tex_draw.c`](https://github.com/sightem/libtexce/blob/master/src/tex/tex_draw.c) (Window Draw), [`src/tex/tex_parse.c`](https://github.com/sightem/libtexce/blob/master/src/tex/tex_parse.c) (Math Parser), [`src/tex/tex_measure.c`](https://github.com/sightem/libtexce/blob/master/src/tex/tex_measure.c) (Math Measurement)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Public API"]
  node_font_api["Font API<br/>[tex_fonts.c]"]
  node_format_api["Format API<br/>[tex_layout.c]"]
  node_renderer_api["Renderer Lifecycle<br/>[tex_renderer.c]"]
end

subgraph group_input["Input and Parsing"]
  node_tokenizer["Document Tokenizer<br/>[tex_token.c]"]
  node_math_parser["Math Parser<br/>[tex_parse.c]"]
  node_symbol_map["Math Symbols<br/>[tex_symbols.c]"]
end

subgraph group_layout["Measurement and Layout"]
  node_layout_engine["Flow Layout<br/>[tex_layout.c]"]
  node_measure["Math Measurement<br/>[tex_measure.c]"]
  node_metrics["Glyph Metrics<br/>[tex_metrics.c]"]
  node_font_format["Font Format<br/>[texfont.h]"]
  node_transient_pool["Transient Pool<br/>[tex_pool.c]"]
end

subgraph group_render["Windowed Rendering"]
  node_renderer_pool["Renderer State<br/>[tex_renderer.c]"]
  node_window_draw["Window Draw<br/>[tex_draw.c]"]
end

node_app(("Application"))
node_display["Graphics Display"]

node_app -->|"opens fonts"| node_font_api
node_app -->|"formats source"| node_format_api
node_app -->|"creates renderer"| node_renderer_api
node_app -->|"requests draw"| node_window_draw
node_format_api -->|"tokenizes input"| node_tokenizer
node_format_api -->|"parses math"| node_math_parser
node_format_api -->|"measures layout"| node_measure
node_math_parser -->|"looks up symbols"| node_symbol_map
node_math_parser -->|"uses measurement"| node_measure
node_measure -->|"queries metrics"| node_metrics
node_metrics -->|"reads glyph data"| node_font_format
node_format_api -.->|"allocates parse data"| node_transient_pool
node_renderer_api -->|"owns slab pool"| node_transient_pool
node_window_draw -->|"measures draw geometry"| node_measure
node_window_draw -->|"rehydrates visible window"| node_math_parser
node_window_draw -->|"uses renderer state"| node_renderer_pool
node_window_draw -.->|"draws pixels"| node_display

click node_font_api "https://github.com/sightem/libtexce/blob/master/src/tex/tex_fonts.c"
click node_format_api "https://github.com/sightem/libtexce/blob/master/src/tex/tex_layout.c"
click node_renderer_api "https://github.com/sightem/libtexce/blob/master/src/tex/tex_renderer.c"
click node_tokenizer "https://github.com/sightem/libtexce/blob/master/src/tex/tex_token.c"
click node_math_parser "https://github.com/sightem/libtexce/blob/master/src/tex/tex_parse.c"
click node_symbol_map "https://github.com/sightem/libtexce/blob/master/src/tex/tex_symbols.c"
click node_layout_engine "https://github.com/sightem/libtexce/blob/master/src/tex/tex_layout.c"
click node_measure "https://github.com/sightem/libtexce/blob/master/src/tex/tex_measure.c"
click node_metrics "https://github.com/sightem/libtexce/blob/master/src/tex/tex_metrics.c"
click node_font_format "https://github.com/sightem/libtexce/blob/master/include/texfont.h"
click node_transient_pool "https://github.com/sightem/libtexce/blob/master/src/tex/tex_pool.c"
click node_renderer_pool "https://github.com/sightem/libtexce/blob/master/src/tex/tex_renderer.c"
click node_window_draw "https://github.com/sightem/libtexce/blob/master/src/tex/tex_draw.c"

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_font_api,node_format_api,node_renderer_api toneBlue
class node_tokenizer,node_math_parser,node_symbol_map toneAmber
class node_layout_engine,node_measure,node_metrics,node_font_format,node_transient_pool toneMint
class node_renderer_pool,node_window_draw toneRose
class node_app,node_display toneIndigo
```

## Components

### Public API

- [Font API](https://github.com/sightem/libtexce/blob/master/src/tex/tex_fonts.c): `src/tex/tex_fonts.c`
- [Format API](https://github.com/sightem/libtexce/blob/master/src/tex/tex_layout.c): `src/tex/tex_layout.c`
- [Renderer Lifecycle](https://github.com/sightem/libtexce/blob/master/src/tex/tex_renderer.c): `src/tex/tex_renderer.c`

### Input and Parsing

- [Document Tokenizer](https://github.com/sightem/libtexce/blob/master/src/tex/tex_token.c): `src/tex/tex_token.c`
- [Math Parser](https://github.com/sightem/libtexce/blob/master/src/tex/tex_parse.c): `src/tex/tex_parse.c`
- [Math Symbols](https://github.com/sightem/libtexce/blob/master/src/tex/tex_symbols.c): `src/tex/tex_symbols.c`

### Measurement and Layout

- [Flow Layout](https://github.com/sightem/libtexce/blob/master/src/tex/tex_layout.c): `src/tex/tex_layout.c`
- [Math Measurement](https://github.com/sightem/libtexce/blob/master/src/tex/tex_measure.c): `src/tex/tex_measure.c`
- [Glyph Metrics](https://github.com/sightem/libtexce/blob/master/src/tex/tex_metrics.c): `src/tex/tex_metrics.c`
- [Font Format](https://github.com/sightem/libtexce/blob/master/include/texfont.h): `include/texfont.h`
- [Transient Pool](https://github.com/sightem/libtexce/blob/master/src/tex/tex_pool.c): `src/tex/tex_pool.c`

### Windowed Rendering

- [Renderer State](https://github.com/sightem/libtexce/blob/master/src/tex/tex_renderer.c): `src/tex/tex_renderer.c`
- [Window Draw](https://github.com/sightem/libtexce/blob/master/src/tex/tex_draw.c): `src/tex/tex_draw.c`

### Other components

- **Application**
- **Graphics Display**

## Connections

- Application → Font API: opens fonts (evidence: `README.md`)
- Application → Format API: formats source (evidence: `README.md`)
- Application → Renderer Lifecycle: creates renderer (evidence: `README.md`)
- Application → Window Draw: requests draw (evidence: `README.md`)
- Format API → Document Tokenizer: tokenizes input (evidence: `src/tex/tex_layout.c`)
- Format API → Math Parser: parses math (evidence: `src/tex/tex_layout.c`)
- Format API → Math Measurement: measures layout (evidence: `src/tex/tex_layout.c`)
- Math Parser → Math Symbols: looks up symbols (evidence: `src/tex/tex_parse.c`)
- Math Parser → Math Measurement: uses measurement (evidence: `src/tex/tex_parse.c`)
- Math Measurement → Glyph Metrics: queries metrics (evidence: `src/tex/tex_measure.c`)
- Glyph Metrics → Font Format: reads glyph data
- Format API → Transient Pool: allocates parse data
- Renderer Lifecycle → Transient Pool: owns slab pool
- Window Draw → Math Measurement: measures draw geometry (evidence: `src/tex/tex_draw.c`)
- Window Draw → Math Parser: rehydrates visible window (evidence: `src/tex/tex_draw.c`)
- Window Draw → Renderer State: uses renderer state (evidence: `src/tex/tex_draw.c`)
- Window Draw → Graphics Display: draws pixels
