label

Lightweight cached glyph text rendering for OpenFL with batched Tilemap surfaces, baked fill and stroke styling, and low-churn updates for game HUD text.
https://github.com/Dimensioncscape/label

To install, run:

haxelib install label 1.0.1 

See using Haxelib in Haxelib documentation for more information.

README.md

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 Label handles 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.TextSurface
  • label.Label
  • label.TextStyle
  • label.TextStyleEvent
  • label.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.

Contributors
Dimensionscape
Version
1.0.1
Published
3 weeks ago
License
MIT

All libraries are free

Every month, more than a thousand developers use Haxelib to find, share, and reuse code — and assemble it in powerful new ways. Enjoy Haxe; It is great!

Explore Haxe

Haxe Manual

Haxe Code Cookbook

Haxe API documentation

You can try Haxe in the browser! try.haxe.org

Join us on GitHub!

Haxe is being developed on GitHub. Feel free to contribute or report issues to our projects.

Haxe on GitHub