Category Archives: Font Tools

Installing TTX for the command-line challenged

In an earlier post, we showed you how to use TTX, an open source font editor, to rename a font in order to avoid font conflicts. This can be helpful because your operating system and your applications recognize fonts by name and name alone, and on occasion you may need to activate a font which conflicts with an installed system font. So even if you have two very different versions of a font, but they have the same name, the operating system cannot discern between them.

The biggest hurdle for most people, is that TTX is a command line tool, which adds one layer of difficulty, but the method of installation, which is very obvious to those acquainted with Python, is not readily apparent to the technologically challenged. But once the steps are explained, and carefully followed, you will get access to a powerful tool for editing fonts.

Why TTX?

First, TTX is free.

Secondly, when you process your fonts using TTX, there is no behind the scenes mystery to what is happening with the fonts. TTX is a tool to convert OpenType and TrueType fonts to and from XML. You could use tools like FontLab Studio or Fontographer to make changes to your fonts, but it is not always transparent what is happening to your fonts during this process. In short, changes made in those applications may include something you not readily apparent in the processed font. TTX is the least invasive option for those seeking to make simple (and sometimes very complex) changes in your font files.

Getting started

First you will need to have Xcode installed, and a download link to the version you require can be found here. Make sure you download the correct version for your OS, as the development tools for Snow Leopard cannot be installed on Leopard.

Then download TTX. A link to the files needed can be found here. Once downloaded, decompress the file and move the folder to the root level of your hard drive.

Next, launch Terminal, which can be found in the Utilities folder in your Applications folder.

Then at the prompt type “cd” (no quotes) and a space, then drag the fonttools folder onto the Terminal window. Terminal will automatically add the path to the folder, which saves us from possible typing errors. What you entered should look something like the line below:

cd /fonttools-2.3\ 3

If you would like to see a list of the contents of the folder in Terminal, just type “ls” (once again, no quotes) at the prompt, or just open the folder in Finder.

Now in Terminal, type the line below (or copy and paste)

sudo python setup.py install

What this command does is run the installer in the fonttools folder (setup.py). The command “sudo” (pronounced soo-doo) means you are running the command as the superuser, which is a special user account used to administer your Mac (or any Unix/Linux system). Because you are running the command as the superuser, you will be required to enter an administrator password. The item “install” is an option telling the setup script what to do.

After you have the command inserted at the prompt, hit return, then enter your password and hit return again.

If all is well, the Terminal will spit back a bunch of information describing what the script is doing, mainly that it is moving files to the locations needed to run TTX.

You are ready to roll

Once installed, your are ready to run TTX. To find out the options you can use with TTX, just type in “ttx” (still no quotes) in Terminal and it will list them all.

There are a lot of things you can do with TTX, including the post mentioned earlier on how to rename fonts with TTX here.

Hopefully, this article lowered a barrier of entry for those looking to work with TTX. It is a powerful tool, and like all powerful tools, it gives you the capability of really messing things up, so always back up your font files before getting too deep in editing them.

Using TTX to rename fonts

One of the most problematic issues associated with font management is how to manage font conflicts. Font conflicts come about when you activate a font with the same name as a font that is currently activated. If you have seen an alert like the one below you know what I am talking about.

picture-167

Your operating system and your applications recognize fonts by name and name alone. So even if you have two very different versions of a font, but they have the same name, the operating system cannot discern between them.

This font name has nothing to so with the font in question’s file name. If the issue were that easy we could rename fonts in the Finder and the problem would be solved. It just isn’t that easy.

There are tools available that allow you to rename a font, such as FontLab Studio or Fontographer, but those tools can be cost prohibitive and oftentimes might not be worth the investment to make changes on just a handful of fonts.

There is an option in the open source world that can help. FontTools/TTX is a tool that converts OpenType and TrueType fonts to XML and back again. You can download FontTools/TTX here.

FontTools/TTX is a command line tool that once set up can be very easy to use. In our example we are going to use an OpenType version of Helvetica Neue Roman.

picture-172

Ordinarily, activating this font in a third-party font manager would result in an alert that the font conflicts with the Helvetica Neue font that resides in the /System/Library/Fonts/ folder. What we are going to do is change the internal name of the font so it will no longer conflict with the system version of the font and can appear in our font menus, along with the system version of Helvetica Neue.

