Skip to content
PACKAGES

textMeasurementFacts()

Measure text and package the result as measurement facts.

import { textMeasurementFacts } from "@graphrefly/ts/solutions/reactive-layout";
function textMeasurementFacts(
text: string,
font: string,
adapter: MeasurementAdapter,
cache: Map<string, Map<string, number>>,
segmentAdapter: SegmentAdapter,
targetId: string,
source: string,
): Measurements
ParameterTypeDescription
textstringText to measure.
fontstringFont string to measure with.
adapterMeasurementAdapterMeasurement adapter.
cacheMap<string, Map<string, number>>Shared segment measurement cache.
segmentAdapterSegmentAdapterSegment adapter used for grapheme/word splitting.
targetIdstringMeasurement target id.
sourcestringMeasurement source label.

Measurement facts describing the text segments and hyphen width.

textMeasurementFacts("Hello", "16px sans-serif", adapter, new Map(), segmentAdapter, "title", "demo");

packages/ts/src/solutions/reactive-layout/measurements.ts