Hiya cuse
Definitely understand your frustration. Currently its a bit tricky to set a font. This will change soon (if you are curious you can see the changes to font here under the "support for text styles" section). Anywho, if you are looking to do this right now here is an example:
const text = new Text({
text: 'hello',
frame: new Rectangle(10,10,100,100),
parent: document.pages[0].layers[0]
})
var newFont = NSFont.fontWithName_size('Arial', 16)
text.sketchObject.setFont(newFont)
I couldn't seem to get .font
to work. If you look at the documentation it requires an instance of NSFont
in order to set the font. So attempting to set it with a string "Arial"
wouldn't work. However the example below also doesn't work.
var newFont = NSFont.fontWithName_size('Arial', 16)
text.font = newFont
To work around this, there is a useful function called setFont()
on MSTextLayer so I dropped down to use that.