Since TTX is a command line tool, we will need to launch Terminal, which is found in the Utilities folder in your Applications folder.

Once you launch Terminal, type “ttx” (no quotes) and  space, then drag the font from the Finder into the Terminal window. Terminal will automatically add the path to the font file. The results in in the Terminal will look like the screenshot below:

picture-174

Once the path is added, hit return. TTX dumps the font tables into XML and saves the file in the same folder containing the original font.

picture-175

This new .ttx file can be viewed in any text editor. In our example we are going to use TextEdit.

Once the file is open in TextEdit we need to find the name of the font. The quickest way to find this is to search the document for “fullname” (no quotes). If your search is successful you will find a line like the one below:

picture-176

This is the name of the font as it appears in the font menus.

The next step is to carefully select the font name inside the quotes. Then, we want to replace all the instances of where the previous name is referred to with our own. I opted to annotate the name with two letters “FG,” so the new font will be named “HelveticaNeueFG” and appear in our application’s font menus as such.

In order to do this we use TextEdit’s Find and Replace feature to change every instance of the name as shown in the screenshot below:

picture-177

Once you have entered our search and replace criteria, select “Replace All.”

Note: If your font has a name that would commonly be used in a font file such as “Glyph” or “Asterisk” you may get some unwanted text replacement and possibly produce an unusable .ttx file. In these cases you should manually scroll through the font file and replace the instances where the name listed.

Then save the file. Make sure it is saved as plain text with the extension .ttx. I also opted to change the font file name in order to differentiate the font from the original in the Finder.

picture-178

Because TTX is smart enough to know the difference between a font file and an XML file, we can run the same command we used earlier to convert the XML file to a font. To do this, Open Terminal, type in “ttx” (no quotes) at the prompt with a space, then drag the newly created .ttx file into the Terminal window.

picture-179

TTX converts the XML to a new OpenType font file in the same folder as a .ttx file.

picture-184

The newly created font can be added to one of your system font folders or to a third-party font manager and be activated without conflict.

The font will now also appear in your font menus under it’s new name, as it appears in Adobe InDesign in the screenshot below.

picture-185

While this is not an ideal solution, and there are certain problems that will be created  if you rename fonts in this manner (such as possibly violating the terms of your font license agreement), this is one way to address issues such as one reported in an earlier FontGeek post concerning Snow Leopard, InDesign and Helvetica Neue.

Note: I mentioned earlier in this post that TTX is easy to use once it is installed. I did not have any luck using the binary installer available on the download page and only got the app installed after downloading the source files, running the python install script, then running TTX and moving the files to the locations required on the drive as I ran into error messages. While this was somewhat difficult, I did get it to finally run.

Another Note: Since this article was posted, we have added a new post that guides you through the steps of installing TTX that hopefully will take some of the pain away. That post can be found here.

Scripting FontAgent Pro

One of the least known features about FontAgent Pro 4 is that you can automate it using AppleScript.

fapicon

For those of you unfamiliar with AppleScript, it is an English-like language used to write scripts that automate the actions of your Mac and the applications on it. In short, when you want your applications to start working together, you can turn to AppleScript. It is the lingua franca that helps your programs and you become more productive.

Not all applications will let you use AppleScript, and not many font managers do. FontAgent Pro from Insider Software supports Applescript as does MasterJuggler. Previous versions of Suitcase supported AppleScript, but the current version of Suitcase Fusion 2 does not. FontExplorer X doesn’t either. So if you have a workflow that uses fonts and you want to automate it with scripts, your choices are limited.

How we can use AppleScript

There are lots of things we can automate with FontAgent Pro, but one of the most useful scripts is one that handles the import and activation of fonts by dragging a folder of fonts onto a AppleScript application.

Let me give you an example of how this might be useful:

In the past, I was employed as a pre-press technician. It was common for me to receive many different jobs from many different clients during the day. The fonts (which they usually gathered using a Package or Collect for Output command) that accompanied the project needed to be imported into FontAgent Pro and activated for me to move forward.

So what I did by using AppleScript and FontAgent Pro was create a droplet application where I would drag the folder of files provided by a client (which was named with the job number) and the fonts contained would be automatically imported into a unique library with the same name as the job number. The script would also deactivate all other fonts in my collection, then activate the library I just imported. At that point I would be ready to launch their project in whatever application they used and proceed.

