RichText
Constructors
Constructs a RichText object from strings and RichTextSymbol. Strings can
include newlines, which are handled by the Text component. Subsequent
string items will be concatenated together.
const rich = RichText("Before ", RichTextSymbol("https://..."), " after");
const lines = MyFont.render(rich);
// Result: Array<{ geometry: Group; advanceX: number; warning: string | undefined; }>
argsunknown[]Strings, RichTextSymbol, and RichTextGlyph to be rendered together.
Properties
Array of strings, RichTextSymbol, and RichTextGlyph.
String length of all of the items, with each symbol counting as one character.
Methods
Append an item to the end of the items. If the item to append and the last item are both strings, they are combined.
item(string | RichTextGlyph | RichTextSymbol)Returns this RichText object, with modified items.
Returns a copy of this RichText with all items cloned.
Concatinates subsequent string items together.
Returns this RichText object, with modified items.
richText(string | RichText)Returns true if the RichText items are all equal, false otherwise.
First item gets leading whitespace removed. Last item gets trailing whitespace removed.
Returns a new RichText object, without modifying the original.
First item gets leading whitespace removed.
Returns a new RichText object, without modifying the original.
Last item gets trailing whitespace removed.
Returns a new RichText object, without modifying the original.
Makes a clone with all string items lowercase.
Returns a new RichText object, without modifying the original.
Makes a clone with all string items uppercase.
Returns a new RichText object, without modifying the original.
Makes a clone with all string items lowercase, taking into account the host environment's current locale.
locales(string | string[])Returns a new RichText object, without modifying the original.
Makes a clone with all string items uppercase, taking into account the host environment's current locale.
locales(string | string[])Returns a new RichText object, without modifying the original.
indexnumberThe zero-based index of the desired character within the items.
Returns the Unicode value of the character at the specified location. If there is no character at the specified index, NaN is returned.
Returns a portion of this RichText`, from the start to the end index, including symbols.
startnumberendnumberReturns a new RichText object, without modifying the original.
Returns a portion of this RichText, starting at the specified index and
extending for a given number of characters and symbols afterwards.
startnumberlengthnumberReturns a new RichText object, without modifying the original.
indexnumberReturns a new RichText object, containing the indexed character or
symbol.
Replaces text in the items, using a regular expression or search string.
searchValue(string | RegExp)replaceValuestringReturns a new RichText object, without modifying the original.
Returns items joined into one string, with RichTextSymbols represented as underscore.
Split a RichText items into multiple RichText using the specified
separator string.
separator(string | RegExp)Returns an array of RichText objects
searchStringstringThe characters to be searched for at the start of the RichText.
positionnumberOptional. The start position at which searchString is expected to be found (the index of searchString's first character). Defaults to 0.
Returns boolean true if the RichText starts with the specified string.
RichTextSymbols are represented as underscore.
searchStringstringThe characters to be searched for at the end of the RichText.
positionnumberOptional. The end position at which searchString is expected to be found (the index of searchString's last character plus 1). Defaults to this.length.
Returns boolean true if the RichText ends with the specified string.
RichTextSymbols are represented as underscore.
Collection of strings,
RichTextSymbol, andRichTextGlyphthat are rendered together. Attempts to be compatible with JavaScript'sStringclass.