Flexbox Layouts & Glyph Compilation
The GUI Extension implements a pure-Dart CSS Flexbox engine that auto-positions layers. The compiled output is a sequence of negative space Unicode characters that Minecraft’s typographic renderer interprets as pixel-precise positioning.The Core Concept
How Minecraft Renders Text
Minecraft’s text renderer reads characters sequentially, left to right, on a single line. Each character advances the cursor by its pixel width. To create 2D layouts, we manipulate this cursor with invisible space characters:Flexbox Properties
The Flexbox engine supports the full CSS Flexbox specification subset:Container Properties
| Property | Values | Description |
|---|---|---|
direction | row, column, row-reverse, column-reverse | Main axis direction |
justify | start, end, center, space-between, space-around, space-evenly | Main axis alignment |
align | start, end, center, stretch | Cross axis alignment |
wrap | nowrap, wrap, wrap-reverse | Line wrapping |
rowGap | pixels | Vertical gap between items |
columnGap | pixels | Horizontal gap between items |
Resolution Algorithm
Negative Space Font
The NegativeSpaceFont (AmberWat) maps pixel offsets to Unicode surrogate pairs:Space Ranges
| Category | Range | Codepoint Range |
|---|---|---|
| Positive integer | 1 to 8192 pixels | U+DB00 U+DC01 → U+DB08 U+DC00 |
| Negative integer | -1 to -8192 pixels | U+DAF8 U+DC00 → U+DAFF U+DFFF |
| Fractional | Rational /4800 | U+D8FB U+DD40 → U+D904 U+DEC0 |
| Infinite negative | -∞ | U+DAC0 U+DC01 |
| Infinite positive | +∞ | U+DB3F U+DFFF |
| New layer | Z-fighting fix | U+DAC0 U+DC00 |
The Compilation Algorithm
Magic Digits (Dynamic Text)
When a text layer contains PlaceholderAPI variables (e.g.,%player_name%), its pixel width is unknown at design time. Magic Digits solve this with the Fibonacci sequence:
Example
Z-Fighting & newlayer
When two layers overlap at the same depth, Minecraft can’t determine which to render on top. This is Z-fighting. The compiler automatically detects overlapping layers at the same Y with intersecting X ranges and insertsnewlayer when needed.
Font Provider Generation
Each unique Y position requires a separate font provider entry indefault.json:
- ascent: Vertical offset from the text baseline. Higher values push the texture down
- height: Scale of the glyph. Controls how tall it renders
- chars: Unicode characters mapped to this texture sheet
- file: Path to the PNG texture atlas inside the resource pack