FONTS, FONTS, AND MORE FONTS

For those who are fairly new to the design world of the computer, the list of fonts that become available for applications can be intimidating. Even those who are “old-timers” can use a little help sometimes when it comes to deciding what font to use for that new project.

With your Adobe InDesign application open, you can easily see what a sample of text will look like using a given font. Simply select the text and choosing the font to sample from the font list (Type > Font).

Of course, now that you know how to use scripts, you can have any number of scripts handy to help you with your font decisions and management. The following will give you some ideas.

IN INDESIGN

With a document open, run the following script from within ScriptEditor. A list of the fonts used in the open document will display in ScriptEditor/s Results panel.
Note: the list returned will include your default fonts.

Fonts in documents

tell application "Adobe InDesign CC 2015"
	tell document 1
		set x to name of fonts 
	end tell
end tell

Sample font styles for type family

The following script requires an open InDesign document having Primary Text Frame with the text frame selected. When this script is run, the user is presented a display dialog box in which to supply a name for a font to display. If the string supplied is a valid font, all of its font members are displayed in the open InDesign document.

set defaultStr to "The quick brown fox jumped"
try
	set userFont to getFontName()
	tell application "Adobe InDesign CC 2015"
		tell document 1
			set defaultStyle to applied paragraph style of text defaults
			set properties of defaultStyle to {point size:10, leading:16}
		end tell
		set fontList to name of (every font whose name contains userFont) as list
		if length of fontList = 0 then
			error "No fonts found containing " & userFont
		end if
		set selList to selection
		set selItem to item 1 of selList
		if class of selItem is not text frame then
			error "Requires text frame selection in InDesign document"
		end if
		set str to ""
		
		repeat with i from 1 to length of fontList
			set fName to item i of fontList
			set str to str & fName & return
			set str to str & defaultStr & return
		end repeat
		
		set contents of selItem to str
		tell selItem
			repeat with i from 2 to (count of paragraphs) by 2
				set x to contents of paragraph (i - 1)
				set fontName to text 1 thru -2 of x
				set applied paragraph style of paragraph (i - 1) to defaultStyle
				set properties of paragraph i to {applied font:fontName, point size:16}
			end repeat
		end tell
		
	end tell
on error errStr
	activate
	display alert "Error: " & errStr
end try>
(*Display dialog routine gets string value for font name*)
on getFontName()
	set userResponse to display dialog "Enter name for font" default answer ""
	set fontName to text returned of userResponse
	if fontName = "" then
		error ("Requires font name")
	end if
	return text returned of userResponse
end getFontName

You can copy the script and paste it into a new script in ScriptEditor. You can experiment with the script by running it from within ScriptEditor. When you have a script you want to run from within InDesign, save it to one of the script folders provided by InDesign. You can run the script by double-clicking its name in InDesign’s Scripts panel (Window > Utilities > Scripts). If this is something that you would use often, you might want to give it a keyboard shortcut (Edit > Keyboard Shortcuts).

 result of InDesign script

If you are using a Macintosh, you don’t need to have an InDesign document open to explore your installed font members. You can use an Apple application that is installed on your machine by default: Font Book.

FONT BOOK

If you are not familiar with Font Book, I would suggest that you take a look at this tidy little application. In addition to providing a handy method for installing and deleting fonts, Font Book provides a listing of all your installed fonts. And, when a font is selected from the list, a full-font sampling of all of the font family’s members is displayed.

Font Book display

(Notice the size input box in the top right corner, for setting the size of the text displayed.)

Best of all, Font Book allows you to set up font collections that can be used to display a subset of your fonts based on a given criteria. For instance, I have created collections in Font Book based on style classification, such as Sans Serif, Traditional, Classic, Old Style, and so on. (A collection named Fixed Width is provided by default.) Now, when I want a slab serif font, for instance, I click on the Slab Serif collection in Font Book to see a full-font listing of the fonts in that collection.

And for those who write scripts (Applescript, of course), Font Book is scriptable. In fact, if you have the Script Menu installed for your machine, Apple provides a small collection of Applescript scripts for working with Font Book (see below). One script of mention is Create Font Sample. Select the fonts you want to proof in Font Book and run the script. A sampling of the fonts selected is displayed in TextEdit for comparison.

QUICK AND EASY

If you are looking for a quick and easy way to get a display of type fonts for comparison, you may want to experiment with the script below. It assumes you have set up collections in Font Book. Copy the code into ScriptEditor and save. Install the script in your Script Menu (see below). Now you have a quick and easy way to compare type fonts within a selected collection without having to open Font Book. In fact, you don’t have to open any application, but you do need TextEdit installed on your machine.

