Skip to main content

Editor.Components.FontStyles

Class

Standard font style names for the preferredStyle property of Editor.Components.Text and Editor.Components.Text3D.

Standard font style names for the preferredStyle property of Editor.Components.Text and Editor.Components.Text3D. Each name maps to a weight and italic pair.

Index

Example

Pick a standard style for a Text component. Leave weight and italic unset: when assigned, they override the matching part of preferredStyle.

type Weight = 'Light' | 'Regular' | 'Bold';

const Styles = Editor.Components.FontStyles;
const STYLE_NAMES: Record<Weight, { upright: string; italic: string }> = {
Light: { upright: Styles.Light, italic: Styles.LightItalic },
Regular: { upright: Styles.Regular, italic: Styles.RegularItalic },
Bold: { upright: Styles.Bold, italic: Styles.BoldItalic },
};

export function createStyledText(
scene: Editor.Assets.Scene,
label: string,
weight: Weight,
italic: boolean,
): Editor.Components.Text {
const text = scene.createSceneObject(label).addComponent('Text');
text.text = label;
const names = STYLE_NAMES[weight];
text.preferredStyle = italic ? names.italic : names.upright;
return text;
}

createStyledText(scene, 'Title', 'Bold', true) sets preferredStyle to "Bold Italic". The caller owns the created scene object.

Properties

Bold

static Bold: string

Style name for bold, non-italic text ("Bold").


BoldItalic

static BoldItalic: string

Bold Italic (weight 700, italic). Value: "Bold Italic".


ExtraBold

static ExtraBold: string

Extra Bold (weight 800). Value: "ExtraBold".


ExtraBoldItalic

static ExtraBoldItalic: string

Extra Bold Italic (weight 800, italic). Value: "ExtraBold Italic".


ExtraLight

static ExtraLight: string

Style name for extra-light, non-italic text ("ExtraLight").


ExtraLightItalic

static ExtraLightItalic: string

Style name for extra-light italic text ("ExtraLight Italic").


Heavy

static Heavy: string

Heavy (weight 900). Value: "Heavy".


HeavyItalic

static HeavyItalic: string

Heavy Italic (weight 900, italic). Value: "Heavy Italic".


Light

static Light: string

Style name for light, non-italic text ("Light").


LightItalic

static LightItalic: string

Style name for light italic text ("Light Italic").


Medium

static Medium: string

Style name for medium, non-italic text ("Medium").


MediumItalic

static MediumItalic: string

Style name for medium italic text ("Medium Italic").


Regular

static Regular: string

Style name for regular, non-italic text ("Regular").


RegularItalic

static RegularItalic: string

Style name for regular italic text ("Regular Italic").


SemiBold

static SemiBold: string

Style name for semi-bold, non-italic text ("SemiBold").


SemiBoldItalic

static SemiBoldItalic: string

Style name for semi-bold italic text ("SemiBold Italic").


Thin

static Thin: string

Style name for thin, non-italic text ("Thin").


ThinItalic

static ThinItalic: string

Style name for thin italic text ("Thin Italic").