author | Claus Gittinger <cg@exept.de> |
Sat, 15 Jun 1996 15:21:44 +0200 | |
changeset 865 | b9e71b51adc1 |
parent 774 | cd53f4973268 |
child 866 | 1f4f443ca0c7 |
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 |
||
21 |
!Font class methodsFor:'documentation'! |
|
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 |
||
192 |
!Font class methodsFor:'initialization'! |
|
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 | |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
199 |
(aDevice isNil or:[aFont device == aDevice]) ifTrue:[ |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
200 |
aFont restored. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
201 |
Lobby registerChange:aFont |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
202 |
] |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
203 |
] |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
204 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
205 |
|
0 | 206 |
initialize |
207 |
"initialize the font tracking array" |
|
208 |
||
23 | 209 |
Lobby isNil ifTrue:[ |
71 | 210 |
Lobby := Registry new. |
0 | 211 |
|
71 | 212 |
" |
213 |
want to be informed when returning from snapshot |
|
214 |
" |
|
215 |
ObjectMemory addDependent:self. |
|
0 | 216 |
|
71 | 217 |
" |
218 |
replacement handling is not yet finished |
|
219 |
" |
|
220 |
Replacements := Dictionary new. |
|
221 |
||
222 |
Replacements at:'clean' put:'courier'. |
|
223 |
Replacements at:'fixed' put:'courier'. |
|
224 |
Replacements at:'new century schoolbook' put:'times'. |
|
225 |
Replacements at:'lucida' put:'helvetica'. |
|
226 |
Replacements at:'lucidabright' put:'helvetica'. |
|
227 |
Replacements at:'lucidatypewriter' put:'courier'. |
|
228 |
Replacements at:'charter' put:'times'. |
|
229 |
Replacements at:'terminal' put:'courier'. |
|
0 | 230 |
] |
231 |
! |
|
232 |
||
233 |
update:something |
|
578 | 234 |
"sent early during restart - flush any leftover device handles" |
235 |
||
414
bf996c417cc8
flush device fonts early; allow selective flushing; catch errors during reinitialize of views
Claus Gittinger <cg@exept.de>
parents:
336
diff
changeset
|
236 |
(something == #earlyRestart) ifTrue:[ |
578 | 237 |
" |
238 |
this is sent by ObjectMemory when restarting from |
|
239 |
an image. All device specific information (especially device |
|
240 |
handles) are now invalid and have to be flushed |
|
241 |
" |
|
242 |
self flushDeviceFontsFor:nil |
|
0 | 243 |
] |
578 | 244 |
|
245 |
"Modified: 20.4.1996 / 23:22:23 / cg" |
|
865 | 246 |
! |
247 |
||
248 |
update:something with:aParameter from:changedObject |
|
249 |
"sent early during restart - flush any leftover device handles" |
|
250 |
||
251 |
(something == #earlyRestart) ifTrue:[ |
|
252 |
" |
|
253 |
this is sent by ObjectMemory when restarting from |
|
254 |
an image. All device specific information (especially device |
|
255 |
handles) are now invalid and have to be flushed |
|
256 |
" |
|
257 |
self flushDeviceFontsFor:nil |
|
258 |
] |
|
259 |
||
260 |
"Modified: 20.4.1996 / 23:22:23 / cg" |
|
261 |
"Created: 15.6.1996 / 15:21:30 / cg" |
|
0 | 262 |
! ! |
263 |
||
264 |
!Font class methodsFor:'instance creation'! |
|
265 |
||
266 |
family:familyString face:faceString style:styleString size:sizeNum encoding:encodingSym |
|
267 |
"returns a font for given family, face, style, size and encoding. |
|
71 | 268 |
The returned font is not associated to a specific device" |
0 | 269 |
|
54 | 270 |
|family newFont| |
0 | 271 |
|
272 |
(familyString at:1) isUppercase ifTrue:[ |
|
71 | 273 |
family := familyString asLowercase |
0 | 274 |
] ifFalse:[ |
71 | 275 |
family := familyString |
0 | 276 |
]. |
277 |
||
278 |
"look if this font is already known" |
|
279 |
||
115 | 280 |
Lobby do:[:aFont | |
71 | 281 |
(aFont family = family) ifTrue:[ |
282 |
(aFont face = faceString) ifTrue:[ |
|
283 |
(aFont style = styleString) ifTrue:[ |
|
284 |
(aFont size == sizeNum) ifTrue:[ |
|
285 |
(encodingSym isNil or:[aFont encoding == encodingSym]) ifTrue:[ |
|
286 |
^ aFont |
|
287 |
] |
|
288 |
] |
|
289 |
] |
|
290 |
] |
|
291 |
] |
|
0 | 292 |
]. |
12 | 293 |
newFont := self basicNew setFamily:familyString |
71 | 294 |
face:faceString |
295 |
style:styleString |
|
296 |
size:sizeNum |
|
297 |
encoding:encodingSym |
|
298 |
device:nil. |
|
23 | 299 |
Lobby register:newFont. |
0 | 300 |
^ newFont |
301 |
! ! |
|
302 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
303 |
!Font methodsFor:'accessing'! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
304 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
305 |
device |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
306 |
"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
|
307 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
308 |
^ device |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
309 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
310 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
311 |
fontId |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
312 |
"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
|
313 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
314 |
^ fontId |
731 | 315 |
! |
316 |
||
317 |
graphicsDevice |
|
318 |
"same as #device, for ST-80 compatibility naming. |
|
319 |
Return the device I am associated with." |
|
320 |
||
321 |
^ device |
|
322 |
||
323 |
"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
|
324 |
! ! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
325 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
326 |
!Font methodsFor:'binary storage'! |
0 | 327 |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
328 |
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
|
329 |
"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
|
330 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
331 |
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
|
332 |
self restored |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
333 |
! ! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
334 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
335 |
!Font methodsFor:'displaying'! |
71 | 336 |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
337 |
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
|
338 |
"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
|
339 |
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
|
340 |
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
|
341 |
|
441 | 342 |
|prevFont| |
343 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
344 |
replacementFont isNil ifTrue:[ |
441 | 345 |
'FONT: oops - no replacementFont. should not happen' errorPrintNL. |
346 |
^ self |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
347 |
]. |
441 | 348 |
prevFont := aGC font. |
442 | 349 |
aGC basicFont:replacementFont. |
441 | 350 |
aGC displayOpaqueString:aString from:index1 to:index2 x:x y:y. |
442 | 351 |
aGC basicFont:prevFont |
441 | 352 |
|
442 | 353 |
"Modified: 23.2.1996 / 17:16:24 / cg" |
71 | 354 |
! |
355 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
356 |
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
|
357 |
"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
|
358 |
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
|
359 |
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
|
360 |
|
441 | 361 |
|prevFont| |
362 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
363 |
replacementFont isNil ifTrue:[ |
441 | 364 |
'FONT: oops - no replacementFont. should not happen' errorPrintNL. |
365 |
^ self |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
366 |
]. |
441 | 367 |
prevFont := aGC font. |
442 | 368 |
aGC basicFont:replacementFont. |
441 | 369 |
aGC displayOpaqueString:aString x:x y:y. |
442 | 370 |
aGC basicFont:prevFont. |
441 | 371 |
|
442 | 372 |
"Modified: 23.2.1996 / 17:16:29 / cg" |
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
373 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
374 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
375 |
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
|
376 |
"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
|
377 |
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
|
378 |
for non-replacement fonts." |
0 | 379 |
|
441 | 380 |
|prevFont| |
381 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
382 |
replacementFont isNil ifTrue:[ |
441 | 383 |
'FONT: oops - no replacementFont. should not happen' errorPrintNL. |
384 |
^ self |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
385 |
]. |
441 | 386 |
prevFont := aGC font. |
442 | 387 |
aGC basicFont:replacementFont. |
441 | 388 |
aGC displayString:aString from:index1 to:index2 x:x y:y. |
442 | 389 |
aGC basicFont:prevFont. |
441 | 390 |
|
442 | 391 |
"Modified: 23.2.1996 / 17:16:33 / cg" |
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
392 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
393 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
394 |
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
|
395 |
"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
|
396 |
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
|
397 |
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
|
398 |
|
441 | 399 |
|prevFont| |
400 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
401 |
replacementFont isNil ifTrue:[ |
441 | 402 |
'FONT: oops - no replacementFont. should not happen' errorPrintNL. |
403 |
^ self |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
404 |
]. |
441 | 405 |
prevFont := aGC font. |
442 | 406 |
aGC basicFont:replacementFont. |
441 | 407 |
aGC displayString:aString x:x y:y. |
442 | 408 |
aGC basicFont:prevFont. |
441 | 409 |
|
442 | 410 |
"Modified: 23.2.1996 / 17:16:37 / cg" |
0 | 411 |
! ! |
412 |
||
413 |
!Font methodsFor:'getting a device font'! |
|
414 |
||
415 |
on:aDevice |
|
416 |
"create a new Font representing the same font as |
|
417 |
myself on aDevice; if one already exists, return the one." |
|
418 |
||
336 | 419 |
|newFont rep| |
0 | 420 |
|
421 |
"if I am already assigned to that device ..." |
|
422 |
(device == aDevice) ifTrue:[^ self]. |
|
423 |
||
424 |
"first look if not already there" |
|
115 | 425 |
Lobby do:[:aFont | |
441 | 426 |
(aDevice == aFont device) ifTrue:[ |
427 |
(size == aFont size) ifTrue:[ |
|
428 |
(family = aFont family) ifTrue:[ |
|
429 |
(face = aFont face) ifTrue:[ |
|
430 |
(style = aFont style) ifTrue:[ |
|
431 |
(encoding isNil or:[encoding == aFont encoding]) ifTrue:[ |
|
432 |
^ aFont |
|
433 |
] |
|
434 |
] |
|
435 |
] |
|
436 |
] |
|
437 |
] |
|
438 |
] |
|
0 | 439 |
]. |
440 |
||
157 | 441 |
newFont := self on:aDevice ifAbsent:nil. |
442 |
newFont isNil ifTrue:[ |
|
441 | 443 |
"oops did not work - (device has no such font)" |
0 | 444 |
|
441 | 445 |
rep := self replacementFontOn:aDevice. |
446 |
device isNil ifTrue:[ |
|
447 |
device := aDevice. |
|
448 |
replacementFont := rep. |
|
449 |
Lobby registerChange:self. |
|
450 |
^ self |
|
451 |
]. |
|
452 |
newFont := (self class basicNew) |
|
453 |
setFamily:family face:face style:style size:size encoding:encoding device:aDevice. |
|
454 |
newFont setReplacementFont:rep. |
|
455 |
Lobby register:newFont. |
|
456 |
^ newFont |
|
0 | 457 |
]. |
458 |
||
459 |
^ newFont |
|
441 | 460 |
|
461 |
" |
|
462 |
Font family:'foo' size:17 |
|
463 |
" |
|
464 |
||
465 |
"Modified: 23.2.1996 / 16:30:06 / cg" |
|
0 | 466 |
! |
467 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
468 |
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
|
469 |
"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
|
470 |
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
|
471 |
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
|
472 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
473 |
|newFont id| |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
474 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
475 |
"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
|
476 |
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
|
477 |
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
|
478 |
"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
|
479 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
480 |
^ exceptionBlock value |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
481 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
482 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
483 |
"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
|
484 |
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
|
485 |
device := aDevice. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
486 |
fontId := id. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
487 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
488 |
self getFontInfos. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
489 |
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
|
490 |
^ self |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
491 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
492 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
493 |
"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
|
494 |
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
|
495 |
face:face |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
496 |
style:style |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
497 |
size:size |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
498 |
encoding:encoding |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
499 |
device:aDevice. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
500 |
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
|
501 |
newFont getFontInfos. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
502 |
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
|
503 |
^ newFont |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
504 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
505 |
|
0 | 506 |
replacementFontOn:aDevice |
12 | 507 |
"return a replacement font for the receiver - this is needed, if |
508 |
an image is restored on another type of display, or one which has |
|
509 |
a different set of fonts." |
|
0 | 510 |
|
511 |
|id f alternative| |
|
512 |
||
144 | 513 |
alternative := Replacements at:family ifAbsent:nil. |
0 | 514 |
alternative notNil ifTrue:[ |
454
b31d0a7e5530
nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
515 |
id := aDevice getFontWithFamily:alternative |
b31d0a7e5530
nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
516 |
face:face |
b31d0a7e5530
nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
517 |
style:style |
b31d0a7e5530
nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
518 |
size:size |
b31d0a7e5530
nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
519 |
encoding:encoding. |
144 | 520 |
]. |
521 |
id notNil ifTrue:[ |
|
700 | 522 |
('FONT: use alternative for ' , (self userFriendlyName)) infoPrintCR. |
144 | 523 |
] ifFalse:[ |
454
b31d0a7e5530
nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
524 |
id := aDevice getDefaultFont. |
700 | 525 |
('FONT: use default for ' , (self userFriendlyName)) infoPrintCR. |
0 | 526 |
]. |
527 |
id isNil ifTrue:[ |
|
454
b31d0a7e5530
nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
528 |
"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
|
529 |
self error:'cannot get default font'. |
b31d0a7e5530
nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
530 |
^ nil |
0 | 531 |
]. |
532 |
f := self class basicNew. |
|
533 |
f setDevice:aDevice fontId:id. |
|
534 |
f getFontInfos. |
|
23 | 535 |
Lobby register:f. |
0 | 536 |
^ f |
454
b31d0a7e5530
nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
537 |
|
700 | 538 |
"Modified: 20.5.1996 / 10:32:23 / cg" |
0 | 539 |
! ! |
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 |
!Font methodsFor:'instance release'! |
0 | 542 |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
543 |
disposed |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
544 |
"some Font has been collected - tell it to the x-server" |
157 | 545 |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
546 |
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
|
547 |
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
|
548 |
fontId := nil |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
549 |
] |
0 | 550 |
! |
551 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
552 |
shallowCopyForFinalization |
578 | 553 |
"redefined to return a lightweight copy |
554 |
- all we need is the device handle" |
|
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| |
0 | 557 |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
558 |
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
|
559 |
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
|
560 |
^ aCopy |
578 | 561 |
|
562 |
"Modified: 20.4.1996 / 23:23:04 / cg" |
|
2 | 563 |
! ! |
564 |
||
0 | 565 |
!Font methodsFor:'printing & storing'! |
566 |
||
109 | 567 |
printOn:aStream |
578 | 568 |
"append a printed representation of the receiver to aStream. |
569 |
Redefined to print more about the fonts name" |
|
570 |
||
46 | 571 |
face isNil ifTrue:[ |
578 | 572 |
family isNil ifTrue:[ |
573 |
aStream nextPutAll:('a replacement-Font'). |
|
574 |
^ self |
|
575 |
]. |
|
576 |
aStream nextPutAll:('a ' , family , '-Font'). |
|
577 |
^ self. |
|
46 | 578 |
]. |
109 | 579 |
aStream nextPutAll:('a ' , family , '-' , |
578 | 580 |
face , '-' , |
581 |
style , '-' , |
|
582 |
size printString , '-Font') |
|
583 |
||
584 |
"Modified: 20.4.1996 / 23:25:11 / cg" |
|
0 | 585 |
! |
586 |
||
109 | 587 |
storeOn:aStream |
588 |
"append a character sequence to the argument, aStream from which the |
|
589 |
receiver can be reconstructed using readFrom:." |
|
0 | 590 |
|
109 | 591 |
aStream nextPutAll:'(Font family:'. family storeOn:aStream. |
592 |
aStream nextPutAll:' face:'. face storeOn:aStream. |
|
593 |
aStream nextPutAll:' style:'. style storeOn:aStream. |
|
594 |
aStream nextPutAll:' size:'. size storeOn:aStream. |
|
595 |
aStream nextPutAll:' encoding:'. encoding storeOn:aStream. |
|
596 |
aStream nextPut:$) |
|
597 |
||
598 |
" |
|
599 |
(Font family:'helvetica' size:10) storeString |
|
600 |
" |
|
453 | 601 |
! |
602 |
||
603 |
userFriendlyName |
|
578 | 604 |
"return a user-friendly printed representation of the receiver" |
605 |
||
453 | 606 |
|nm| |
607 |
||
608 |
nm := family. |
|
609 |
face notNil ifTrue:[ |
|
610 |
nm := nm , '-', face. |
|
611 |
]. |
|
612 |
style notNil ifTrue:[ |
|
613 |
nm := nm , '-', style. |
|
614 |
]. |
|
615 |
size notNil ifTrue:[ |
|
616 |
nm := nm , '-', size printString. |
|
617 |
]. |
|
456 | 618 |
encoding notNil ifTrue:[ |
619 |
nm := nm , '-', encoding . |
|
620 |
]. |
|
453 | 621 |
^ nm |
622 |
||
623 |
" |
|
624 |
View defaultFont userFriendlyName |
|
625 |
Button defaultFont userFriendlyName |
|
626 |
" |
|
456 | 627 |
|
578 | 628 |
"Modified: 20.4.1996 / 23:25:36 / cg" |
0 | 629 |
! ! |
2 | 630 |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
631 |
!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
|
632 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
633 |
getFontInfos |
578 | 634 |
"ask the device about all of my actual attributes" |
635 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
636 |
replacementFont isNil ifTrue:[ |
438 | 637 |
encoding := device encodingOf:fontId. |
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
638 |
ascent := device ascentOf:fontId. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
639 |
descent := device descentOf:fontId. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
640 |
maxAscent := device maxAscentOf:fontId. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
641 |
maxDescent := device maxDescentOf:fontId. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
642 |
minWidth := device minWidthOfFont:fontId. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
643 |
maxWidth := device maxWidthOfFont:fontId. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
644 |
width := device widthOf:' ' inFont:fontId. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
645 |
width < minWidth ifTrue:[ |
710 | 646 |
"/ some systems/fonts return a wrong value (0) for space-width |
647 |
"/ - at least with X11 ... |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
648 |
width := minWidth |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
649 |
] |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
650 |
] ifFalse:[ |
438 | 651 |
encoding := replacementFont encoding. |
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
652 |
ascent := replacementFont ascent. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
653 |
descent := replacementFont descent. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
654 |
maxAscent := replacementFont maxAscent. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
655 |
maxDescent := replacementFont maxDescent. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
656 |
width := replacementFont width. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
657 |
minWidth := replacementFont minWidth. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
658 |
maxWidth := replacementFont maxWidth. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
659 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
660 |
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
|
661 |
|
710 | 662 |
"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
|
663 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
664 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
665 |
restored |
578 | 666 |
"flush device handles when restored" |
667 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
668 |
device := nil. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
669 |
fontId := nil. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
670 |
replacementFont := nil |
578 | 671 |
|
672 |
"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
|
673 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
674 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
675 |
setDevice:aDevice |
578 | 676 |
"set the device handle" |
677 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
678 |
device := aDevice |
578 | 679 |
|
680 |
"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
|
681 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
682 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
683 |
setDevice:aDevice fontId:aFontId |
578 | 684 |
"set the device and font handles" |
685 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
686 |
device := aDevice. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
687 |
fontId := aFontId |
578 | 688 |
|
689 |
"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
|
690 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
691 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
692 |
setFamily:familyString face:faceString style:styleString size:sizeNum encoding:encodingSym device:aDevice |
578 | 693 |
"set my instance attributes" |
694 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
695 |
family := familyString. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
696 |
face := faceString. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
697 |
style := styleString. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
698 |
size := sizeNum. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
699 |
encoding := encodingSym. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
700 |
device := aDevice |
578 | 701 |
|
702 |
"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
|
703 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
704 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
705 |
setFontId:aFontId |
578 | 706 |
"set my font handle" |
707 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
708 |
fontId := aFontId |
578 | 709 |
|
710 |
"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
|
711 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
712 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
713 |
setReplacementFont:aFont |
578 | 714 |
"set my replacement font" |
715 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
716 |
replacementFont := aFont |
578 | 717 |
|
718 |
"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
|
719 |
! ! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
720 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
721 |
!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
|
722 |
|
628
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
723 |
ascentOn:aDevice |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
724 |
"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
|
725 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
726 |
device == aDevice ifTrue:[ |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
727 |
^ ascent |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
728 |
]. |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
729 |
^ (self on:aDevice) ascent |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
730 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
731 |
"Created: 30.4.1996 / 16:41:32 / cg" |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
732 |
"Modified: 30.4.1996 / 16:44:49 / cg" |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
733 |
! |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
734 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
735 |
descentOn:aDevice |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
736 |
"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
|
737 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
738 |
device == aDevice ifTrue:[ |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
739 |
^ descent |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
740 |
]. |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
741 |
^ (self on:aDevice) descent |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
742 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
743 |
"Created: 30.4.1996 / 16:41:43 / cg" |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
744 |
"Modified: 30.4.1996 / 16:45:02 / cg" |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
745 |
! |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
746 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
747 |
existsOn:aDevice |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
748 |
"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
|
749 |
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
|
750 |
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
|
751 |
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
|
752 |
will automatically take a replacement font." |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
753 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
754 |
^ (self on:aDevice ifAbsent:nil) notNil |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
755 |
! |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
756 |
|
667
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
757 |
heightOf:aString on:aDevice |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
758 |
"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
|
759 |
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
|
760 |
|
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
761 |
device == aDevice ifTrue:[ |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
762 |
^ self heightOf:aString |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
763 |
]. |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
764 |
^ (self on:aDevice) heightOf:aString |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
765 |
|
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
766 |
"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
|
767 |
"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
|
768 |
! |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
769 |
|
628
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
770 |
heightOn:aDevice |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
771 |
"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
|
772 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
773 |
device == aDevice ifTrue:[ |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
774 |
^ descent + ascent |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
775 |
]. |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
776 |
^ (self on:aDevice) height |
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 |
"Created: 30.4.1996 / 16:41:59 / cg" |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
779 |
"Modified: 30.4.1996 / 16:44:39 / cg" |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
780 |
! |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
781 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
782 |
widthOf:aString from:startIndex to:endIndex on:aDevice |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
783 |
"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
|
784 |
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
|
785 |
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
|
786 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
787 |
device == aDevice ifTrue:[ |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
788 |
^ self widthOf:aString from:startIndex to:endIndex |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
789 |
]. |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
790 |
^ (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
|
791 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
792 |
"Modified: 30.4.1996 / 17:14:50 / cg" |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
793 |
"Created: 30.4.1996 / 17:15:20 / cg" |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
794 |
! |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
795 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
796 |
widthOf:aString on:aDevice |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
797 |
"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
|
798 |
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
|
799 |
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
|
800 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
801 |
device == aDevice ifTrue:[ |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
802 |
^ self widthOf:aString |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
803 |
]. |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
804 |
^ (self on:aDevice) widthOf:aString |
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 |
"Created: 30.4.1996 / 17:14:18 / cg" |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
807 |
"Modified: 30.4.1996 / 17:14:50 / cg" |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
808 |
! |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
809 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
810 |
widthOn:aDevice |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
811 |
"return the fonts width, if used on aDevice. |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
812 |
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
|
813 |
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
|
814 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
815 |
device == aDevice ifTrue:[ |
774 | 816 |
^ self width |
628
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
817 |
]. |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
818 |
^ (self on:aDevice) width |
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 |
"Created: 30.4.1996 / 16:42:28 / cg" |
774 | 821 |
"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
|
822 |
! ! |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
823 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
824 |
!Font methodsFor:'queries-deviceFonts'! |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
825 |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
826 |
ascent |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
827 |
"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
|
828 |
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
|
829 |
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
|
830 |
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
|
831 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
832 |
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
|
833 |
self errorNoDevice |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
834 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
835 |
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
|
836 |
^ replacementFont ascent |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
837 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
838 |
^ ascent |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
839 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
840 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
841 |
descent |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
842 |
"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
|
843 |
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
|
844 |
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
|
845 |
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
|
846 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
847 |
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
|
848 |
self errorNoDevice |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
849 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
850 |
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
|
851 |
^ replacementFont descent |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
852 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
853 |
^ descent |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
854 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
855 |
|
628
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
856 |
fullName |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
857 |
"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
|
858 |
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
|
859 |
|
438 | 860 |
device isNil ifTrue:[ |
861 |
^ nil |
|
862 |
]. |
|
863 |
^ device fullNameOf:fontId. |
|
864 |
||
628
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
865 |
" |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
866 |
((Font name:'6x10') on:Display) fullName |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
867 |
" |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
868 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
869 |
"Modified: 30.4.1996 / 17:30:10 / cg" |
438 | 870 |
! |
871 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
872 |
height |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
873 |
"return the fonts characters 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
|
874 |
That is the number of units (usually pixels) on the device. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
875 |
The receiver must be associated to a device, |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
876 |
for this query to be legal." |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
877 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
878 |
device isNil ifTrue:[ |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
879 |
self errorNoDevice. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
880 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
881 |
replacementFont notNil ifTrue:[ |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
882 |
^ replacementFont height |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
883 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
884 |
^ descent + ascent. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
885 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
886 |
|
667
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
887 |
heightOf:textOrString |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
888 |
"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
|
889 |
the argument must be a String. |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
890 |
CAVEAT: |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
891 |
currently only constant height fonts are supported." |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
892 |
|
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
893 |
device isNil ifTrue:[ |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
894 |
self errorNoDevice. |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
895 |
^ 0 |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
896 |
]. |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
897 |
replacementFont notNil ifTrue:[ |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
898 |
^ replacementFont heightOf:textOrString |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
899 |
]. |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
900 |
|
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
901 |
^ descent + ascent |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
902 |
|
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
903 |
"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
|
904 |
! |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
905 |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
906 |
isFixedWidth |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
907 |
"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
|
908 |
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
|
909 |
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
|
910 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
911 |
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
|
912 |
self errorNoDevice. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
913 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
914 |
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
|
915 |
^ replacementFont isFixedWidth |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
916 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
917 |
^ isFixedWidth |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
918 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
919 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
920 |
maxAscent |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
921 |
"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
|
922 |
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
|
923 |
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
|
924 |
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
|
925 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
926 |
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
|
927 |
self errorNoDevice |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
928 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
929 |
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
|
930 |
^ replacementFont maxAscent |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
931 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
932 |
^ maxAscent |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
933 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
934 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
935 |
maxDescent |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
936 |
"return the 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
|
937 |
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
|
938 |
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
|
939 |
for this query to be legal." |
2 | 940 |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
941 |
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
|
942 |
self errorNoDevice |
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 |
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
|
945 |
^ replacementFont maxDescent |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
946 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
947 |
^ maxDescent |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
948 |
! |
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 |
maxHeight |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
951 |
"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
|
952 |
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
|
953 |
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
|
954 |
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
|
955 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
956 |
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
|
957 |
self errorNoDevice. |
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 |
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
|
960 |
^ replacementFont maxHeight |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
961 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
962 |
^ maxDescent + maxAscent. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
963 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
964 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
965 |
maxWidth |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
966 |
"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
|
967 |
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
|
968 |
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
|
969 |
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
|
970 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
971 |
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
|
972 |
self errorNoDevice |
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 |
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
|
975 |
^ replacementFont maxWidth |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
976 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
977 |
^ maxWidth |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
978 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
979 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
980 |
minWidth |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
981 |
"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
|
982 |
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
|
983 |
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
|
984 |
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
|
985 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
986 |
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
|
987 |
self errorNoDevice |
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 |
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
|
990 |
^ replacementFont minWidth |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
991 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
992 |
^ minWidth |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
993 |
! |
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 |
width |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
996 |
"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
|
997 |
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
|
998 |
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
|
999 |
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
|
1000 |
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
|
1001 |
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
|
1002 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1003 |
device isNil ifTrue:[ |
628
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
1004 |
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
|
1005 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1006 |
replacementFont notNil ifTrue:[ |
628
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
1007 |
^ 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
|
1008 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1009 |
^ width |
628
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
1010 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
1011 |
"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
|
1012 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1013 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1014 |
widthOf:textOrString |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1015 |
"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
|
1016 |
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
|
1017 |
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
|
1018 |
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
|
1019 |
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
|
1020 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1021 |
|this max| |
2 | 1022 |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1023 |
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
|
1024 |
self errorNoDevice. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1025 |
^ 0 |
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 |
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
|
1028 |
^ 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
|
1029 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1030 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1031 |
(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
|
1032 |
isFixedWidth ifFalse:[ |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1033 |
^ device widthOf:textOrString inFont:fontId |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1034 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1035 |
^ 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
|
1036 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1037 |
(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
|
1038 |
isFixedWidth ifFalse:[ |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1039 |
^ 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
|
1040 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1041 |
^ width |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1042 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1043 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1044 |
max := 0. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1045 |
isFixedWidth ifFalse:[ |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1046 |
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
|
1047 |
line notNil ifTrue:[ |
435
5288c637512e
care for nonStrings when asked for the size
Claus Gittinger <cg@exept.de>
parents:
434
diff
changeset
|
1048 |
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
|
1049 |
(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
|
1050 |
] |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1051 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1052 |
^ max |
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 do:[:lineString | |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1056 |
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
|
1057 |
(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
|
1058 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1059 |
^ max * width |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1060 |
|
435
5288c637512e
care for nonStrings when asked for the size
Claus Gittinger <cg@exept.de>
parents:
434
diff
changeset
|
1061 |
"Modified: 22.2.1996 / 21:53:52 / cg" |
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1062 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1063 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1064 |
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
|
1065 |
"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
|
1066 |
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
|
1067 |
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
|
1068 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1069 |
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
|
1070 |
self errorNoDevice. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1071 |
^ 0 |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1072 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1073 |
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
|
1074 |
^ 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
|
1075 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1076 |
(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
|
1077 |
isFixedWidth ifFalse:[ |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1078 |
^ 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
|
1079 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1080 |
^ (stop - start + 1) * width |
2 | 1081 |
! ! |
434
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 |
!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
|
1084 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1085 |
fixedWidth |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1086 |
"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
|
1087 |
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
|
1088 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1089 |
^ self isFixedWidth |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1090 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1091 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1092 |
pixelSize |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1093 |
"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
|
1094 |
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
|
1095 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1096 |
^ self height |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1097 |
! ! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1098 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1099 |
!Font class methodsFor:'documentation'! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1100 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1101 |
version |
865 | 1102 |
^ '$Header: /cvs/stx/stx/libview/Font.st,v 1.47 1996-06-15 13:21: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
|
1103 |
! ! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1104 |
Font initialize! |