Skip to main content

Font

Class

A font asset used for rendering text.

  • Available on all platforms
Platform details: Snapchat, SPECS, Camera Kit Web, Camera Kit Mobile fully supported.

Platform details

  • Snapchat — Fully supported.

  • SPECS — Fully supported.

  • Camera Kit Web — Fully supported.

  • Camera Kit Mobile — Fully supported.

Index

Example

// Assign a Font to a Label
//@input Component.Label label
//@input Asset.Font font
script.label.fontAsset = script.font;

Extends

Properties

customVariationStyles

customVariationStyles: CustomVariationStyle[]

User-defined variation styles. See CustomVariationStyle. Populated via Font.createVariationStyle. Not applicable to static fonts.

Since

Lens Scripting Version 372

Default Value

[]

isVariableFont

readonly isVariableFont: boolean

Returns true if this font is a variable font.

Since

Lens Scripting Version 372


name

name: string

The name of the Asset in Lens Studio.

Default Value

""

Inherited from

Asset.name


namedInstances

readonly namedInstances: NamedInstanceInfo[]

Named instance info for this font. Empty for static fonts. See NamedInstanceInfo.

Since

Lens Scripting Version 372


uniqueIdentifier

readonly uniqueIdentifier: string

Since

Lens Scripting Version 176

Inherited from

Asset.uniqueIdentifier


variationAxes

readonly variationAxes: VariationAxisInfo[]

Variation axes of this font. Empty for static fonts. See VariationAxisInfo.

Since

Lens Scripting Version 372

Methods

createVariationStyle()

createVariationStyle(name): CustomVariationStyle

Create a new CustomVariationStyle bound to this font, append it to Font.customVariationStyles, and return it. Throws if called on a static font.

name must be non-empty and must not collide (case-, whitespace-, and hyphen-insensitive) with a FontStyles constant (e.g. FontStyles.Bold), a named instance on this font, or an existing custom variation style. Returns null when the name is invalid.

Parameters

ParameterType
namestring

Returns

CustomVariationStyle

Since

Lens Scripting Version 372

Example

//@input Asset.Font fontAsset
//@input Component.Text text
var style = script.fontAsset.createVariationStyle("CustomStyle");
style.weight = 565;
style.GRAD = 14;
script.text.preferredStyle = style.name;

getTypeName()

static getTypeName(): TypeName<Font>

Returns the fully-qualified JavaScript type name for this class (for example, "Component.Camera"). This is a static accessor (no instance required) and returns the same value as the instance getTypeName().

Returns

TypeName<Font>

Overrides

Asset.getTypeName


getTypeName()

getTypeName(): string

Returns the name of this object's type.

Returns

string

Inherited from

Asset.getTypeName


isOfType()

isOfType(type): boolean

Returns true if the object matches or derives from the passed in type.

Parameters

ParameterType
typestring

Returns

boolean

Inherited from

Asset.isOfType


isSame()

isSame(other): boolean

Returns true if this object is the same as other. Useful for checking if two references point to the same thing.

Parameters

ParameterType
otherScriptObject

Returns

boolean

Inherited from

Asset.isSame

See also