-
Notifications
You must be signed in to change notification settings - Fork 10
EN:Development
English | 中文版
This document summarizes the core design philosophy and modular architecture of the luatex-cn typesetting engine.
luatex-cn utilizes a three-layer architecture to decouple layout logic from rendering:
-
LaTeX Interface Layer (
.sty,.cls): Defines user commands; sets attributes and parameters vialuatexbase. -
Coordination Layer (
core_*.lua): Manages logic flow. For instance,core_mainorchestrates the main process, whilecore_textflowhandles interlinear note splitting. -
Processing Layer (
layout_*.lua,render_*.lua):- Flattening: Converts TeX node lists into linear Lua tables.
- Layout: Calculates grid coordinates for each character and its associated elements.
- Rendering: Reassembles content based on coordinates and outputs PDF instructions.
Leverages LuaTeX's dir RTT attribute. In RTT mode, text flows top-to-bottom, and lines stack right-to-left.
Uses LuaTeX attributes to pass metadata across languages (e.g., "this glyph belongs to an interlinear note").
Warning
\selectfont clears all active attributes. Ensure attributes are reset AFTER setting the font size.
Passing nodes to TeX via tex.box[n] = node transfers ownership. Use node.copy_list() if you need to reuse nodes.
-
Color Commands: Must use normalized RGB (e.g.,
0 0 0 rg), not names. - Rendering Order: PDF follows the "painter's model"—later content overlays earlier content. Insert backgrounds at the head of the list to ensure they are at the bottom.
-
Module Loading: Standardize on
require()and utilizepackage.loadedfor caching.
👉 For more details, refer to ai_must_read/LEARNING.md in the source repository.
📜 LuaTeX-CN | Licensed under Apache License 2.0