Re: Font book scripts in 10.8.x? Is this another sandboxing issue?
Re: Font book scripts in 10.8.x? Is this another sandboxing issue?
- Subject: Re: Font book scripts in 10.8.x? Is this another sandboxing issue?
- From: Alex Zavatone <email@hidden>
- Date: Wed, 21 Aug 2013 16:23:05 -0400
Actually, it doesn't.
It does select the All Fonts collection.
It does not select all the fonts within that collection.
Open up Font Book on 10.8.x and make sure nothing is selected. Press Command A.
All items are selected under Collection.
Open up Font Book on 10.6.x and make sure nothing is selected. Press Command A.
All fonts under fonts are selected.
The lines of code are:
set selectedFamilies to selected font families
set selectedTypefaces to selection
The fonts aren't selected under 10.8.x, so this can't work unless the code is changed, or you have manually selected all the fonts first.
On Aug 21, 2013, at 3:26 PM, Nigel Garvey wrote:
> Alex Zavatone wrote on Tue, 20 Aug 2013 16:09:01 +0000 (GMT):
>
>> I just had to use a temp Mac for a while and while trying to run the
> Create
>> Font Sample font book script under 10.8.x, When it completes, it
> displays
>> this in TextEdit:
>>
>> Font Samples - 0 families 0 typefaces
>>
>> Things like this are really frustrating when using a new version of the
> OS,
>> because they used to work in the older one, and it wastes people's time.
>
> As Yvan's already pointed out, the script does work in 10.8.x, provided
> you're expecting it to do what it does: create a TextEdit document
> containing examples of fonts currently selected in FontBook. But there's
> nothing in the comments to tell you this and the script itself is
> somewhat inefficient, contains nested 'tells' to different applications,
> etc. A typical example script! ;)
>
> If your time's at a premium, this version's faster:
>
> -- Creates a TextEdit document ahowing examples of the font(s) selected in FontBook.
> on main()
> script o
> property allIDs : missing value
> property allFamilyNames : missing value
> property allPSNames : missing value
> property selectedTypefaces : missing value
> end script
>
> tell application "System Events"
> set wasTextEditRunning to (name of application processes contains "TextEdit")
> end tell
>
> tell application "Font Book"
> set {o's allIDs, o's allFamilyNames, o's allPSNames} to {ID, family name, PostScript name} of typefaces
> set totalFaces to (count o's allIDs)
>
> set numFamilies to (count selected font families)
> set o's selectedTypefaces to selection
> set numFaces to count o's selectedTypefaces
> end tell
>
> tell application "TextEdit"
> if (wasTextEditRunning) then
> make new document at the end of documents of it
> end if
> tell the front document
> make new paragraph at end of paragraphs with data "Font Samples - " & ¬
> numFamilies & " families " & ¬
> numFaces & " typefaces" & return & return with properties {size:18}
> end tell
> end tell
>
> -- asuuming that items in selection are sorted in font family.
>
> set currentFamilyName to ""
> repeat with i from 1 to numFaces
> tell application "Font Book"
> set thisID to ID of item i of o's selectedTypefaces
> end tell
>
> repeat with j from 1 to totalFaces
> if item j of o's allIDs is thisID then exit repeat
> end repeat
>
> set familyName to item j of o's allFamilyNames
> set psName to item j of o's allPSNames
>
> if (familyName is not currentFamilyName) then
> set currentFamilyName to familyName
> tell the front document of application "TextEdit"
> if (j is 1) then
> make new paragraph at end of paragraphs with data familyName & return with properties {font:"LucidaGrande", size:14}
> else
> make new paragraph at end of paragraphs with data return & familyName & return with properties {font:"LucidaGrande", size:14}
> set size of paragraph -2 to 12
> end if
> end tell
> end if
> try
> tell the front document of application "TextEdit"
> make new paragraph at end of paragraphs with data tab & psName & return with properties {font:psName, size:12}
> end tell
> end try
>
> end repeat
> tell application "TextEdit" to activate
> end main
>
> main()
>
>
> NG
>
>
> _______________________________________________
> 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
_______________________________________________
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