1

我正在尝试通过从我的设计令牌中读取的插件来创建 Figma Text 样式。我遇到的问题是在设置自定义字体时,加载它的承诺没有解决,所以它似乎停止了该功能。

我在这里错过了什么吗?

async function createNewTextStyle(token) {
    // Style does not yet exist, so create it
    const newStyle = figma.createTextStyle();

    // the new text style is preloaded with Roboto, so we need to load that
    await figma.loadFontAsync(newStyle.fontName);
    
    // This is the font i want to set my text style to.
    // it seems that this promise never resolves (or errors).
    await figma.loadFontAsync({
        family: 'SF Pro Text',
        style: 'Regular',
    });

// Set the properties of the text style
    newStyle.fontName = {
        family: 'SF Pro Text',
        style: 'Regular',
    };
    newStyle.name = designToken.name;
    newStyle.fontSize = designToken.value;
    newStyle.lineHeight = { value: designToken.lineHeight, unit: 'PIXELS' };
}
4

0 回答 0