On Jan 27, 2008, at 5:08 PM, Neil Faiman wrote:
Unfortunately, trying this out, it seems that you can read the "enabled" property of a font family but can't write it ... i.e., it seems as though the property really is read-only, even though it isn't marked in the dictionary.
Further investigation:
You can't set the 'enabled' property of a font family, but you CAN set the enabled property of a typeface (which is the Font Book class name for an individual font in a family). This script enables the Lucida Bright Regular.
tell application "Font Book" set enabled of typeface "lucida bright" to true end tell
However, this
tell application "Font Book" set enabled of (every typeface) to true end tell
seems to go into an infinite loop. (Or maybe it really is taking that long to loop over all the fonts.) After some experimentation, I came up with the following solution:
tell application "Font Book" repeat with f in (every typeface) set enabled of (f) to true delay 1 end repeat end tell
What's the delay for, you ask? Now that's an interesting story. I tried the obvious loop:
tell application "Font Book" repeat with f in (every typeface) set enabled of (f) to true end repeat end tell
but that gives a bizarre result which looks a lot like a Font Book (or AppleScript) bug. Here's the event log:
tell application "Font Book" count every typeface 471 set enabled of item 1 of every typeface to true set enabled of item 2 of every typeface to true current application "Font Book got an error: Can’t set item 2 of every typeface to true."
If I had to guess, I'd say that Font Book is returning control to the script before it actually completes the operation, so that it trips over its own feet when it tries to execute the next operation. But that's just a guess. Anyway, the script above with the delay does appear to do what you want (slowly).
Regards,
Neil Faiman
|