VectorTextBuilder
ClassA mutable builder for an immutable VectorText run.
- Snapchat: not supported
- SPECS: fully supported
- Camera Kit Web: not supported
- Camera Kit Mobile: not supported
- SnapchatNot supported — Available on SPECS only
- SPECSFully supported
- Camera Kit WebNot supported — Available on SPECS only
- Camera Kit MobileNot supported — Available on SPECS only
Since Lens Scripting v374
A mutable builder for an immutable VectorText run. Start one with
VectorTextBuilder.create, optionally refine with
VectorTextBuilder#setWeight, VectorTextBuilder#setItalic,
VectorTextBuilder#setLetterSpacing, and VectorTextBuilder#setHorizontalAlignment,
then call VectorTextBuilder#build to produce the text run. The builder
remains usable after build(). The font is the composite's font source (see
VectorCompositeBuilder#setFontSource), not a per-run family.
Index
Example
var tb = VectorTextBuilder.create("Hello", 48);
tb.setWeight(700);
tb.setHorizontalAlignment(HorizontalAlignment.Center);
var text = tb.build();
Extends
Methods
build()
build():
VectorText
SPECS
Returns a new immutable VectorText that snapshots the current builder state. The builder remains usable afterward; the returned text run is an independent snapshot.
Returns
Since
Lens Scripting Version 374
create()
staticcreate(text,size):VectorTextBuilder
SPECS
Creates a builder for a text run with the given text content and font
size. Throws if size is not greater than 0, or if size is not finite.
Parameters
| Parameter | Type | Description |
|---|---|---|
text | string | The text content (String). |
size | number | The font size (Number, must be > 0), in canvas pixels. |
Returns
VectorTextBuilder
Since
Lens Scripting Version 374
getTypeName()
staticgetTypeName():TypeName<VectorTextBuilder>
SPECS
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<VectorTextBuilder>
Since
Lens Scripting Version 374
Overrides
getTypeName()
getTypeName():
string
Returns the name of this object's type.
Returns
string
Inherited from
isOfType()
isOfType(
type):boolean
Returns true if the object matches or derives from the passed in type.
Parameters
| Parameter | Type |
|---|---|
type | string |
Returns
boolean
Inherited from
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
| Parameter | Type |
|---|---|
other | ScriptObject |
Returns
boolean
Inherited from
setHorizontalAlignment()
setHorizontalAlignment(
horizontalAlignment):void
SPECS
Sets the HorizontalAlignment — where this run sits relative to its baseline position. Defaults to Left (the SVG start default).
Parameters
| Parameter | Type | Description |
|---|---|---|
horizontalAlignment | HorizontalAlignment | The horizontal anchor. |
Returns
void
Since
Lens Scripting Version 374
setItalic()
setItalic(
italic):void
SPECS
Sets whether the run is italicized. Defaults to false.
Parameters
| Parameter | Type | Description |
|---|---|---|
italic | boolean | Whether the run is italicized (Boolean). |
Returns
void
Since
Lens Scripting Version 374
setLetterSpacing()
setLetterSpacing(
spacing):void
SPECS
Sets additional spacing between characters, in canvas pixels. Must be
finite. Defaults to 0. Throws if spacing is not finite.
Parameters
| Parameter | Type | Description |
|---|---|---|
spacing | number | The letter spacing (Number, finite). |
Returns
void
Since
Lens Scripting Version 374
setWeight()
setWeight(
weight):void
SPECS
Sets the font weight. Must be between 100 and 900, inclusive. Defaults to
400 (normal). Throws if weight is outside [100, 900].
Parameters
| Parameter | Type | Description |
|---|---|---|
weight | number | The font weight (Number, must be in [100, 900]). |
Returns
void
Since
Lens Scripting Version 374