Skip to content

UWAL / MSDFFont

Classes

MSDFFont

MSDF font management class, designed exclusively for internal usage.

Constructors

Constructor
ts
new MSDFFont(label?, generated?): MSDFFont;
Parameters
ParameterTypeDefault valueDescription
label?string"MSDFFont"Font label.
generated?booleanfalseWhether the font was generated here.
Returns

MSDFFont

Methods

GetBindGroupLayoutEntries()
ts
static GetBindGroupLayoutEntries(Renderer): BindGroupLayoutEntry[];

Create font layout entries for the MSDFText pipeline layout.

Parameters
ParameterTypeDescription
RendererRenderStageRenderer instance to create layout entries.
Returns

BindGroupLayoutEntry[]

GetCharacter()
ts
GetCharacter(code): Char;

Get character information by its code.

Parameters
ParameterTypeDescription
codenumberCharacter code.
Returns

Char

GetXAdvance()
ts
GetXAdvance(code, nextCode?): number;

Get the distance in pixels the cursor should advance for a given character. If the next character is given, any kerning between the two characters will be taken into account.

Parameters
ParameterTypeDefault valueDescription
codenumberundefinedCharacter code.
nextCode?number-1Next character code.
Returns

number

CreateBindGroupResources()
ts
CreateBindGroupResources(
   Pipeline, 
   url, 
requestOptions?): Promise<Record<string, GPUBindingResource>>;

Load and parse a font from a valid source file and save its characters info into a storage buffer.

Parameters
ParameterTypeDescription
PipelineRenderPipelineInstanceMSDFText pipeline.
urlstringFont source path.
requestOptions?RequestInitfetch request options.
Returns

Promise<Record<string, GPUBindingResource>>

Destroy()
ts
Destroy(): void;

Destroy all page textures.

Returns

void

Accessors

BindGroupResources
Get Signature
ts
get BindGroupResources(): Record<string, GPUBindingResource>;
Throws

ERROR.FONT_RESOURCES_NOT_FOUND if the font has not yet been loaded with MSDFText.LoadFont.

Returns

Record<string, GPUBindingResource>

Font bind group resources.

LineHeight
Get Signature
ts
get LineHeight(): number;
Returns

number

Font line height.

Generated
Get Signature
ts
get Generated(): boolean;
Returns

boolean

Whether the font was generated here.

Released under the MIT License.