Expand description
Point text labels: a port of MapLibre GL JS’s symbol pipeline.
-
Glyph PBFs (
style/parse_glyph_pbf.ts): SDF bitmaps with a 3 px border. -
Shaping (
symbol/shaping.ts,symbol/tagged_string.ts): line breaking by least badness, justification, anchor alignment, letter spacing. -
Quads (
symbol/quads.ts) with corner offsets stored at 1/32 precision (symbol_bucket.ts addVertex). -
Anchors (
symbol/symbol_layout.ts addFeature): points, the first vertex of lines, and the pole of inaccessibility of polygons; anchors outside the tile are dropped. -
Placement (
symbol/placement.ts,symbol/collision_index.ts): layers top-down, tiles by (x, y), features by sort key; boxes in a viewport grid padded by 100 px. -
Drawing (
webgl/draw/draw_symbol.ts,symbol_sdf.*.glsl): bilinear SDF sampling, EDGE_GAMMA, one- or two-pass halos. -
Icons (
render/image_atlas.ts,getIconQuads,symbol_icon.*.glsl): premultiplied sprite images with 1 px padding, NEAREST/LINEAR per draw_symbol.ts, SDF icons through the text shader; text/icon placement combined through text-optional / icon-optional. -
Line placement (
symbol_line.rs): merged, clipped lines; anchors by spacing and max angle; collision circles; glyphs placed along the projected line with keep-upright flipping. -
Vertical text (
vertical.rs): point labels withtext-writing-modevertical (upright glyphs, the label turned 90°, tried in the layer’s writing-mode order) and line labels whose line runs vertically (updateLineLabels switches to the vertical shaping).
Structs§
- Glyph
- A glyph as laid out in MapLibre’s atlas: the SDF bitmap (glyph + 3 px border) surrounded by 1 px of zero padding.
- Glyph
Map - Glyphs by font stack (comma-joined, as in the glyph URL) and code point.
- Placement
- Placed symbols per style layer index.
- Shaping
- Sprite
- Sprite
Image - A sprite image as MapLibre stores it in its icon atlas: premultiplied RGBA
(
premultiplyAlpha, Math.round(c * a / 255)) with 1 px of zero padding. - Symbol
Assets - Everything symbol layers need besides the tiles.
- Symbol
Tile - A tile placed on the canvas, as the renderer sees it.
Functions§
- draw_
layer - Draw the placed symbols of one layer: icons for all tiles, then text.
Draw one symbol layer. Placement is in CSS pixels (
cssis the CSS viewport size); quads are drawndprtimes larger. - feature_
fontstack - The comma-joined font stack of a symbol layer for a feature.
- feature_
icon - The icon image name a symbol layer shows for a feature, or None.
- feature_
text - The label text a symbol layer shows for a feature (text-field + tokens + format + text-transform), or None.
- layer_
visible - place
- Run MapLibre’s placement for every visible symbol layer.
- required_
glyph_ ranges - Glyph ranges (font stack, range start) the visible symbol layers need.
- svg_
layer - Write one symbol layer as SVG in draw_layer’s order: icons, then text, each per tile with the shader’s halo passes. Glyphs and SDF icons are outlines traced from their SDFs at the shader’s thresholds, one path per quad (MapLibre blends each quad separately); other icons are embedded sprite images.