What is provided below is not intended to be a lesson in the basics of AppleScript. There are other much better resources for that sort of thing. If you just want to get the script and start rolling, you can download it here and unzip it on your desktop and you are good to go.

fapdragactivatorimg

The script is provided as is, that means you are using the script at your own risk, and I will not answer emails for support. I am happy to answer any questions you might have and you can reach me at my email, scott@fontgeek.net.

The script

The text for the script is below:

on open these_items
set afolder to these_items
set {name:folderName} to info for afolder
try
tell application “FontAgent Pro”

set DB to default database
tell DB
– this section deactivates all fonts in FAP
set LibList to every library
deactivate fonts LibList
— get the path to where libraries are kept and returned a as a POSIX path
set LibFolder to library path of first library as POSIX file
— build path to new libary
tell application “Finder” to set libpath to POSIX path of (container of folder LibFolder as string) & folderName
end tell
set NL to new library in DB with properties {library name:folderName, library path:libpath}
import fonts afolder options {destination library:NL, activate after importing:true}
end tell
on error the error_message number the error_number
display dialog “Error: ” & the error_number & “. ” & the error_message buttons {”OK”} default button 1
end try
end open

If you copy and paste the text into Script Editor, you may get a syntax error when you attempt to compile the script. This is most likely because the quotation marks in the text are “smart quotation marks” or curly quotes as opposed to the straight “dumb quotation marks.” Just do a find and replace with the dumb quotes and you can edit the script from there.

How to use the script

Simply take a folder of fonts and give it a name. I used a folder created when I packaged an InDesign CS 4 project for output.

fontfolder2

Drag the folder onto the FAPDragActivator icon on your desktop and let the script do its stuff.

folderscript

From the screenshot below, we can see that the fonts were imported into FontAgent Pro (in a library named after the folder) and are indicated active with a green activation sphere. Also notice all the other fonts in the collection are deactivated.

libadded

The fun doesn’t have to stop here. This script can be integrated into a larger script that further automates your workflow. This script could activate the fonts and could hand the document off to InDesign or QuarkXpress to print a soft proof using a preset print setting.

In future posts we will talk more about using AppleScript to automate font related workflows. Stay tuned to FontGeek.

Using ftxvalidator

A few posts ago we talked about Apple Font Tools, ftxinstalled fonts in particular. Apple Font Tools is a suite of command line utilities that can help you with many issues concerning fonts on your Mac. One of the helpful tools included in this suite is ftxvalidator. This tool can be very useful if you have fonts that don’t validate in Font Book or in third-party applications such as FontAgent Pro. ftxvalidator can give you more information on why the font is bad or corrupt, and maybe give you a clue as to what to do to fix the font. So if an application tells you a font is corrupt, and you don’t quite agree, or want to know why, ftxvalidator can offer you the second opinion you want.

Download and Install Apple Font Tools

If you already downloaded Apple Font Tools for the tutorial on ftxinstalled fonts there is no need to download again, and you can skip the install instructions below and proceed to the next section. If this is your first time working with Apple Font Tools, download Apple Font Tools Release 3.1.0 at the link here.

Download the file, unzip it, then double-click on the Apple Font Tool Suite 3.1.0.dmg to open it. Then, double-click on the Apple Font Tool Suite 3.1.0.mpkg and click through the installer.

Since Apple Font Tools are command line based (there are a couple of gui utilities installed as well, but we will visit those later); there is no application you can double-click on to access these tools. You will need to run these tools from Terminal.

Apple Font Tools - ftxvalidator

The utility we are going to look at in this article is ftxvalidator. This powerful tool inspects font files for errors. This tool can be used to examine individual font tables within a file, but here we are going to examine entire fonts which will return information about all the tables ftxvalidator tests for.

Running ftxvalidator

First we need to launch Terminal. This can be found in the Applications/Utilities Folder.

ftxfinderscreensnapz0011

Then at the prompt type “ftxvalidator”, a space, then drag a font file to the terminal window. When you drag a file onto the terminal, it will insert the path to the file. Then hit return.

For example, I use FontAgent Pro to manage fonts. One of the features of FontAgent Pro is that it checks fonts for corruption. When it finds a corrupt font, it sequesters the font file to a folder called Corrupt files in the FontAgent Pro Fonts folder.

