Re: scripting font change in TextEdit / NoteTaker, etc
Re: scripting font change in TextEdit / NoteTaker, etc
- Subject: Re: scripting font change in TextEdit / NoteTaker, etc
- From: Martin Crisp <email@hidden>
- Date: Tue, 20 Jul 2004 17:32:48 +1000
- Organization: Tesseract Computing
On Mon, 19 Jul 2004 04:02:30 +1000, Michael Cytrynowicz wrote
(in message
<r02010100-1034-A3BB5AD4D8E411D8A73C000393C49D60@[172.26.0.2):
>
Hi list,
>
>
I thought it would be pretty trivial, but I can't figure how to do it.
>
What I need to do is in TextEdit - and alsi in Notetaker - to be able to
>
change the font of selected text to, say, verdana 10.
Don't have Notetaker, but changing the font of particular parts of
a TextEdit document is trivial. Changing the font of the selection,
however, is basically impossible [unless you can calculate where it
is as a range of characters in the text of the document].
>
In NoteTaker, likewise, I need to be able to select some entries and
>
change them all to say, Georgia 14.
>
>
I can select text in both apps, or select entries in NoteTaker using
>
applescript, but I can't for the life of me figure how to change the
>
font. Seems inaccessible.
>
>
Exploring both dictionaries showed that there is a property font of the
>
fist char in a given run (so is it an rtf thing?)
Don't use the attribute runs, unless you want to specifically deal
with attribute runs [useful under some circumstances, but istm not
your circumstance]. Since a selection may cross attribute run
boundaries it could get messy very quickly.
>
I tried finding a service that would do that - nope.
>
I tried GUI scripting - and I can't figure how (and if) it is possible
>
to target Cocoa Fonts panel with UI Browser. Apparently not.
Nope, I can't find a way to get UI scripting to even see that
dialog/window. But I am not a UI Scripting person... so perhaps
that's just me.
What you can do is use UI Scripting to get the selection onto the
clipboard [save any existing clipboard content sideways so it can
be restored afterwards], an error would indicate no (copyable)
selection. The offset of that text in the text of the document
gives you the position of the first (and perhaps only) occurrence
in the document, giving you a way of referring to that text in the
document for your font/size chage.
How to handle (the potential for) multiple occurrences of the
selected text in the document is something for which I don't see an
obvious solution.
>
What am I missing here? All I need is to change the font from a to b
>
!!!!????
set font of characters n thru m of text of document 1 to "Palatino"
set size of characters p thru q of document 1 to 23
Works for me when n, m, p, & q are integers between 1 and length of
text of document 1.
Have Fun
Martin
_______________________________________________
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.