deck.gl icon indicating copy to clipboard operation
deck.gl copied to clipboard

feat(layers): support per-object text max width

Open ibgreen-openai opened this issue 3 months ago • 1 comments

Summary

  • add getMaxWidth accessor to TextLayer
  • allow individual labels to control their wrapping width
  • document getMaxWidth and expose through GeoJsonLayer

The layout is handled entirely on the CPU. TextLayer.transformParagraph resolves the effective maxWidth for each datum and runs the transformParagraph utility to wrap/truncate the text before any geometry is sent to the GPU, so the shader simply receives per-character offsets that already reflect the width limit. The sublayer that actually renders each glyph (MultiIconLayer) just reuses the existing IconLayer shaders and adds SDF uniforms; it does not read or use maxWidth, so no changes to shader code are necessary.

Questions

  • Ideally I would like to limit maxWidth based on world coordinates (OrthographicViews) because I am trying to make the text fit into containing boxes in world coordinates.
  • Do we still need maxWidth prop or should we deprecate it?

Testing

  • yarn test node test/modules/layers/text-layer/text-layer.spec.ts (fails: SyntaxError Unexpected identifier 'assert')

https://chatgpt.com/codex/tasks/task_i_68a736833ef0832c99608800972619f1

ibgreen-openai avatar Aug 21 '25 15:08 ibgreen-openai