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