Font.st
changeset 991 b3a0b903bd7f
parent 927 c4bc2a7ff733
child 994 7e720b29c838
--- a/Font.st	Tue Jul 23 20:17:18 1996 +0200
+++ b/Font.st	Wed Jul 24 12:20:08 1996 +0200
@@ -617,33 +617,59 @@
 
 !Font methodsFor:'private'!
 
+fontMetricsInto:aBlock
+    "evaluate aBlock, passing all of my fontMetrics as arguments"
+
+    device isNil ifTrue:[
+        self errorNoDevice.
+        ^ self
+    ].
+    replacementFont notNil ifTrue:[
+        replacementFont fontMetricsInto:aBlock.
+	^ self
+    ].
+
+    aBlock
+	value:encoding 
+	value:ascent 
+	value:descent 
+	value:maxAscent 
+	value:maxDescent
+	value:minWidth 
+	value:maxWidth 
+	value:width
+!
+
 getFontInfos
     "ask the device about all of my actual attributes"
 
+    |b|
+
+    b := [
+            :_encoding :_avgAscent :_avgDescent :_maxAscent :_maxDescent
+            :_minWidth :_maxWidth :_avgWidth |
+
+            encoding := _encoding.
+            ascent := _avgAscent.
+            adescent := _avgDescent.
+            maxAscent := _maxAscent.
+            maxDescent := _maxDescent.
+            minWidth := _minWidth.
+            maxWidth := _maxWidth.
+            width := _avgWidth
+        ].
+
     replacementFont isNil ifTrue:[
-        encoding := device encodingOf:fontId.
-        ascent := device ascentOf:fontId.
-        descent := device descentOf:fontId.
-        maxAscent := device maxAscentOf:fontId.
-        maxDescent := device maxDescentOf:fontId.
-        minWidth := device minWidthOfFont:fontId.
-        maxWidth := device maxWidthOfFont:fontId.
-        width := device widthOf:' ' inFont:fontId.
-        width < minWidth ifTrue:[
-            "/ some systems/fonts return a wrong value (0) for space-width
-            "/ - at least with X11 ...
-            width := minWidth
-        ]
+	device fontMetricsOf:fontId into:b.
     ] ifFalse:[
-        encoding := replacementFont encoding.
-        ascent := replacementFont ascent.
-        descent := replacementFont descent.
-        maxAscent := replacementFont maxAscent.
-        maxDescent := replacementFont maxDescent.
-        width := replacementFont width.
-        minWidth := replacementFont minWidth.
-        maxWidth := replacementFont maxWidth.
+	replacementFont fontMetricsInto:b
     ].
+
+    width < minWidth ifTrue:[
+        "/ some systems/fonts return a wrong value (0) as width of a space
+        "/ - at least with X11 ...
+        width := minWidth
+    ]
     isFixedWidth := minWidth == maxWidth
 
     "Modified: 22.5.1996 / 13:08:40 / cg"
@@ -1086,6 +1112,6 @@
 !Font  class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/Font.st,v 1.49 1996-07-05 16:06:05 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/Font.st,v 1.50 1996-07-24 10:19:52 cg Exp $'
 ! !
 Font initialize!