Paint Text To CustomWindow

This is a bit of a conversation from the Supercard list about making text shaped custom windows, I came up with a suggestion on how to do this and Ken Norris commented on the process, making it a lot clearer.
Although it is probably of limited practical use without further work it is an interesting script to experement with covering some scripting of the paint tools and customWindows.

Ken is in bold and I am in blue my second round of comments are in bold green

Here is a text file of the basic script: script

OK, let me see if I get this right, and for the benefit of others looking on. It's fairly generic. Maybe this can serve as a kind of tutorial for converting text to bitmapped graphics.
NOTE: I have haven't used SC's paint tools under script control at all before, and barely at all by hand, so this is great for me!

On Jun 2, 2004, at 9:03 AM, John Johnston wrote:

on mouseUp
repeat until the number of bg grcs = 0
delete bg grc 1
end repeat

===========
Clears all previous grc work
===========

get "John"
===========
I did actually did it with a text string extracted from an editable field.
===========

set editbackground to true
set the textSize to 50
choose paint text tool
set the showFill to false
drag from "0,0" to "500,400"
click at "50,50"
type it

===========
As before. This puts the text onto the screen, but because of the way SC handles text in this venue, it needs some tweaking to correct it for use in a customWindow. The following does this, along with other things, by selecting, cutting, and pasting, which 'filters' it through the clipboard, thus 'normalizing' the bitmapped graphical content.
===========

choose paint select tool

drag from "0,0" to "500,40" with commandKey,optionkey

cut

===========
Cuts horizontally about halfway through the current grc (grc 1). This will leave the top half of the letters open to the background because its bottom is cut away. This means any closed letters, such as O, D, or Q will allow the background in when pasted back to the background.
NOTE: The dividing lines for letters A, P, and especially capital B, and lower case letters; must be calculated to account for their respective enclosed areas.
===========

-- delete last bg grc
===========
Commented out. Don't delete here.
===========

paste objects
===========
Now we have 2 grc's with toplefts in the same place, with grc 2 (top layer) as the background-corrected top half allowing the background to enter what remains of formerly closed letters ("o" in this case) because there is no bottom to close it off.
===========

set the topleft of last bg grc to "0,0"
===========
Moves the top-half, bkgnd-corrected piece, i.e., grc 2 to the topleft
position in the window for customWindow processing.
===========

set name of last bg grc to "structureRgn"
===========
As before. We now have 2 graphics; grc 1 is an _uncorrected_ bottom half in original position, grc 2 is a _corrected_ top half in the topleft position.
===========

drag from "0,0" to "500,500" with commandKey,optionkey
cut

===========
Includes both grc's in their current positions, puts both to clipboard.
I think this only gets the top half we are still using the paint select tool
===========

delete bg grc 1
===========
Deletes the uncorrected version.
===========

paste objects
===========
Puts both grc's in the clipboard into the window. We now have 2 grc's, both top and bottom halves with, corrected bitmaps and open letters with bkgnds allowed into half-cut letters (again "o" on this case). The top half is the oldest and therefore becomes grc 1 and is still in the topleft of the window. The bottom half is newest and thus becomes grc 2, and is still in the original position.
===========

set the left of bg grc 2 to 0
set the top of bg grc 2 to the bottom of bg grc 1

===========
Moves grc 2, the now-corrected bottom half, into position with grc 1, thus connecting the two together.
===========

get max(the right of bg grc 1,the right of bg grc 2)
set the right of bg grc 1 to it
set the right of bg grc 2 to it

===========
Makes both grc's the same size and vertically aligned.
NOTE: There is probably another way to do this which would create properly sized and aligned grc's to begin with, but the insurance is good in this case.
Note 2: this only works for words that the top and bottom have the same length, capital T will mess this up as will L, here is JohnT:


===========
set name of last bg grc to "structureRgn"
===========
For customWindow processing. We now have two bitmap-corrected structureRgn grc's, a top half and a bottom half, positioned and aligned to look like one block of text.

choose browse tool
set editbackground to false

===========
Reset tools and background for cleanup.
===========

set the style of wd 1 to customwindow
wait 3 seconds
set the style of wd 1 to standard
end mouseUp

===========
Temporarily checks the result and switches back to show the button(s) for further script-tweaking as necessary. This, like the rest of it, is just for development purposes.