author | Claus Gittinger <cg@exept.de> |
Thu, 18 Jan 2018 17:02:13 +0100 | |
changeset 8258 | b80bc4ef7fd3 |
parent 8072 | af7e92e97e19 |
child 8642 | 9e67ffea5474 |
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 |
||
6932 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
109 | 16 |
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
|
17 |
instanceVariableNames:'device fontId replacementFont ascent descent width isFixedWidth |
4023 | 18 |
minWidth maxWidth maxAscent maxDescent minCode maxCode direction' |
1372
2b55617a712f
keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents:
1229
diff
changeset
|
19 |
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
|
20 |
poolDictionaries:'' |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
21 |
category:'Graphics-Support' |
0 | 22 |
! |
23 |
||
2433
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
24 |
Object subclass:#DeviceFontHandle |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
25 |
instanceVariableNames:'device fontId' |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
26 |
classVariableNames:'' |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
27 |
poolDictionaries:'' |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
28 |
privateIn:Font |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
29 |
! |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
30 |
|
1087
1e5a93e03d7f
handle text-argument in withOf:
Claus Gittinger <cg@exept.de>
parents:
1067
diff
changeset
|
31 |
!Font class methodsFor:'documentation'! |
0 | 32 |
|
46 | 33 |
copyright |
34 |
" |
|
35 |
COPYRIGHT (c) 1992 by Claus Gittinger |
|
71 | 36 |
All Rights Reserved |
46 | 37 |
|
38 |
This software is furnished under a license and may be used |
|
39 |
only in accordance with the terms of that license and with the |
|
40 |
inclusion of the above copyright notice. This software may not |
|
41 |
be provided or otherwise made available to, or used by, any |
|
42 |
other person. No title to or ownership of the software is |
|
43 |
hereby transferred. |
|
44 |
" |
|
45 |
! |
|
0 | 46 |
|
46 | 47 |
documentation |
48 |
" |
|
49 |
Font represents fonts in a device independent manner; after being |
|
50 |
created using 'Font family:family face:face style:style size:size', |
|
51 |
the returned font is not associated to a specific device. |
|
157 | 52 |
(therefore, those fonts can be used to draw on any GC) |
0 | 53 |
|
46 | 54 |
To get a device font, any font can be sent the message |
7431 | 55 |
'aFont onDevice:aDevice' which returns an instance of Font which is |
46 | 56 |
associated to a device (it returns the receiver, if that is already |
57 |
associated to that device). |
|
0 | 58 |
|
46 | 59 |
For proper operation, each graphics operation working with fonts |
60 |
must get a device font before doing the draw. |
|
7577 | 61 |
Most draw methods in DeviceDrawable do that automatically for you, |
157 | 62 |
before doing the draw; so you do not have to care. |
46 | 63 |
|
81 | 64 |
However, some operations require explicit conversion to a device font |
7346 | 65 |
before being allowed. For example, a query for a font's height (in device |
81 | 66 |
units) can only be done if the font being asked is associated to |
67 |
a device (which should be clear, since a 'courier-roman-12' font may |
|
68 |
have a different number of pixels on a 75dpi vs. a 120dpi display. And |
|
564 | 69 |
a totally different number of device units on a 600dpi laser printer. |
81 | 70 |
Thus, to query a font for its height (or ascent, or descent, or width), |
71 |
use something like: |
|
72 |
||
564 | 73 |
myFont := Font family:'courier' ... size:12. |
74 |
... |
|
7577 | 75 |
|
564 | 76 |
'want to know its height on the Display' |
7577 | 77 |
|
564 | 78 |
h := (myFont on:Display) height. |
7577 | 79 |
|
564 | 80 |
'want to know its height on a printer' |
7577 | 81 |
|
564 | 82 |
h := (myFont on:aPrinter) height. |
2545 | 83 |
|
84 |
there are alternative shortcuts for these operations: |
|
85 |
||
86 |
h := myFont heightOn:Display. |
|
87 |
h := myFont heightOn:Printer. |
|
88 |
||
89 |
or: |
|
90 |
||
91 |
a := myFont ascentOn:Display. |
|
92 |
||
81 | 93 |
Keep in mind, that each device is free to think in whatever units it |
94 |
likes - a display may return units of pixels, a postscript printer may |
|
95 |
think in (fractions of) inches, a dot matrix printer may think in dots. |
|
96 |
Also, notice that currently only graphic displays are really supported; |
|
7577 | 97 |
printer devices are being developed and may or may not be in the current |
81 | 98 |
system. |
99 |
||
564 | 100 |
If a font cannot be represented on a device, a replacement |
7577 | 101 |
font is chosen and kept in the replacementFont instance variable. |
564 | 102 |
This is done to preserve the original font information, in case the image |
103 |
is restarted later on another display which has that font available. |
|
104 |
||
105 |
||
601 | 106 |
[Instance variables:] |
46 | 107 |
|
7346 | 108 |
family <String> the font's family ('courier', 'helvetica' etc) |
109 |
face <String> the font's face ('bold', 'medium' etc) |
|
110 |
style <String> the font's style ('roman', 'italic', 'oblique') |
|
7577 | 111 |
size <String> the font's size (not in pixels) |
7346 | 112 |
encoding <Symbol> the font's encoding (usually #iso8859) |
0 | 113 |
|
109 | 114 |
device <Object> the device the font is associated to, or nil |
115 |
fontId <Object> the id of the font on that device, or nil |
|
116 |
replacement <Font> the replacement font or nil |
|
0 | 117 |
|
7346 | 118 |
ascent <Integer> the font's ascent in device units on device |
119 |
descent <Integer> the font's descent in device units on device |
|
109 | 120 |
width <Integer> the character width in device units on device |
564 | 121 |
(for variable fonts, its the width of a space) |
109 | 122 |
isFixedWidth <Boolean> true if font is a fixed width font |
123 |
minWidth <Integer> width of the smallest-width character in |
|
564 | 124 |
in device units on device |
109 | 125 |
maxWidth <Integer> width of the largest-width character in |
564 | 126 |
in device units on device |
0 | 127 |
|
601 | 128 |
[class variables:] |
0 | 129 |
|
109 | 130 |
Replacements <Dictionary> replacement fonts |
601 | 131 |
|
132 |
[see also:] |
|
7577 | 133 |
DeviceWorkstation |
628
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
134 |
DeviceDrawable GraphicsContext |
601 | 135 |
Cursor Color |
628
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
136 |
( introduction to view programming :html: programming/viewintro.html#FONTS ) |
611 | 137 |
|
138 |
[author:] |
|
139 |
Claus Gittinger |
|
46 | 140 |
" |
628
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
141 |
! |
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 |
examples |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
144 |
" |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
145 |
standard fonts: |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
146 |
|
5170 | 147 |
Font family:'courier' size:12 |
628
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
148 |
|
5170 | 149 |
Font |
150 |
family:'helvetica' |
|
151 |
face:'roman' |
|
152 |
style:'bold' |
|
153 |
size:16 |
|
154 |
||
155 |
Font |
|
156 |
family:'helvetica' |
|
157 |
pixelSize:20 |
|
628
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
158 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
159 |
|
5170 | 160 |
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
|
161 |
|
5170 | 162 |
Font name:'6x10' |
628
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
163 |
|
5170 | 164 |
Font name:'k14' |
628
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
165 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
166 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
167 |
setting the font of a button: |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
168 |
[exBegin] |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
169 |
|b| |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
170 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
171 |
b := Button new. |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
172 |
b label:'hello'. |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
173 |
b font:(Font family:'helvetica' |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
174 |
face:'medium' |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
175 |
style:'roman' |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
176 |
size:16). |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
177 |
b open |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
178 |
[exEnd] |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
179 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
180 |
asking a font about a strings size in pixels, |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
181 |
if it was used on some device: |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
182 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
183 |
aFont widthOf:'hello' on:Display |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
184 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
185 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
186 |
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
|
187 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
188 |
aFont ascentOn:Display |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
189 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
190 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
191 |
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
|
192 |
a bit faster: |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
193 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
194 |
|aFont| |
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 |
... |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
197 |
|
7431 | 198 |
aFont := aFont onDevice:aDevice. |
628
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 widthOf:'hello' |
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 |
aFont ascent |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
203 |
... |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
204 |
" |
0 | 205 |
! ! |
206 |
||
1087
1e5a93e03d7f
handle text-argument in withOf:
Claus Gittinger <cg@exept.de>
parents:
1067
diff
changeset
|
207 |
!Font class methodsFor:'initialization'! |
0 | 208 |
|
209 |
initialize |
|
210 |
"initialize the font tracking array" |
|
211 |
||
3213 | 212 |
Replacements isNil ifTrue:[ |
213 |
Replacements := Dictionary new. |
|
71 | 214 |
|
5512
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
215 |
Replacements |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
216 |
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
|
217 |
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
|
218 |
at:'monospace' put:#('courier new' 'courier' 'andale mono' 'lucidatypewriter' 'fixed'). |
5145 | 219 |
|
5512
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
220 |
Replacements |
6109 | 221 |
at:'clean' put:#('courier new' 'courier'); |
222 |
at:'fixed' put:#('courier new' 'courier'); |
|
223 |
at:'new century schoolbook' put:#('times' 'times new roman'); |
|
5512
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
224 |
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
|
225 |
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
|
226 |
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
|
227 |
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
|
228 |
at:'courier' put:#('courier new'); |
6109 | 229 |
at:'courier new' put:#('courier'); |
5512
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
230 |
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
|
231 |
at:'times new roman' put:#('times'); |
6109 | 232 |
at:'times' put:#('times new roman'); |
5512
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
233 |
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
|
234 |
at:'helvetica' put:#('arial' 'lucida'). |
6109 | 235 |
]. |
0 | 236 |
! ! |
237 |
||
1087
1e5a93e03d7f
handle text-argument in withOf:
Claus Gittinger <cg@exept.de>
parents:
1067
diff
changeset
|
238 |
!Font class methodsFor:'instance creation'! |
0 | 239 |
|
5186 | 240 |
family:familyString face:faceString style:styleString size:sizeArgOrNil sizeUnit:sizeUnitArg encoding:encodingSym |
5167 | 241 |
"returns a font for given family, face, style, size and encoding. |
5225 | 242 |
The returned font is not associated to a specific device." |
5167 | 243 |
|
54 | 244 |
|family newFont| |
0 | 245 |
|
246 |
(familyString at:1) isUppercase ifTrue:[ |
|
2925 | 247 |
family := familyString asLowercase |
0 | 248 |
] ifFalse:[ |
2925 | 249 |
family := familyString |
0 | 250 |
]. |
251 |
||
1372
2b55617a712f
keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents:
1229
diff
changeset
|
252 |
newFont := self basicNew |
2925 | 253 |
setFamily:familyString |
254 |
face:faceString |
|
255 |
style:styleString |
|
5167 | 256 |
size:sizeArgOrNil |
5186 | 257 |
sizeUnit:sizeUnitArg |
2925 | 258 |
encoding:encodingSym |
259 |
device:nil. |
|
1372
2b55617a712f
keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents:
1229
diff
changeset
|
260 |
|
6539 | 261 |
"/ "look if this font is already known on the default device (the most common case)" |
262 |
"/ don't do this!! |
|
263 |
"/ is incompatible with Xft fonts. If reenabled, check printing in document viewer with XFT fonts enabled. |
|
264 |
"/ |
|
265 |
"/ Display notNil ifTrue:[ |
|
266 |
"/ Display deviceFonts do:[:aFont | |
|
267 |
"/ (newFont sameDeviceFontAs:aFont) ifTrue:[ |
|
268 |
"/ "/ self assert:(aFont encoding = newFont encoding). |
|
269 |
"/ ^ aFont |
|
270 |
"/ ] |
|
271 |
"/ ] |
|
272 |
"/ ]. |
|
5167 | 273 |
|
0 | 274 |
^ newFont |
2925 | 275 |
|
276 |
"Modified: / 26.9.1999 / 13:49:45 / cg" |
|
0 | 277 |
! ! |
278 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
279 |
!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
|
280 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
281 |
device |
4146 | 282 |
"return the device I am on. |
283 |
Obsolete - use #graphicsDevice" |
|
284 |
||
285 |
<resource:#obsolete> |
|
7269 | 286 |
self obsoleteMethodWarning:'use #graphicsDevice (2013-07-25)'. |
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
287 |
^ device |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
288 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
289 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
290 |
fontId |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
291 |
"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
|
292 |
|
6109 | 293 |
replacementFont notNil ifTrue:[ |
294 |
^ replacementFont fontId |
|
295 |
]. |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
296 |
^ fontId |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
297 |
! ! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
298 |
|
5145 | 299 |
|
5559 | 300 |
!Font methodsFor:'converting'! |
301 |
||
302 |
asFontDescription |
|
303 |
^ FontDescription |
|
304 |
family:family |
|
305 |
face:face |
|
306 |
style:style |
|
307 |
size:size |
|
308 |
sizeUnit:(sizeUnit ? #pt) |
|
309 |
encoding:encoding |
|
7871 | 310 |
! |
311 |
||
312 |
asNonXftFont |
|
313 |
"in some situations, we do not want an Xft font..." |
|
314 |
||
315 |
^ self. |
|
316 |
||
317 |
"Created: / 12-02-2017 / 21:56:51 / cg" |
|
5559 | 318 |
! ! |
319 |
||
3027
efb7b0c760f5
blocked deepCopying of fonts
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
320 |
!Font methodsFor:'copying'! |
efb7b0c760f5
blocked deepCopying of fonts
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
321 |
|
4934 | 322 |
deepCopyUsing:aDictionary postCopySelector:postCopySelector |
3027
efb7b0c760f5
blocked deepCopying of fonts
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
323 |
^ self |
efb7b0c760f5
blocked deepCopying of fonts
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
324 |
! ! |
efb7b0c760f5
blocked deepCopying of fonts
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
325 |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
326 |
!Font methodsFor:'displaying'! |
71 | 327 |
|
3663 | 328 |
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
|
329 |
"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
|
330 |
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
|
331 |
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
|
332 |
|
441 | 333 |
|prevFont| |
334 |
||
2545 | 335 |
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
|
336 |
replacementFont isNil ifTrue:[ |
2545 | 337 |
fontId notNil ifTrue:[ |
338 |
aGC basicFont:self. |
|
3663 | 339 |
aGC displayString:aString from:index1 to:index2 x:x y:y opaque:opaque. |
2545 | 340 |
] ifFalse:[ |
341 |
'Font: [warning]: no replacementFont. should not happen' errorPrintCR. |
|
342 |
]. |
|
343 |
] ifFalse:[ |
|
344 |
aGC basicFont:replacementFont. |
|
3663 | 345 |
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
|
346 |
]. |
442 | 347 |
aGC basicFont:prevFont. |
441 | 348 |
|
1176
e0e2c8cbb3c8
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1166
diff
changeset
|
349 |
"Modified: 10.1.1997 / 17:51:17 / cg" |
6471 | 350 |
! |
351 |
||
352 |
displayString:aString from:index1 to:index2 x:x y:y in:aGC opaque:opaque maxWidth:maxWindowWidth |
|
353 |
"this is only called for fonts which have a nil fontId, |
|
354 |
and therefore use the replacementFont. Should never be called |
|
355 |
for non-replacement fonts." |
|
356 |
||
357 |
|prevFont| |
|
358 |
||
359 |
prevFont := aGC font. |
|
360 |
replacementFont isNil ifTrue:[ |
|
361 |
fontId notNil ifTrue:[ |
|
362 |
aGC basicFont:self. |
|
363 |
aGC displayString:aString from:index1 to:index2 x:x y:y opaque:opaque maxWidth:maxWindowWidth. |
|
364 |
] ifFalse:[ |
|
365 |
'Font: [warning]: no replacementFont. should not happen' errorPrintCR. |
|
366 |
]. |
|
367 |
] ifFalse:[ |
|
368 |
aGC basicFont:replacementFont. |
|
369 |
aGC displayString:aString from:index1 to:index2 x:x y:y opaque:opaque maxWidth:maxWindowWidth. |
|
370 |
]. |
|
371 |
aGC basicFont:prevFont. |
|
372 |
||
373 |
"Modified: 10.1.1997 / 17:51:17 / cg" |
|
0 | 374 |
! ! |
375 |
||
376 |
!Font methodsFor:'getting a device font'! |
|
377 |
||
3628 | 378 |
onDevice:aDevice |
0 | 379 |
"create a new Font representing the same font as |
380 |
myself on aDevice; if one already exists, return the one." |
|
381 |
||
5167 | 382 |
|newFont rep| |
3628 | 383 |
|
384 |
"if I am already assigned to that device ..." |
|
385 |
(device == aDevice) ifTrue:[^ self]. |
|
386 |
||
5222
09fb6ebff525
changed #onDevice: - formatting
Stefan Vogel <sv@exept.de>
parents:
5197
diff
changeset
|
387 |
(aDevice isNil and:[device notNil]) ifTrue:[ |
09fb6ebff525
changed #onDevice: - formatting
Stefan Vogel <sv@exept.de>
parents:
5197
diff
changeset
|
388 |
^ self |
5174 | 389 |
]. |
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
|
390 |
|
3628 | 391 |
aDevice deviceFonts do:[:aFont | |
5167 | 392 |
(self sameDeviceFontAs:aFont) ifTrue:[ |
393 |
^ aFont |
|
394 |
]. |
|
3628 | 395 |
]. |
396 |
||
397 |
newFont := self onDevice:aDevice ifAbsent:nil. |
|
398 |
newFont isNil ifTrue:[ |
|
399 |
"oops did not work - (device has no such font)" |
|
400 |
aDevice isOpen ifFalse:[ |
|
401 |
"/ the display device is not connected |
|
402 |
"/ (or has a broken connection). |
|
3739
909fefa92b5a
Raise #drawingOnClosedDeviceSignal instead of #error
Stefan Vogel <sv@exept.de>
parents:
3663
diff
changeset
|
403 |
aDevice class drawingOnClosedDeviceSignal raiseRequestWith:aDevice. |
3628 | 404 |
^ self. |
405 |
]. |
|
6109 | 406 |
|
5040
b28c261dd543
replacement font handling did not remember font in the registry,
Claus Gittinger <cg@exept.de>
parents:
4934
diff
changeset
|
407 |
"/ look for a replacement font |
3628 | 408 |
rep := self replacementFontOnDevice:aDevice. |
409 |
device isNil ifTrue:[ |
|
410 |
device := aDevice. |
|
411 |
replacementFont := rep. |
|
6109 | 412 |
newFont := self. |
413 |
] ifFalse:[ |
|
414 |
newFont := self class basicNew. |
|
415 |
newFont |
|
416 |
setFamily:family |
|
417 |
face:face |
|
418 |
style:style |
|
419 |
size:(sizeUnit == #px ifTrue:[pixelSize] ifFalse:[size]) |
|
420 |
sizeUnit:sizeUnit |
|
421 |
encoding:encoding |
|
422 |
device:aDevice; |
|
423 |
isGenericFont:self isGenericFont; |
|
424 |
setReplacementFont:rep. |
|
3628 | 425 |
]. |
426 |
aDevice registerFont:newFont. |
|
427 |
]. |
|
428 |
||
429 |
^ newFont |
|
430 |
||
431 |
" |
|
6109 | 432 |
(Font family:'fooXXXXXX' size:17) onDevice:Screen current |
3628 | 433 |
" |
434 |
||
435 |
"Modified: 14.4.1997 / 18:22:31 / cg" |
|
2848 | 436 |
! |
437 |
||
7701 | 438 |
onDevice:aDevice xFontsOnly:xFontsOnly xftFontsOnly:xftFontsOnly ifAbsent:exceptionBlock |
439 |
"create a new Font representing the same font as myself on aDevice. |
|
440 |
The xFontsOnly/xftFontsOnly are only relevant for XWindow devices; |
|
441 |
xFontsOnly will suppress xft fonts, whereas xftFontsOnly will suppress x fonts |
|
442 |
(the first is useful if ST/X has a slow remote X connection for display, |
|
443 |
on which xft fonts are very slow. Yes, this is actually a reasonable setup |
|
444 |
in use at one of our customers) |
|
445 |
This does NOT try to look for existing |
|
2848 | 446 |
or replacement fonts (i.e. can be used to get physical fonts)." |
447 |
||
7624 | 448 |
|id xftFont| |
2848 | 449 |
|
450 |
"receiver was not associated - do it now" |
|
451 |
device isNil ifTrue:[ |
|
7701 | 452 |
aDevice supportsXftFonts ifTrue:[ |
453 |
xFontsOnly ifFalse:[ |
|
454 |
xftFont := (XftFontDescription for:self) onDevice:aDevice ifAbsent:[nil]. |
|
455 |
xftFont notNil ifTrue:[^ xftFont]. |
|
456 |
xftFontsOnly ifTrue:[^ nil]. |
|
457 |
]. |
|
7624 | 458 |
]. |
459 |
||
3785 | 460 |
"ask that device for the font" |
5167 | 461 |
id := aDevice |
462 |
getFontWithFamily:family |
|
463 |
face:face |
|
464 |
style:style |
|
5186 | 465 |
size:(sizeUnit == #px ifTrue:[pixelSize] ifFalse:[size]) |
466 |
sizeUnit:sizeUnit |
|
6158 | 467 |
encoding:encoding ? '*'. |
3785 | 468 |
id isNil ifTrue:[ |
469 |
"oops did not work - (device has no such font)" |
|
470 |
||
471 |
^ exceptionBlock value |
|
472 |
]. |
|
473 |
||
2848 | 474 |
device := aDevice. |
475 |
fontId := id. |
|
476 |
||
477 |
self getFontInfos. |
|
478 |
aDevice registerFont:self. |
|
479 |
^ self |
|
480 |
]. |
|
481 |
||
482 |
"receiver was already associated to another device - need a new font" |
|
7710 | 483 |
^ super |
484 |
onDevice:aDevice |
|
485 |
xFontsOnly:xFontsOnly xftFontsOnly:xftFontsOnly |
|
486 |
ifAbsent:exceptionBlock |
|
487 |
||
488 |
"Modified: / 24-11-2016 / 16:53:36 / cg" |
|
2848 | 489 |
! |
490 |
||
3628 | 491 |
replacementFontOnDevice:aDevice |
12 | 492 |
"return a replacement font for the receiver - this is needed, if |
493 |
an image is restored on another type of display, or one which has |
|
494 |
a different set of fonts." |
|
0 | 495 |
|
6204
56abbbb55591
Replace references to Diplay with "Screen current" - where appropriate
Stefan Vogel <sv@exept.de>
parents:
6163
diff
changeset
|
496 |
|id f trySize alternatives alternateFamilyName useEncoding| |
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
|
497 |
|
5512
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
498 |
"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
|
499 |
but do not try this on scaled fonts (they have size == 0)" |
0 | 500 |
|
6204
56abbbb55591
Replace references to Diplay with "Screen current" - where appropriate
Stefan Vogel <sv@exept.de>
parents:
6163
diff
changeset
|
501 |
useEncoding := encoding ? #'iso10646-1'. |
5512
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
502 |
alternateFamilyName := family. |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
503 |
self isGenericFont ifFalse:[ |
6109 | 504 |
trySize := (sizeUnit == #px ifTrue:[pixelSize] ifFalse:[size]) ? 0. |
5512
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
505 |
[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
|
506 |
id := aDevice |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
507 |
getFontWithFamily:family |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
508 |
face:face |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
509 |
style:style |
6109 | 510 |
size:trySize |
5512
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
511 |
sizeUnit:sizeUnit |
6204
56abbbb55591
Replace references to Diplay with "Screen current" - where appropriate
Stefan Vogel <sv@exept.de>
parents:
6163
diff
changeset
|
512 |
encoding:useEncoding. |
5512
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
513 |
]. |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
514 |
]. |
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
|
515 |
|
144 | 516 |
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
|
517 |
('Font [info]: use alternative size ', trySize printString, ' for ' , (self userFriendlyName)) infoPrintCR. |
144 | 518 |
] ifFalse:[ |
5512
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
519 |
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
|
520 |
alternatives notNil ifTrue:[ |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
521 |
alternatives detect:[:eachAlternateFamilyName| |
6109 | 522 |
trySize := (sizeUnit == #px ifTrue:[pixelSize] ifFalse:[size]) ? 0. |
5512
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
523 |
[ |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
524 |
id := aDevice |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
525 |
getFontWithFamily:eachAlternateFamilyName |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
526 |
face:face |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
527 |
style:style |
6109 | 528 |
size:trySize |
5512
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
529 |
sizeUnit:sizeUnit |
6204
56abbbb55591
Replace references to Diplay with "Screen current" - where appropriate
Stefan Vogel <sv@exept.de>
parents:
6163
diff
changeset
|
530 |
encoding:useEncoding. |
5990 | 531 |
] doWhile:[id isNil and:[trySize := trySize - 1. trySize > 4. false]]. |
5512
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
532 |
alternateFamilyName := eachAlternateFamilyName. |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
533 |
id notNil. |
5526
2eb1df09a195
changed: #replacementFontOnDevice:
Stefan Vogel <sv@exept.de>
parents:
5512
diff
changeset
|
534 |
] 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
|
535 |
]. |
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
|
536 |
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
|
537 |
('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
|
538 |
] ifFalse:[ |
6204
56abbbb55591
Replace references to Diplay with "Screen current" - where appropriate
Stefan Vogel <sv@exept.de>
parents:
6163
diff
changeset
|
539 |
useEncoding = #'iso10646-1' ifTrue:[ |
5990 | 540 |
"/ try latin1 (for osx-X11) |
541 |
id := aDevice |
|
542 |
getFontWithFamily:family |
|
543 |
face:face |
|
544 |
style:style |
|
545 |
size:(sizeUnit == #px ifTrue:[pixelSize] ifFalse:[size ? 0]) |
|
546 |
sizeUnit:sizeUnit |
|
547 |
encoding:#'iso8859-1'. |
|
548 |
id notNil ifTrue:[ |
|
549 |
('Font [info]: use latin1 encoding for: ' , (self userFriendlyName)) infoPrintCR. |
|
550 |
]. |
|
551 |
]. |
|
552 |
id isNil ifTrue:[ |
|
6204
56abbbb55591
Replace references to Diplay with "Screen current" - where appropriate
Stefan Vogel <sv@exept.de>
parents:
6163
diff
changeset
|
553 |
id := aDevice getDefaultFontWithEncoding:useEncoding. |
5990 | 554 |
('Font [info]: use default for ' , (self userFriendlyName)) infoPrintCR. |
555 |
]. |
|
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
|
556 |
]. |
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
|
557 |
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
|
558 |
"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
|
559 |
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
|
560 |
^ 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
|
561 |
]. |
0 | 562 |
]. |
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
|
563 |
|
5040
b28c261dd543
replacement font handling did not remember font in the registry,
Claus Gittinger <cg@exept.de>
parents:
4934
diff
changeset
|
564 |
"/ 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
|
565 |
"/ 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
|
566 |
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
|
567 |
(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
|
568 |
^ eachDeviceFont |
5040
b28c261dd543
replacement font handling did not remember font in the registry,
Claus Gittinger <cg@exept.de>
parents:
4934
diff
changeset
|
569 |
] |
b28c261dd543
replacement font handling did not remember font in the registry,
Claus Gittinger <cg@exept.de>
parents:
4934
diff
changeset
|
570 |
]. |
b28c261dd543
replacement font handling did not remember font in the registry,
Claus Gittinger <cg@exept.de>
parents:
4934
diff
changeset
|
571 |
|
0 | 572 |
f := self class basicNew. |
6109 | 573 |
f |
6204
56abbbb55591
Replace references to Diplay with "Screen current" - where appropriate
Stefan Vogel <sv@exept.de>
parents:
6163
diff
changeset
|
574 |
setFamily:alternateFamilyName face:face style:style size:trySize sizeUnit:sizeUnit encoding:useEncoding device:aDevice; |
6109 | 575 |
setDevice:aDevice fontId:id; |
576 |
getFontInfos. |
|
5040
b28c261dd543
replacement font handling did not remember font in the registry,
Claus Gittinger <cg@exept.de>
parents:
4934
diff
changeset
|
577 |
|
1372
2b55617a712f
keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents:
1229
diff
changeset
|
578 |
aDevice registerFont:f. |
0 | 579 |
^ f |
454
b31d0a7e5530
nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
580 |
|
1166 | 581 |
"Modified: 10.1.1997 / 15:40:21 / cg" |
0 | 582 |
! ! |
583 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
584 |
!Font methodsFor:'instance release'! |
0 | 585 |
|
2848 | 586 |
executor |
578 | 587 |
"redefined to return a lightweight copy |
588 |
- all we need is the device handle" |
|
589 |
||
2848 | 590 |
^ DeviceFontHandle basicNew setDevice:device fontId:fontId. |
578 | 591 |
|
2433
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
592 |
"Modified: / 20.4.1996 / 23:23:04 / cg" |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
593 |
"Modified: / 3.2.1999 / 16:13:10 / stefan" |
2 | 594 |
! ! |
595 |
||
4852 | 596 |
!Font methodsFor:'object persistency'! |
0 | 597 |
|
4207 | 598 |
elementDescriptorFor:aspect |
4852 | 599 |
"support for persistency: |
600 |
answer the elements to be made persistent with an ObjectCoder" |
|
601 |
||
4006 | 602 |
"binary storage encoding vector" |
603 |
||
604 |
^ Array |
|
605 |
with:(#family->self family) |
|
606 |
with:(#face->self face) |
|
607 |
with:(#style->self style) |
|
608 |
with:(#size->self size) |
|
609 |
with:(#encoding->self encoding) |
|
4852 | 610 |
! ! |
611 |
||
612 |
!Font methodsFor:'printing & storing'! |
|
3934 | 613 |
|
109 | 614 |
printOn:aStream |
2805 | 615 |
"append a user printed representation of the receiver to aStream. |
616 |
The format is suitable for a human - not meant to be read back. |
|
7346 | 617 |
Redefined to print more about the font's name" |
578 | 618 |
|
46 | 619 |
face isNil ifTrue:[ |
578 | 620 |
family isNil ifTrue:[ |
621 |
aStream nextPutAll:('a replacement-Font'). |
|
622 |
^ self |
|
623 |
]. |
|
624 |
aStream nextPutAll:('a ' , family , '-Font'). |
|
625 |
^ self. |
|
46 | 626 |
]. |
109 | 627 |
aStream nextPutAll:('a ' , family , '-' , |
578 | 628 |
face , '-' , |
4803 | 629 |
style printString , '-' , |
4007 | 630 |
size printString , |
631 |
' (' , encoding printString , ')' , |
|
632 |
'-Font') |
|
578 | 633 |
|
634 |
"Modified: 20.4.1996 / 23:25:11 / cg" |
|
0 | 635 |
! |
636 |
||
109 | 637 |
storeOn:aStream |
638 |
"append a character sequence to the argument, aStream from which the |
|
639 |
receiver can be reconstructed using readFrom:." |
|
0 | 640 |
|
109 | 641 |
aStream nextPutAll:'(Font family:'. family storeOn:aStream. |
642 |
aStream nextPutAll:' face:'. face storeOn:aStream. |
|
643 |
aStream nextPutAll:' style:'. style storeOn:aStream. |
|
644 |
aStream nextPutAll:' size:'. size storeOn:aStream. |
|
645 |
aStream nextPutAll:' encoding:'. encoding storeOn:aStream. |
|
646 |
aStream nextPut:$) |
|
647 |
||
648 |
" |
|
649 |
(Font family:'helvetica' size:10) storeString |
|
650 |
" |
|
0 | 651 |
! ! |
2 | 652 |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
653 |
!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
|
654 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
655 |
getFontInfos |
578 | 656 |
"ask the device about all of my actual attributes" |
657 |
||
5578 | 658 |
|info fetchedEncoding| |
991 | 659 |
|
3479 | 660 |
replacementFont notNil ifTrue:[ |
661 |
replacementFont getFontInfos. |
|
662 |
^ self |
|
663 |
]. |
|
991 | 664 |
|
4023 | 665 |
info := self getFontMetrics. |
666 |
||
667 |
minCode := info minCode. |
|
668 |
maxCode := info maxCode. |
|
669 |
direction := info direction. |
|
670 |
||
5578 | 671 |
fetchedEncoding := info encoding. |
672 |
fetchedEncoding isNil ifTrue:[ |
|
673 |
fetchedEncoding := device encodingOf:fontId. |
|
674 |
]. |
|
6078 | 675 |
|
5578 | 676 |
encoding notNil ifTrue:[ |
6078 | 677 |
(encoding ~= fetchedEncoding) ifTrue:[ |
678 |
(( #( #'iso10646-1' #'ms-default' #'ms-ansi' #'ms-oem' ) includes:encoding) |
|
679 |
and:[ ( #( #'iso10646-1' #'ms-default' #'ms-ansi' #'ms-oem' ) includes:fetchedEncoding)]) ifFalse:[ |
|
680 |
encoding ~= #* ifTrue:[ |
|
681 |
('Font [warning]: encoding for "%1" should be %2; is %3 ' |
|
682 |
bindWith:self with: encoding with: fetchedEncoding) infoPrintCR. |
|
683 |
]. |
|
684 |
]. |
|
5582 | 685 |
]. |
5578 | 686 |
] ifFalse:[ |
687 |
encoding := fetchedEncoding. |
|
3527 | 688 |
]. |
3479 | 689 |
ascent := info ascent. |
690 |
descent := info descent. |
|
691 |
maxAscent := info maxAscent. |
|
692 |
maxDescent := info maxDescent. |
|
693 |
minWidth := info minWidth. |
|
694 |
maxWidth := info maxWidth. |
|
695 |
width := info averageWidth. |
|
991 | 696 |
|
697 |
width < minWidth ifTrue:[ |
|
698 |
"/ some systems/fonts return a wrong value (0) as width of a space |
|
699 |
"/ - at least with X11 ... |
|
700 |
width := minWidth |
|
994 | 701 |
]. |
5647 | 702 |
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
|
703 |
|
5647 | 704 |
"/ a temporary hack for the vista-cleartype font redraw problem |
5668 | 705 |
false "isFixedWidth" ifFalse:[ |
5647 | 706 |
UserPreferences current workAroundRenderingBugOnVista ifTrue:[ |
707 |
self hasOverlappingCharacters:true. |
|
708 |
] |
|
709 |
]. |
|
710 |
"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
|
711 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
712 |
|
3658
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
713 |
getFontMetrics |
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
714 |
"ask the device about all of my actual attributes" |
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
715 |
|
6163 | 716 |
|metrics| |
717 |
||
3658
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
718 |
replacementFont notNil ifTrue:[ |
4023 | 719 |
^ replacementFont getFontMetrics |
3658
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
720 |
]. |
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
721 |
|
6163 | 722 |
metrics := device fontMetricsOf:fontId. |
723 |
||
724 |
"the MS TrueType unicode core fonts in Linux have way to large ascent |
|
725 |
and descent values, so the line spacing is too wide. |
|
726 |
Take them from the latin-1 equivalent" |
|
727 |
(device platformName == #X11 |
|
728 |
and:[encoding = #'iso10646-1' |
|
729 |
and:[metrics ascent = metrics maxAscent |
|
730 |
and:[metrics descent == metrics maxDescent]]]) ifTrue:[ |
|
731 |
|latinFont latinMetrics| |
|
732 |
||
733 |
latinFont := self asEncoding:'iso8859-1'. |
|
734 |
latinFont notNil ifTrue:[ |
|
735 |
latinMetrics := latinFont getFontMetrics. |
|
736 |
metrics ascent:latinMetrics ascent descent:latinMetrics descent. |
|
737 |
]. |
|
738 |
]. |
|
739 |
||
740 |
^ metrics. |
|
741 |
||
742 |
" |
|
743 |
(View defaultFont onDevice:Screen current) getFontMetrics |
|
744 |
" |
|
3658
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
745 |
! |
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
746 |
|
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
747 |
getFontResolution |
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
748 |
"ask the device about all of my actual attributes" |
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
749 |
|
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
750 |
|f| |
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
751 |
|
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
752 |
f := fontId. |
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
753 |
replacementFont notNil ifTrue:[ |
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
754 |
f := replacementFont fontId. |
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
755 |
]. |
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
756 |
|
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
757 |
^ device fontResolutionOf:f. |
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
758 |
! |
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
759 |
|
7443 | 760 |
installInDeviceForGCId:aGCId |
761 |
"install the font for aGCId" |
|
762 |
||
763 |
(device isNil or:[fontId isNil]) ifTrue:[ |
|
764 |
"this should not happen, since #onDevice tries replacement fonts" |
|
765 |
Logger error:'no device font for: %1' with:self. |
|
766 |
^ nil. |
|
767 |
]. |
|
768 |
device setFont:fontId in:aGCId. |
|
769 |
! |
|
770 |
||
2846 | 771 |
releaseFromDevice |
772 |
"I am no longer available on the device" |
|
773 |
||
774 |
device := nil. |
|
775 |
fontId := nil. |
|
776 |
replacementFont := nil |
|
777 |
||
778 |
"Modified: 20.4.1996 / 23:26:26 / cg" |
|
779 |
! |
|
780 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
781 |
restored |
578 | 782 |
"flush device handles when restored" |
783 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
784 |
device := nil. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
785 |
fontId := nil. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
786 |
replacementFont := nil |
578 | 787 |
|
788 |
"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
|
789 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
790 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
791 |
setDevice:aDevice |
578 | 792 |
"set the device handle" |
793 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
794 |
device := aDevice |
578 | 795 |
|
796 |
"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
|
797 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
798 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
799 |
setDevice:aDevice fontId:aFontId |
578 | 800 |
"set the device and font handles" |
801 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
802 |
device := aDevice. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
803 |
fontId := aFontId |
578 | 804 |
|
805 |
"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
|
806 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
807 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
808 |
setFamily:familyString face:faceString style:styleString size:sizeNum encoding:encodingSym device:aDevice |
5186 | 809 |
<resource: #obsolete> |
6109 | 810 |
self obsoleteMethodWarning:'2013-07-25'. |
5186 | 811 |
|
812 |
self |
|
813 |
setFamily:familyString |
|
814 |
face:faceString |
|
815 |
style:styleString |
|
816 |
size:sizeNum |
|
817 |
sizeUnit:#pt |
|
818 |
encoding:encodingSym |
|
819 |
device:aDevice |
|
820 |
! |
|
821 |
||
822 |
setFamily:familyString face:faceString style:styleString size:sizeArg sizeUnit:sizeUnitArg encoding:encodingSym device:aDevice |
|
578 | 823 |
"set my instance attributes" |
824 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
825 |
family := familyString. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
826 |
face := faceString. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
827 |
style := styleString. |
5253 | 828 |
sizeUnit := (sizeUnitArg ? #pt). |
829 |
sizeUnit == #pt ifTrue:[ |
|
830 |
size := sizeArg |
|
831 |
] ifFalse:[ |
|
832 |
sizeUnit == #px ifTrue:[ |
|
833 |
pixelSize := sizeArg |
|
834 |
] ifFalse:[ |
|
835 |
self error:'invalid sizeUnit' mayProceed:true. |
|
836 |
size := 12. |
|
837 |
sizeUnit := #pt |
|
838 |
]. |
|
839 |
]. |
|
5167 | 840 |
encoding := encodingSym. |
841 |
device := aDevice |
|
842 |
||
843 |
"Modified: 20.4.1996 / 23:26:56 / cg" |
|
844 |
! |
|
845 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
846 |
setFontId:aFontId |
578 | 847 |
"set my font handle" |
848 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
849 |
fontId := aFontId |
578 | 850 |
|
851 |
"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
|
852 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
853 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
854 |
setReplacementFont:aFont |
578 | 855 |
"set my replacement font" |
856 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
857 |
replacementFont := aFont |
578 | 858 |
|
859 |
"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
|
860 |
! ! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
861 |
|
2545 | 862 |
!Font methodsFor:'queries-deviceFonts'! |
863 |
||
864 |
fullName |
|
865 |
"return the full (device specific) name of the receiver. |
|
866 |
This is query only valid if the receiver is associated to a device" |
|
867 |
||
868 |
device isNil ifTrue:[ |
|
869 |
^ nil |
|
870 |
]. |
|
3415
5318d7f58d35
Rename #fullNameOf: to #fullFontNameOf:
Stefan Vogel <sv@exept.de>
parents:
3213
diff
changeset
|
871 |
^ device fullFontNameOf:fontId. |
2545 | 872 |
|
873 |
" |
|
874 |
((Font name:'6x10') on:Display) fullName |
|
875 |
" |
|
876 |
||
877 |
"Modified: 30.4.1996 / 17:30:10 / cg" |
|
878 |
! |
|
879 |
||
880 |
isFixedWidth |
|
881 |
"return true, if all characters have same width (as in courier). |
|
882 |
The receiver must be associated to a device, |
|
883 |
for this query to be legal." |
|
884 |
||
885 |
device isNil ifTrue:[ |
|
886 |
self errorNoDevice. |
|
887 |
]. |
|
888 |
replacementFont notNil ifTrue:[ |
|
889 |
^ replacementFont isFixedWidth |
|
890 |
]. |
|
891 |
^ isFixedWidth |
|
6932 | 892 |
! |
893 |
||
894 |
maxWidth |
|
895 |
"return the width of the widest character; |
|
896 |
if the receiver is a fixed width font its the width of every character. |
|
897 |
The receiver must be associated to a device, |
|
898 |
for this query to be legal." |
|
899 |
||
900 |
device isNil ifTrue:[ |
|
901 |
self errorNoDevice |
|
902 |
]. |
|
903 |
replacementFont notNil ifTrue:[ |
|
904 |
^ replacementFont maxWidth |
|
905 |
]. |
|
906 |
^ maxWidth |
|
2545 | 907 |
! ! |
908 |
||
909 |
!Font methodsFor:'queries-dimensions'! |
|
910 |
||
911 |
ascent |
|
912 |
"return the font-ascent (i.e. the normal average of all characters); |
|
913 |
That is the number of units (usually pixels) above the baseline. |
|
914 |
The receiver must be associated to a device, |
|
915 |
for this query to be legal." |
|
916 |
||
917 |
device isNil ifTrue:[ |
|
918 |
self errorNoDevice |
|
919 |
]. |
|
920 |
replacementFont notNil ifTrue:[ |
|
921 |
^ replacementFont ascent |
|
922 |
]. |
|
923 |
^ ascent |
|
924 |
! |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
925 |
|
628
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
926 |
ascentOn:aDevice |
7346 | 927 |
"return the font's ascent (average), if used on aDevice." |
628
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
928 |
|
2321
75a179c343cf
try replacement forn first if nonnil in queries
Claus Gittinger <cg@exept.de>
parents:
2096
diff
changeset
|
929 |
replacementFont notNil ifTrue:[ |
75a179c343cf
try replacement forn first if nonnil in queries
Claus Gittinger <cg@exept.de>
parents:
2096
diff
changeset
|
930 |
^ replacementFont ascentOn:aDevice |
75a179c343cf
try replacement forn first if nonnil in queries
Claus Gittinger <cg@exept.de>
parents:
2096
diff
changeset
|
931 |
]. |
628
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
932 |
device == aDevice ifTrue:[ |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
933 |
^ ascent |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
934 |
]. |
2833 | 935 |
^ (self onDevice:aDevice) ascent |
628
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
936 |
|
2321
75a179c343cf
try replacement forn first if nonnil in queries
Claus Gittinger <cg@exept.de>
parents:
2096
diff
changeset
|
937 |
"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
|
938 |
"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
|
939 |
! |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
940 |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
941 |
descent |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
942 |
"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
|
943 |
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
|
944 |
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
|
945 |
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
|
946 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
947 |
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
|
948 |
self errorNoDevice |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
949 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
950 |
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
|
951 |
^ replacementFont descent |
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 |
^ descent |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
954 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
955 |
|
2545 | 956 |
descentOn:aDevice |
7346 | 957 |
"return the font's 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
|
958 |
|
2545 | 959 |
replacementFont notNil ifTrue:[ |
960 |
^ replacementFont descentOn:aDevice |
|
438 | 961 |
]. |
2545 | 962 |
device == aDevice ifTrue:[ |
963 |
^ descent |
|
964 |
]. |
|
2833 | 965 |
^ (self onDevice:aDevice) descent |
438 | 966 |
|
2545 | 967 |
"Created: / 30.4.1996 / 16:41:43 / cg" |
968 |
"Modified: / 10.9.1998 / 12:09:30 / cg" |
|
438 | 969 |
! |
970 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
971 |
height |
7346 | 972 |
"return the font's characters normal (average) height; |
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
973 |
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
|
974 |
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
|
975 |
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
|
976 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
977 |
device isNil ifTrue:[ |
7346 | 978 |
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
|
979 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
980 |
replacementFont notNil ifTrue:[ |
7346 | 981 |
^ replacementFont height |
434
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 |
^ descent + ascent. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
984 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
985 |
|
667
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
986 |
heightOf:textOrString |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
987 |
"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
|
988 |
the argument must be a String. |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
989 |
CAVEAT: |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
990 |
currently only constant height fonts are supported." |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
991 |
|
5981 | 992 |
|sum| |
993 |
||
667
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
994 |
device isNil ifTrue:[ |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
995 |
self errorNoDevice. |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
996 |
^ 0 |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
997 |
]. |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
998 |
replacementFont notNil ifTrue:[ |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
999 |
^ replacementFont heightOf:textOrString |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
1000 |
]. |
5981 | 1001 |
device supportsVariableHeightFonts ifFalse:[ |
1002 |
^ descent + ascent |
|
1003 |
]. |
|
667
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
1004 |
|
5981 | 1005 |
(textOrString isString) ifTrue:[ |
1006 |
^ device heightOf:textOrString string inFont:fontId |
|
1007 |
]. |
|
1008 |
(textOrString isCharacter) ifTrue:[ |
|
1009 |
^ device heightOf:textOrString asString inFont:fontId |
|
1010 |
]. |
|
1011 |
||
1012 |
sum := 0. |
|
1013 |
textOrString do:[:lineString | |
|
1014 |
lineString isString ifTrue:[ |
|
1015 |
sum := sum + (device heightOf:lineString asString inFont:fontId). |
|
1016 |
] |
|
1017 |
]. |
|
1018 |
^ sum |
|
667
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
1019 |
|
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
1020 |
"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
|
1021 |
! |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
1022 |
|
2545 | 1023 |
heightOf:aString on:aDevice |
1024 |
"return the height of aString, if displayed on aDevice. |
|
1025 |
The argument must be a string-like object." |
|
1026 |
||
1027 |
replacementFont notNil ifTrue:[ |
|
1028 |
^ replacementFont heightOf:aString on:aDevice |
|
1029 |
]. |
|
1030 |
device == aDevice ifTrue:[ |
|
1031 |
^ self heightOf:aString |
|
1032 |
]. |
|
2833 | 1033 |
^ (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
|
1034 |
|
2545 | 1035 |
"Created: / 30.4.1996 / 17:14:18 / cg" |
1036 |
"Modified: / 10.9.1998 / 12:09:47 / cg" |
|
1037 |
! |
|
1038 |
||
1039 |
heightOn:aDevice |
|
7346 | 1040 |
"return the font's height (average), if used on aDevice." |
2545 | 1041 |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1042 |
replacementFont notNil ifTrue:[ |
2545 | 1043 |
^ replacementFont heightOn:aDevice |
1044 |
]. |
|
1045 |
device == aDevice ifTrue:[ |
|
1046 |
^ 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
|
1047 |
]. |
2833 | 1048 |
^ (self onDevice:aDevice) height |
2545 | 1049 |
|
1050 |
"Created: / 30.4.1996 / 16:41:59 / cg" |
|
1051 |
"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
|
1052 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1053 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1054 |
maxAscent |
7346 | 1055 |
"return the font's maximum-ascent (i.e. the maximum of all characters); |
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1056 |
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
|
1057 |
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
|
1058 |
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
|
1059 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1060 |
device isNil ifTrue:[ |
7346 | 1061 |
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
|
1062 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1063 |
replacementFont notNil ifTrue:[ |
7346 | 1064 |
^ replacementFont maxAscent |
434
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 |
^ maxAscent |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1067 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1068 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1069 |
maxDescent |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1070 |
"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
|
1071 |
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
|
1072 |
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
|
1073 |
for this query to be legal." |
2 | 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 |
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
|
1076 |
self errorNoDevice |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1077 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1078 |
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
|
1079 |
^ replacementFont maxDescent |
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 |
^ maxDescent |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1082 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1083 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1084 |
maxHeight |
7346 | 1085 |
"return the font's characters maximum height; |
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1086 |
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
|
1087 |
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
|
1088 |
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
|
1089 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1090 |
device isNil ifTrue:[ |
7346 | 1091 |
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
|
1092 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1093 |
replacementFont notNil ifTrue:[ |
7346 | 1094 |
^ replacementFont maxHeight |
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1095 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1096 |
^ maxDescent + maxAscent. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1097 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1098 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1099 |
minWidth |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1100 |
"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
|
1101 |
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
|
1102 |
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
|
1103 |
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
|
1104 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1105 |
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
|
1106 |
self errorNoDevice |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1107 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1108 |
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
|
1109 |
^ replacementFont minWidth |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1110 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1111 |
^ minWidth |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1112 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1113 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1114 |
width |
7346 | 1115 |
"return the font's characters width; |
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1116 |
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
|
1117 |
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
|
1118 |
For fixed fonts, this is the same as minWidth or maxWidth (or any character). |
2545 | 1119 |
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
|
1120 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1121 |
device isNil ifTrue:[ |
628
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
1122 |
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
|
1123 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1124 |
replacementFont notNil ifTrue:[ |
628
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
1125 |
^ 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
|
1126 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1127 |
^ width |
628
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
1128 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
1129 |
"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
|
1130 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1131 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1132 |
widthOf:textOrString |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1133 |
"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
|
1134 |
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
|
1135 |
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
|
1136 |
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
|
1137 |
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
|
1138 |
|
3483 | 1139 |
|this max string| |
2 | 1140 |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1141 |
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
|
1142 |
self errorNoDevice. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1143 |
^ 0 |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1144 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1145 |
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
|
1146 |
^ 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
|
1147 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1148 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1149 |
(textOrString isString) ifTrue:[ |
3483 | 1150 |
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
|
1151 |
isFixedWidth ifFalse:[ |
3483 | 1152 |
^ 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
|
1153 |
]. |
3483 | 1154 |
^ 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
|
1155 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1156 |
(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
|
1157 |
isFixedWidth ifFalse:[ |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1158 |
^ 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
|
1159 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1160 |
^ width |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1161 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1162 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1163 |
max := 0. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1164 |
isFixedWidth ifFalse:[ |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1165 |
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
|
1166 |
line notNil ifTrue:[ |
435
5288c637512e
care for nonStrings when asked for the size
Claus Gittinger <cg@exept.de>
parents:
434
diff
changeset
|
1167 |
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
|
1168 |
(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
|
1169 |
] |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1170 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1171 |
^ max |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1172 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1173 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1174 |
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
|
1175 |
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
|
1176 |
(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
|
1177 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1178 |
^ max * width |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1179 |
|
1087
1e5a93e03d7f
handle text-argument in withOf:
Claus Gittinger <cg@exept.de>
parents:
1067
diff
changeset
|
1180 |
"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
|
1181 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1182 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1183 |
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
|
1184 |
"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
|
1185 |
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
|
1186 |
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
|
1187 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1188 |
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
|
1189 |
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
|
1190 |
^ 0 |
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1191 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1192 |
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
|
1193 |
^ 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
|
1194 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1195 |
(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
|
1196 |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1197 |
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
|
1198 |
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
|
1199 |
^ (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
|
1200 |
]. |
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
|
1201 |
^ 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
|
1202 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1203 |
^ (stop - start + 1) * width |
2545 | 1204 |
! |
1205 |
||
1206 |
widthOf:aString from:startIndex to:endIndex on:aDevice |
|
1207 |
"return the width of substring, if displayed on aDevice. |
|
1208 |
The argument may be a Character, String or some Text; |
|
1209 |
in the last case the width of the longest line in the text is returned." |
|
1210 |
||
1211 |
replacementFont notNil ifTrue:[ |
|
1212 |
^ replacementFont widthOf:aString from:startIndex to:endIndex on:aDevice |
|
1213 |
]. |
|
1214 |
device == aDevice ifTrue:[ |
|
1215 |
^ self widthOf:aString from:startIndex to:endIndex |
|
1216 |
]. |
|
2833 | 1217 |
^ (self onDevice:aDevice) widthOf:aString from:startIndex to:endIndex |
2545 | 1218 |
|
1219 |
"Created: / 30.4.1996 / 17:15:20 / cg" |
|
1220 |
"Modified: / 10.9.1998 / 12:10:11 / cg" |
|
1221 |
! |
|
1222 |
||
1223 |
widthOf:aString on:aDevice |
|
1224 |
"return the width of aString, if displayed on aDevice. |
|
1225 |
The argument may be a Character, String or some Text; |
|
1226 |
in the last case the width of the longest line in the text is returned." |
|
1227 |
||
1228 |
replacementFont notNil ifTrue:[ |
|
1229 |
^ replacementFont widthOf:aString on:aDevice |
|
1230 |
]. |
|
1231 |
device == aDevice ifTrue:[ |
|
1232 |
^ self widthOf:aString |
|
1233 |
]. |
|
2833 | 1234 |
^ (self onDevice:aDevice) widthOf:aString |
2545 | 1235 |
|
1236 |
"Created: / 30.4.1996 / 17:14:18 / cg" |
|
1237 |
"Modified: / 10.9.1998 / 12:10:26 / cg" |
|
1238 |
! |
|
1239 |
||
1240 |
widthOn:aDevice |
|
7346 | 1241 |
"return the font's width, if used on aDevice. |
2545 | 1242 |
For variable pitch fonts, the width of the space character is returned. |
1243 |
For fixed fonts, this is the same as minWidth or maxWidth (or any character)." |
|
1244 |
||
1245 |
replacementFont notNil ifTrue:[ |
|
1246 |
^ replacementFont widthOn:aDevice |
|
1247 |
]. |
|
1248 |
device == aDevice ifTrue:[ |
|
1249 |
^ self width |
|
1250 |
]. |
|
2833 | 1251 |
^ (self onDevice:aDevice) width |
2545 | 1252 |
|
1253 |
"Created: / 30.4.1996 / 16:42:28 / cg" |
|
1254 |
"Modified: / 10.9.1998 / 12:11:33 / cg" |
|
2 | 1255 |
! ! |
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1256 |
|
4023 | 1257 |
!Font methodsFor:'queries-misc'! |
1258 |
||
1259 |
direction |
|
1260 |
device isNil ifTrue:[ |
|
1261 |
self errorNoDevice |
|
1262 |
]. |
|
1263 |
replacementFont notNil ifTrue:[ |
|
1264 |
^ replacementFont direction |
|
1265 |
]. |
|
1266 |
^ direction |
|
1267 |
! |
|
1268 |
||
8072 | 1269 |
graphicsDevice |
1270 |
"same as #device, for ST-80 compatibility naming. |
|
1271 |
Return the device I am associated with." |
|
1272 |
||
1273 |
^ device |
|
1274 |
||
1275 |
"Created: 28.5.1996 / 18:39:53 / cg" |
|
1276 |
! |
|
1277 |
||
4205 | 1278 |
maxAscii |
1279 |
"squeak compatibility" |
|
1280 |
||
1281 |
^ self maxCode |
|
1282 |
! |
|
1283 |
||
4023 | 1284 |
maxCode |
1285 |
device isNil ifTrue:[ |
|
1286 |
self errorNoDevice |
|
1287 |
]. |
|
1288 |
replacementFont notNil ifTrue:[ |
|
1289 |
^ replacementFont maxCode |
|
1290 |
]. |
|
1291 |
^ maxCode |
|
1292 |
! |
|
1293 |
||
4205 | 1294 |
minAscii |
1295 |
"squeak compatibility" |
|
1296 |
||
1297 |
^ self minCode |
|
1298 |
! |
|
1299 |
||
4023 | 1300 |
minCode |
1301 |
device isNil ifTrue:[ |
|
1302 |
self errorNoDevice |
|
1303 |
]. |
|
1304 |
replacementFont notNil ifTrue:[ |
|
1305 |
^ replacementFont minCode |
|
1306 |
]. |
|
1307 |
^ minCode |
|
1308 |
! ! |
|
1309 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1310 |
!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
|
1311 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1312 |
fixedWidth |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1313 |
"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
|
1314 |
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
|
1315 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1316 |
^ self isFixedWidth |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1317 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1318 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1319 |
pixelSize |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1320 |
"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
|
1321 |
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
|
1322 |
|
5197 | 1323 |
^ 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
|
1324 |
! ! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1325 |
|
6104 | 1326 |
!Font methodsFor:'testing'! |
1327 |
||
1328 |
isAlienFont |
|
7873 | 1329 |
"answer true, if this is an alien font which does not have a device representation. |
1330 |
Alien fonts are eg. Hershey or Bitmap fonts, which are drawn by st/x itself." |
|
6104 | 1331 |
|
1332 |
^ false |
|
7873 | 1333 |
|
1334 |
"Modified (comment): / 12-02-2017 / 22:03:33 / cg" |
|
6104 | 1335 |
! ! |
1336 |
||
2433
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1337 |
!Font::DeviceFontHandle class methodsFor:'documentation'! |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1338 |
|
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1339 |
documentation |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1340 |
" |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1341 |
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
|
1342 |
|
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1343 |
[author:] |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1344 |
Stefan Vogel (stefan@nilpferd) |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1345 |
|
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1346 |
[see also:] |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1347 |
Font |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1348 |
|
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1349 |
[instance variables:] |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1350 |
|
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1351 |
[class variables:] |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1352 |
" |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1353 |
! ! |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1354 |
|
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1355 |
!Font::DeviceFontHandle methodsFor:'accessing'! |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1356 |
|
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1357 |
setDevice:aDevice fontId:anId |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1358 |
"set the handles contents" |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1359 |
|
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1360 |
device := aDevice. |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1361 |
fontId := anId. |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1362 |
|
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1363 |
"Created: / 3.2.1999 / 16:08:31 / stefan" |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1364 |
! ! |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1365 |
|
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1366 |
!Font::DeviceFontHandle methodsFor:'finalization'! |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1367 |
|
3611
8b4384c9e660
Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents:
3527
diff
changeset
|
1368 |
finalize |
2433
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1369 |
"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
|
1370 |
|
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1371 |
|id| |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1372 |
|
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1373 |
(id := fontId) notNil ifTrue:[ |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1374 |
fontId := nil. |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1375 |
device releaseFont:id. |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1376 |
] |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1377 |
|
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1378 |
"Created: / 3.2.1999 / 16:09:25 / stefan" |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1379 |
! ! |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1380 |
|
1087
1e5a93e03d7f
handle text-argument in withOf:
Claus Gittinger <cg@exept.de>
parents:
1067
diff
changeset
|
1381 |
!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
|
1382 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1383 |
version |
6932 | 1384 |
^ '$Header$' |
5442
218a6ae3e112
changed: #family:face:style:size:sizeUnit:encoding:
Claus Gittinger <cg@exept.de>
parents:
5253
diff
changeset
|
1385 |
! |
218a6ae3e112
changed: #family:face:style:size:sizeUnit:encoding:
Claus Gittinger <cg@exept.de>
parents:
5253
diff
changeset
|
1386 |
|
218a6ae3e112
changed: #family:face:style:size:sizeUnit:encoding:
Claus Gittinger <cg@exept.de>
parents:
5253
diff
changeset
|
1387 |
version_CVS |
6932 | 1388 |
^ '$Header$' |
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1389 |
! ! |
3739
909fefa92b5a
Raise #drawingOnClosedDeviceSignal instead of #error
Stefan Vogel <sv@exept.de>
parents:
3663
diff
changeset
|
1390 |
|
5981 | 1391 |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1392 |
Font initialize! |