--- a/CompoundFont.st Tue Jul 23 19:22:33 2002 +0200
+++ b/CompoundFont.st Tue Jul 23 21:33:48 2002 +0200
@@ -28,10 +28,11 @@
"{ Package: 'stx:libview' }"
FontDescription subclass:#CompoundFont
- instanceVariableNames:'baseFont characterToFontMapping maxAscent maxDescent'
- classVariableNames:''
- poolDictionaries:''
- category:'Graphics-Support'
+ instanceVariableNames:'baseFont characterToFontMapping maxAscent maxDescent maxHeight
+ device'
+ classVariableNames:''
+ poolDictionaries:''
+ category:'Graphics-Support'
!
!CompoundFont class methodsFor:'documentation'!
@@ -194,6 +195,12 @@
characterToFontMapping at:char put:aFont.
maxAscent := maxDescent := nil.
+!
+
+graphicsDevice
+ "return the device I am on"
+
+ ^ device
! !
!CompoundFont methodsFor:'displaying'!
@@ -245,10 +252,12 @@
computeMaxBounds
maxAscent := baseFont ascent.
maxDescent := baseFont descent.
+ maxHeight := baseFont height.
characterToFontMapping notNil ifTrue:[
characterToFontMapping keysAndValuesDo:[:char :aFont |
maxAscent := maxAscent max:aFont ascent.
maxDescent := maxDescent max:aFont descent.
+ maxHeight := maxHeight max:aFont height.
]
].
!
@@ -313,6 +322,13 @@
^ maxDescent
!
+height
+ maxHeight isNil ifTrue:[
+ self computeMaxBounds
+ ].
+ ^ maxHeight.
+!
+
isFixedWidth
"return true, if this is a fixed pitch font (i.e. all characters
are of the same width)"
@@ -337,14 +353,24 @@
"return a device representation of the receiver.
Since I am device independent, return the receiver."
- |newFonts|
+ |newFonts lastFont lastDeviceFont newFont|
+
+ aDevice == device ifTrue:[ ^ self ].
baseFont := baseFont onDevice:aDevice.
newFonts := Dictionary new.
characterToFontMapping keysAndValuesDo:[:char :font |
- newFonts at:char put:(font onDevice:aDevice)
+ font == lastFont ifTrue:[
+ newFont := lastDeviceFont
+ ] ifFalse:[
+ newFont := font onDevice:aDevice.
+ lastFont := font.
+ lastDeviceFont := newFont.
+ ].
+ newFonts at:char put:newFont
].
- characterToFontMapping := newFonts
+ characterToFontMapping := newFonts.
+ device := aDevice.
!
widthOf:aString from:index1 to:index2
@@ -363,5 +389,5 @@
!CompoundFont class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview/CompoundFont.st,v 1.3 2002-07-23 17:22:33 mb Exp $'
+ ^ '$Header: /cvs/stx/stx/libview/CompoundFont.st,v 1.4 2002-07-23 19:33:48 mb Exp $'
! !