Mantis - Squeak
Viewing Issue Advanced Details
1477 Multilingual minor always 07-15-05 22:46 09-12-07 01:46
mzimmerm  
 
normal  
new  
open  
none    
none  
0001477: [BUG][Partial Fix] Paragraph>>asForm
Michael Latta <lattam@mac.com>:

"Image 3.7 current full version.

This method behaves contrary to the example included in the method, and
contrary to my expectation.

The method forces foreground color to black and background to white.
It goes to great lengths to do this to support a ColorForm with 2
colors, except that in the case of a TTCStyle it uses a Form with depth
32. It looks like a clear bug. I have yet to figure out how to create
the form with all transparent pixels. The constructor creates it as
black fill, and using "over" or other rules do not replace it with
Color transparent.

Michael

asForm
    "Answer a Form made up of the bits that represent the receiver's
displayable text."
    | theForm oldBackColor oldForeColor |
    oldBackColor _ backColor.
    oldForeColor _ foreColor.
    textStyle isTTCStyle ifTrue: [
        theForm _ (Form extent: compositionRectangle extent depth: 32)
            offset: offset.
        theForm fill: theForm boundingBox rule: Form erase fillColor: Color
transparent.
    ] ifFalse: [
        theForm _ (ColorForm extent: compositionRectangle extent)
            offset: offset;
            colors: (Array
                with: (backColor == nil ifTrue: [Color transparent] ifFalse:
[backColor])
                with: (foreColor == nil ifTrue: [Color black] ifFalse:
[foreColor])).
        backColor _ Color white.
        foreColor _ Color black.
    ].
    self displayOn: theForm
        at: 0@0
        clippingBox: theForm boundingBox
        rule: Form over
        fillColor: nil.
    backColor _ oldBackColor.
    foreColor _ oldForeColor.
    ^ theForm

"Example:
| p |
p _ 'Abc' asParagraph.
p foregroundColor: Color red backgroundColor: Color black.
p asForm displayOn: Display at: 30@30 rule: Form over""

child of 0006570assigned tim A Mother for font and font test problems 

Notes
(0001812)
mzimmerm   
07-15-05 23:00   
"Boris Gaertner" <Boris.Gaertner@gmx.net>

"> Image 3.7 current full version.
>

> "Example:
> | p |
> p _ 'Abc' asParagraph.
> p foregroundColor: Color red backgroundColor: Color black.
> p asForm displayOn: Display at: 30@30 rule: Form over"
>

This example works both in Morphic and in MVC when
you use StrikeFonts. It does not work when you use
TrueType Fonts. (3.8 gamma 6527) I think it is fair to say
that the example became outdated with the introduction of
support for TrueType fonts. An updated example should
read:

 "example: (coloring needs a StrikeFont)
| p |
p _ 'Abc' asParagraph.
p textStyle: (TextStyle named: 'Accuny').
p foregroundColor: Color red backgroundColor: Color black.
p asForm displayOn: Display at: 30@30 rule: Form over ""