author | Claus Gittinger <cg@exept.de> |
Tue, 26 Oct 1999 19:52:27 +0200 | |
changeset 2980 | 409e9547a45c |
parent 2925 | fadcf27b8f99 |
child 3027 | efb7b0c760f5 |
permissions | -rw-r--r-- |
0 | 1 |
" |
6 | 2 |
COPYRIGHT (c) 1992 by Claus Gittinger |
71 | 3 |
All Rights Reserved |
0 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
109 | 13 |
FontDescription subclass:#Font |
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
14 |
instanceVariableNames:'device fontId replacementFont ascent descent width isFixedWidth |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
15 |
minWidth maxWidth maxAscent maxDescent' |
1372
2b55617a712f
keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents:
1229
diff
changeset
|
16 |
classVariableNames:'Replacements' |
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
17 |
poolDictionaries:'' |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
18 |
category:'Graphics-Support' |
0 | 19 |
! |
20 |
||
2433
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
21 |
Object subclass:#DeviceFontHandle |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
22 |
instanceVariableNames:'device fontId' |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
23 |
classVariableNames:'' |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
24 |
poolDictionaries:'' |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
25 |
privateIn:Font |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
26 |
! |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
27 |
|
1087
1e5a93e03d7f
handle text-argument in withOf:
Claus Gittinger <cg@exept.de>
parents:
1067
diff
changeset
|
28 |
!Font class methodsFor:'documentation'! |
0 | 29 |
|
46 | 30 |
copyright |
31 |
" |
|
32 |
COPYRIGHT (c) 1992 by Claus Gittinger |
|
71 | 33 |
All Rights Reserved |
46 | 34 |
|
35 |
This software is furnished under a license and may be used |
|
36 |
only in accordance with the terms of that license and with the |
|
37 |
inclusion of the above copyright notice. This software may not |
|
38 |
be provided or otherwise made available to, or used by, any |
|
39 |
other person. No title to or ownership of the software is |
|
40 |
hereby transferred. |
|
41 |
" |
|
42 |
! |
|
0 | 43 |
|
46 | 44 |
documentation |
45 |
" |
|
46 |
Font represents fonts in a device independent manner; after being |
|
47 |
created using 'Font family:family face:face style:style size:size', |
|
48 |
the returned font is not associated to a specific device. |
|
157 | 49 |
(therefore, those fonts can be used to draw on any GC) |
0 | 50 |
|
46 | 51 |
To get a device font, any font can be sent the message |
52 |
'aFont on:aDevice' which returns an instance of Font which is |
|
53 |
associated to a device (it returns the receiver, if that is already |
|
54 |
associated to that device). |
|
0 | 55 |
|
46 | 56 |
For proper operation, each graphics operation working with fonts |
57 |
must get a device font before doing the draw. |
|
58 |
Most draw methods in DeviceDrawable do that automatically for you, |
|
157 | 59 |
before doing the draw; so you do not have to care. |
46 | 60 |
|
81 | 61 |
However, some operations require explicit conversion to a device font |
62 |
before being allowed. For example, a query for a fonts height (in device |
|
63 |
units) can only be done if the font being asked is associated to |
|
64 |
a device (which should be clear, since a 'courier-roman-12' font may |
|
65 |
have a different number of pixels on a 75dpi vs. a 120dpi display. And |
|
564 | 66 |
a totally different number of device units on a 600dpi laser printer. |
81 | 67 |
Thus, to query a font for its height (or ascent, or descent, or width), |
68 |
use something like: |
|
69 |
||
564 | 70 |
myFont := Font family:'courier' ... size:12. |
71 |
... |
|
81 | 72 |
|
564 | 73 |
'want to know its height on the Display' |
81 | 74 |
|
564 | 75 |
h := (myFont on:Display) height. |
81 | 76 |
|
564 | 77 |
'want to know its height on a printer' |
81 | 78 |
|
564 | 79 |
h := (myFont on:aPrinter) height. |
2545 | 80 |
|
81 |
there are alternative shortcuts for these operations: |
|
82 |
||
83 |
h := myFont heightOn:Display. |
|
84 |
h := myFont heightOn:Printer. |
|
85 |
||
86 |
or: |
|
87 |
||
88 |
a := myFont ascentOn:Display. |
|
89 |
||
81 | 90 |
Keep in mind, that each device is free to think in whatever units it |
91 |
likes - a display may return units of pixels, a postscript printer may |
|
92 |
think in (fractions of) inches, a dot matrix printer may think in dots. |
|
93 |
Also, notice that currently only graphic displays are really supported; |
|
94 |
printer devices are being developped and may or may not be in the current |
|
95 |
system. |
|
96 |
||
564 | 97 |
If a font cannot be represented on a device, a replacement |
46 | 98 |
font is chosen and kept in the replacementFont instance variable. |
564 | 99 |
This is done to preserve the original font information, in case the image |
100 |
is restarted later on another display which has that font available. |
|
101 |
||
102 |
||
601 | 103 |
[Instance variables:] |
46 | 104 |
|
109 | 105 |
family <String> the fonts family ('courier', 'helvetica' etc) |
106 |
face <String> the fonts face ('bold', 'medium' etc) |
|
107 |
style <String> the fonts style ('roman', 'italic', 'oblique') |
|
108 |
size <String> the fonts size (not in pixels) |
|
109 |
encoding <Symbol> the fonts encoding (usually #iso8859) |
|
0 | 110 |
|
109 | 111 |
device <Object> the device the font is associated to, or nil |
112 |
fontId <Object> the id of the font on that device, or nil |
|
113 |
replacement <Font> the replacement font or nil |
|
0 | 114 |
|
109 | 115 |
ascent <Integer> the fonts ascent in device units on device |
116 |
descent <Integer> the fonts descent in device units on device |
|
117 |
width <Integer> the character width in device units on device |
|
564 | 118 |
(for variable fonts, its the width of a space) |
109 | 119 |
isFixedWidth <Boolean> true if font is a fixed width font |
120 |
minWidth <Integer> width of the smallest-width character in |
|
564 | 121 |
in device units on device |
109 | 122 |
maxWidth <Integer> width of the largest-width character in |
564 | 123 |
in device units on device |
0 | 124 |
|
601 | 125 |
[class variables:] |
0 | 126 |
|
109 | 127 |
Replacements <Dictionary> replacement fonts |
601 | 128 |
|
129 |
[see also:] |
|
130 |
DeviceWorkstation |
|
628
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
131 |
DeviceDrawable GraphicsContext |
601 | 132 |
Cursor Color |
628
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
133 |
( introduction to view programming :html: programming/viewintro.html#FONTS ) |
611 | 134 |
|
135 |
[author:] |
|
136 |
Claus Gittinger |
|
46 | 137 |
" |
628
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
138 |
! |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
139 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
140 |
examples |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
141 |
" |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
142 |
standard fonts: |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
143 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
144 |
aFont := Font family:'courier' size:12 |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
145 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
146 |
aFont := Font |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
147 |
family:'helvetica' |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
148 |
face:'roman' |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
149 |
style:'bold' |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
150 |
size:16 |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
151 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
152 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
153 |
special (non-portable displayType specific) fonts: |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
154 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
155 |
aFont := Font name:'6x10' |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
156 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
157 |
aFont := Font name:'k14' |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
158 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
159 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
160 |
setting the font of a button: |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
161 |
[exBegin] |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
162 |
|b| |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
163 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
164 |
b := Button new. |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
165 |
b label:'hello'. |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
166 |
b font:(Font family:'helvetica' |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
167 |
face:'medium' |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
168 |
style:'roman' |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
169 |
size:16). |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
170 |
b open |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
171 |
[exEnd] |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
172 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
173 |
asking a font about a strings size in pixels, |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
174 |
if it was used on some device: |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
175 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
176 |
aFont widthOf:'hello' on:Display |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
177 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
178 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
179 |
asking about the ascent, if used on some device: |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
180 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
181 |
aFont ascentOn:Display |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
182 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
183 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
184 |
if the font has been associated to a device, the following are |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
185 |
a bit faster: |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
186 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
187 |
|aFont| |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
188 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
189 |
... |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
190 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
191 |
aFont := aFont on:aDevice. |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
192 |
... |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
193 |
aFont widthOf:'hello' |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
194 |
... |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
195 |
aFont ascent |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
196 |
... |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
197 |
" |
0 | 198 |
! ! |
199 |
||
1087
1e5a93e03d7f
handle text-argument in withOf:
Claus Gittinger <cg@exept.de>
parents:
1067
diff
changeset
|
200 |
!Font class methodsFor:'initialization'! |
0 | 201 |
|
202 |
initialize |
|
203 |
"initialize the font tracking array" |
|
204 |
||
1372
2b55617a712f
keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents:
1229
diff
changeset
|
205 |
" |
2b55617a712f
keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents:
1229
diff
changeset
|
206 |
replacement handling is not yet finished |
2b55617a712f
keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents:
1229
diff
changeset
|
207 |
" |
2b55617a712f
keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents:
1229
diff
changeset
|
208 |
Replacements := Dictionary new. |
71 | 209 |
|
1372
2b55617a712f
keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents:
1229
diff
changeset
|
210 |
Replacements at:'clean' put:'courier'. |
2b55617a712f
keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents:
1229
diff
changeset
|
211 |
Replacements at:'fixed' put:'courier'. |
2b55617a712f
keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents:
1229
diff
changeset
|
212 |
Replacements at:'new century schoolbook' put:'times'. |
2b55617a712f
keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents:
1229
diff
changeset
|
213 |
Replacements at:'lucida' put:'helvetica'. |
2b55617a712f
keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents:
1229
diff
changeset
|
214 |
Replacements at:'lucidabright' put:'helvetica'. |
2b55617a712f
keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents:
1229
diff
changeset
|
215 |
Replacements at:'lucidatypewriter' put:'courier'. |
2b55617a712f
keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents:
1229
diff
changeset
|
216 |
Replacements at:'charter' put:'times'. |
2b55617a712f
keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents:
1229
diff
changeset
|
217 |
Replacements at:'terminal' put:'courier'. |
0 | 218 |
! ! |
219 |
||
1087
1e5a93e03d7f
handle text-argument in withOf:
Claus Gittinger <cg@exept.de>
parents:
1067
diff
changeset
|
220 |
!Font class methodsFor:'instance creation'! |
0 | 221 |
|
222 |
family:familyString face:faceString style:styleString size:sizeNum encoding:encodingSym |
|
223 |
"returns a font for given family, face, style, size and encoding. |
|
71 | 224 |
The returned font is not associated to a specific device" |
0 | 225 |
|
54 | 226 |
|family newFont| |
0 | 227 |
|
228 |
(familyString at:1) isUppercase ifTrue:[ |
|
2925 | 229 |
family := familyString asLowercase |
0 | 230 |
] ifFalse:[ |
2925 | 231 |
family := familyString |
0 | 232 |
]. |
233 |
||
1372
2b55617a712f
keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents:
1229
diff
changeset
|
234 |
"look if this font is already known on the default device |
2b55617a712f
keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents:
1229
diff
changeset
|
235 |
(the most common case)" |
0 | 236 |
|
2767
04fdb969488a
dont access DIsplay if its nil
Claus Gittinger <cg@exept.de>
parents:
2545
diff
changeset
|
237 |
Display notNil ifTrue:[ |
04fdb969488a
dont access DIsplay if its nil
Claus Gittinger <cg@exept.de>
parents:
2545
diff
changeset
|
238 |
Display deviceFonts do:[:aFont | |
2925 | 239 |
(aFont family = family) ifTrue:[ |
240 |
(aFont face = faceString) ifTrue:[ |
|
241 |
(aFont style = styleString |
|
242 |
or:[styleString = 'italic' and:[aFont style = 'oblique']]) ifTrue:[ |
|
243 |
(aFont size == sizeNum) ifTrue:[ |
|
244 |
(encodingSym isNil or:[aFont encoding == encodingSym]) ifTrue:[ |
|
245 |
^ aFont |
|
246 |
] |
|
247 |
] |
|
248 |
] |
|
249 |
] |
|
250 |
] |
|
251 |
] |
|
0 | 252 |
]. |
1372
2b55617a712f
keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents:
1229
diff
changeset
|
253 |
|
2b55617a712f
keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents:
1229
diff
changeset
|
254 |
newFont := self basicNew |
2925 | 255 |
setFamily:familyString |
256 |
face:faceString |
|
257 |
style:styleString |
|
258 |
size:sizeNum |
|
259 |
encoding:encodingSym |
|
260 |
device:nil. |
|
1372
2b55617a712f
keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents:
1229
diff
changeset
|
261 |
|
0 | 262 |
^ newFont |
2925 | 263 |
|
264 |
"Modified: / 26.9.1999 / 13:49:45 / cg" |
|
0 | 265 |
! ! |
266 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
267 |
!Font methodsFor:'accessing'! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
268 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
269 |
device |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
270 |
"return the device I am on" |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
271 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
272 |
^ device |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
273 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
274 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
275 |
fontId |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
276 |
"return the device-dependent font-id" |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
277 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
278 |
^ fontId |
731 | 279 |
! |
280 |
||
281 |
graphicsDevice |
|
282 |
"same as #device, for ST-80 compatibility naming. |
|
283 |
Return the device I am associated with." |
|
284 |
||
285 |
^ device |
|
286 |
||
287 |
"Created: 28.5.1996 / 18:39:53 / cg" |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
288 |
! ! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
289 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
290 |
!Font methodsFor:'binary storage'! |
0 | 291 |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
292 |
readBinaryContentsFrom: stream manager: manager |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
293 |
"tell the newly restored Font about restoration" |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
294 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
295 |
super readBinaryContentsFrom: stream manager: manager. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
296 |
self restored |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
297 |
! ! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
298 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
299 |
!Font methodsFor:'displaying'! |
71 | 300 |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
301 |
displayOpaqueString:aString from:index1 to:index2 x:x y:y in:aGC |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
302 |
"this is only called for fonts which have a nil fontId, |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
303 |
and therefore use the replacementFont. Should never be called |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
304 |
for non-replacement fonts." |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
305 |
|
441 | 306 |
|prevFont| |
307 |
||
2545 | 308 |
prevFont := aGC font. |
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
309 |
replacementFont isNil ifTrue:[ |
2545 | 310 |
fontId notNil ifTrue:[ |
311 |
aGC basicFont:self. |
|
312 |
aGC displayOpaqueString:aString from:index1 to:index2 x:x y:y. |
|
313 |
] ifFalse:[ |
|
314 |
'Font: [warning]: no replacementFont. should not happen' errorPrintCR. |
|
315 |
]. |
|
316 |
] ifFalse:[ |
|
317 |
aGC basicFont:replacementFont. |
|
318 |
aGC displayOpaqueString:aString from:index1 to:index2 x:x y:y. |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
319 |
]. |
442 | 320 |
aGC basicFont:prevFont |
441 | 321 |
|
1176
e0e2c8cbb3c8
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1166
diff
changeset
|
322 |
"Modified: 10.1.1997 / 17:51:10 / cg" |
71 | 323 |
! |
324 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
325 |
displayString:aString from:index1 to:index2 x:x y:y in:aGC |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
326 |
"this is only called for fonts which have a nil fontId, |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
327 |
and therefore use the replacementFont. Should never be called |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
328 |
for non-replacement fonts." |
0 | 329 |
|
441 | 330 |
|prevFont| |
331 |
||
2545 | 332 |
prevFont := aGC font. |
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
333 |
replacementFont isNil ifTrue:[ |
2545 | 334 |
fontId notNil ifTrue:[ |
335 |
aGC basicFont:self. |
|
336 |
aGC displayString:aString from:index1 to:index2 x:x y:y. |
|
337 |
] ifFalse:[ |
|
338 |
'Font: [warning]: no replacementFont. should not happen' errorPrintCR. |
|
339 |
]. |
|
340 |
] ifFalse:[ |
|
341 |
aGC basicFont:replacementFont. |
|
342 |
aGC displayString:aString from:index1 to:index2 x:x y:y. |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
343 |
]. |
442 | 344 |
aGC basicFont:prevFont. |
441 | 345 |
|
1176
e0e2c8cbb3c8
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1166
diff
changeset
|
346 |
"Modified: 10.1.1997 / 17:51:17 / cg" |
0 | 347 |
! ! |
348 |
||
349 |
!Font methodsFor:'getting a device font'! |
|
350 |
||
351 |
on:aDevice |
|
352 |
"create a new Font representing the same font as |
|
353 |
myself on aDevice; if one already exists, return the one." |
|
354 |
||
2848 | 355 |
"/ self obsoleteMethodWarning:'use onDevice:'. |
356 |
^ self onDevice:aDevice |
|
357 |
||
358 |
! |
|
359 |
||
360 |
on:aDevice ifAbsent:exceptionBlock |
|
361 |
"create a new Font representing the same font as |
|
362 |
myself on aDevice. This does NOT try to look for existing |
|
363 |
or replacement fonts (i.e. can be used to get physical fonts)." |
|
364 |
||
365 |
|newFont id| |
|
366 |
||
367 |
"ask that device for the font" |
|
368 |
id := aDevice getFontWithFamily:family face:face style:style size:size encoding:encoding. |
|
369 |
id isNil ifTrue:[ |
|
370 |
"oops did not work - (device has no such font)" |
|
371 |
||
372 |
^ exceptionBlock value |
|
373 |
]. |
|
374 |
||
375 |
"receiver was not associated - do it now" |
|
376 |
device isNil ifTrue:[ |
|
377 |
device := aDevice. |
|
378 |
fontId := id. |
|
379 |
||
380 |
self getFontInfos. |
|
381 |
aDevice registerFont:self. |
|
382 |
^ self |
|
383 |
]. |
|
384 |
||
385 |
"receiver was already associated to another device - need a new font" |
|
386 |
newFont := (self class basicNew) |
|
387 |
setFamily:family |
|
388 |
face:face |
|
389 |
style:style |
|
390 |
size:size |
|
391 |
encoding:encoding |
|
392 |
device:aDevice. |
|
393 |
newFont setFontId:id. |
|
394 |
newFont getFontInfos. |
|
395 |
aDevice registerFont:newFont. |
|
396 |
^ newFont |
|
397 |
! |
|
398 |
||
399 |
onDevice:aDevice |
|
400 |
"create a new Font representing the same font as |
|
401 |
myself on aDevice; if one already exists, return the one." |
|
402 |
||
336 | 403 |
|newFont rep| |
0 | 404 |
|
405 |
"if I am already assigned to that device ..." |
|
406 |
(device == aDevice) ifTrue:[^ self]. |
|
407 |
||
2980
409e9547a45c
ignore nil device in #onDevice:
Claus Gittinger <cg@exept.de>
parents:
2925
diff
changeset
|
408 |
aDevice isNil ifTrue:[^ self]. |
409e9547a45c
ignore nil device in #onDevice:
Claus Gittinger <cg@exept.de>
parents:
2925
diff
changeset
|
409 |
|
0 | 410 |
"first look if not already there" |
1372
2b55617a712f
keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents:
1229
diff
changeset
|
411 |
aDevice deviceFonts do:[:aFont | |
2b55617a712f
keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents:
1229
diff
changeset
|
412 |
(size == aFont size) ifTrue:[ |
2b55617a712f
keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents:
1229
diff
changeset
|
413 |
(family = aFont family) ifTrue:[ |
2b55617a712f
keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents:
1229
diff
changeset
|
414 |
(face = aFont face) ifTrue:[ |
2b55617a712f
keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents:
1229
diff
changeset
|
415 |
(style = aFont style) ifTrue:[ |
2b55617a712f
keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents:
1229
diff
changeset
|
416 |
(encoding isNil or:[encoding == aFont encoding]) ifTrue:[ |
2b55617a712f
keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents:
1229
diff
changeset
|
417 |
^ aFont |
441 | 418 |
] |
419 |
] |
|
420 |
] |
|
421 |
] |
|
422 |
] |
|
0 | 423 |
]. |
424 |
||
157 | 425 |
newFont := self on:aDevice ifAbsent:nil. |
426 |
newFont isNil ifTrue:[ |
|
441 | 427 |
"oops did not work - (device has no such font)" |
0 | 428 |
|
1596
579d2c28f824
raise an error, if trying to get a font from a disconnected
Claus Gittinger <cg@exept.de>
parents:
1373
diff
changeset
|
429 |
aDevice isOpen ifFalse:[ |
579d2c28f824
raise an error, if trying to get a font from a disconnected
Claus Gittinger <cg@exept.de>
parents:
1373
diff
changeset
|
430 |
"/ the display device is not connected |
579d2c28f824
raise an error, if trying to get a font from a disconnected
Claus Gittinger <cg@exept.de>
parents:
1373
diff
changeset
|
431 |
"/ (or has a broken connection). |
579d2c28f824
raise an error, if trying to get a font from a disconnected
Claus Gittinger <cg@exept.de>
parents:
1373
diff
changeset
|
432 |
self error:'trying to get font from closed display'. |
579d2c28f824
raise an error, if trying to get a font from a disconnected
Claus Gittinger <cg@exept.de>
parents:
1373
diff
changeset
|
433 |
^ self. |
579d2c28f824
raise an error, if trying to get a font from a disconnected
Claus Gittinger <cg@exept.de>
parents:
1373
diff
changeset
|
434 |
]. |
579d2c28f824
raise an error, if trying to get a font from a disconnected
Claus Gittinger <cg@exept.de>
parents:
1373
diff
changeset
|
435 |
|
441 | 436 |
rep := self replacementFontOn:aDevice. |
437 |
device isNil ifTrue:[ |
|
438 |
device := aDevice. |
|
439 |
replacementFont := rep. |
|
1372
2b55617a712f
keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents:
1229
diff
changeset
|
440 |
aDevice registerFont:self. |
441 | 441 |
^ self |
442 |
]. |
|
1372
2b55617a712f
keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents:
1229
diff
changeset
|
443 |
|
441 | 444 |
newFont := (self class basicNew) |
445 |
setFamily:family face:face style:style size:size encoding:encoding device:aDevice. |
|
446 |
newFont setReplacementFont:rep. |
|
1372
2b55617a712f
keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents:
1229
diff
changeset
|
447 |
aDevice registerFont:newFont. |
441 | 448 |
^ newFont |
0 | 449 |
]. |
450 |
||
451 |
^ newFont |
|
441 | 452 |
|
453 |
" |
|
454 |
Font family:'foo' size:17 |
|
455 |
" |
|
456 |
||
1596
579d2c28f824
raise an error, if trying to get a font from a disconnected
Claus Gittinger <cg@exept.de>
parents:
1373
diff
changeset
|
457 |
"Modified: 14.4.1997 / 18:22:31 / cg" |
0 | 458 |
! |
459 |
||
460 |
replacementFontOn:aDevice |
|
12 | 461 |
"return a replacement font for the receiver - this is needed, if |
462 |
an image is restored on another type of display, or one which has |
|
463 |
a different set of fonts." |
|
0 | 464 |
|
465 |
|id f alternative| |
|
466 |
||
144 | 467 |
alternative := Replacements at:family ifAbsent:nil. |
0 | 468 |
alternative notNil ifTrue:[ |
454
b31d0a7e5530
nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
469 |
id := aDevice getFontWithFamily:alternative |
b31d0a7e5530
nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
470 |
face:face |
b31d0a7e5530
nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
471 |
style:style |
b31d0a7e5530
nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
472 |
size:size |
b31d0a7e5530
nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
473 |
encoding:encoding. |
144 | 474 |
]. |
475 |
id notNil ifTrue:[ |
|
1166 | 476 |
('Font [info]: use alternative for ' , (self userFriendlyName)) infoPrintCR. |
144 | 477 |
] ifFalse:[ |
454
b31d0a7e5530
nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
478 |
id := aDevice getDefaultFont. |
1166 | 479 |
('Font [info]: use default for ' , (self userFriendlyName)) infoPrintCR. |
0 | 480 |
]. |
481 |
id isNil ifTrue:[ |
|
454
b31d0a7e5530
nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
482 |
"oops did not work - this is a serious an error" |
b31d0a7e5530
nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
483 |
self error:'cannot get default font'. |
b31d0a7e5530
nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
484 |
^ nil |
0 | 485 |
]. |
486 |
f := self class basicNew. |
|
487 |
f setDevice:aDevice fontId:id. |
|
488 |
f getFontInfos. |
|
1372
2b55617a712f
keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents:
1229
diff
changeset
|
489 |
aDevice registerFont:f. |
0 | 490 |
^ f |
454
b31d0a7e5530
nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
491 |
|
1166 | 492 |
"Modified: 10.1.1997 / 15:40:21 / cg" |
0 | 493 |
! ! |
494 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
495 |
!Font methodsFor:'instance release'! |
0 | 496 |
|
2848 | 497 |
executor |
578 | 498 |
"redefined to return a lightweight copy |
499 |
- all we need is the device handle" |
|
500 |
||
2848 | 501 |
^ DeviceFontHandle basicNew setDevice:device fontId:fontId. |
578 | 502 |
|
2433
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
503 |
"Modified: / 20.4.1996 / 23:23:04 / cg" |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
504 |
"Modified: / 3.2.1999 / 16:13:10 / stefan" |
2 | 505 |
! ! |
506 |
||
0 | 507 |
!Font methodsFor:'printing & storing'! |
508 |
||
109 | 509 |
printOn:aStream |
2805 | 510 |
"append a user printed representation of the receiver to aStream. |
511 |
The format is suitable for a human - not meant to be read back. |
|
578 | 512 |
Redefined to print more about the fonts name" |
513 |
||
46 | 514 |
face isNil ifTrue:[ |
578 | 515 |
family isNil ifTrue:[ |
516 |
aStream nextPutAll:('a replacement-Font'). |
|
517 |
^ self |
|
518 |
]. |
|
519 |
aStream nextPutAll:('a ' , family , '-Font'). |
|
520 |
^ self. |
|
46 | 521 |
]. |
109 | 522 |
aStream nextPutAll:('a ' , family , '-' , |
578 | 523 |
face , '-' , |
524 |
style , '-' , |
|
525 |
size printString , '-Font') |
|
526 |
||
527 |
"Modified: 20.4.1996 / 23:25:11 / cg" |
|
0 | 528 |
! |
529 |
||
109 | 530 |
storeOn:aStream |
531 |
"append a character sequence to the argument, aStream from which the |
|
532 |
receiver can be reconstructed using readFrom:." |
|
0 | 533 |
|
109 | 534 |
aStream nextPutAll:'(Font family:'. family storeOn:aStream. |
535 |
aStream nextPutAll:' face:'. face storeOn:aStream. |
|
536 |
aStream nextPutAll:' style:'. style storeOn:aStream. |
|
537 |
aStream nextPutAll:' size:'. size storeOn:aStream. |
|
538 |
aStream nextPutAll:' encoding:'. encoding storeOn:aStream. |
|
539 |
aStream nextPut:$) |
|
540 |
||
541 |
" |
|
542 |
(Font family:'helvetica' size:10) storeString |
|
543 |
" |
|
0 | 544 |
! ! |
2 | 545 |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
546 |
!Font methodsFor:'private'! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
547 |
|
991 | 548 |
fontMetricsInto:aBlock |
549 |
"evaluate aBlock, passing all of my fontMetrics as arguments" |
|
550 |
||
551 |
device isNil ifTrue:[ |
|
552 |
self errorNoDevice. |
|
553 |
^ self |
|
554 |
]. |
|
555 |
replacementFont notNil ifTrue:[ |
|
556 |
replacementFont fontMetricsInto:aBlock. |
|
557 |
^ self |
|
558 |
]. |
|
559 |
||
560 |
aBlock |
|
561 |
value:encoding |
|
562 |
value:ascent |
|
563 |
value:descent |
|
564 |
value:maxAscent |
|
565 |
value:maxDescent |
|
566 |
value:minWidth |
|
567 |
value:maxWidth |
|
568 |
value:width |
|
569 |
! |
|
570 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
571 |
getFontInfos |
578 | 572 |
"ask the device about all of my actual attributes" |
573 |
||
991 | 574 |
|b| |
575 |
||
576 |
b := [ |
|
1067 | 577 |
:fencoding :favgAscent :favgDescent :fmaxAscent :fmaxDescent |
578 |
:fminWidth :fmaxWidth :favgWidth | |
|
991 | 579 |
|
1067 | 580 |
encoding := fencoding. |
581 |
ascent := favgAscent. |
|
582 |
descent := favgDescent. |
|
583 |
maxAscent := fmaxAscent. |
|
584 |
maxDescent := fmaxDescent. |
|
585 |
minWidth := fminWidth. |
|
586 |
maxWidth := fmaxWidth. |
|
587 |
width := favgWidth |
|
991 | 588 |
]. |
589 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
590 |
replacementFont isNil ifTrue:[ |
991 | 591 |
device fontMetricsOf:fontId into:b. |
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
592 |
] ifFalse:[ |
991 | 593 |
replacementFont fontMetricsInto:b |
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
594 |
]. |
991 | 595 |
|
596 |
width < minWidth ifTrue:[ |
|
597 |
"/ some systems/fonts return a wrong value (0) as width of a space |
|
598 |
"/ - at least with X11 ... |
|
599 |
width := minWidth |
|
994 | 600 |
]. |
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
601 |
isFixedWidth := minWidth == maxWidth |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
602 |
|
710 | 603 |
"Modified: 22.5.1996 / 13:08:40 / cg" |
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
604 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
605 |
|
2846 | 606 |
releaseFromDevice |
607 |
"I am no longer available on the device" |
|
608 |
||
609 |
device := nil. |
|
610 |
fontId := nil. |
|
611 |
replacementFont := nil |
|
612 |
||
613 |
"Modified: 20.4.1996 / 23:26:26 / cg" |
|
614 |
! |
|
615 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
616 |
restored |
578 | 617 |
"flush device handles when restored" |
618 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
619 |
device := nil. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
620 |
fontId := nil. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
621 |
replacementFont := nil |
578 | 622 |
|
623 |
"Modified: 20.4.1996 / 23:26:26 / cg" |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
624 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
625 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
626 |
setDevice:aDevice |
578 | 627 |
"set the device handle" |
628 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
629 |
device := aDevice |
578 | 630 |
|
631 |
"Modified: 20.4.1996 / 23:26:35 / cg" |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
632 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
633 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
634 |
setDevice:aDevice fontId:aFontId |
578 | 635 |
"set the device and font handles" |
636 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
637 |
device := aDevice. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
638 |
fontId := aFontId |
578 | 639 |
|
640 |
"Modified: 20.4.1996 / 23:26:43 / cg" |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
641 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
642 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
643 |
setFamily:familyString face:faceString style:styleString size:sizeNum encoding:encodingSym device:aDevice |
578 | 644 |
"set my instance attributes" |
645 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
646 |
family := familyString. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
647 |
face := faceString. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
648 |
style := styleString. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
649 |
size := sizeNum. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
650 |
encoding := encodingSym. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
651 |
device := aDevice |
578 | 652 |
|
653 |
"Modified: 20.4.1996 / 23:26:56 / cg" |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
654 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
655 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
656 |
setFontId:aFontId |
578 | 657 |
"set my font handle" |
658 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
659 |
fontId := aFontId |
578 | 660 |
|
661 |
"Modified: 20.4.1996 / 23:27:05 / cg" |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
662 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
663 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
664 |
setReplacementFont:aFont |
578 | 665 |
"set my replacement font" |
666 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
667 |
replacementFont := aFont |
578 | 668 |
|
669 |
"Modified: 20.4.1996 / 23:27:16 / cg" |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
670 |
! ! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
671 |
|
2545 | 672 |
!Font methodsFor:'queries-deviceFonts'! |
673 |
||
674 |
fullName |
|
675 |
"return the full (device specific) name of the receiver. |
|
676 |
This is query only valid if the receiver is associated to a device" |
|
677 |
||
678 |
device isNil ifTrue:[ |
|
679 |
^ nil |
|
680 |
]. |
|
681 |
^ device fullNameOf:fontId. |
|
682 |
||
683 |
" |
|
684 |
((Font name:'6x10') on:Display) fullName |
|
685 |
" |
|
686 |
||
687 |
"Modified: 30.4.1996 / 17:30:10 / cg" |
|
688 |
! |
|
689 |
||
690 |
isFixedWidth |
|
691 |
"return true, if all characters have same width (as in courier). |
|
692 |
The receiver must be associated to a device, |
|
693 |
for this query to be legal." |
|
694 |
||
695 |
device isNil ifTrue:[ |
|
696 |
self errorNoDevice. |
|
697 |
]. |
|
698 |
replacementFont notNil ifTrue:[ |
|
699 |
^ replacementFont isFixedWidth |
|
700 |
]. |
|
701 |
^ isFixedWidth |
|
702 |
! ! |
|
703 |
||
704 |
!Font methodsFor:'queries-dimensions'! |
|
705 |
||
706 |
ascent |
|
707 |
"return the font-ascent (i.e. the normal average of all characters); |
|
708 |
That is the number of units (usually pixels) above the baseline. |
|
709 |
The receiver must be associated to a device, |
|
710 |
for this query to be legal." |
|
711 |
||
712 |
device isNil ifTrue:[ |
|
713 |
self errorNoDevice |
|
714 |
]. |
|
715 |
replacementFont notNil ifTrue:[ |
|
716 |
^ replacementFont ascent |
|
717 |
]. |
|
718 |
^ ascent |
|
719 |
! |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
720 |
|
628
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
721 |
ascentOn:aDevice |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
722 |
"return the fonts ascent (average), if used on aDevice." |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
723 |
|
2321
75a179c343cf
try replacement forn first if nonnil in queries
Claus Gittinger <cg@exept.de>
parents:
2096
diff
changeset
|
724 |
replacementFont notNil ifTrue:[ |
75a179c343cf
try replacement forn first if nonnil in queries
Claus Gittinger <cg@exept.de>
parents:
2096
diff
changeset
|
725 |
^ replacementFont ascentOn:aDevice |
75a179c343cf
try replacement forn first if nonnil in queries
Claus Gittinger <cg@exept.de>
parents:
2096
diff
changeset
|
726 |
]. |
628
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
727 |
device == aDevice ifTrue:[ |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
728 |
^ ascent |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
729 |
]. |
2833 | 730 |
^ (self onDevice:aDevice) ascent |
628
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
731 |
|
2321
75a179c343cf
try replacement forn first if nonnil in queries
Claus Gittinger <cg@exept.de>
parents:
2096
diff
changeset
|
732 |
"Created: / 30.4.1996 / 16:41:32 / cg" |
75a179c343cf
try replacement forn first if nonnil in queries
Claus Gittinger <cg@exept.de>
parents:
2096
diff
changeset
|
733 |
"Modified: / 10.9.1998 / 12:09:06 / cg" |
628
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
734 |
! |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
735 |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
736 |
descent |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
737 |
"return the font-descent (i.e. the normal average of all characters); |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
738 |
That is the number of units (usually pixels) below the baseline. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
739 |
The receiver must be associated to a device, |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
740 |
for this query to be legal." |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
741 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
742 |
device isNil ifTrue:[ |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
743 |
self errorNoDevice |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
744 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
745 |
replacementFont notNil ifTrue:[ |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
746 |
^ replacementFont descent |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
747 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
748 |
^ descent |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
749 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
750 |
|
2545 | 751 |
descentOn:aDevice |
752 |
"return the fonts descent (average), if used on aDevice." |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
753 |
|
2545 | 754 |
replacementFont notNil ifTrue:[ |
755 |
^ replacementFont descentOn:aDevice |
|
438 | 756 |
]. |
2545 | 757 |
device == aDevice ifTrue:[ |
758 |
^ descent |
|
759 |
]. |
|
2833 | 760 |
^ (self onDevice:aDevice) descent |
438 | 761 |
|
2545 | 762 |
"Created: / 30.4.1996 / 16:41:43 / cg" |
763 |
"Modified: / 10.9.1998 / 12:09:30 / cg" |
|
438 | 764 |
! |
765 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
766 |
height |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
767 |
"return the fonts characters normal (average) height; |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
768 |
That is the number of units (usually pixels) on the device. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
769 |
The receiver must be associated to a device, |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
770 |
for this query to be legal." |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
771 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
772 |
device isNil ifTrue:[ |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
773 |
self errorNoDevice. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
774 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
775 |
replacementFont notNil ifTrue:[ |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
776 |
^ replacementFont height |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
777 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
778 |
^ descent + ascent. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
779 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
780 |
|
667
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
781 |
heightOf:textOrString |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
782 |
"return the height (device specific) of the argument; |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
783 |
the argument must be a String. |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
784 |
CAVEAT: |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
785 |
currently only constant height fonts are supported." |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
786 |
|
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
787 |
device isNil ifTrue:[ |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
788 |
self errorNoDevice. |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
789 |
^ 0 |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
790 |
]. |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
791 |
replacementFont notNil ifTrue:[ |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
792 |
^ replacementFont heightOf:textOrString |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
793 |
]. |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
794 |
|
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
795 |
^ descent + ascent |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
796 |
|
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
797 |
"Created: 12.5.1996 / 11:05:00 / cg" |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
798 |
! |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
799 |
|
2545 | 800 |
heightOf:aString on:aDevice |
801 |
"return the height of aString, if displayed on aDevice. |
|
802 |
The argument must be a string-like object." |
|
803 |
||
804 |
replacementFont notNil ifTrue:[ |
|
805 |
^ replacementFont heightOf:aString on:aDevice |
|
806 |
]. |
|
807 |
device == aDevice ifTrue:[ |
|
808 |
^ self heightOf:aString |
|
809 |
]. |
|
2833 | 810 |
^ (self onDevice:aDevice) heightOf:aString |
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
811 |
|
2545 | 812 |
"Created: / 30.4.1996 / 17:14:18 / cg" |
813 |
"Modified: / 10.9.1998 / 12:09:47 / cg" |
|
814 |
! |
|
815 |
||
816 |
heightOn:aDevice |
|
817 |
"return the fonts height (average), if used on aDevice." |
|
818 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
819 |
replacementFont notNil ifTrue:[ |
2545 | 820 |
^ replacementFont heightOn:aDevice |
821 |
]. |
|
822 |
device == aDevice ifTrue:[ |
|
823 |
^ descent + ascent |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
824 |
]. |
2833 | 825 |
^ (self onDevice:aDevice) height |
2545 | 826 |
|
827 |
"Created: / 30.4.1996 / 16:41:59 / cg" |
|
828 |
"Modified: / 10.9.1998 / 12:08:18 / cg" |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
829 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
830 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
831 |
maxAscent |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
832 |
"return the fonts maximum-ascent (i.e. the maximum of all characters); |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
833 |
That is the number of units (usually pixels) above the baseline. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
834 |
The receiver must be associated to a device, |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
835 |
for this query to be legal." |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
836 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
837 |
device isNil ifTrue:[ |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
838 |
self errorNoDevice |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
839 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
840 |
replacementFont notNil ifTrue:[ |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
841 |
^ replacementFont maxAscent |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
842 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
843 |
^ maxAscent |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
844 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
845 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
846 |
maxDescent |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
847 |
"return the font-descent (i.e. the maximum of all characters); |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
848 |
That is the number of units (usually pixels) below the baseline. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
849 |
The receiver must be associated to a device, |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
850 |
for this query to be legal." |
2 | 851 |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
852 |
device isNil ifTrue:[ |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
853 |
self errorNoDevice |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
854 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
855 |
replacementFont notNil ifTrue:[ |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
856 |
^ replacementFont maxDescent |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
857 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
858 |
^ maxDescent |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
859 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
860 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
861 |
maxHeight |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
862 |
"return the fonts characters maximum height; |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
863 |
That is the number of units (usually pixels) on the device. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
864 |
The receiver must be associated to a device, |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
865 |
for this query to be legal." |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
866 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
867 |
device isNil ifTrue:[ |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
868 |
self errorNoDevice. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
869 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
870 |
replacementFont notNil ifTrue:[ |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
871 |
^ replacementFont maxHeight |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
872 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
873 |
^ maxDescent + maxAscent. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
874 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
875 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
876 |
maxWidth |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
877 |
"return the width of the widest character; |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
878 |
if the receiver is a fixed width font its the width of every character. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
879 |
The receiver must be associated to a device, |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
880 |
for this query to be legal." |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
881 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
882 |
device isNil ifTrue:[ |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
883 |
self errorNoDevice |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
884 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
885 |
replacementFont notNil ifTrue:[ |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
886 |
^ replacementFont maxWidth |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
887 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
888 |
^ maxWidth |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
889 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
890 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
891 |
minWidth |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
892 |
"return the width of the smallest character; |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
893 |
if the receiver is a fixed width font its the width of every character. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
894 |
The receiver must be associated to a device, |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
895 |
for this query to be legal." |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
896 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
897 |
device isNil ifTrue:[ |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
898 |
self errorNoDevice |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
899 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
900 |
replacementFont notNil ifTrue:[ |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
901 |
^ replacementFont minWidth |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
902 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
903 |
^ minWidth |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
904 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
905 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
906 |
width |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
907 |
"return the fonts characters width; |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
908 |
That is the number of units (usually pixels) on the device. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
909 |
For variable pitch fonts, the width of the space character is returned. |
628
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
910 |
For fixed fonts, this is the same as minWidth or maxWidth (or any character). |
2545 | 911 |
The receiver must be associated to a device, for this query to be legal." |
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
912 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
913 |
device isNil ifTrue:[ |
628
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
914 |
self errorNoDevice. |
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
915 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
916 |
replacementFont notNil ifTrue:[ |
628
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
917 |
^ replacementFont width |
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
918 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
919 |
^ width |
628
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
920 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
921 |
"Modified: 30.4.1996 / 16:43:45 / cg" |
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
922 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
923 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
924 |
widthOf:textOrString |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
925 |
"return the width (device specific) of the argument; |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
926 |
the argument may be a Character, String or some Text; |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
927 |
in the last case the width of the longest line in the text is returned. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
928 |
The receiver must be associated to a device, |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
929 |
for this query to be legal." |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
930 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
931 |
|this max| |
2 | 932 |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
933 |
device isNil ifTrue:[ |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
934 |
self errorNoDevice. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
935 |
^ 0 |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
936 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
937 |
replacementFont notNil ifTrue:[ |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
938 |
^ replacementFont widthOf:textOrString |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
939 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
940 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
941 |
(textOrString isString) ifTrue:[ |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
942 |
isFixedWidth ifFalse:[ |
1087
1e5a93e03d7f
handle text-argument in withOf:
Claus Gittinger <cg@exept.de>
parents:
1067
diff
changeset
|
943 |
^ device widthOf:textOrString string inFont:fontId |
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
944 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
945 |
^ width * textOrString size |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
946 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
947 |
(textOrString isCharacter) ifTrue:[ |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
948 |
isFixedWidth ifFalse:[ |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
949 |
^ device widthOf:textOrString asString inFont:fontId |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
950 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
951 |
^ width |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
952 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
953 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
954 |
max := 0. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
955 |
isFixedWidth ifFalse:[ |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
956 |
textOrString do:[:line | |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
957 |
line notNil ifTrue:[ |
435
5288c637512e
care for nonStrings when asked for the size
Claus Gittinger <cg@exept.de>
parents:
434
diff
changeset
|
958 |
this := device widthOf:line asString inFont:fontId. |
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
959 |
(this > max) ifTrue:[max := this] |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
960 |
] |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
961 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
962 |
^ max |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
963 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
964 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
965 |
textOrString do:[:lineString | |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
966 |
this := lineString size. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
967 |
(this > max) ifTrue:[max := this] |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
968 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
969 |
^ max * width |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
970 |
|
1087
1e5a93e03d7f
handle text-argument in withOf:
Claus Gittinger <cg@exept.de>
parents:
1067
diff
changeset
|
971 |
"Modified: 22.10.1996 / 17:11:14 / cg" |
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
972 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
973 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
974 |
widthOf:aString from:start to:stop |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
975 |
"return the width of a substring. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
976 |
The receiver must be associated to a device, |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
977 |
for this query to be legal." |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
978 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
979 |
device isNil ifTrue:[ |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
980 |
self errorNoDevice. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
981 |
^ 0 |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
982 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
983 |
replacementFont notNil ifTrue:[ |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
984 |
^ replacementFont widthOf:aString from:start to:stop |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
985 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
986 |
(stop < start) ifTrue:[^ 0]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
987 |
isFixedWidth ifFalse:[ |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
988 |
^ device widthOf:aString from:start to:stop inFont:fontId |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
989 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
990 |
^ (stop - start + 1) * width |
2545 | 991 |
! |
992 |
||
993 |
widthOf:aString from:startIndex to:endIndex on:aDevice |
|
994 |
"return the width of substring, if displayed on aDevice. |
|
995 |
The argument may be a Character, String or some Text; |
|
996 |
in the last case the width of the longest line in the text is returned." |
|
997 |
||
998 |
replacementFont notNil ifTrue:[ |
|
999 |
^ replacementFont widthOf:aString from:startIndex to:endIndex on:aDevice |
|
1000 |
]. |
|
1001 |
device == aDevice ifTrue:[ |
|
1002 |
^ self widthOf:aString from:startIndex to:endIndex |
|
1003 |
]. |
|
2833 | 1004 |
^ (self onDevice:aDevice) widthOf:aString from:startIndex to:endIndex |
2545 | 1005 |
|
1006 |
"Created: / 30.4.1996 / 17:15:20 / cg" |
|
1007 |
"Modified: / 10.9.1998 / 12:10:11 / cg" |
|
1008 |
! |
|
1009 |
||
1010 |
widthOf:aString on:aDevice |
|
1011 |
"return the width of aString, if displayed on aDevice. |
|
1012 |
The argument may be a Character, String or some Text; |
|
1013 |
in the last case the width of the longest line in the text is returned." |
|
1014 |
||
1015 |
replacementFont notNil ifTrue:[ |
|
1016 |
^ replacementFont widthOf:aString on:aDevice |
|
1017 |
]. |
|
1018 |
device == aDevice ifTrue:[ |
|
1019 |
^ self widthOf:aString |
|
1020 |
]. |
|
2833 | 1021 |
^ (self onDevice:aDevice) widthOf:aString |
2545 | 1022 |
|
1023 |
"Created: / 30.4.1996 / 17:14:18 / cg" |
|
1024 |
"Modified: / 10.9.1998 / 12:10:26 / cg" |
|
1025 |
! |
|
1026 |
||
1027 |
widthOn:aDevice |
|
1028 |
"return the fonts width, if used on aDevice. |
|
1029 |
For variable pitch fonts, the width of the space character is returned. |
|
1030 |
For fixed fonts, this is the same as minWidth or maxWidth (or any character)." |
|
1031 |
||
1032 |
replacementFont notNil ifTrue:[ |
|
1033 |
^ replacementFont widthOn:aDevice |
|
1034 |
]. |
|
1035 |
device == aDevice ifTrue:[ |
|
1036 |
^ self width |
|
1037 |
]. |
|
2833 | 1038 |
^ (self onDevice:aDevice) width |
2545 | 1039 |
|
1040 |
"Created: / 30.4.1996 / 16:42:28 / cg" |
|
1041 |
"Modified: / 10.9.1998 / 12:11:33 / cg" |
|
2 | 1042 |
! ! |
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1043 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1044 |
!Font methodsFor:'st-80 queries'! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1045 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1046 |
fixedWidth |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1047 |
"return true, if this font is a fixed width font - |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1048 |
for st-80 compatibility" |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1049 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1050 |
^ self isFixedWidth |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1051 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1052 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1053 |
pixelSize |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1054 |
"return the height of the font in pixels - |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1055 |
for st-80 compatibility" |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1056 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1057 |
^ self height |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1058 |
! ! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1059 |
|
2433
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1060 |
!Font::DeviceFontHandle class methodsFor:'documentation'! |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1061 |
|
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1062 |
documentation |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1063 |
" |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1064 |
This is used as a finalization handle for fonts. |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1065 |
|
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1066 |
[author:] |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1067 |
Stefan Vogel (stefan@nilpferd) |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1068 |
|
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1069 |
[see also:] |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1070 |
Font |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1071 |
|
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1072 |
[instance variables:] |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1073 |
|
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1074 |
[class variables:] |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1075 |
" |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1076 |
! ! |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1077 |
|
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1078 |
!Font::DeviceFontHandle methodsFor:'accessing'! |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1079 |
|
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1080 |
setDevice:aDevice fontId:anId |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1081 |
"set the handles contents" |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1082 |
|
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1083 |
device := aDevice. |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1084 |
fontId := anId. |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1085 |
|
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1086 |
"Created: / 3.2.1999 / 16:08:31 / stefan" |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1087 |
! ! |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1088 |
|
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1089 |
!Font::DeviceFontHandle methodsFor:'finalization'! |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1090 |
|
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1091 |
disposed |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1092 |
"some Font has been collected - tell it to the x-server" |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1093 |
|
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1094 |
|id| |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1095 |
|
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1096 |
(id := fontId) notNil ifTrue:[ |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1097 |
fontId := nil. |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1098 |
device releaseFont:id. |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1099 |
] |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1100 |
|
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1101 |
"Created: / 3.2.1999 / 16:09:25 / stefan" |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1102 |
! ! |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1103 |
|
1087
1e5a93e03d7f
handle text-argument in withOf:
Claus Gittinger <cg@exept.de>
parents:
1067
diff
changeset
|
1104 |
!Font class methodsFor:'documentation'! |
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1105 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1106 |
version |
2980
409e9547a45c
ignore nil device in #onDevice:
Claus Gittinger <cg@exept.de>
parents:
2925
diff
changeset
|
1107 |
^ '$Header: /cvs/stx/stx/libview/Font.st,v 1.73 1999-10-26 17:52:10 cg Exp $' |
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1108 |
! ! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1109 |
Font initialize! |