-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1a9c17a
commit d1a5fa6
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Change font | ||
var font_name = [doc askForUserInput:"Font name:" initialValue:"Arial"] | ||
|
||
function check_layer(layer){ | ||
var klass = [layer className] | ||
log("Checking layer " + layer + " of klass: " + klass) | ||
if (klass == "MSTextLayer") { | ||
log("Found text layer!") | ||
layer.setFontPostscriptName(font_name); | ||
} | ||
if ( klass == "MSPage" || klass == "MSLayerGroup" || klass == "MSArtboardGroup" ){ | ||
var sublayers = [layer layers] | ||
log("This is a group/artboard/page with " + [sublayers count] + " sublayers") | ||
for(var i=0; i < [sublayers count]; i++) { | ||
var sublayer = [sublayers objectAtIndex:i] | ||
check_layer(sublayer); | ||
} | ||
} | ||
} | ||
|
||
log("################################################################") | ||
|
||
// Use selection, if any | ||
if(selection && [selection count]){ | ||
for (var i = 0; i < [selection count]; i++) { | ||
check_layer([selection objectAtIndex:i]) | ||
} | ||
} else { | ||
// Otherwise, loop trough pages, artboards & layers | ||
var pages = [doc pages] | ||
for (var i = 0; i < [pages count]; i++) { | ||
var current_page = [pages objectAtIndex:i], | ||
artboards = [current_page artboards] | ||
if ([artboards count]) { | ||
log("Traversing artboards") | ||
for (var i = 0; i < [artboards count]; i++) { | ||
var artboard = [artboards objectAtIndex:i] | ||
check_layer(artboard) | ||
} | ||
} else { | ||
log("Page has no artboards") | ||
check_layer(current_page) | ||
} | ||
} | ||
} |