LynxTextMeasure
Measure how wide a string renders, and where it breaks into lines, before you lay it out. import { LynxTextMeasure } from '@blotch/angular-lynx';
Usage
src/app/label.ts
API
LynxTextMeasure
Measures text with the platform's text engine. On a device, it works on both threads, including in event handlers.
LynxTextMeasure.measure()
Returns the text's width in pixels. With maxWidth and a maxLine above 1, it also returns the text of each line.
- Empty
textreturns{ width: 0 }. - Built-in fonts only. A custom font, from
@font-faceorLynxFont, is measured with the system font instead. - Invalid options, such as a
fontSizeof 0, return{ width: 0 }. - Throws in the web preview and outside Lynx, such as in unit tests, where Lynx's text measuring isn't available.
Types
TextInfo and TextMetrics come from @lynx-js/types.
TextInfo
Other text styles, such as fontWeight and letterSpacing, aren't supported.
