Article View: adobe.scripting.indesign
Article #18755AppleScript font sampler
From: Olav Kvern
Date: Mon, 03 Mar 2003 22:33
Date: Mon, 03 Mar 2003 22:33
70 lines
3228 bytes
3228 bytes
Gang--
Here's an AppleScript that creates a font sampler:
--FontSampler
--This script creates a font sampler from all of the fonts currently available to InDesign.
--Note: Turn off the Show List of Problem Tags Before Place option in the Tagged Text Import Options
--dialog box before you run this script.
set myFile to choose file name with prompt "Save tagged text file as:"
set myFamilyNames to {}
set myStyleNames to {}
tell application "InDesign 2.0.2"
set myFamilyNames to family of fonts
set myStyleNames to style of fonts
end tell
repeat with myCounter from 1 to (count myFamilyNames)
if myCounter = 1 then
my write_to_file("<ASCII-MAC>" & return, myFile, false)
my write_to_file("<Version:2.000000><FeatureSet:InDesign-Roman><ColorTable:=<Black:COLOR:CMYK:Process:0.000000,0.000000,0.000000,1.000000>>" & return, myFile, true)
else
set myString to "<ParaStyle:>Font Family: " & item myCounter of myFamilyNames
set myString to myString & " Font Style: " & item myCounter of myStyleNames & return
set myString to myString & "<ParaStyle:><cFont:" & item myCounter of myFamilyNames & ">"
set myString to myString & "<cTypeface:" & item myCounter of myStyleNames & ">"
--Your example string goes here (for more example strings, use google to search for "pangram"):
set myString to myString & "Sphinx of black quartz, judge my vow!" & return
my write_to_file(myString, myFile, true)
end if
end repeat
set myFileName to (myFile as string)
tell application "InDesign 2.0.2"
set myDocument to make document
tell page 1 of myDocument
set myX to margin left of margin preferences
set myY to margin top of margin preferences
place myFileName place point {myX, myY} with autoflowing
end tell
end tell
--Write to file routine from Apple's AppleScript Guidebook module "Essential subroutines."
on write_to_file(this_data, target_file, append_data)
try
set the target_file to the target_file as text
set the open_target_file to �
open for access file target_file with write permission
if append_data is false then �
set eof of the open_target_file to 0
write (this_data as international text) to the open_target_file starting at eof
close access the open_target_file
return true
on error
try
close access file target_file
end try
return false
end try
end write_to_file
Thanks,
Ole
Technical Details
Message-ID:
<1de81ec4.-1@WebX.la2eafNXanI>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!216.166.71.14.MISMATCH!border3.nntp.aus1.giganews.com!nntp2.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeed.tpinternet.pl!newsfeed01.sul.t-online.de!t-online.de!WebXShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: f939a,dd44ed54ef5511d9,start X-Google-Attributes: gidf939a,public X-Google-ArrivalTime: 2003-03-03 14:38:08 PST From: "Olav Kvern" <okvern@adobe.com> Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!216.166.71.14.MISMATCH!border3.nntp.aus1.giganews.com!nntp2.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeed.tpinternet.pl!newsfeed01.sul.t-online.de!t-online.de!WebX Newsgroups: adobe.scripting.indesign Subject: AppleScript font sampler Message-ID: <1de81ec4.-1@WebX.la2eafNXanI> Date: Mon, 3 Mar 2003 14:33:25 -0800 Lines: 78 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit