label
label is a lightweight OpenFL text renderer built around cached glyph bitmaps and Tilemap.
It is designed for simple HUD and gameplay text where low allocation churn matters more than full rich-text layout.
Features
- Batched rendering with
TextSurface - Mutable
Labelhandles you can keep and update - Baked fill and stroked outline styling with
TextStyle - Shared glyph atlas cache across labels and surfaces
- Low churn for changing counters, stats, and HUD text
- Style-driven synchronous and asynchronous glyph prewarming
Install
For local development:
haxelib dev label path/to/this/repo
After publishing:
haxelib install label
Then add it to your OpenFL project:
<haxelib name="label" />
Quick Start
import label.Label;
import label.TextStyle;
import label.TextSurface;
var style = new TextStyle("_sans", 24, 0xFFFFFF, 0x000000, 2);
var surface = new TextSurface();
addChild(surface);
var hp:Label = surface.drawText("HP 999", 24, 24, style);
hp.text = "HP 734";
surface.refresh();
Single Label Convenience
import label.SimpleText;
import label.TextStyle;
var style = new TextStyle("_sans", 24, 0xFFE7A1, 0x553300, 3, true);
var text = new SimpleText("READY", style);
addChild(text);
text.x = 32;
text.y = 32;
text.text = "GO";
text.refresh();
Prewarming
Prewarming is attached to TextStyle because glyphs are cached by character and style signature.
import label.TextStyle;
import label.TextStyleEvent;
var hudStyle = new TextStyle("_sans", 24, 0xFFFFFF, 0x000000, 2);
hudStyle.prewarmGlyphs("HPMP0123456789");
hudStyle.addEventListener(TextStyleEvent.PREWARM_PROGRESS, function (event) {
trace(event.progress);
});
hudStyle.addEventListener(TextStyleEvent.PREWARM_COMPLETE, function (_) {
trace("done");
});
hudStyle.prewarmGlyphsAsync("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", 8);
Public API
label.TextSurfacelabel.Labellabel.TextStylelabel.TextStyleEventlabel.SimpleText
Demo
This repository includes a small OpenFL demo app in sample/Source/Main.hx.
Run it with:
cd sample
openfl test html5
Notes
- Text is single-line by design. Newlines and tabs are normalized to spaces.
- Glyphs are cached per character and per style signature.
- Fill and stroke colors are baked into atlas pages.
- This library is optimized for simple HUD text, not complex shaping or rich typography.
License
MIT, Copyright (c) 2026 Dimensioncscape LLC.