Skip to content

feat(layers): add getLetterSpacing and getTextAlign to TextLayer - #10856

Draft
athomct wants to merge 2 commits into
visgl:masterfrom
chesapeake-tech:feat/text-layer-letter-spacing-align
Draft

athomct wants to merge 2 commits into
visgl:masterfrom
chesapeake-tech:feat/text-layer-letter-spacing-align

Conversation

@athomct

@athomct athomct commented Oct 12, 2026

Copy link
Copy Markdown

Closes #10855

TextLayer cannot space characters, and it aligns the rows of a multi-line label by getTextAnchor. The deck.gl-community basemap-layers module patches the private transformParagraph to emulate MapLibre's text-letter-spacing and text-justify (visgl/deck.gl-community#861). It can switch to these props.

Change List

  • Add getLetterSpacing: em spacing after each character but a row's last
  • Letter spacing widens the background and counts toward maxWidth wrapping
  • Add getTextAlign: 'auto' (default, current behavior), 'left', 'center', 'right'
  • Changing a constant layout accessor (incl. getTextAnchor, getAlignmentBaseline) now updates the layout
  • New golden image text-layer-letter-spacing-align
  • Unit tests, render test, documentation, what's new

Before (text-layer-multi-lines, current master):

before

After: the same labels with letter spacing 0.1 / 0.2 / 0.3 em and rows aligned right / left / center, while anchored start / middle / end:

after

Ran yarn lint, the node and headless suites, and the WebGL and WebGPU render tests (headless Chromium).

getLetterSpacing adds space after each character of a row but the last,
in ems of the text size. The space widens the text block, so it sizes the
background and counts toward maxWidth wrapping.

getTextAlign aligns the rows of a multi-line block to its left, center
or right edge, independently of getTextAnchor. The default 'auto' keeps
the current behavior.

Constant layout accessors (getTextAnchor, getAlignmentBaseline and the
two new ones) now re-layout the text when their value changes.
…triggers

A function accessor's update trigger could equal the value of the constant
that replaced it, so the layout was not updated.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feat] TextLayer: letter spacing and row alignment

2 participants