Skip to content

Commit ce22087

Browse files
committed
Create Set Font Size.sketchplugin
1 parent 0274ebc commit ce22087

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

Set Font Size.sketchplugin

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Change Selected Layers' Font Size (cmd shift t)
2+
// This plugin will change the font size of all the text layers in the selection.
3+
// If the selection is mixed (i.e: shapes and text layers) only text layers will be
4+
// affected, and the selection will be modified when running the command, so only
5+
// text layers will remain selected after running it.
6+
7+
var textLayers = []
8+
9+
for (var i=0; i < [selection count]; i++) {
10+
var layer = [selection objectAtIndex:i]
11+
if ([layer isKindOfClass:[MSTextLayer class]]) {
12+
textLayers.push(layer)
13+
}
14+
}
15+
16+
if (textLayers.length == 0) {
17+
[doc showMessage:"You need to select at least one text layer"]
18+
} else {
19+
var size = [doc askForUserInput:"Font Size for selected layers?" initialValue:16]
20+
for (var i=0; i < textLayers.length; i++) {
21+
var textLayer = textLayers[i]
22+
[textLayer setFontSize:size]
23+
}
24+
[[doc currentPage] deselectAllLayers]
25+
for(var i=0; i < textLayers.length; i++){
26+
var layer = textLayers[i]
27+
[layer select:true byExpandingSelection:true]
28+
}
29+
}

0 commit comments

Comments
 (0)