Skip to content

Commit

Permalink
Font name starts with
Browse files Browse the repository at this point in the history
implementing recommended change to check for start of font name instead of exact match
  • Loading branch information
vml-rmott committed Oct 7, 2015
1 parent 2754d4b commit 3020517
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Select text using specified font.sketchplugin
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
var doc = doc || context.document,
selection = selection || context.selection

var font_name = [doc askForUserInput:"Font name:" initialValue:"OpenSans"]
var font_name = [doc askForUserInput:"Font name starts with:" initialValue:"OpenSans"]

function check_layer(layer){
var klass = [layer className]
//log("Checking layer " + layer + " of klass: " + klass)
if (klass == "MSTextLayer") {
// This log here will show you all the fonts you use in your document
log("Found text layer w/font: " + [layer fontPostscriptName])
// You might want to change this check here to check if the fontPostscriptName starts with font_name, so you'll catch OpenSans-Bold too, for example
if ([layer fontPostscriptName] == font_name) {
// This checks if the fontPostscriptName starts with font_name, so you'll catch OpenSans-Bold too, for example
if ([layer fontPostscriptName].lastIndexOf(font_name, 0) === 0) {
log(" Selected!")
[layer select:true byExpandingSelection:true]
}
Expand Down

0 comments on commit 3020517

Please sign in to comment.