API reference
@searsuite/sear-render-metrics
Platform-neutral text shaping and glyph measurement contracts.
16 exportsderived from source
- classRenderContextTextShapersource ↗
-
class RenderContextTextShaper extends TextShaperPortable fallback backed by the host's render-neutral text measurements.
constructorconstructor RenderContextTextShaper(context: RenderContext): RenderContextTextShapercontext: RenderContext
- classTextMeasurementManagersource ↗
-
class TextMeasurementManagerOwns reusable semantic text measurements for one editor runtime.
constructorconstructor TextMeasurementManager(textShaper: TextShaper): TextMeasurementManagertextShaper: TextShaper
propertysymbolstatic readonly symbol: typeof symbolDI token for resolving the editor-local text measurement manager.
methodclear clear(): voidClears semantic measurements without taking ownership of the text shaper.
methodmeasureSpace measureSpace(font: string): TextShapeResultMeasures one space for a font and reuses the editor-local result.
font: string
- classTextShapersource ↗
-
class TextShaperAbstract adapter boundary for HarfBuzz, Skia, browser-native, or platform text-shaping implementations.
Concrete adapters translate the normalized request to their shaping library and return engine-neutral glyph/cluster data.
constructorconstructor TextShaper(): TextShaperpropertysymbolstatic readonly symbol: symbolDI token for resolving the editor-local text-shaper provider.
methodclearCache clearCache(): voidClears all cached shaping results owned by this adapter.
methodshape shape(input: TextShapeInput): TextShapeResultShapes one homogeneous text run, reusing an identical cached request.
input: TextShapeInput
- classWebTextShapersource ↗
-
class WebTextShaper extends TextShaperBrowser-native TextShaper backed by Canvas2D.
Canvas2D preserves the browser's native shaping for complete text runs but does not expose glyph ids or glyph ranges. Results therefore contain grapheme clusters and caret measurements while leaving
glyphsempty. CallclearCache()after an asynchronously loaded font becomes available.constructorconstructor WebTextShaper(context: WebTextShaperContext): WebTextShaperCreates a Web text shaper over a host-owned Canvas2D context.
context: WebTextShaperContext
- classWebTextShaperErrorsource ↗
-
class WebTextShaperError extends SearErrorError raised when a Web text-shaping request cannot be represented by Canvas2D.
constructorconstructor WebTextShaperError(message: string, details?: SearErrorDetails): WebTextShaperErrorCreates a Web text-shaper error with stable diagnostics.
message: stringdetails: SearErrorDetails
propertycode readonly code: "WEB_TEXT_SHAPER_ERROR"Stable machine-readable identifier for this error category.
Inherited members 9
Inherited from SearError.
- interfaceFontDescriptorInputsource ↗
-
interface FontDescriptorInputStructured font values supplied by editor configuration and host contexts.
propertyfontFamily readonly fontFamily: stringpropertyfontSize readonly fontSize: number - interfaceShapedCaretStopsource ↗
-
interface ShapedCaretStopA logical caret boundary produced by the shaping implementation.
propertytextOffset readonly textOffset: numberUTF-16 source-text offset for this caret boundary.
propertyx readonly x: numberAdvance position in the shaped run's logical direction.
- interfaceShapedGlyphsource ↗
-
interface ShapedGlyphOne positioned glyph returned by a text-shaping implementation.
propertycluster readonly cluster: numberUTF-16 offset of the source text cluster represented by this glyph.
propertyglyphId readonly glyphId: numberpropertyxAdvance readonly xAdvance: numberpropertyxOffset readonly xOffset: numberpropertyyAdvance readonly yAdvance: numberpropertyyOffset readonly yOffset: number - interfaceShapedTextClustersource ↗
-
interface ShapedTextClusterMapping between source text and the glyph range generated for it.
propertyglyphEnd readonly glyphEnd: numberpropertyglyphStart readonly glyphStart: numberpropertytextEnd readonly textEnd: numberpropertytextStart readonly textStart: number - interfaceTextShapeInputsource ↗
-
interface TextShapeInputInput passed to a text-shaper implementation. Offsets are UTF-16 offsets.
propertydirection readonly direction?: TextShapeDirectionpropertyfeatures readonly features?: Readonly<Record<string, TextShapeFeatureValue>>Explicit OpenType feature settings, for example
{ liga: true, kern: true }.propertyfont readonly font: stringFont descriptor understood by the selected shaping implementation.
propertylanguage readonly language?: stringISO/BCP language tag, when known.
propertyscript readonly script?: stringOpenType script tag, when known.
propertytext readonly text: stringpropertyvariations readonly variations?: Readonly<Record<string, number>>Variation-axis values for variable fonts, keyed by four-character axis tag.
- interfaceTextShapeResultsource ↗
-
interface TextShapeResultEngine-neutral result of shaping one homogeneous text run.
propertycaretStops readonly caretStops: readonly ShapedCaretStop[]propertyclusters readonly clusters: readonly ShapedTextCluster[]propertyfontAscent readonly fontAscent?: numberpropertyfontDescent readonly fontDescent?: numberpropertyfontLineGap readonly fontLineGap?: numberpropertyglyphs readonly glyphs: readonly ShapedGlyph[]propertyheight readonly height: numberTotal vertical advance, normally zero for horizontal text.
propertywidth readonly width: numberTotal horizontal advance of the shaped run.
- interfaceWebTextShaperContextsource ↗
-
interface WebTextShaperContextNative text settings and operations required by the Web adapter.
propertydirection direction: CanvasDirectionpropertyfont font: stringpropertyfontKerning fontKerning?: CanvasFontKerningmethodmeasureText measureText(text: string): TextMetricstext: string
methodrestore restore(): voidmethodsave save(): void - typeTextShapeDirectionsource ↗
-
type TextShapeDirection = "ltr" | "rtl"Direction of a shaped text run in logical document order.
- typeTextShapeFeatureValuesource ↗
-
type TextShapeFeatureValue = boolean | numberOpenType feature value accepted by a text-shaper adapter.
- functioncreateFontDescriptorsource ↗
-
createFontDescriptor(input: FontDescriptorInput): stringCreates the low-level font descriptor consumed by text shaping and rendering.
input: FontDescriptorInput
- functioncreateWebTextShaperContextsource ↗
-
createWebTextShaperContext(renderContext: RenderContext): WebTextShaperContextAdapts the shared render context to the Web shaper contract.
renderContext: RenderContext
No public exports match that search.