Skip to main content

TextLayer

Host-facing façade for CPU text layoutTextRenderer instance buffer. Owns a GlyphAtlas by default; call replaceAtlas to swap in MsdfGlyphAtlas.

Import

import { TextLayer, createTextLayerForPointsRenderer } from "stratum-map";

Construction

TextLayer.create(options: TextLayerOptions)

FieldTypeDescription
deviceGPUDeviceShared WebGPU device
formatGPUTextureFormatSwapchain / render target format
canvasHTMLCanvasElementLayout / DPR reference
dprnumber?Override device pixel ratio
maxGlyphsnumber?Cap emitted instances

TextLayer.createForPointsRenderer(renderer, options?)

Convenience: pulls device, format, and canvas from an existing WebGpuPointsRenderer.

Label pipeline

  1. setLabels(labels: TextLabel[]) — map-anchored strings, priorities, halos.
  2. setMapToClipMatrix(m) — same contract as points.
  3. setCullExtent(extent, margin?) — optional map-space cull.
  4. rebuildInstancesIfDirty(view: TextViewState) — CPU layout + declutter when dirty.

Decluttering

MethodPurpose
setDeclutterEnabled(on)Toggle screen-space collision
setDeclutterPaddingPx(px)Extra collision padding
setMapZoomForDeclutter(zoom)Zoom min/max gates on labels
setDeclutterDebug(on)Emit debug rects (dev)

Performance notes

  • Layout is CPU O(n) in label count; cap labels per view.
  • MSDF avoids per-zoom atlas rebuild; bitmap atlas rebuilds on DPR changes.

See also