set choicePrompt to "choose fonts from list to proof"
try
   collectionName to getCollectionName()
   tell application "System Events"
      set wasTextEditRunning to (name of processes) contains "TextEdit"
   end tell
   set postScriptNames to {}
   set totalFaces to 0
   tell application "Font Book"
      set testCol to font collection collectionName
      set fontList to name of every font family of testCol
      set userChoice to my getUserChoice(fontList, choicePrompt, true)
      set numFamilies to length of userChoice
      repeat while userChoice is not {}
         set thisItem to first item of userChoice
         set familyName to thisItem
         set thisFamily to font family familyName
         set members to typefaces of thisFamily
         set memberList to {}
         repeat with eachMember in members
            if family name of eachMember is familyName then
               set the end of memberList to PostScript name of eachMember
               set totalFaces to totalFaces + 1
            end if
         end repeat
         set end of postScriptNames to {familyName, memberList}
         set userChoice to the rest of userChoice
      end repeat
   end tell
   doDisplay(postScriptNames, wasTextEditRunning, numFamilies, totalFaces)
on error errStr
   activate
   display alert "Error: " & errStr
end try
on doDisplay(postScriptNames, wasTextEditRunning, numFamilies, totalFaces)
tell application "TextEdit"
   if wasTextEditRunning then
      make new document at the end of documents of it
   end if
   tell the front document
      set size to 18
      set paraIndex to 1
      set paragraph paraIndex to "Font Samples - " & numFamilies & " families  " & totalFaces & " total typefaces" & return & return
      set font to "LucidaGrande"
      set size to 14
      set paraIndex to paraIndex + 1
      repeat with i from 1 to length of postScriptNames
         set familyName to item 1 of item i of postScriptNames
         tell paragraph paraIndex
            set font to "LucidaGrande"
            set characters to familyName & return & return & return
         end tell
         set paraIndex to paraIndex + 1
         set theMembers to item 2 of item i of postScriptNames
         set chars to ""
         repeat with j from 1 to length of theMembers
            set psName to item j of theMembers
            tell paragraph paraIndex
               set font to psName
               set characters to tab & psName & return & return
            end tell
            set paraIndex to paraIndex + 1
         end repeat
      end repeat
   end tell
end tell
end doDisplay
(*User chooses collection for fonts*)
on getCollectionName()
   tell application "Font Book"
      set colNames to name of every font collection
   end tell
   set userChoice to choose from list colNames with prompt "Choose font collection" without multiple selections allowed
   if userChoice is false then
      error "User cancelled"
   end if
   return item 1 of userChoice
end getCollectionName
(*User chooses fonts to proof*)
on getUserChoice(theList, choicePrompt, doMulti)
   set userChoice to choose from list theList with prompt choicePrompt multiple selections allowed doMulti
   if userChoice is false then
      error "Selection required"
   end if
   return userChoice
end getUserChoice

For convenience, install the script in Script Menu and run it from there (see below).

When you run the script, it displays a list of your Font Book collections.

Choose collection

When the user selects a collection from the list, a choose from list dialog lists the fonts within the collection.
The user then chooses one or more fonts by selecting items with the Command key held down. Optionally, contiguous items (or all items) can be selected by holding the shift key down while selecting.

Choose fonts

Click on the OK button when fonts are selected: Voila! Almost instantly you have a display of the the fonts in TextEdit.

Font display in TextEdit

ONWARD AND UPWARD

You might want to improve this script by allowing the user to enter a string in a dialog box that will display after the font style name as part of the font display.

APPLESCRIPT SCRIPT MENU

To enable the AppleScript menu on your Macintosh (OS X):

  • If you do not have the Script Editor installed:
    • Open the Applications folder and scroll down to open the Utilities folder
    • Locate Script Editor (AppleScript Editor in older OS X versions)
  • Launch ScriptEditor
  • Select Preferences… from the AppleScript Editor menu.
  • Check Show Script menu in menu bar
  • Check Show Computer scripts

tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.

Enable Script Menu

    You should now have a script icon in your top menu bar.
  • When you click on this icon, a list of scripting folders displays.
  • Click on the listing for Font Book to open its folder.

To install scripts

  • drag your Font Book scripts into this folder.
    (You may be asked to enter your administrator password.)
  • Close the folder and the script menu when done.

To run a script from the script menu:

    • Click on the script menu icon.
    • Continue to hold the mouse down and slide down to select the appropriate script folder (fly-out menu will display).
    • Continue to hold the mouse down and slide across to select the script in the fly-out menu.

That’s it.To edit a script in the script menu:

  • Single click on the appropriate folder for the script in the Script Menu list (this opens the folder).
  • Double-click on the name of the script in the folder. (It should open in Script Editor for editing.)

nec ullamcorper mattis, pulvinar dapibus leo.