• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Scripting Fontbook
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Scripting Fontbook


  • Subject: Re: Scripting Fontbook
  • From: Neil Faiman <email@hidden>
  • Date: Sun, 27 Jan 2008 18:41:09 -0500

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
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Scripting Fontbook (From: Michael Curtis <email@hidden>)
 >Re: Scripting Fontbook (From: Neil Faiman <email@hidden>)
 >Re: Scripting Fontbook (From: Michael Curtis <email@hidden>)
 >Re: Scripting Fontbook (From: Neil Faiman <email@hidden>)

  • Prev by Date: Re: Scripting Fontbook
  • Next by Date: Re: Re: Is Preview scriptable?
  • Previous by thread: Re: Scripting Fontbook
  • Next by thread: iCal response was rejected by the Apple moderators
  • Index(es):
    • Date
    • Thread