deleteCharacters
Remove characters in the text from start
(inclusive) to end
(exclusive).
Supported On:
Signature
deleteCharacters(start: number, end: number): void
Remarks
This API allows you to remove characters in a text node while preserving the styles of the existing characters. However, you still need to call figma.loadFontAsync
before using this API.
caution
⚠ Did you know: not all glyphs that you might think as a "character" are actually stored as a single character in JavaScript string? JavaScript strings are UTF-16 encoded. Some characters like "👍" are stored using two characters! Try it in the JavaScript console: "👍".length is 2! The two characters are called "surrogate pairs". Even more mindblowing: some characters are made of multiple emojis. For example, "👨👧", which you should see in your browser as a single character, has length 5. "👨👧".substring(0, 2) is "👨" and "👨👧".substring(3, 5) is "👧".