DekGenius.com
[ Team LiB ] Previous Section Next Section

13.6 Styled Text

A style is an attribute of text, such as its font and size, whether it's underlined, that sort of thing. AppleScript defines a styled text class, but you can't manipulate it in any interesting way; in fact, you can barely even detect that it exists, because if you happen to encounter one and ask for its class, you're told it's a string. So you may as well treat it as such.

The styled text class isn't much used; most applications that provide scriptable text styling use a more sophisticated class that lets you access and manipulate the style information. Nevertheless, you might encounter styled text from time to time, especially when retrieving text data from the clipboard. You can detect that this has happened by coercing the text to a record, like so:

tell application "Finder"
        activate
        set x to (the clipboard)
end tell
x as record
-- {«class ktxt»:"test", ¬
«class ksty»:«data styl000100000000000D000A00100000000C000000000000»}

As you can see, the string is actually made up of text information and style information. But the text information is all that AppleScript is normally willing to show you.

    [ Team LiB ] Previous Section Next Section