Re: Font, size, and color
Re: Font, size, and color
- Subject: Re: Font, size, and color
- From: Graff <email@hidden>
- Date: Wed, 14 Jan 2004 14:44:46 -0500
Yep, that works perfectly. It makes a lot of sense too, I was
wondering why just using the attribute run alone was giving me just the
text of the attribute run.
Thanks!
- Ken
On Jan 14, 2004, at 2:02 PM, <email@hidden> wrote:
tell application "Script Editor"
set theText to a reference to text of the first document
set colorList to the color of every attribute run of theText
set fontList to the font of every attribute run of theText
set sizeList to the font of every attribute run of theText
end tell
This makes three lists of all the properties of the attribute runs.
I suspect the issue you were running up against, is thus: if you try to
set a variable to the text of the first document, it is automatically
coerced into Unicode text, which has no formatting, and thus no
attributes. By retaining the text as a reference, you can get the
properties and elements of Script Editor's native "text" class. This
method also works for the "by integer" syntax you were trying to use.
Additionally, if you try to set a variable to an attribute run, it is
automatically coerced into a Unicode string, so you have to retain any
attribute runs as references in order to get their properties. Mine
works because I always use the attribute runs directly, so it's always
by reference. Your fixed code follows.
tell application "Script Editor"
set documentList to every document whose name is "Untitled 2"
set theText to a reference to text of item 1 in documentList
set thisRun to a reference to attribute run 1 of theText
set theSize to size of thisRun
set theFont to font of thisRun
set theColor to color of character 1 of thisRun
end tell
BJ
On Jan 13, 2004, at 4:52 PM, Graff wrote:
I've been trying to get the font, size of the font, and color of text
in Script Editor.app. I have no problem getting the text of a
document, and I can even break the text down into "attribute runs" but
I've failed every single time I've tried to get the properties of an
attribute run. Here's an example that doesn't work:
------------
tell application "Script Editor"
set documentList to every document whose name is "foo.scpt"
set theText to text of item 1 in documentList
set thisRun to attribute run 1 of theText
set theSize to size of thisRun
set theFont to font of (thisRun as attribute run)
set theColor to color of character 1 of thisRun
end tell
------------
Anyone have any idea on how to do this?
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.