Skip to content

Commit

Permalink
Added support for new symbols. Closes #10
Browse files Browse the repository at this point in the history
  • Loading branch information
bomberstudios authored Jun 20, 2016
1 parent da22d1e commit 14e878d
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions Replace Font.sketchplugin
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@ var font_name = [doc askForUserInput:"Font name:" initialValue:"Arial"]

function check_layer(layer){
var klass = [layer className]
log("Checking layer " + layer + " of klass: " + klass)
// log("Checking layer " + layer + " of klass: " + klass)
if (klass == "MSTextLayer") {
log("Found text layer!")
layer.setFontPostscriptName(font_name);
// log("Found text layer!")
var font = NSFont.fontWithName_size(font_name, layer.fontSize())
layer.setFont(font)
layer.syncTextStyleAttributes()
layer.adjustFrameToFit()
}
if ( klass == "MSPage" || klass == "MSLayerGroup" || klass == "MSArtboardGroup" ){
if ( klass == "MSPage" || klass == "MSLayerGroup" || klass == "MSArtboardGroup" || klass == "MSSymbolMaster" || klass == "MSSymbolInstance"){
var sublayers = [layer layers]
log("This is a group/artboard/page with " + [sublayers count] + " sublayers")
// 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);
Expand Down Expand Up @@ -46,5 +49,11 @@ if(selection && [selection count]){
log("Page has no artboards")
check_layer(current_page)
}
// Also traverse layers not on an artboard:
var layers = current_page.layers()
for (var l=0; l < [layers count]; l++) {
var currentLayer = [layers objectAtIndex:l]
check_layer(currentLayer)
}
}
}

0 comments on commit 14e878d

Please sign in to comment.