many changes but still buggy ?
authorMichael Beyl <mb@exept.de>
Wed, 24 Jul 2002 20:04:33 +0200
changeset 3671 72a56e3c744a
parent 3670 f61f690d281c
child 3672 d627bfa7b9a2
many changes but still buggy ?
CompoundFont.st
--- a/CompoundFont.st	Wed Jul 24 20:03:27 2002 +0200
+++ b/CompoundFont.st	Wed Jul 24 20:04:33 2002 +0200
@@ -116,6 +116,23 @@
     top open.
                                                                         [exEnd]
 
+                                                                        [exBegin]
+    |font font2 top list|
+
+    font := CompoundFont basedOn:(Font family:'courier' size:18).
+    font2 := Font family:'times' size:24.
+
+    #($a $e $i $o $u $j) do:[:char |
+        font glyphAt:char putFont:font2.
+        font glyphAt:char asUppercase putFont:font2.
+    ].
+    top := ScrollableView forView:(list := EditTextView new).
+    list font:font.
+    list list:#('hello' 'abcdefghijklmnopqrstuvwxyz' 'xyz'
+                'HELLO' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'XYZ').
+    top extent:200@200.
+    top open.
+                                                                        [exEnd]
 
     a mixed font; the dollar character is replaced by the european
     EURO symbol; the rest is helvetica
@@ -218,22 +235,37 @@
     self 
         substringPartsOf:aString from:index1 to:index2 
         do:[:s :i1 :i2 :font |
+            |wString|
+
+            wString := font widthOf:aString from:i1 to:i2.
+            opaque ifTrue:[
+                (font maxAscent < maxAscent 
+                or:[font maxDescent < maxDescent]) 
+                ifTrue:[       
+                    aGC 
+                        fillRectangleX:x 
+                        y:y-maxAscent+1      
+                        width:wString 
+                        height:maxAscent+maxDescent 
+                        color:aGC backgroundPaint.
+                ].
+            ].
             font displayString:s from:i1 to:i2 x:x y:y in:aGC opaque:opaque.
-            x := x + (font widthOf:aString from:i1 to:i2).
+            x := x + wString.
         ].
 ! !
 
 !CompoundFont methodsFor:'private'!
 
 computeMaxBounds
-    maxAscent := baseFont ascent.
-    maxDescent := baseFont descent.
-    maxHeight := baseFont height.
+    maxAscent := baseFont maxAscent.
+    maxDescent := baseFont maxDescent.
+    maxHeight := baseFont maxHeight.
     characterToFontMapping notNil ifTrue:[
         characterToFontMapping keysAndValuesDo:[:char :aFont |
-            maxAscent := maxAscent max:aFont ascent.
-            maxDescent := maxDescent max:aFont descent.
-            maxHeight := maxHeight max:aFont height.
+            maxAscent := maxAscent max:aFont maxAscent.
+            maxDescent := maxDescent max:aFont maxDescent.
+            maxHeight := maxHeight max:aFont maxHeight.
         ]
     ].
 !
@@ -285,17 +317,11 @@
 !CompoundFont methodsFor:'queries'!
 
 ascent
-    maxAscent isNil ifTrue:[
-        self computeMaxBounds
-    ].
-    ^ maxAscent
+    ^ self maxAscent
 !
 
 descent
-    maxDescent isNil ifTrue:[
-        self computeMaxBounds
-    ].
-    ^ maxDescent
+    ^ self maxDescent
 !
 
 height
@@ -322,11 +348,17 @@
 !
 
 maxAscent
-    ^ self ascent
+    maxAscent isNil ifTrue:[
+        self computeMaxBounds
+    ].
+    ^ maxAscent
 !
 
 maxDescent
-    ^ self descent
+    maxDescent isNil ifTrue:[
+        self computeMaxBounds
+    ].
+    ^ maxDescent
 !
 
 onDevice:aDevice
@@ -369,5 +401,5 @@
 !CompoundFont class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/CompoundFont.st,v 1.6 2002-07-24 13:43:38 mb Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/CompoundFont.st,v 1.7 2002-07-24 18:04:33 mb Exp $'
 ! !