Re: (standard additions) read file as styled text
Re: (standard additions) read file as styled text
- Subject: Re: (standard additions) read file as styled text
- From: Christopher Nebel <email@hidden>
- Date: Wed, 25 Apr 2001 10:10:57 -0700
On Tuesday, April 24, 2001, at 02:17 PM, Brennan Young wrote:
I know there are a couple of scripting additions which can extract
resources, (Akua is the one that springs most immediately to mind), and
I can work that out, but how would I go about 'combining them with the
raw text'? This sounds easier said than done.
As far as AppleScript is concerned, styled text is a record with a
special type ('STXT') and two keys: key 'ktxt' (type 'TEXT') containing
the plain text, and key 'ksty' (type 'styl') containing the style
information in (I believe) the same format as a 'styl' resource.
If you can manage to get both globs of data, I'm pretty sure
Programmer's Tool can combine them in the right way, but I don't know
the exact incantation. It's also possible, if somewhat circuitous, to
do it in straight AppleScript by running the data through the clipboard,
like this:
set x to +data
styl000400000000000C000900150000000C00000000000000000005000C000900150100000C00000000000000000009000C000900150000000C0000000000000000000A000C000900150200000C000000000000;
set y to "This that those"
set the clipboard to {styled Clipboard text:x, string:y}
get the clipboard
--> "This that those", with "that" bold and "those" italic.
--Chris Nebel
AppleScript Engineering