Text rendering
Overview
The text stack is optional and sits beside the point renderer:
GlyphAtlas— CPU-rasterized bitmap atlas; simple to reason about; rebuilds on DPR changes.MsdfGlyphAtlas— precomputed MSDF atlas + JSON metrics; better minification; fixed atlas cost.TextLayer— owns labels, map matrix, cull rect, declutter options; feedsTextRenderer.TextRenderer— GPU pipeline for glyph instances and frame uniforms.
Import paths
import {
TextLayer,
createTextLayerForPointsRenderer,
GlyphAtlas,
tryLoadMsdfAtlasFromUrls,
} from "stratum-map";
Workflow
- Build
TextLabel[](anchor in map CRS, strings, priorities, optional halos). textLayer.setLabels(labels)and updatesetMapToClipMatrixeach frame.textLayer.rebuildInstancesIfDirty(viewState)then encode the text pass after points (or interleaved per your compositing rules).
See Text layer API and Text renderer API.
Runnable: GPU text labels demo (OpenLayers overlay + TextLayer).
MSDF assets
Ship atlas.png + atlas.json (versioned schema). Use tryLoadMsdfAtlasFromUrls or construct MsdfGlyphAtlas from existing GPU textures in advanced integrations.