在Sketch插件脚本中更改新创建的Text图层的字体

时间:2018-12-21 03:59:47

标签: cocoa sketchapp

我一生无法解决如何通过Sketch插件创建文本层和设置字体的问题。我正在关注本文档https://developer.sketchapp.com/reference/api/#font

var Document = require('sketch/dom').Document;
var Text = require('sketch/dom').Text;

export default function (context) {
  const document = sketch.fromNative(context.document)
  const page = document.selectedPage;

  var text = new Text({
    parent: page,
    text: 'blah',
  });

  // THIS DOESNT WORK
  text.font = 'Arial';

}

0 个答案:

没有答案