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