nolastan / sync.sketchplugin

Keep your design team in sync!
http://www.usesync.com/
MIT License
349 stars 15 forks source link

Add support for paragraph spacing #23

Closed patrickhill closed 2 years ago

patrickhill commented 8 years ago

Neither the spreadsheet template or the plugin currently support paragraph spacing.

username1290 commented 8 years ago

Hi, I think that's a Sketch bug

patrickhill commented 8 years ago

Doing some research. I found methods for setLineSpacing and setLineHeight for MSTextLayer. They can't both do the same thing so I'm hoping one of them controls paragraph spacing. Will test soon.

nolastan commented 8 years ago

Getting close. The following works if I have a text layer selected on the canvas. However, if I create a text layer dynamically ([[MSTextLayer alloc] initWithFrame:nil];), it doesn't have a paragraphStyle as part of attributes. So if we can just figure out how to add a paragraphStyle to attributes we should be set.

var layer = context.selection[0];
var paragraphStyle = layer.style().textStyle().attributes().NSParagraphStyle;
paragraphStyle.setParagraphSpacing(20);
mathieudutour commented 7 years ago

you should be able to do layer.paragraphStyle().setParagraphSpacing(20) directly

nolastan commented 7 years ago

@mathieudutour Thanks. I'd expect this to log 99, but it logs 0:

var textLayer = [[MSTextLayer alloc] initWithFrame:nil];
textLayer.paragraphStyle().setParagraphSpacing(99);
log(textLayer.paragraphStyle().paragraphSpacing())
mathieudutour commented 7 years ago

hum weird. Here is what I'm doing: https://github.com/mathieudutour/sketch-module-json-sync/blob/master/src/NS/spacing.js and it seems to work