Skip to content

Commit

Permalink
Merge pull request #8 from vml-rmott/patch-1
Browse files Browse the repository at this point in the history
Font name starts-with
  • Loading branch information
bomberstudios committed Oct 8, 2015
2 parents 2754d4b + 3020517 commit f7a24f8
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 f7a24f8

Please sign in to comment.