Vertical alignment of text sections
A matching development SDK with commonLineSymbols also supports shared planar line symbols, including true per-glyph curved geometry, target ownership, joint icon/text groups and shared budgets. Earlier point-only scope and pending line-symbol notes below are superseded for this bounded subset. Complex shaping, tilted/globe/terrain placement and complete road stitching remain pending.
Shared point labels support vertical-align: 'top' | 'center' | 'bottom' in format sections, defaulting to bottom. After wrapping, each row uses its largest font-size em box as the reference. top moves a smaller section upward by the full size difference; center moves it by half; bottom keeps the existing shared baseline. Different characters have different ink shapes, so aligning font-size boxes does not require identical pixel edges.
map.setLayoutProperty('formatted', 'text-field', ['format',
'AA', {'font-scale': 1.5, 'text-color': 'red'},
'BB', {
'font-scale': 0.5, 'text-color': 'blue',
'vertical-align': 'top'
}
]);
await map.sqs.flush({render: true});
This updates an existing formatted point-text layer; see formatted text sections for the basic source and layer setup. vertical-align can also use a shared expression returning one of these three strings, including lexical variables and branches. Layout still uses integer zoom, with existing text, section, size, glyph and expression budgets.
Sections share one anchor, offset, rotation and collision box. Actual moved glyph bounds participate in queries. Each wrapped row computes its own reference; a zero-scale section does not affect alignment. Omitted alignment preserves exactly the same image as explicit bottom, and ordinary string layout is unchanged. Explicitly small or zero line height may still cause overlapping rows.
The commonFormattedTextVerticalAlign capability covers this shared path. Unknown enum values or incorrect dynamic types fail explicitly, preserving the previous label and image. Per-section font stacks now use the PBF path. Registered RGBA image sections are available. SDF image sections, font files, complex shaping, line placement and 3D combinations remain unfinished. Semantics follow the MapLibre format specification, with this project's own implementation; complete format compatibility is not claimed.
Copy portable-format-align.js, or use the complete browser page. A large red glyph and smaller green, blue and orange glyphs demonstrate top, bottom and center alignment.