Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing text spacing properties #51

Closed
Nealo opened this issue May 12, 2017 · 1 comment
Closed

Changing text spacing properties #51

Nealo opened this issue May 12, 2017 · 1 comment

Comments

@Nealo
Copy link

Nealo commented May 12, 2017

I'm trying to change the line spacing on some API generated text. There doesn't seem to be a way to do it with current JS API, but is there a way to add it using the old API?

var text = group.newText({alignment: NSTextAlignmentCenter, text:copy, fixedWidth: true, font: NSFont.fontWithName_size_("Gotham HTF Book", 68.5)})

After looking at the code for the Sketch Set Line Height plugin, I tried using text.lineHeight() and text.setLineHeight() to no success. They come back saying those functions do not exist.

Any ideas? If there's a way to do it we can see about adding it to the JS API

@robintindale
Copy link
Contributor

robintindale commented May 15, 2017

if you want to use old API calls on a new API object, you need to use sketchObject e.g.

var sketch = context.api();
var document = sketch.selectedDocument
var page = document.selectedPage
var layer = page.newText({alignment: NSTextAlignmentCenter, systemFontSize: 36, text:"Hello World"})
layer.sketchObject.setLineHeight(50)

http://www.sketchplugins.com is the official forum for plugin dev questions, although I guess this issue is also a request to add something to the new API (but there is a lot missing :p)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants