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