Below, I have a screen shot of a file, in this case VT102Font, that has been tucked away in the Corrupt files folder.

newcorruptview

To check this font with ftxvalidator all I need to do is copy the text below and paste it into Terminal.

ftxvalidator

Then drag the font file onto the Terminal window. (You will need to make sure that there is a space after ftxvalidator)

ftxdragtoterminal

Then hit return. The report is in the screenshot below:

ftxvalidatorrepot

From the report we can see that this font had two styles, VT100 Roman and VT100 Bold. Both styles have errors in the cmap table, which suggests a structural problem with the font file. There is also an error in both styles concerning a missing a font table. In this case the glyf table, which is required.

From this report we can see why the font was deemed corrupt by FontAgent Pro. Many times the report can give us information that can suggest a plan of action, but with this font there is little we can do. If fact, this font cannot even be opened with a font editor like FontLab Studio or Fontographer.

Checking More than One Font for Errors

The proceedure above is good for checking one font, but if you want to check a folder of fonts, ftxvalidator can do this too.

First, get a folder of fonts. the type cd into Terminal, and drag the folder into Terminal. This changes the working directory in Terminal to the directory containing the fonts.

Then type (or copy and paste) the text below to the prompt in Terminal.

ftxvalidator *

Note: The asterisk (*) is a wildcard. This means every font in a folder will be checked for errors. If a font does not have any errors ftxvalidator will return the name of the font with no additional information.

If you don’t want to scroll through a Terminal window to search the results of this command, you can save a text file of the report by using the command below:

ftxvalidator * > ~/Desktop/validatorreport.txt

This writes a file named validatorreport.txt to the desktop. This report can be opened in a text editor and you can easily scan it to see if any of the fonts in the folder have errors.

In this article we have taken a look at the validation abilities of ftxvalidator. Stay tuned for future posts that show additional capabilities of Apple Font Tools Suite.

Put all your fonts in a “Smart Folder”

If you are a graphic designer chances are you have been collecting font for years, and these collections can get huge. Chances are they are not neatly organized in one folder. Wouldn’t it be nice if there was a way to gather them all in one location?

Well you can. With Spotlight, the Mac OS X search utility, you can create a Smart Folder where all your fonts can be easily found.

First go to Finder and type Command + f (or select File>Find… from the menu bar). this will open a new Search window. Make sure you have “This Mac” selected in the Search bar so you are searching the whole system.

Spotlight can use regular expressions so if you you type in the line below (or copy and paste), it will find every font on your Mac that Spotlight has indexed.

kind:truetype OR kind:outline OR kind:suitcase OR kind:opentype

spotlightsearch

This returns a list of all your fonts on your machine. Now if you hit the “Save” button, you can give your give your Smart folder a name and Save that. Notice that you can opt to add the Smart Folder to your sidebar where you will have easy access to it every time you launch a window.

savethesearch

This is very cool because not only are your fonts listed in one location, if you are running Leopard, you can select a font, hit the space bar and with Quick Look, get a preview of the font.

previewofspotlitfonts

Then, you can click on the up or down arrow on your keyboard to change the preview to the next font in the list. Depending on the size of your collection, you now have a great way to kill a few hours wistfully going through your fonts, fondly remembering the project where you first used Filosofia, or cringing at the memory of a brochure you created when the client insisted you use Comic Sans.

Are you telling me you haven’t deleted Comic Sans from your collection yet? How embarassing…

Using Apple Font Tools

When troubleshooting font issues on your Mac, there are not very many tools that you can use to get under the hood and examine what the problem might be. Most of the time you are at the mercy of interpreting what might be happening. Sometimes you activate a font, but it does not show in your fonts menu, a font appears in your menus and you don’t remember ever activating it. At that point you are left to go between applications and see if the activation state is consistent between apps. And even then you can’t be sure if it is an application update issue, a cache issue or simply if you have a bad font.

Apple Font Tools

There is a an application (or in this case a suite of applications) that can help. Apple Font Tools is a little known, but extremely powerful set of command line utilities that can help you with may issues concerning fonts on your Mac.

The problem is there are so many things you can do with Apple Font Tools that there is no way to cover them all in a single blog post. I will visit some of the other interesting features of Apple Font Tools in the future, but the first I’d like to take a look at is ftxinstalled fonts.

