Skip to content

1681-engine / ui / RichMeasure

Interface: RichMeasure ​

Defined in: src/ui/rich/richLayout.ts:12

Line breaking and placement for RichText, pure: every width and height comes from a RichMeasure the caller hands in, so the same layout runs under node in a test, with a canvas font, or with a bitmap font.

Lines break only at spaces and \n; a word wider than the whole line is broken between letters. Text and icons with no space between them ([icon=coin]50) stay together. Text of one style that ends up side by side on a line is one item, so a paragraph in one colour costs one display object a line.

Methods ​

ascent()? ​

ts
optional ascent(style): number;

Defined in: src/ui/rich/richLayout.ts:18

Baseline from the top of such a line; 0.8 of the line height when not given.

Parameters ​

ParameterType
styleRichStyle

Returns ​

number


iconSize() ​

ts
iconSize(key, frame): object;

Defined in: src/ui/rich/richLayout.ts:20

Size of an icon's frame in texture pixels.

Parameters ​

ParameterType
keystring
framestring | undefined

Returns ​

object

height ​
ts
height: number;
width ​
ts
width: number;

lineHeight() ​

ts
lineHeight(style): number;

Defined in: src/ui/rich/richLayout.ts:16

Height of a line of text in style.

Parameters ​

ParameterType
styleRichStyle

Returns ​

number


textWidth() ​

ts
textWidth(text, style): number;

Defined in: src/ui/rich/richLayout.ts:14

Advance width of text in style (spaces included: they are measured on their own).

Parameters ​

ParameterType
textstring
styleRichStyle

Returns ​

number

Released under the MIT License.