| anchorBox | Project one anchor to its screen LabelBox (screen = k·ref + (x,y) + the constant offset). |
| canvasFont | Strip a /line-height token from a CSS font shorthand so it is valid for the canvas font property (which rejects line-height), e.g. "600 11px/1 system-ui" → "600 11px system-ui". |
| cullLabels | Reduce label candidates to a renderable subset: drop anchors outside the viewport (+padding), then place highest-priority first, skipping any whose box collides with an already-placed one. Collision uses each label’s true screen footprint (see labelGeometry) — the box it renders in, oriented labels included — so dense regions thin down to a readable set instead of overprinting (#204), and the survivor of each cluster is the most important label. |
| fontRowHeight | The label row-box height for a font (px size × 1.25, e.g. 11px → 14) — derived from the font string alone, so getting it never costs a measureText call. |
| labelCullScratch | A fresh, empty scratch (buffers grow lazily on first use). Hold one per label layer. |
| labelGeometry | Resolve a LabelBox to its on-screen geometry. Plain labels get an axis-aligned box placed by textAnchor/baseline (default: the historical top-left box); oriented labels (rotation) place the text along the rotated axis, vertically centred on the anchor, with the optional upright flip folded in. The collision corners and the CSS transform come from the same computation, so render and culling stay consistent. |
| labelTextY | The y a backend drawing native text with a "middle" baseline must use — the vertical centre of the same box. Mirrors labelGeometry’s vertical placement (a unit test pins the two against each other), so overlay and native text sit on the same line. |
| labelTransform | The CSS transform that renders a label in the box labelGeometry culls against, applied to an element whose left/top is the anchor (with transform-origin at that point). Derived from the same extents as the box: the element’s left edge must land at x + lx0, i.e. a translate of lx0/width — 0% / −50% / −100% for start / middle / end, and likewise 0% / −50% vertically. Returns "" for the default top-left box, so a caller’s own transform still applies there (back-compatible). |
| measureText | Measure a label’s screen box (CSS px) for collision. font is a canvas font shorthand (no /line-height — strip it first). Width is measured; height is the font size × 1.25 (a consistent row box; 11px → 14, matching the estimates this replaces). |
| placeLabels | Project label anchors to screen px (screen = k·ref + (x,y) + the constant offset) and resolve collisions, returning the survivors as LabelBoxes (carrying text/opacity). Shared by the HTML overlay (LabelLayer.update) and the backend-native text path (#105 N7b-2) so both place and cull labels identically — they differ only in how they render the survivors. |
| resolveLabelStyle | The engine-label styling policy (#224): merge a caller’s inline LabelStyle over DEFAULT_LABEL_STYLE — a partial override keeps the rest — but when a className is given, return only the explicit style (possibly undefined): the class’s CSS keeps full control, since an inline default would beat it. Shared so other engines lift the exact same policy (#223); pass the result as LabelLayer’s style. |
| trimToWidth | Trim text to at most maxWidth px with a trailing ELLIPSIS (#496). widthOf measures a string’s px width. A text that already fits comes back as the same string. Otherwise it is the longest prefix that fits together with the ellipsis (binary search: O(log length) measurements), cut on a whole character (never between the halves of a surrogate pair) and without whitespace before the ellipsis. When not even one character fits it is the ellipsis alone. |