Re: Styled text in Panther
Re: Styled text in Panther
- Subject: Re: Styled text in Panther
- From: Walter Ian Kaye <email@hidden>
- Date: Mon, 26 Jan 2004 06:30:10 -0800
At 02:38p +0100 01/26/2004, Brennan didst inscribe upon an electronic papyrus:
You don't need to know what I want to do with this style data afterwards,
suffice to say it will be akin to generating HTML code for formatted text.
It would also be acceptable to read the styled text directly from a file.
If it's saved as SimpleText format, you'd have the TEXT in the data
fork and the styl in the resource fork. Same as ktxt and ksty in an
STXT structure.
TextEdit has this nice 'attribute run' class, but this includes font,
fontsize and color, it omits actual style information (bold, underline
etc.).
I think they expect "real" styles to have separate fonts, though that
rules out combinations like bold+underlined.
Beyond that, there's TexEdit Plus and Style, both of which I trust to do
what they say on the tin,
Tex-Edit Plus is great. :D
I have some ugly old code for generating styled text, involving a
clipboard hack which still works under OSX (astonishing!)
set styleRecord to {styled text:"AppleComputer", style:<<data
styl000200000000000C000C2F8B0100000CFFFF0000000000000005001800182F8B020000
18FFFF0000FFFF>>}
-- hack: use the clipboard to coerce the record to rendered styled text
set oldClipboard to the clipboard
set the clipboard to styleRecord
set myStyledClip to the clipboard
set the clipboard to oldClipboard
return myStyledClip
(watch those chevrons). However I actually want to go the *other* way.
Any ideas?
Hmm. I see (in Jaguar) that I can get a character from a styled text,
and it retains its style. Therefore you could parse its style data
(the last 6 bytes are its color, etc.). Since it could take a while,
you might want to include a time estimate in your script so the user
will know whether to wait or do something else... ;)
-boo
_______________________________________________
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.