GraphReFlyTS

API Reference

textMeasurementFacts()

Measure text and package the result as measurement facts.

Import

import { textMeasurementFacts } from "@graphrefly/ts/solutions/reactive-layout";

Signature

function textMeasurementFacts(
	text: string,
	font: string,
	adapter: MeasurementAdapter,
	cache: Map<string, Map<string, number>>,
	segmentAdapter: SegmentAdapter,
	targetId: string,
	source: string,
): Measurements

Parameters

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.

Returns

Measurement facts describing the text segments and hyphen width.

Example

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

Source

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