Skip to content

1681-engine / ui / CanvasRichFont

Class: CanvasRichFont ​

Defined in: src/ui/rich/richFonts.ts:45

Runs as canvas Text: any font the page has, with bold and italic. Every style used gets one Pixi TextStyle, shared by every run in it. Changing a run's text repaints and uploads its canvas, so text rewritten every frame belongs in a BitmapRichFont.

Implements ​

Constructors ​

Constructor ​

ts
new CanvasRichFont(options): CanvasRichFont;

Defined in: src/ui/rich/richFonts.ts:49

Parameters ​

ParameterType
optionsRichFontOptions

Returns ​

CanvasRichFont

Methods ​

ascent() ​

ts
ascent(style): number;

Defined in: src/ui/rich/richFonts.ts:60

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

Parameters ​

ParameterType
styleRichStyle

Returns ​

number

Implementation of ​

RichFont.ascent


createRun() ​

ts
createRun(): Container;

Defined in: src/ui/rich/richFonts.ts:64

A fresh, empty run.

Returns ​

Container

Implementation of ​

RichFont.createRun


lineHeight() ​

ts
lineHeight(style): number;

Defined in: src/ui/rich/richFonts.ts:56

Height of a line of text in style.

Parameters ​

ParameterType
styleRichStyle

Returns ​

number

Implementation of ​

RichFont.lineHeight


textWidth() ​

ts
textWidth(text, style): number;

Defined in: src/ui/rich/richFonts.ts:51

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

Parameters ​

ParameterType
textstring
styleRichStyle

Returns ​

number

Implementation of ​

RichFont.textWidth


updateRun() ​

ts
updateRun(
   run, 
   text, 
   style
): void;

Defined in: src/ui/rich/richFonts.ts:68

Shows text in style on a run made by createRun; cheap when neither changed.

Parameters ​

ParameterType
runContainer
textstring
styleRichStyle

Returns ​

void

Implementation of ​

RichFont.updateRun

Released under the MIT License.