Skip to main content

TextBuilder

A builder for the Text item.

Extends GenericItemBuilder

Example

import OBR, { buildText } from "@owlbear-rodeo/sdk";

const item = buildText()
.richText([
{
type: "paragraph",
children: [{ text: "Owlbear Rodeo" }],
},
])
.build();
OBR.scene.items.addItems([item]);

Reference

Methods

text

text(text);

Set the texts text content.

Parameters

NAMETYPEDESCRIPTION
textTextContentThe content of the text

Returns the current builder.


width

width(width);

Set the texts width.

Parameters

NAMETYPEDESCRIPTION
widthTextSizeThe text width

Returns the current builder.


height

height(height);

Set the texts height.

Parameters

NAMETYPEDESCRIPTION
heightTextSizeThe text height

Returns the current builder.


richText

richText(richText);

Set the texts richText.

Parameters

NAMETYPEDESCRIPTION
richTextRichTextThe rich text

Returns the current builder.


plainText

plainText(plainText);

Set the texts plainText.

Parameters

NAMETYPEDESCRIPTION
plainTextstringThe plain text

Returns the current builder.


textType

textType(textType);

Set the texts textType.

Parameters

NAMETYPEDESCRIPTION
textType"PLAIN" | "RICH"The text type

Returns the current builder.


padding

padding(padding);

Set the text styles padding.

Parameters

NAMETYPEDESCRIPTION
paddingnumberThe text padding

Returns the current builder.


fontFamily

fontFamily(fontFamily);

Set the text styles fontFamily.

Parameters

NAMETYPEDESCRIPTION
fontFamilystringThe text font family

Returns the current builder.


fontSize

fontSize(fontSize);

Set the text styles fontSize.

Parameters

NAMETYPEDESCRIPTION
fontSizenumberThe text font size

Returns the current builder.


fontWeight

fontWeight(fontWeight);

Set the text styles fontWeight.

Parameters

NAMETYPEDESCRIPTION
fontWeightnumberThe text font weight

Returns the current builder.


textAlign

textAlign(textAlign);

Set the text styles textAlign.

Parameters

NAMETYPEDESCRIPTION
textAlign"LEFT" | "CENTER" | "RIGHT"The text horizontal alignment

Returns the current builder.


textAlignVertical

textAlignVertical(textAlignVertical);

Set the text styles textAlignVertical.

Parameters

NAMETYPEDESCRIPTION
textAlignVertical"BOTTOM" | "MIDDLE" | "TOP"The text vertical alignment

Returns the current builder.


fillColor

fillColor(fillColor);

Set the text styles fillColor.

Parameters

NAMETYPEDESCRIPTION
fillColorstringThe texts fill color

Returns the current builder.


fillOpacity

fillOpacity(fillOpacity);

Set the text styles fillOpacity.

Parameters

NAMETYPEDESCRIPTION
fillOpacitynumberThe texts fill opacity

Returns the current builder.


strokeColor

strokeColor(strokeColor);

Set the text styles strokeColor.

Parameters

NAMETYPEDESCRIPTION
strokeColorstringThe texts stroke color

Returns the current builder.


strokeOpacity

strokeOpacity(strokeOpacity);

Set the text styles strokeOpacity.

Parameters

NAMETYPEDESCRIPTION
strokeOpacitynumberThe texts stroke opacity

Returns the current builder.


strokeWidth

strokeWidth(strokeWidth);

Set the text styles strokeWidth.

Parameters

NAMETYPEDESCRIPTION
strokeWidthnumberThe texts stroke width

Returns the current builder.


lineHeight

lineHeight(lineHeight);

Set the text styles lineHeight.

Parameters

NAMETYPEDESCRIPTION
lineHeightnumberThe texts line height

Returns the current builder.


build

build();

Returns the final Text item.