Download and Install Apple Font Tools

The first thing you will need to do is download is Apple Font Tools Release 3.1.0. The download can be found at the link here.

Download the file, unzip it, then double-click on the Apple Font Tool Suite 3.1.0.dmg to open it. Then, double-click on the Apple Font Tool Suite 3.1.0.mpkg and click through the installer.

Since Apple Font Tools are command line based (there are a couple gui utilities installed as well, but we will visit those later) there is no application you can double-click on to access these tools. You will need to run these tools from Terminal.

Apple Tools - ftxinstalledfonts

The first tool we are going to look at is ftxinstalledfonts. The title of the utility pretty much says it all. It is a utility to see what fonts are installed on your Mac and where the fonts are located. This may sound trivial, but this is a very powerful tool for troubleshooting activation issues.

Running ftxinstalledfonts

Next we need to Launch Terminal. This can be found in the Applications/Utilities Folder.

ftxfinderscreensnapz0011

For those who suffer from command-line jitters, Terminal can be a frightening place and there is no shortage of warnings for those who venture there proceed at extreme peril.

Now it is true you can do some real damage through the command line, but the tool I am going to discuss today is basically a harmless one. In fact, the commands I am going to tell you about you will be able to copy and paste right from this blog entry so you won’t need to worry about typos of the disk erasing, never-ever-ever-recover-your-data variety.

To run ftxinstalledfonts type “ftxinstalledfonts” and then, depending on the output you want, add a number of operands to the command.

For example, if you copy and paste the line below into Terminal and hit return you will be given a list of the active fonts on your Mac.

ftxinstalledfonts -f

Your returned information in the Terminal, depending on the activation state of your fonts, should look something like this below:

ftxinstalledfontsf

The information returned can be somewhat confusing because this command will also list fonts on your system that will never appear in your font menus such as Keyboard or AquaKana. But if you are aware that this can be the case (these fonts are found in the /System/Library/Fonts/ folder and are fonts your OS needs) you can get some really useful information form the output.

Now if we run the command below you will be given a list of the active fonts and their locations.

ftxinstalledfonts -fl

This information is especially valuable if you are using a third-party font manage as it will be easy to determine what fonts are activated by that application and what fonts are active because they are in a system fonts folder.

I use FontAgent Pro to manage my fonts. If, for example, I want to find out what fonts are activated from within FontAgent Pro, I can type the line below and only the fonts activated by FontAgent Pro will be returned.

ftxinstalledfonts -fl | grep FontAgent

Note: The vertical line in the above command is called a “pipe” which takes the results from the first command and feeds it into the next command, in this case grep, which filters all the lines that contain the text “FontAgent.” If you want to learn more about the command command line, just Google “unix command line tutorial” and you will get a bunch of sites that can shepherd you along to command line guru status.

The result appears in the screenshot below:

ftxinstalledfontsfontagent

From this we can determine that I have five fonts activated by FontAgent Pro (highlights mine) and that Terminal allows you to select non-contiguous text to copy and paste (way cool!).

You can also learn additional information about a font. Copy and paste the following command into Terminal:

ftxinstalledfonts -flrq

This will give you a list of all fonts in the system, showing their full name, FOND (QuickDraw) name, version name and directory location.

And if you would like to get a report of active fonts, you can take that the information into a text file and save it to your desktop using the command below.

ftxinstalledfonts -flrq > ~/Desktop/report.txt

ftxinstalled fonts can be used for troubleshooting as well. If you have a font that keeps appearing in your menus, although you never activated it in your font manager, it has to be somewhere. ftxinstalledfonts can tell you where it is.

For example, suppose we have a font appearing in our font menu in Flash named DINEngschrift, but we have not activated it in our font manager. With the command below we can find the location of the font.

ftxinstalledfonts -fl | grep DINEngschrift

After we hit enter we will get the information returned like in the screen shot below.

ftxgrep

As we can see in the highlighted area, the font in question is installed in the home user font folder buried in a folder called “hidden font.”

These are just a couple of uses for ftxinstalled fonts. There are lots of other options you can find out about by reading the documentation and tutorials provided with the Apple Font Tool Suite.

Keep an eye out for future articles where we will discuss some of the uses for the other utilities that come with the Apple Font Tools Suite.