Skip to main content
Question

table index is out of bounds when use await figma.loadFontAsync(labelText.fontName);


Hay Abados

Hi everyone,

I'm developing a Figma plugin that clones a bar chart component and updates each bar's label dynamically. However, I'm facing two main issues:

  1. "table index is out of bounds" error (WebAssembly crash) when modifying cloned instances.
  2. Font loading issues when setting .characters on text nodes inside each bar.

How My Plugin Works

  • The user selects a chart component (which contains multiple "Bar Elements").
  • The plugin clones the selected instance and adjusts bar heights.
  • Each "Bar Element" contains a label text node inside a "Label Frame".
  • I need to load the font before modifying the label text.
 

 

What I’ve Tried So Far

  1. Checked if nodes exist before modifying them.
  2. Ensured figma.loadFontAsync() runs before updating .characters.
  3. Wrapped barElement.clone() in try...catch to prevent crashes.
  4. Checked fontName before calling loadFontAsync().
  5. Tried moving figma.loadFontAsync() outside the for loop to load it once before modifying text.

Despite these fixes, I still get "table index is out of bounds" errors, but the plugin works good and modifying text nodes as needed, the problem is the errors in the console.
 

Questions for the Community

  • Why is figma.loadFontAsync() still causing errors, even when awaited properly?
  • Could there be an issue with how I’m cloning instances inside a detached parent?
  • Is there a better way to safely modify text in cloned instances?

Would love any insights! Thanks in advance. 

 

0 replies

Be the first to reply!

Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings