Hi
I am wondering if it would be possible to write an applescript to export sample text for every font in a collection in the Font Book application to a TextEdit document, with each sample text on a new line?
If anyone has such a script or could help me get going to write one I’d be grateful,
Thanks,
Nick
Try this…
-- this will find all of the fonts on your computer and show them in TextEdit
-- you will see a font name and then theText in the font's style
set theText to "The quick brown fox jumps over the lazy dog"
set textSize to 12
set titleFont to "Helvetica"
set titleSize to 12
tell application "Font Book"
launch
set theFonts to name of every typeface
quit
end tell
set usedFonts to {}
tell application "TextEdit"
activate
make new document at front
repeat with aFont in theFonts
if (contents of aFont) is not in usedFonts then -- this makes sure we don't present a duplicate
set end of usedFonts to (contents of aFont)
make new paragraph at end of document 1 with data (aFont & ": ") with properties {font:titleFont, size:titleSize}
make new paragraph at end of document 1 with data (theText & return) with properties {font:aFont, size:textSize}
end if
end repeat
end tell
Thanks. For some reason your script locked up my Font Book app. I now have an alternative script that does the job:
tell application "Font Book"
set fontCollectionNames to name of every font collection
set collectionName to item 1 of (choose from list fontCollectionNames with prompt "Choose a font collection")
set fontNames to name of every font family of font collection collectionName
end tell
set exampleText to ""
repeat (count of fontNames) times
set exampleText to exampleText & "This is my example text" & return
end repeat
tell application "TextEdit"
activate
set theDoc to make new document
set text of theDoc to exampleText
repeat with i from 1 to (count of fontNames)
set font of paragraph i of text of theDoc to (item i of fontNames)
end repeat
end tell
Yet another version:
set txt to "easgunkdlijtfy IEQGRJMA ;-=_\"?&$%#@([{</| 01346"
set sze to 20
set text item delimiters to {linefeed, return}
--tell application "Font Book"
-- set l to name of typefaces
-- -- family name of typefaces of font collection "sans"
--end
--set l to do shell script "echo " & quoted form of (l as text) & " | sort | uniq"
--set l to "Arial
--Geneva
--Gill Sans
--Helvetica
--Helvetica Neue
--Myriad Pro
--Trebuchet MS
--Verdana"
set l to text items of l
tell application "TextEdit"
activate
repeat with v in l
make new paragraph at end of document 1 with data (v & tab & txt & linefeed) with properties {font:v, size:sze}
end repeat
end tell