author | Stefan Vogel <sv@exept.de> |
Wed, 25 Apr 2012 21:05:49 +0200 | |
changeset 5907 | ad7449037a9e |
parent 5668 | 7c7c6df62b22 |
child 5981 | 100d92bb2b39 |
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 |
|
5170 | 145 |
Font family:'courier' size:12 |
628
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
146 |
|
5170 | 147 |
Font |
148 |
family:'helvetica' |
|
149 |
face:'roman' |
|
150 |
style:'bold' |
|
151 |
size:16 |
|
152 |
||
153 |
Font |
|
154 |
family:'helvetica' |
|
155 |
pixelSize:20 |
|
628
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
156 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
157 |
|
5170 | 158 |
special (non-portable displayType specific) fonts (typically: old X11 fonts): |
628
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
159 |
|
5170 | 160 |
Font name:'6x10' |
628
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
161 |
|
5170 | 162 |
Font name:'k14' |
628
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
163 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
164 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
165 |
setting the font of a button: |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
166 |
[exBegin] |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
167 |
|b| |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
168 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
169 |
b := Button new. |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
170 |
b label:'hello'. |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
171 |
b font:(Font family:'helvetica' |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
172 |
face:'medium' |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
173 |
style:'roman' |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
174 |
size:16). |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
175 |
b open |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
176 |
[exEnd] |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
177 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
178 |
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
|
179 |
if it was used on some device: |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
180 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
181 |
aFont widthOf:'hello' on:Display |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
182 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
183 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
184 |
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
|
185 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
186 |
aFont ascentOn:Display |
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 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
189 |
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
|
190 |
a bit faster: |
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| |
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 |
... |
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 := aFont on:aDevice. |
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 |
aFont widthOf:'hello' |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
199 |
... |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
200 |
aFont ascent |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
201 |
... |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
202 |
" |
0 | 203 |
! ! |
204 |
||
1087
1e5a93e03d7f
handle text-argument in withOf:
Claus Gittinger <cg@exept.de>
parents:
1067
diff
changeset
|
205 |
!Font class methodsFor:'initialization'! |
0 | 206 |
|
207 |
initialize |
|
208 |
"initialize the font tracking array" |
|
209 |
||
3213 | 210 |
Replacements isNil ifTrue:[ |
211 |
Replacements := Dictionary new. |
|
71 | 212 |
|
5512
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
213 |
Replacements |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
214 |
at:'serif' put:#('times' 'times new roman' 'palatino' 'bookman'); |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
215 |
at:'sans-serif' put:#('arial' 'lucida' 'helvetica'); |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
216 |
at:'monospace' put:#('courier new' 'courier' 'andale mono' 'lucidatypewriter' 'fixed'). |
5145 | 217 |
|
5512
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
218 |
Replacements |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
219 |
at:'clean' put:#('courier'); |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
220 |
at:'fixed' put:#('courier'); |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
221 |
at:'new century schoolbook' put:#('times'); |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
222 |
at:'arial' put:#('helvetica' 'lucida'); |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
223 |
at:'lucida' put:#('arial' 'helvetica'); |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
224 |
at:'lucidabright' put:#('arial' 'helvetica'); |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
225 |
at:'lucidatypewriter' put:#('courier' 'courier new'); |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
226 |
at:'courier' put:#('courier new'); |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
227 |
at:'charter' put:#('times' 'times new roman'); |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
228 |
at:'times new roman' put:#('times'); |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
229 |
at:'times' put:#('times'); |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
230 |
at:'terminal' put:#('courier' 'courier new'); |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
231 |
at:'helvetica' put:#('arial' 'lucida'). |
3213 | 232 |
] |
0 | 233 |
! ! |
234 |
||
1087
1e5a93e03d7f
handle text-argument in withOf:
Claus Gittinger <cg@exept.de>
parents:
1067
diff
changeset
|
235 |
!Font class methodsFor:'instance creation'! |
0 | 236 |
|
5186 | 237 |
family:familyString face:faceString style:styleString size:sizeArgOrNil sizeUnit:sizeUnitArg encoding:encodingSym |
5167 | 238 |
"returns a font for given family, face, style, size and encoding. |
5225 | 239 |
The returned font is not associated to a specific device." |
5167 | 240 |
|
54 | 241 |
|family newFont| |
0 | 242 |
|
243 |
(familyString at:1) isUppercase ifTrue:[ |
|
2925 | 244 |
family := familyString asLowercase |
0 | 245 |
] ifFalse:[ |
2925 | 246 |
family := familyString |
0 | 247 |
]. |
248 |
||
1372
2b55617a712f
keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents:
1229
diff
changeset
|
249 |
newFont := self basicNew |
2925 | 250 |
setFamily:familyString |
251 |
face:faceString |
|
252 |
style:styleString |
|
5167 | 253 |
size:sizeArgOrNil |
5186 | 254 |
sizeUnit:sizeUnitArg |
2925 | 255 |
encoding:encodingSym |
256 |
device:nil. |
|
1372
2b55617a712f
keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents:
1229
diff
changeset
|
257 |
|
5167 | 258 |
"look if this font is already known on the default device (the most common case)" |
259 |
||
260 |
Display notNil ifTrue:[ |
|
261 |
Display deviceFonts do:[:aFont | |
|
262 |
(newFont sameDeviceFontAs:aFont) ifTrue:[ |
|
5442
218a6ae3e112
changed: #family:face:style:size:sizeUnit:encoding:
Claus Gittinger <cg@exept.de>
parents:
5253
diff
changeset
|
263 |
"/ self assert:(aFont encoding = newFont encoding). |
5167 | 264 |
^ aFont |
265 |
] |
|
266 |
] |
|
267 |
]. |
|
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 |
|
5559 | 301 |
!Font methodsFor:'converting'! |
302 |
||
303 |
asFontDescription |
|
304 |
^ FontDescription |
|
305 |
family:family |
|
306 |
face:face |
|
307 |
style:style |
|
308 |
size:size |
|
309 |
sizeUnit:(sizeUnit ? #pt) |
|
310 |
encoding:encoding |
|
311 |
! ! |
|
312 |
||
3027
efb7b0c760f5
blocked deepCopying of fonts
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
313 |
!Font methodsFor:'copying'! |
efb7b0c760f5
blocked deepCopying of fonts
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
314 |
|
4934 | 315 |
deepCopyUsing:aDictionary postCopySelector:postCopySelector |
3027
efb7b0c760f5
blocked deepCopying of fonts
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
316 |
^ self |
efb7b0c760f5
blocked deepCopying of fonts
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
317 |
! ! |
efb7b0c760f5
blocked deepCopying of fonts
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
318 |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
319 |
!Font methodsFor:'displaying'! |
71 | 320 |
|
3663 | 321 |
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
|
322 |
"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
|
323 |
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
|
324 |
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
|
325 |
|
441 | 326 |
|prevFont| |
327 |
||
2545 | 328 |
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
|
329 |
replacementFont isNil ifTrue:[ |
2545 | 330 |
fontId notNil ifTrue:[ |
331 |
aGC basicFont:self. |
|
3663 | 332 |
aGC displayString:aString from:index1 to:index2 x:x y:y opaque:opaque. |
2545 | 333 |
] ifFalse:[ |
334 |
'Font: [warning]: no replacementFont. should not happen' errorPrintCR. |
|
335 |
]. |
|
336 |
] ifFalse:[ |
|
337 |
aGC basicFont:replacementFont. |
|
3663 | 338 |
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
|
339 |
]. |
442 | 340 |
aGC basicFont:prevFont. |
441 | 341 |
|
1176
e0e2c8cbb3c8
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1166
diff
changeset
|
342 |
"Modified: 10.1.1997 / 17:51:17 / cg" |
0 | 343 |
! ! |
344 |
||
345 |
!Font methodsFor:'getting a device font'! |
|
346 |
||
3628 | 347 |
onDevice:aDevice |
0 | 348 |
"create a new Font representing the same font as |
349 |
myself on aDevice; if one already exists, return the one." |
|
350 |
||
5167 | 351 |
|newFont rep| |
3628 | 352 |
|
353 |
"if I am already assigned to that device ..." |
|
354 |
(device == aDevice) ifTrue:[^ self]. |
|
355 |
||
5222
09fb6ebff525
changed #onDevice: - formatting
Stefan Vogel <sv@exept.de>
parents:
5197
diff
changeset
|
356 |
(aDevice isNil and:[device notNil]) ifTrue:[ |
09fb6ebff525
changed #onDevice: - formatting
Stefan Vogel <sv@exept.de>
parents:
5197
diff
changeset
|
357 |
^ self |
5174 | 358 |
]. |
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
|
359 |
|
3628 | 360 |
aDevice deviceFonts do:[:aFont | |
5167 | 361 |
(self sameDeviceFontAs:aFont) ifTrue:[ |
362 |
^ aFont |
|
363 |
]. |
|
3628 | 364 |
]. |
365 |
||
366 |
newFont := self onDevice:aDevice ifAbsent:nil. |
|
367 |
newFont isNil ifTrue:[ |
|
368 |
"oops did not work - (device has no such font)" |
|
3623 | 369 |
|
3628 | 370 |
aDevice isOpen ifFalse:[ |
371 |
"/ the display device is not connected |
|
372 |
"/ (or has a broken connection). |
|
3739
909fefa92b5a
Raise #drawingOnClosedDeviceSignal instead of #error
Stefan Vogel <sv@exept.de>
parents:
3663
diff
changeset
|
373 |
aDevice class drawingOnClosedDeviceSignal raiseRequestWith:aDevice. |
3628 | 374 |
^ self. |
375 |
]. |
|
5040
b28c261dd543
replacement font handling did not remember font in the registry,
Claus Gittinger <cg@exept.de>
parents:
4934
diff
changeset
|
376 |
"/ look for a replacement font |
3628 | 377 |
|
378 |
rep := self replacementFontOnDevice:aDevice. |
|
379 |
device isNil ifTrue:[ |
|
380 |
device := aDevice. |
|
381 |
replacementFont := rep. |
|
382 |
aDevice registerFont:self. |
|
383 |
^ self |
|
384 |
]. |
|
3623 | 385 |
|
3628 | 386 |
newFont := (self class basicNew) |
5167 | 387 |
setFamily:family |
388 |
face:face |
|
389 |
style:style |
|
5186 | 390 |
size:(sizeUnit == #px ifTrue:[pixelSize] ifFalse:[size]) |
391 |
sizeUnit:sizeUnit |
|
5167 | 392 |
encoding:encoding |
393 |
device:aDevice. |
|
5512
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
394 |
newFont isGenericFont:self isGenericFont. |
3628 | 395 |
newFont setReplacementFont:rep. |
396 |
aDevice registerFont:newFont. |
|
397 |
^ newFont |
|
398 |
]. |
|
399 |
||
400 |
^ newFont |
|
401 |
||
402 |
" |
|
403 |
Font family:'foo' size:17 |
|
404 |
" |
|
405 |
||
406 |
"Modified: 14.4.1997 / 18:22:31 / cg" |
|
2848 | 407 |
! |
408 |
||
3628 | 409 |
onDevice:aDevice ifAbsent:exceptionBlock |
2848 | 410 |
"create a new Font representing the same font as |
411 |
myself on aDevice. This does NOT try to look for existing |
|
412 |
or replacement fonts (i.e. can be used to get physical fonts)." |
|
413 |
||
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
|
414 |
|id| |
2848 | 415 |
|
416 |
"receiver was not associated - do it now" |
|
417 |
device isNil ifTrue:[ |
|
3785 | 418 |
"ask that device for the font" |
5167 | 419 |
id := aDevice |
420 |
getFontWithFamily:family |
|
421 |
face:face |
|
422 |
style:style |
|
5186 | 423 |
size:(sizeUnit == #px ifTrue:[pixelSize] ifFalse:[size]) |
424 |
sizeUnit:sizeUnit |
|
5167 | 425 |
encoding:encoding. |
3785 | 426 |
id isNil ifTrue:[ |
427 |
"oops did not work - (device has no such font)" |
|
428 |
||
429 |
^ exceptionBlock value |
|
430 |
]. |
|
431 |
||
2848 | 432 |
device := aDevice. |
433 |
fontId := id. |
|
434 |
||
435 |
self getFontInfos. |
|
436 |
aDevice registerFont:self. |
|
437 |
^ self |
|
438 |
]. |
|
439 |
||
440 |
"receiver was already associated to another device - need a new font" |
|
3785 | 441 |
^ super onDevice:aDevice ifAbsent:exceptionBlock |
2848 | 442 |
! |
443 |
||
3628 | 444 |
replacementFontOnDevice:aDevice |
12 | 445 |
"return a replacement font for the receiver - this is needed, if |
446 |
an image is restored on another type of display, or one which has |
|
447 |
a different set of fonts." |
|
0 | 448 |
|
5512
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
449 |
|id f trySize alternatives alternateFamilyName| |
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 |
|
5512
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
451 |
"try font with smaller size - |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
452 |
but do not try this on scaled fonts (they have size == 0)" |
0 | 453 |
|
5512
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
454 |
alternateFamilyName := family. |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
455 |
self isGenericFont ifFalse:[ |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
456 |
trySize := size ? 0. |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
457 |
[id isNil and:[trySize := trySize - 1. trySize > 4]] whileTrue:[ |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
458 |
id := aDevice |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
459 |
getFontWithFamily:family |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
460 |
face:face |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
461 |
style:style |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
462 |
size:(sizeUnit == #px ifTrue:[pixelSize] ifFalse:[trySize]) |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
463 |
sizeUnit:sizeUnit |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
464 |
encoding:encoding. |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
465 |
]. |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
466 |
]. |
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
|
467 |
|
144 | 468 |
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
|
469 |
('Font [info]: use alternative size ', trySize printString, ' for ' , (self userFriendlyName)) infoPrintCR. |
144 | 470 |
] ifFalse:[ |
5512
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
471 |
alternatives := Replacements at:family asLowercase ifAbsent:nil. |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
472 |
alternatives notNil ifTrue:[ |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
473 |
alternatives detect:[:eachAlternateFamilyName| |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
474 |
trySize := size ? 0. |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
475 |
[ |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
476 |
id := aDevice |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
477 |
getFontWithFamily:eachAlternateFamilyName |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
478 |
face:face |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
479 |
style:style |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
480 |
size:(sizeUnit == #px ifTrue:[pixelSize] ifFalse:[trySize]) |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
481 |
sizeUnit:sizeUnit |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
482 |
encoding:encoding. |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
483 |
] doWhile:[id isNil and:[trySize := trySize - 1. trySize > 4]]. |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
484 |
alternateFamilyName := eachAlternateFamilyName. |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
485 |
id notNil. |
5526
2eb1df09a195
changed: #replacementFontOnDevice:
Stefan Vogel <sv@exept.de>
parents:
5512
diff
changeset
|
486 |
] ifNone:[]. |
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
|
487 |
]. |
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
|
488 |
id notNil ifTrue:[ |
5512
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
489 |
('Font [info]: use alternative: ', alternateFamilyName , ' for: ' , (self userFriendlyName)) infoPrintCR. |
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
|
490 |
] ifFalse:[ |
5907
ad7449037a9e
changed: #replacementFontOnDevice:
Stefan Vogel <sv@exept.de>
parents:
5668
diff
changeset
|
491 |
id := aDevice getDefaultFontWithEncoding: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
|
492 |
('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
|
493 |
]. |
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
|
494 |
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
|
495 |
"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
|
496 |
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
|
497 |
^ 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
|
498 |
]. |
0 | 499 |
]. |
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
|
500 |
|
5040
b28c261dd543
replacement font handling did not remember font in the registry,
Claus Gittinger <cg@exept.de>
parents:
4934
diff
changeset
|
501 |
"/ 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
|
502 |
"/ to avoid allocating multiple replacements for the same font |
5512
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
503 |
aDevice deviceFonts do:[:eachDeviceFont | |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
504 |
(self sameDeviceFontAs:eachDeviceFont) ifTrue:[ |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
505 |
^ eachDeviceFont |
5040
b28c261dd543
replacement font handling did not remember font in the registry,
Claus Gittinger <cg@exept.de>
parents:
4934
diff
changeset
|
506 |
] |
b28c261dd543
replacement font handling did not remember font in the registry,
Claus Gittinger <cg@exept.de>
parents:
4934
diff
changeset
|
507 |
]. |
b28c261dd543
replacement font handling did not remember font in the registry,
Claus Gittinger <cg@exept.de>
parents:
4934
diff
changeset
|
508 |
|
0 | 509 |
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
|
510 |
|
5512
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
511 |
f setFamily:alternateFamilyName face:face style:style size:(sizeUnit == #px ifTrue:[pixelSize] ifFalse:[trySize]) sizeUnit:sizeUnit encoding:encoding device:aDevice. |
0 | 512 |
f setDevice:aDevice fontId:id. |
513 |
f getFontInfos. |
|
1372
2b55617a712f
keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents:
1229
diff
changeset
|
514 |
aDevice registerFont:f. |
0 | 515 |
^ f |
454
b31d0a7e5530
nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
516 |
|
1166 | 517 |
"Modified: 10.1.1997 / 15:40:21 / cg" |
0 | 518 |
! ! |
519 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
520 |
!Font methodsFor:'instance release'! |
0 | 521 |
|
2848 | 522 |
executor |
578 | 523 |
"redefined to return a lightweight copy |
524 |
- all we need is the device handle" |
|
525 |
||
2848 | 526 |
^ DeviceFontHandle basicNew setDevice:device fontId:fontId. |
578 | 527 |
|
2433
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
528 |
"Modified: / 20.4.1996 / 23:23:04 / cg" |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
529 |
"Modified: / 3.2.1999 / 16:13:10 / stefan" |
2 | 530 |
! ! |
531 |
||
4852 | 532 |
!Font methodsFor:'object persistency'! |
0 | 533 |
|
4207 | 534 |
elementDescriptorFor:aspect |
4852 | 535 |
"support for persistency: |
536 |
answer the elements to be made persistent with an ObjectCoder" |
|
537 |
||
4006 | 538 |
"binary storage encoding vector" |
539 |
||
540 |
^ Array |
|
541 |
with:(#family->self family) |
|
542 |
with:(#face->self face) |
|
543 |
with:(#style->self style) |
|
544 |
with:(#size->self size) |
|
545 |
with:(#encoding->self encoding) |
|
4852 | 546 |
! ! |
547 |
||
548 |
!Font methodsFor:'printing & storing'! |
|
3934 | 549 |
|
109 | 550 |
printOn:aStream |
2805 | 551 |
"append a user printed representation of the receiver to aStream. |
552 |
The format is suitable for a human - not meant to be read back. |
|
578 | 553 |
Redefined to print more about the fonts name" |
554 |
||
46 | 555 |
face isNil ifTrue:[ |
578 | 556 |
family isNil ifTrue:[ |
557 |
aStream nextPutAll:('a replacement-Font'). |
|
558 |
^ self |
|
559 |
]. |
|
560 |
aStream nextPutAll:('a ' , family , '-Font'). |
|
561 |
^ self. |
|
46 | 562 |
]. |
109 | 563 |
aStream nextPutAll:('a ' , family , '-' , |
578 | 564 |
face , '-' , |
4803 | 565 |
style printString , '-' , |
4007 | 566 |
size printString , |
567 |
' (' , encoding printString , ')' , |
|
568 |
'-Font') |
|
578 | 569 |
|
570 |
"Modified: 20.4.1996 / 23:25:11 / cg" |
|
0 | 571 |
! |
572 |
||
109 | 573 |
storeOn:aStream |
574 |
"append a character sequence to the argument, aStream from which the |
|
575 |
receiver can be reconstructed using readFrom:." |
|
0 | 576 |
|
109 | 577 |
aStream nextPutAll:'(Font family:'. family storeOn:aStream. |
578 |
aStream nextPutAll:' face:'. face storeOn:aStream. |
|
579 |
aStream nextPutAll:' style:'. style storeOn:aStream. |
|
580 |
aStream nextPutAll:' size:'. size storeOn:aStream. |
|
581 |
aStream nextPutAll:' encoding:'. encoding storeOn:aStream. |
|
582 |
aStream nextPut:$) |
|
583 |
||
584 |
" |
|
585 |
(Font family:'helvetica' size:10) storeString |
|
586 |
" |
|
0 | 587 |
! ! |
2 | 588 |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
589 |
!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
|
590 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
591 |
getFontInfos |
578 | 592 |
"ask the device about all of my actual attributes" |
593 |
||
5578 | 594 |
|info fetchedEncoding| |
991 | 595 |
|
3479 | 596 |
replacementFont notNil ifTrue:[ |
597 |
replacementFont getFontInfos. |
|
598 |
^ self |
|
599 |
]. |
|
991 | 600 |
|
4023 | 601 |
info := self getFontMetrics. |
602 |
||
603 |
minCode := info minCode. |
|
604 |
maxCode := info maxCode. |
|
605 |
direction := info direction. |
|
606 |
||
5578 | 607 |
fetchedEncoding := info encoding. |
608 |
fetchedEncoding isNil ifTrue:[ |
|
609 |
fetchedEncoding := device encodingOf:fontId. |
|
610 |
]. |
|
611 |
encoding notNil ifTrue:[ |
|
5582 | 612 |
(encoding ~= fetchedEncoding |
613 |
and:[encoding ~= #'ms-default' |
|
614 |
and:[encoding ~= #*]]) ifTrue:[ |
|
5585 | 615 |
'Font [warning]: encoding for ' infoPrint. self infoPrint. ' should be ' infoPrint. encoding infoPrint. |
5579 | 616 |
' is ' infoPrint. fetchedEncoding infoPrintCR. |
5582 | 617 |
]. |
5578 | 618 |
] ifFalse:[ |
619 |
encoding := fetchedEncoding. |
|
3527 | 620 |
]. |
3479 | 621 |
ascent := info ascent. |
622 |
descent := info descent. |
|
623 |
maxAscent := info maxAscent. |
|
624 |
maxDescent := info maxDescent. |
|
625 |
minWidth := info minWidth. |
|
626 |
maxWidth := info maxWidth. |
|
627 |
width := info averageWidth. |
|
991 | 628 |
|
629 |
width < minWidth ifTrue:[ |
|
630 |
"/ some systems/fonts return a wrong value (0) as width of a space |
|
631 |
"/ - at least with X11 ... |
|
632 |
width := minWidth |
|
994 | 633 |
]. |
5647 | 634 |
isFixedWidth := minWidth == maxWidth. |
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
635 |
|
5647 | 636 |
"/ a temporary hack for the vista-cleartype font redraw problem |
5668 | 637 |
false "isFixedWidth" ifFalse:[ |
5647 | 638 |
UserPreferences current workAroundRenderingBugOnVista ifTrue:[ |
639 |
self hasOverlappingCharacters:true. |
|
640 |
] |
|
641 |
]. |
|
642 |
"Modified: / 09-11-2010 / 12:58: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
|
643 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
644 |
|
3658
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
645 |
getFontMetrics |
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
646 |
"ask the device about all of my actual attributes" |
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
647 |
|
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
648 |
replacementFont notNil ifTrue:[ |
4023 | 649 |
^ replacementFont getFontMetrics |
3658
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
650 |
]. |
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
651 |
|
4023 | 652 |
^ device fontMetricsOf:fontId. |
3658
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
653 |
! |
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
654 |
|
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
655 |
getFontResolution |
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
656 |
"ask the device about all of my actual attributes" |
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
657 |
|
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
658 |
|f| |
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
659 |
|
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
660 |
f := fontId. |
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
661 |
replacementFont notNil ifTrue:[ |
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
662 |
f := replacementFont fontId. |
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
663 |
]. |
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
664 |
|
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
665 |
^ device fontResolutionOf:f. |
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
666 |
! |
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
667 |
|
2846 | 668 |
releaseFromDevice |
669 |
"I am no longer available on the device" |
|
670 |
||
671 |
device := nil. |
|
672 |
fontId := nil. |
|
673 |
replacementFont := nil |
|
674 |
||
675 |
"Modified: 20.4.1996 / 23:26:26 / cg" |
|
676 |
! |
|
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 |
restored |
578 | 679 |
"flush device handles when restored" |
680 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
681 |
device := nil. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
682 |
fontId := nil. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
683 |
replacementFont := nil |
578 | 684 |
|
685 |
"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
|
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 |
setDevice:aDevice |
578 | 689 |
"set the device 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 |
device := aDevice |
578 | 692 |
|
693 |
"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
|
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 |
setDevice:aDevice fontId:aFontId |
578 | 697 |
"set the device and font handles" |
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 |
device := aDevice. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
700 |
fontId := aFontId |
578 | 701 |
|
702 |
"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
|
703 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
704 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
705 |
setFamily:familyString face:faceString style:styleString size:sizeNum encoding:encodingSym device:aDevice |
5186 | 706 |
<resource: #obsolete> |
707 |
||
708 |
self |
|
709 |
setFamily:familyString |
|
710 |
face:faceString |
|
711 |
style:styleString |
|
712 |
size:sizeNum |
|
713 |
sizeUnit:#pt |
|
714 |
encoding:encodingSym |
|
715 |
device:aDevice |
|
716 |
! |
|
717 |
||
718 |
setFamily:familyString face:faceString style:styleString size:sizeArg sizeUnit:sizeUnitArg encoding:encodingSym device:aDevice |
|
578 | 719 |
"set my instance attributes" |
720 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
721 |
family := familyString. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
722 |
face := faceString. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
723 |
style := styleString. |
5253 | 724 |
sizeUnit := (sizeUnitArg ? #pt). |
725 |
sizeUnit == #pt ifTrue:[ |
|
726 |
size := sizeArg |
|
727 |
] ifFalse:[ |
|
728 |
sizeUnit == #px ifTrue:[ |
|
729 |
pixelSize := sizeArg |
|
730 |
] ifFalse:[ |
|
731 |
self error:'invalid sizeUnit' mayProceed:true. |
|
732 |
size := 12. |
|
733 |
sizeUnit := #pt |
|
734 |
]. |
|
735 |
]. |
|
5167 | 736 |
encoding := encodingSym. |
737 |
device := aDevice |
|
738 |
||
739 |
"Modified: 20.4.1996 / 23:26:56 / cg" |
|
740 |
! |
|
741 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
742 |
setFontId:aFontId |
578 | 743 |
"set my font handle" |
744 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
745 |
fontId := aFontId |
578 | 746 |
|
747 |
"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
|
748 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
749 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
750 |
setReplacementFont:aFont |
578 | 751 |
"set my replacement font" |
752 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
753 |
replacementFont := aFont |
578 | 754 |
|
755 |
"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
|
756 |
! ! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
757 |
|
2545 | 758 |
!Font methodsFor:'queries-deviceFonts'! |
759 |
||
760 |
fullName |
|
761 |
"return the full (device specific) name of the receiver. |
|
762 |
This is query only valid if the receiver is associated to a device" |
|
763 |
||
764 |
device isNil ifTrue:[ |
|
765 |
^ nil |
|
766 |
]. |
|
3415
5318d7f58d35
Rename #fullNameOf: to #fullFontNameOf:
Stefan Vogel <sv@exept.de>
parents:
3213
diff
changeset
|
767 |
^ device fullFontNameOf:fontId. |
2545 | 768 |
|
769 |
" |
|
770 |
((Font name:'6x10') on:Display) fullName |
|
771 |
" |
|
772 |
||
773 |
"Modified: 30.4.1996 / 17:30:10 / cg" |
|
774 |
! |
|
775 |
||
776 |
isFixedWidth |
|
777 |
"return true, if all characters have same width (as in courier). |
|
778 |
The receiver must be associated to a device, |
|
779 |
for this query to be legal." |
|
780 |
||
781 |
device isNil ifTrue:[ |
|
782 |
self errorNoDevice. |
|
783 |
]. |
|
784 |
replacementFont notNil ifTrue:[ |
|
785 |
^ replacementFont isFixedWidth |
|
786 |
]. |
|
787 |
^ isFixedWidth |
|
788 |
! ! |
|
789 |
||
790 |
!Font methodsFor:'queries-dimensions'! |
|
791 |
||
792 |
ascent |
|
793 |
"return the font-ascent (i.e. the normal average of all characters); |
|
794 |
That is the number of units (usually pixels) above the baseline. |
|
795 |
The receiver must be associated to a device, |
|
796 |
for this query to be legal." |
|
797 |
||
798 |
device isNil ifTrue:[ |
|
799 |
self errorNoDevice |
|
800 |
]. |
|
801 |
replacementFont notNil ifTrue:[ |
|
802 |
^ replacementFont ascent |
|
803 |
]. |
|
804 |
^ ascent |
|
805 |
! |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
806 |
|
628
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
807 |
ascentOn:aDevice |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
808 |
"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
|
809 |
|
2321
75a179c343cf
try replacement forn first if nonnil in queries
Claus Gittinger <cg@exept.de>
parents:
2096
diff
changeset
|
810 |
replacementFont notNil ifTrue:[ |
75a179c343cf
try replacement forn first if nonnil in queries
Claus Gittinger <cg@exept.de>
parents:
2096
diff
changeset
|
811 |
^ replacementFont ascentOn:aDevice |
75a179c343cf
try replacement forn first if nonnil in queries
Claus Gittinger <cg@exept.de>
parents:
2096
diff
changeset
|
812 |
]. |
628
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
813 |
device == aDevice ifTrue:[ |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
814 |
^ ascent |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
815 |
]. |
2833 | 816 |
^ (self onDevice:aDevice) ascent |
628
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
817 |
|
2321
75a179c343cf
try replacement forn first if nonnil in queries
Claus Gittinger <cg@exept.de>
parents:
2096
diff
changeset
|
818 |
"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
|
819 |
"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
|
820 |
! |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
821 |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
822 |
descent |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
823 |
"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
|
824 |
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
|
825 |
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
|
826 |
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
|
827 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
828 |
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
|
829 |
self errorNoDevice |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
830 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
831 |
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
|
832 |
^ replacementFont descent |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
833 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
834 |
^ descent |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
835 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
836 |
|
2545 | 837 |
descentOn:aDevice |
838 |
"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
|
839 |
|
2545 | 840 |
replacementFont notNil ifTrue:[ |
841 |
^ replacementFont descentOn:aDevice |
|
438 | 842 |
]. |
2545 | 843 |
device == aDevice ifTrue:[ |
844 |
^ descent |
|
845 |
]. |
|
2833 | 846 |
^ (self onDevice:aDevice) descent |
438 | 847 |
|
2545 | 848 |
"Created: / 30.4.1996 / 16:41:43 / cg" |
849 |
"Modified: / 10.9.1998 / 12:09:30 / cg" |
|
438 | 850 |
! |
851 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
852 |
height |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
853 |
"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
|
854 |
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
|
855 |
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
|
856 |
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
|
857 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
858 |
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
|
859 |
self errorNoDevice. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
860 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
861 |
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
|
862 |
^ replacementFont height |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
863 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
864 |
^ descent + ascent. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
865 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
866 |
|
667
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
867 |
heightOf:textOrString |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
868 |
"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
|
869 |
the argument must be a String. |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
870 |
CAVEAT: |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
871 |
currently only constant height fonts are supported." |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
872 |
|
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
873 |
device isNil ifTrue:[ |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
874 |
self errorNoDevice. |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
875 |
^ 0 |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
876 |
]. |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
877 |
replacementFont notNil ifTrue:[ |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
878 |
^ replacementFont heightOf:textOrString |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
879 |
]. |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
880 |
|
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
881 |
^ descent + ascent |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
882 |
|
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
883 |
"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
|
884 |
! |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
885 |
|
2545 | 886 |
heightOf:aString on:aDevice |
887 |
"return the height of aString, if displayed on aDevice. |
|
888 |
The argument must be a string-like object." |
|
889 |
||
890 |
replacementFont notNil ifTrue:[ |
|
891 |
^ replacementFont heightOf:aString on:aDevice |
|
892 |
]. |
|
893 |
device == aDevice ifTrue:[ |
|
894 |
^ self heightOf:aString |
|
895 |
]. |
|
2833 | 896 |
^ (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
|
897 |
|
2545 | 898 |
"Created: / 30.4.1996 / 17:14:18 / cg" |
899 |
"Modified: / 10.9.1998 / 12:09:47 / cg" |
|
900 |
! |
|
901 |
||
902 |
heightOn:aDevice |
|
903 |
"return the fonts height (average), if used on aDevice." |
|
904 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
905 |
replacementFont notNil ifTrue:[ |
2545 | 906 |
^ replacementFont heightOn:aDevice |
907 |
]. |
|
908 |
device == aDevice ifTrue:[ |
|
909 |
^ 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
|
910 |
]. |
2833 | 911 |
^ (self onDevice:aDevice) height |
2545 | 912 |
|
913 |
"Created: / 30.4.1996 / 16:41:59 / cg" |
|
914 |
"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
|
915 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
916 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
917 |
maxAscent |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
918 |
"return the fonts 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
|
919 |
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
|
920 |
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
|
921 |
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
|
922 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
923 |
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
|
924 |
self errorNoDevice |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
925 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
926 |
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
|
927 |
^ replacementFont maxAscent |
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 |
^ maxAscent |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
930 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
931 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
932 |
maxDescent |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
933 |
"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
|
934 |
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
|
935 |
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
|
936 |
for this query to be legal." |
2 | 937 |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
938 |
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
|
939 |
self errorNoDevice |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
940 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
941 |
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
|
942 |
^ replacementFont maxDescent |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
943 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
944 |
^ maxDescent |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
945 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
946 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
947 |
maxHeight |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
948 |
"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
|
949 |
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
|
950 |
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
|
951 |
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
|
952 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
953 |
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
|
954 |
self errorNoDevice. |
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 |
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
|
957 |
^ replacementFont maxHeight |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
958 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
959 |
^ maxDescent + maxAscent. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
960 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
961 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
962 |
maxWidth |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
963 |
"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
|
964 |
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
|
965 |
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
|
966 |
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
|
967 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
968 |
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
|
969 |
self errorNoDevice |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
970 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
971 |
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
|
972 |
^ replacementFont maxWidth |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
973 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
974 |
^ maxWidth |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
975 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
976 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
977 |
minWidth |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
978 |
"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
|
979 |
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
|
980 |
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
|
981 |
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
|
982 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
983 |
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
|
984 |
self errorNoDevice |
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 |
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
|
987 |
^ replacementFont minWidth |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
988 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
989 |
^ minWidth |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
990 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
991 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
992 |
width |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
993 |
"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
|
994 |
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
|
995 |
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
|
996 |
For fixed fonts, this is the same as minWidth or maxWidth (or any character). |
2545 | 997 |
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
|
998 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
999 |
device isNil ifTrue:[ |
628
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
1000 |
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
|
1001 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1002 |
replacementFont notNil ifTrue:[ |
628
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
1003 |
^ 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
|
1004 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1005 |
^ width |
628
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
1006 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
1007 |
"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
|
1008 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1009 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1010 |
widthOf:textOrString |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1011 |
"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
|
1012 |
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
|
1013 |
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
|
1014 |
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
|
1015 |
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
|
1016 |
|
3483 | 1017 |
|this max string| |
2 | 1018 |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1019 |
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
|
1020 |
self errorNoDevice. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1021 |
^ 0 |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1022 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1023 |
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
|
1024 |
^ 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
|
1025 |
]. |
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 |
(textOrString isString) ifTrue:[ |
3483 | 1028 |
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
|
1029 |
isFixedWidth ifFalse:[ |
3483 | 1030 |
^ 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
|
1031 |
]. |
3483 | 1032 |
^ 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
|
1033 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1034 |
(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
|
1035 |
isFixedWidth ifFalse:[ |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1036 |
^ 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
|
1037 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1038 |
^ width |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1039 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1040 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1041 |
max := 0. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1042 |
isFixedWidth ifFalse:[ |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1043 |
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
|
1044 |
line notNil ifTrue:[ |
435
5288c637512e
care for nonStrings when asked for the size
Claus Gittinger <cg@exept.de>
parents:
434
diff
changeset
|
1045 |
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
|
1046 |
(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
|
1047 |
] |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1048 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1049 |
^ max |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1050 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1051 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1052 |
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
|
1053 |
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
|
1054 |
(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
|
1055 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1056 |
^ max * width |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1057 |
|
1087
1e5a93e03d7f
handle text-argument in withOf:
Claus Gittinger <cg@exept.de>
parents:
1067
diff
changeset
|
1058 |
"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
|
1059 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1060 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1061 |
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
|
1062 |
"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
|
1063 |
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
|
1064 |
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
|
1065 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1066 |
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
|
1067 |
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
|
1068 |
^ 0 |
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1069 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1070 |
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
|
1071 |
^ 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
|
1072 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1073 |
(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
|
1074 |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1075 |
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
|
1076 |
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
|
1077 |
^ (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
|
1078 |
]. |
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
|
1079 |
^ 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
|
1080 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1081 |
^ (stop - start + 1) * width |
2545 | 1082 |
! |
1083 |
||
1084 |
widthOf:aString from:startIndex to:endIndex on:aDevice |
|
1085 |
"return the width of substring, if displayed on aDevice. |
|
1086 |
The argument may be a Character, String or some Text; |
|
1087 |
in the last case the width of the longest line in the text is returned." |
|
1088 |
||
1089 |
replacementFont notNil ifTrue:[ |
|
1090 |
^ replacementFont widthOf:aString from:startIndex to:endIndex on:aDevice |
|
1091 |
]. |
|
1092 |
device == aDevice ifTrue:[ |
|
1093 |
^ self widthOf:aString from:startIndex to:endIndex |
|
1094 |
]. |
|
2833 | 1095 |
^ (self onDevice:aDevice) widthOf:aString from:startIndex to:endIndex |
2545 | 1096 |
|
1097 |
"Created: / 30.4.1996 / 17:15:20 / cg" |
|
1098 |
"Modified: / 10.9.1998 / 12:10:11 / cg" |
|
1099 |
! |
|
1100 |
||
1101 |
widthOf:aString on:aDevice |
|
1102 |
"return the width of aString, if displayed on aDevice. |
|
1103 |
The argument may be a Character, String or some Text; |
|
1104 |
in the last case the width of the longest line in the text is returned." |
|
1105 |
||
1106 |
replacementFont notNil ifTrue:[ |
|
1107 |
^ replacementFont widthOf:aString on:aDevice |
|
1108 |
]. |
|
1109 |
device == aDevice ifTrue:[ |
|
1110 |
^ self widthOf:aString |
|
1111 |
]. |
|
2833 | 1112 |
^ (self onDevice:aDevice) widthOf:aString |
2545 | 1113 |
|
1114 |
"Created: / 30.4.1996 / 17:14:18 / cg" |
|
1115 |
"Modified: / 10.9.1998 / 12:10:26 / cg" |
|
1116 |
! |
|
1117 |
||
1118 |
widthOn:aDevice |
|
1119 |
"return the fonts width, if used on aDevice. |
|
1120 |
For variable pitch fonts, the width of the space character is returned. |
|
1121 |
For fixed fonts, this is the same as minWidth or maxWidth (or any character)." |
|
1122 |
||
1123 |
replacementFont notNil ifTrue:[ |
|
1124 |
^ replacementFont widthOn:aDevice |
|
1125 |
]. |
|
1126 |
device == aDevice ifTrue:[ |
|
1127 |
^ self width |
|
1128 |
]. |
|
2833 | 1129 |
^ (self onDevice:aDevice) width |
2545 | 1130 |
|
1131 |
"Created: / 30.4.1996 / 16:42:28 / cg" |
|
1132 |
"Modified: / 10.9.1998 / 12:11:33 / cg" |
|
2 | 1133 |
! ! |
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1134 |
|
4023 | 1135 |
!Font methodsFor:'queries-misc'! |
1136 |
||
1137 |
direction |
|
1138 |
device isNil ifTrue:[ |
|
1139 |
self errorNoDevice |
|
1140 |
]. |
|
1141 |
replacementFont notNil ifTrue:[ |
|
1142 |
^ replacementFont direction |
|
1143 |
]. |
|
1144 |
^ direction |
|
1145 |
! |
|
1146 |
||
4205 | 1147 |
maxAscii |
1148 |
"squeak compatibility" |
|
1149 |
||
1150 |
^ self maxCode |
|
1151 |
! |
|
1152 |
||
4023 | 1153 |
maxCode |
1154 |
device isNil ifTrue:[ |
|
1155 |
self errorNoDevice |
|
1156 |
]. |
|
1157 |
replacementFont notNil ifTrue:[ |
|
1158 |
^ replacementFont maxCode |
|
1159 |
]. |
|
1160 |
^ maxCode |
|
1161 |
! |
|
1162 |
||
4205 | 1163 |
minAscii |
1164 |
"squeak compatibility" |
|
1165 |
||
1166 |
^ self minCode |
|
1167 |
! |
|
1168 |
||
4023 | 1169 |
minCode |
1170 |
device isNil ifTrue:[ |
|
1171 |
self errorNoDevice |
|
1172 |
]. |
|
1173 |
replacementFont notNil ifTrue:[ |
|
1174 |
^ replacementFont minCode |
|
1175 |
]. |
|
1176 |
^ minCode |
|
1177 |
! ! |
|
1178 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1179 |
!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
|
1180 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1181 |
fixedWidth |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1182 |
"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
|
1183 |
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
|
1184 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1185 |
^ self isFixedWidth |
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 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1188 |
pixelSize |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1189 |
"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
|
1190 |
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
|
1191 |
|
5197 | 1192 |
^ pixelSize ? self height |
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1193 |
! ! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1194 |
|
2433
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1195 |
!Font::DeviceFontHandle class methodsFor:'documentation'! |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1196 |
|
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1197 |
documentation |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1198 |
" |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1199 |
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
|
1200 |
|
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1201 |
[author:] |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1202 |
Stefan Vogel (stefan@nilpferd) |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1203 |
|
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1204 |
[see also:] |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1205 |
Font |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1206 |
|
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1207 |
[instance variables:] |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1208 |
|
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1209 |
[class variables:] |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1210 |
" |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1211 |
! ! |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1212 |
|
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1213 |
!Font::DeviceFontHandle methodsFor:'accessing'! |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1214 |
|
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1215 |
setDevice:aDevice fontId:anId |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1216 |
"set the handles contents" |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1217 |
|
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1218 |
device := aDevice. |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1219 |
fontId := anId. |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1220 |
|
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1221 |
"Created: / 3.2.1999 / 16:08:31 / stefan" |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1222 |
! ! |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1223 |
|
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1224 |
!Font::DeviceFontHandle methodsFor:'finalization'! |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1225 |
|
3611
8b4384c9e660
Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents:
3527
diff
changeset
|
1226 |
finalize |
2433
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1227 |
"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
|
1228 |
|
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1229 |
|id| |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1230 |
|
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1231 |
(id := fontId) notNil ifTrue:[ |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1232 |
fontId := nil. |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1233 |
device releaseFont:id. |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1234 |
] |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1235 |
|
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1236 |
"Created: / 3.2.1999 / 16:09:25 / stefan" |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1237 |
! ! |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1238 |
|
1087
1e5a93e03d7f
handle text-argument in withOf:
Claus Gittinger <cg@exept.de>
parents:
1067
diff
changeset
|
1239 |
!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
|
1240 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1241 |
version |
5907
ad7449037a9e
changed: #replacementFontOnDevice:
Stefan Vogel <sv@exept.de>
parents:
5668
diff
changeset
|
1242 |
^ '$Header: /cvs/stx/stx/libview/Font.st,v 1.127 2012-04-25 19:05:49 stefan Exp $' |
5442
218a6ae3e112
changed: #family:face:style:size:sizeUnit:encoding:
Claus Gittinger <cg@exept.de>
parents:
5253
diff
changeset
|
1243 |
! |
218a6ae3e112
changed: #family:face:style:size:sizeUnit:encoding:
Claus Gittinger <cg@exept.de>
parents:
5253
diff
changeset
|
1244 |
|
218a6ae3e112
changed: #family:face:style:size:sizeUnit:encoding:
Claus Gittinger <cg@exept.de>
parents:
5253
diff
changeset
|
1245 |
version_CVS |
5907
ad7449037a9e
changed: #replacementFontOnDevice:
Stefan Vogel <sv@exept.de>
parents:
5668
diff
changeset
|
1246 |
^ '$Header: /cvs/stx/stx/libview/Font.st,v 1.127 2012-04-25 19:05:49 stefan Exp $' |
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1247 |
! ! |
3739
909fefa92b5a
Raise #drawingOnClosedDeviceSignal instead of #error
Stefan Vogel <sv@exept.de>
parents:
3663
diff
changeset
|
1248 |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1249 |
Font initialize! |