author | Claus Gittinger <cg@exept.de> |
Fri, 14 Oct 2016 14:56:04 +0200 | |
changeset 7624 | b49d1f99b8dd |
parent 7577 | 81657d05b6ef |
child 7701 | 8ec4585fa762 |
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 |
731 | 297 |
! |
298 |
||
299 |
graphicsDevice |
|
300 |
"same as #device, for ST-80 compatibility naming. |
|
301 |
Return the device I am associated with." |
|
302 |
||
303 |
^ device |
|
304 |
||
305 |
"Created: 28.5.1996 / 18:39:53 / cg" |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
306 |
! ! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
307 |
|
5145 | 308 |
|
5559 | 309 |
!Font methodsFor:'converting'! |
310 |
||
311 |
asFontDescription |
|
312 |
^ FontDescription |
|
313 |
family:family |
|
314 |
face:face |
|
315 |
style:style |
|
316 |
size:size |
|
317 |
sizeUnit:(sizeUnit ? #pt) |
|
318 |
encoding:encoding |
|
319 |
! ! |
|
320 |
||
3027
efb7b0c760f5
blocked deepCopying of fonts
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
321 |
!Font methodsFor:'copying'! |
efb7b0c760f5
blocked deepCopying of fonts
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
322 |
|
4934 | 323 |
deepCopyUsing:aDictionary postCopySelector:postCopySelector |
3027
efb7b0c760f5
blocked deepCopying of fonts
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
324 |
^ self |
efb7b0c760f5
blocked deepCopying of fonts
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
325 |
! ! |
efb7b0c760f5
blocked deepCopying of fonts
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
326 |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
327 |
!Font methodsFor:'displaying'! |
71 | 328 |
|
3663 | 329 |
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
|
330 |
"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
|
331 |
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
|
332 |
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
|
333 |
|
441 | 334 |
|prevFont| |
335 |
||
2545 | 336 |
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
|
337 |
replacementFont isNil ifTrue:[ |
2545 | 338 |
fontId notNil ifTrue:[ |
339 |
aGC basicFont:self. |
|
3663 | 340 |
aGC displayString:aString from:index1 to:index2 x:x y:y opaque:opaque. |
2545 | 341 |
] ifFalse:[ |
342 |
'Font: [warning]: no replacementFont. should not happen' errorPrintCR. |
|
343 |
]. |
|
344 |
] ifFalse:[ |
|
345 |
aGC basicFont:replacementFont. |
|
3663 | 346 |
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
|
347 |
]. |
442 | 348 |
aGC basicFont:prevFont. |
441 | 349 |
|
1176
e0e2c8cbb3c8
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1166
diff
changeset
|
350 |
"Modified: 10.1.1997 / 17:51:17 / cg" |
6471 | 351 |
! |
352 |
||
353 |
displayString:aString from:index1 to:index2 x:x y:y in:aGC opaque:opaque maxWidth:maxWindowWidth |
|
354 |
"this is only called for fonts which have a nil fontId, |
|
355 |
and therefore use the replacementFont. Should never be called |
|
356 |
for non-replacement fonts." |
|
357 |
||
358 |
|prevFont| |
|
359 |
||
360 |
prevFont := aGC font. |
|
361 |
replacementFont isNil ifTrue:[ |
|
362 |
fontId notNil ifTrue:[ |
|
363 |
aGC basicFont:self. |
|
364 |
aGC displayString:aString from:index1 to:index2 x:x y:y opaque:opaque maxWidth:maxWindowWidth. |
|
365 |
] ifFalse:[ |
|
366 |
'Font: [warning]: no replacementFont. should not happen' errorPrintCR. |
|
367 |
]. |
|
368 |
] ifFalse:[ |
|
369 |
aGC basicFont:replacementFont. |
|
370 |
aGC displayString:aString from:index1 to:index2 x:x y:y opaque:opaque maxWidth:maxWindowWidth. |
|
371 |
]. |
|
372 |
aGC basicFont:prevFont. |
|
373 |
||
374 |
"Modified: 10.1.1997 / 17:51:17 / cg" |
|
0 | 375 |
! ! |
376 |
||
377 |
!Font methodsFor:'getting a device font'! |
|
378 |
||
3628 | 379 |
onDevice:aDevice |
0 | 380 |
"create a new Font representing the same font as |
381 |
myself on aDevice; if one already exists, return the one." |
|
382 |
||
5167 | 383 |
|newFont rep| |
3628 | 384 |
|
385 |
"if I am already assigned to that device ..." |
|
386 |
(device == aDevice) ifTrue:[^ self]. |
|
387 |
||
5222
09fb6ebff525
changed #onDevice: - formatting
Stefan Vogel <sv@exept.de>
parents:
5197
diff
changeset
|
388 |
(aDevice isNil and:[device notNil]) ifTrue:[ |
09fb6ebff525
changed #onDevice: - formatting
Stefan Vogel <sv@exept.de>
parents:
5197
diff
changeset
|
389 |
^ self |
5174 | 390 |
]. |
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
|
391 |
|
3628 | 392 |
aDevice deviceFonts do:[:aFont | |
5167 | 393 |
(self sameDeviceFontAs:aFont) ifTrue:[ |
394 |
^ aFont |
|
395 |
]. |
|
3628 | 396 |
]. |
397 |
||
398 |
newFont := self onDevice:aDevice ifAbsent:nil. |
|
399 |
newFont isNil ifTrue:[ |
|
400 |
"oops did not work - (device has no such font)" |
|
401 |
aDevice isOpen ifFalse:[ |
|
402 |
"/ the display device is not connected |
|
403 |
"/ (or has a broken connection). |
|
3739
909fefa92b5a
Raise #drawingOnClosedDeviceSignal instead of #error
Stefan Vogel <sv@exept.de>
parents:
3663
diff
changeset
|
404 |
aDevice class drawingOnClosedDeviceSignal raiseRequestWith:aDevice. |
3628 | 405 |
^ self. |
406 |
]. |
|
6109 | 407 |
|
5040
b28c261dd543
replacement font handling did not remember font in the registry,
Claus Gittinger <cg@exept.de>
parents:
4934
diff
changeset
|
408 |
"/ look for a replacement font |
3628 | 409 |
rep := self replacementFontOnDevice:aDevice. |
410 |
device isNil ifTrue:[ |
|
411 |
device := aDevice. |
|
412 |
replacementFont := rep. |
|
6109 | 413 |
newFont := self. |
414 |
] ifFalse:[ |
|
415 |
newFont := self class basicNew. |
|
416 |
newFont |
|
417 |
setFamily:family |
|
418 |
face:face |
|
419 |
style:style |
|
420 |
size:(sizeUnit == #px ifTrue:[pixelSize] ifFalse:[size]) |
|
421 |
sizeUnit:sizeUnit |
|
422 |
encoding:encoding |
|
423 |
device:aDevice; |
|
424 |
isGenericFont:self isGenericFont; |
|
425 |
setReplacementFont:rep. |
|
3628 | 426 |
]. |
427 |
aDevice registerFont:newFont. |
|
428 |
]. |
|
429 |
||
430 |
^ newFont |
|
431 |
||
432 |
" |
|
6109 | 433 |
(Font family:'fooXXXXXX' size:17) onDevice:Screen current |
3628 | 434 |
" |
435 |
||
436 |
"Modified: 14.4.1997 / 18:22:31 / cg" |
|
2848 | 437 |
! |
438 |
||
3628 | 439 |
onDevice:aDevice ifAbsent:exceptionBlock |
2848 | 440 |
"create a new Font representing the same font as |
441 |
myself on aDevice. This does NOT try to look for existing |
|
442 |
or replacement fonts (i.e. can be used to get physical fonts)." |
|
443 |
||
7624 | 444 |
|id xftFont| |
2848 | 445 |
|
446 |
"receiver was not associated - do it now" |
|
447 |
device isNil ifTrue:[ |
|
7624 | 448 |
(aDevice supportsXftFonts |
449 |
and:[ UserPreferences current useXFontsOnly not ]) ifTrue:[ |
|
450 |
xftFont := (XftFontDescription for:self) onDevice:aDevice ifAbsent:[nil]. |
|
451 |
xftFont notNil ifTrue:[^ xftFont]. |
|
452 |
UserPreferences current useXftFontsOnly ifTrue:[^ nil]. |
|
453 |
]. |
|
454 |
||
3785 | 455 |
"ask that device for the font" |
5167 | 456 |
id := aDevice |
457 |
getFontWithFamily:family |
|
458 |
face:face |
|
459 |
style:style |
|
5186 | 460 |
size:(sizeUnit == #px ifTrue:[pixelSize] ifFalse:[size]) |
461 |
sizeUnit:sizeUnit |
|
6158 | 462 |
encoding:encoding ? '*'. |
3785 | 463 |
id isNil ifTrue:[ |
464 |
"oops did not work - (device has no such font)" |
|
465 |
||
466 |
^ exceptionBlock value |
|
467 |
]. |
|
468 |
||
2848 | 469 |
device := aDevice. |
470 |
fontId := id. |
|
471 |
||
472 |
self getFontInfos. |
|
473 |
aDevice registerFont:self. |
|
474 |
^ self |
|
475 |
]. |
|
476 |
||
477 |
"receiver was already associated to another device - need a new font" |
|
3785 | 478 |
^ super onDevice:aDevice ifAbsent:exceptionBlock |
2848 | 479 |
! |
480 |
||
3628 | 481 |
replacementFontOnDevice:aDevice |
12 | 482 |
"return a replacement font for the receiver - this is needed, if |
483 |
an image is restored on another type of display, or one which has |
|
484 |
a different set of fonts." |
|
0 | 485 |
|
6204
56abbbb55591
Replace references to Diplay with "Screen current" - where appropriate
Stefan Vogel <sv@exept.de>
parents:
6163
diff
changeset
|
486 |
|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
|
487 |
|
5512
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
488 |
"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
|
489 |
but do not try this on scaled fonts (they have size == 0)" |
0 | 490 |
|
6204
56abbbb55591
Replace references to Diplay with "Screen current" - where appropriate
Stefan Vogel <sv@exept.de>
parents:
6163
diff
changeset
|
491 |
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
|
492 |
alternateFamilyName := family. |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
493 |
self isGenericFont ifFalse:[ |
6109 | 494 |
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
|
495 |
[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
|
496 |
id := aDevice |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
497 |
getFontWithFamily:family |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
498 |
face:face |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
499 |
style:style |
6109 | 500 |
size:trySize |
5512
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
501 |
sizeUnit:sizeUnit |
6204
56abbbb55591
Replace references to Diplay with "Screen current" - where appropriate
Stefan Vogel <sv@exept.de>
parents:
6163
diff
changeset
|
502 |
encoding:useEncoding. |
5512
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
503 |
]. |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
504 |
]. |
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
|
505 |
|
144 | 506 |
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
|
507 |
('Font [info]: use alternative size ', trySize printString, ' for ' , (self userFriendlyName)) infoPrintCR. |
144 | 508 |
] ifFalse:[ |
5512
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
509 |
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
|
510 |
alternatives notNil ifTrue:[ |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
511 |
alternatives detect:[:eachAlternateFamilyName| |
6109 | 512 |
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
|
513 |
[ |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
514 |
id := aDevice |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
515 |
getFontWithFamily:eachAlternateFamilyName |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
516 |
face:face |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
517 |
style:style |
6109 | 518 |
size:trySize |
5512
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
519 |
sizeUnit:sizeUnit |
6204
56abbbb55591
Replace references to Diplay with "Screen current" - where appropriate
Stefan Vogel <sv@exept.de>
parents:
6163
diff
changeset
|
520 |
encoding:useEncoding. |
5990 | 521 |
] 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
|
522 |
alternateFamilyName := eachAlternateFamilyName. |
e4ede40d58ee
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5493
diff
changeset
|
523 |
id notNil. |
5526
2eb1df09a195
changed: #replacementFontOnDevice:
Stefan Vogel <sv@exept.de>
parents:
5512
diff
changeset
|
524 |
] 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
|
525 |
]. |
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
|
526 |
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
|
527 |
('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
|
528 |
] ifFalse:[ |
6204
56abbbb55591
Replace references to Diplay with "Screen current" - where appropriate
Stefan Vogel <sv@exept.de>
parents:
6163
diff
changeset
|
529 |
useEncoding = #'iso10646-1' ifTrue:[ |
5990 | 530 |
"/ try latin1 (for osx-X11) |
531 |
id := aDevice |
|
532 |
getFontWithFamily:family |
|
533 |
face:face |
|
534 |
style:style |
|
535 |
size:(sizeUnit == #px ifTrue:[pixelSize] ifFalse:[size ? 0]) |
|
536 |
sizeUnit:sizeUnit |
|
537 |
encoding:#'iso8859-1'. |
|
538 |
id notNil ifTrue:[ |
|
539 |
('Font [info]: use latin1 encoding for: ' , (self userFriendlyName)) infoPrintCR. |
|
540 |
]. |
|
541 |
]. |
|
542 |
id isNil ifTrue:[ |
|
6204
56abbbb55591
Replace references to Diplay with "Screen current" - where appropriate
Stefan Vogel <sv@exept.de>
parents:
6163
diff
changeset
|
543 |
id := aDevice getDefaultFontWithEncoding:useEncoding. |
5990 | 544 |
('Font [info]: use default for ' , (self userFriendlyName)) infoPrintCR. |
545 |
]. |
|
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
|
546 |
]. |
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
|
547 |
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
|
548 |
"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
|
549 |
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
|
550 |
^ 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
|
551 |
]. |
0 | 552 |
]. |
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
|
553 |
|
5040
b28c261dd543
replacement font handling did not remember font in the registry,
Claus Gittinger <cg@exept.de>
parents:
4934
diff
changeset
|
554 |
"/ 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
|
555 |
"/ 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
|
556 |
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
|
557 |
(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
|
558 |
^ eachDeviceFont |
5040
b28c261dd543
replacement font handling did not remember font in the registry,
Claus Gittinger <cg@exept.de>
parents:
4934
diff
changeset
|
559 |
] |
b28c261dd543
replacement font handling did not remember font in the registry,
Claus Gittinger <cg@exept.de>
parents:
4934
diff
changeset
|
560 |
]. |
b28c261dd543
replacement font handling did not remember font in the registry,
Claus Gittinger <cg@exept.de>
parents:
4934
diff
changeset
|
561 |
|
0 | 562 |
f := self class basicNew. |
6109 | 563 |
f |
6204
56abbbb55591
Replace references to Diplay with "Screen current" - where appropriate
Stefan Vogel <sv@exept.de>
parents:
6163
diff
changeset
|
564 |
setFamily:alternateFamilyName face:face style:style size:trySize sizeUnit:sizeUnit encoding:useEncoding device:aDevice; |
6109 | 565 |
setDevice:aDevice fontId:id; |
566 |
getFontInfos. |
|
5040
b28c261dd543
replacement font handling did not remember font in the registry,
Claus Gittinger <cg@exept.de>
parents:
4934
diff
changeset
|
567 |
|
1372
2b55617a712f
keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents:
1229
diff
changeset
|
568 |
aDevice registerFont:f. |
0 | 569 |
^ f |
454
b31d0a7e5530
nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
570 |
|
1166 | 571 |
"Modified: 10.1.1997 / 15:40:21 / cg" |
0 | 572 |
! ! |
573 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
574 |
!Font methodsFor:'instance release'! |
0 | 575 |
|
2848 | 576 |
executor |
578 | 577 |
"redefined to return a lightweight copy |
578 |
- all we need is the device handle" |
|
579 |
||
2848 | 580 |
^ DeviceFontHandle basicNew setDevice:device fontId:fontId. |
578 | 581 |
|
2433
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
582 |
"Modified: / 20.4.1996 / 23:23:04 / cg" |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
583 |
"Modified: / 3.2.1999 / 16:13:10 / stefan" |
2 | 584 |
! ! |
585 |
||
4852 | 586 |
!Font methodsFor:'object persistency'! |
0 | 587 |
|
4207 | 588 |
elementDescriptorFor:aspect |
4852 | 589 |
"support for persistency: |
590 |
answer the elements to be made persistent with an ObjectCoder" |
|
591 |
||
4006 | 592 |
"binary storage encoding vector" |
593 |
||
594 |
^ Array |
|
595 |
with:(#family->self family) |
|
596 |
with:(#face->self face) |
|
597 |
with:(#style->self style) |
|
598 |
with:(#size->self size) |
|
599 |
with:(#encoding->self encoding) |
|
4852 | 600 |
! ! |
601 |
||
602 |
!Font methodsFor:'printing & storing'! |
|
3934 | 603 |
|
109 | 604 |
printOn:aStream |
2805 | 605 |
"append a user printed representation of the receiver to aStream. |
606 |
The format is suitable for a human - not meant to be read back. |
|
7346 | 607 |
Redefined to print more about the font's name" |
578 | 608 |
|
46 | 609 |
face isNil ifTrue:[ |
578 | 610 |
family isNil ifTrue:[ |
611 |
aStream nextPutAll:('a replacement-Font'). |
|
612 |
^ self |
|
613 |
]. |
|
614 |
aStream nextPutAll:('a ' , family , '-Font'). |
|
615 |
^ self. |
|
46 | 616 |
]. |
109 | 617 |
aStream nextPutAll:('a ' , family , '-' , |
578 | 618 |
face , '-' , |
4803 | 619 |
style printString , '-' , |
4007 | 620 |
size printString , |
621 |
' (' , encoding printString , ')' , |
|
622 |
'-Font') |
|
578 | 623 |
|
624 |
"Modified: 20.4.1996 / 23:25:11 / cg" |
|
0 | 625 |
! |
626 |
||
109 | 627 |
storeOn:aStream |
628 |
"append a character sequence to the argument, aStream from which the |
|
629 |
receiver can be reconstructed using readFrom:." |
|
0 | 630 |
|
109 | 631 |
aStream nextPutAll:'(Font family:'. family storeOn:aStream. |
632 |
aStream nextPutAll:' face:'. face storeOn:aStream. |
|
633 |
aStream nextPutAll:' style:'. style storeOn:aStream. |
|
634 |
aStream nextPutAll:' size:'. size storeOn:aStream. |
|
635 |
aStream nextPutAll:' encoding:'. encoding storeOn:aStream. |
|
636 |
aStream nextPut:$) |
|
637 |
||
638 |
" |
|
639 |
(Font family:'helvetica' size:10) storeString |
|
640 |
" |
|
0 | 641 |
! ! |
2 | 642 |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
643 |
!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
|
644 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
645 |
getFontInfos |
578 | 646 |
"ask the device about all of my actual attributes" |
647 |
||
5578 | 648 |
|info fetchedEncoding| |
991 | 649 |
|
3479 | 650 |
replacementFont notNil ifTrue:[ |
651 |
replacementFont getFontInfos. |
|
652 |
^ self |
|
653 |
]. |
|
991 | 654 |
|
4023 | 655 |
info := self getFontMetrics. |
656 |
||
657 |
minCode := info minCode. |
|
658 |
maxCode := info maxCode. |
|
659 |
direction := info direction. |
|
660 |
||
5578 | 661 |
fetchedEncoding := info encoding. |
662 |
fetchedEncoding isNil ifTrue:[ |
|
663 |
fetchedEncoding := device encodingOf:fontId. |
|
664 |
]. |
|
6078 | 665 |
|
5578 | 666 |
encoding notNil ifTrue:[ |
6078 | 667 |
(encoding ~= fetchedEncoding) ifTrue:[ |
668 |
(( #( #'iso10646-1' #'ms-default' #'ms-ansi' #'ms-oem' ) includes:encoding) |
|
669 |
and:[ ( #( #'iso10646-1' #'ms-default' #'ms-ansi' #'ms-oem' ) includes:fetchedEncoding)]) ifFalse:[ |
|
670 |
encoding ~= #* ifTrue:[ |
|
671 |
('Font [warning]: encoding for "%1" should be %2; is %3 ' |
|
672 |
bindWith:self with: encoding with: fetchedEncoding) infoPrintCR. |
|
673 |
]. |
|
674 |
]. |
|
5582 | 675 |
]. |
5578 | 676 |
] ifFalse:[ |
677 |
encoding := fetchedEncoding. |
|
3527 | 678 |
]. |
3479 | 679 |
ascent := info ascent. |
680 |
descent := info descent. |
|
681 |
maxAscent := info maxAscent. |
|
682 |
maxDescent := info maxDescent. |
|
683 |
minWidth := info minWidth. |
|
684 |
maxWidth := info maxWidth. |
|
685 |
width := info averageWidth. |
|
991 | 686 |
|
687 |
width < minWidth ifTrue:[ |
|
688 |
"/ some systems/fonts return a wrong value (0) as width of a space |
|
689 |
"/ - at least with X11 ... |
|
690 |
width := minWidth |
|
994 | 691 |
]. |
5647 | 692 |
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
|
693 |
|
5647 | 694 |
"/ a temporary hack for the vista-cleartype font redraw problem |
5668 | 695 |
false "isFixedWidth" ifFalse:[ |
5647 | 696 |
UserPreferences current workAroundRenderingBugOnVista ifTrue:[ |
697 |
self hasOverlappingCharacters:true. |
|
698 |
] |
|
699 |
]. |
|
700 |
"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
|
701 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
702 |
|
3658
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
703 |
getFontMetrics |
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
704 |
"ask the device about all of my actual attributes" |
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
705 |
|
6163 | 706 |
|metrics| |
707 |
||
3658
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
708 |
replacementFont notNil ifTrue:[ |
4023 | 709 |
^ replacementFont getFontMetrics |
3658
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
710 |
]. |
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
711 |
|
6163 | 712 |
metrics := device fontMetricsOf:fontId. |
713 |
||
714 |
"the MS TrueType unicode core fonts in Linux have way to large ascent |
|
715 |
and descent values, so the line spacing is too wide. |
|
716 |
Take them from the latin-1 equivalent" |
|
717 |
(device platformName == #X11 |
|
718 |
and:[encoding = #'iso10646-1' |
|
719 |
and:[metrics ascent = metrics maxAscent |
|
720 |
and:[metrics descent == metrics maxDescent]]]) ifTrue:[ |
|
721 |
|latinFont latinMetrics| |
|
722 |
||
723 |
latinFont := self asEncoding:'iso8859-1'. |
|
724 |
latinFont notNil ifTrue:[ |
|
725 |
latinMetrics := latinFont getFontMetrics. |
|
726 |
metrics ascent:latinMetrics ascent descent:latinMetrics descent. |
|
727 |
]. |
|
728 |
]. |
|
729 |
||
730 |
^ metrics. |
|
731 |
||
732 |
" |
|
733 |
(View defaultFont onDevice:Screen current) getFontMetrics |
|
734 |
" |
|
3658
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
735 |
! |
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
736 |
|
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
737 |
getFontResolution |
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
738 |
"ask the device about all of my actual attributes" |
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
739 |
|
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
740 |
|f| |
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
741 |
|
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
742 |
f := fontId. |
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
743 |
replacementFont notNil ifTrue:[ |
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
744 |
f := replacementFont fontId. |
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 |
^ device fontResolutionOf:f. |
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
748 |
! |
8932bb6311ef
#getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents:
3628
diff
changeset
|
749 |
|
7443 | 750 |
installInDeviceForGCId:aGCId |
751 |
"install the font for aGCId" |
|
752 |
||
753 |
(device isNil or:[fontId isNil]) ifTrue:[ |
|
754 |
"this should not happen, since #onDevice tries replacement fonts" |
|
755 |
Logger error:'no device font for: %1' with:self. |
|
756 |
^ nil. |
|
757 |
]. |
|
758 |
device setFont:fontId in:aGCId. |
|
759 |
! |
|
760 |
||
2846 | 761 |
releaseFromDevice |
762 |
"I am no longer available on the device" |
|
763 |
||
764 |
device := nil. |
|
765 |
fontId := nil. |
|
766 |
replacementFont := nil |
|
767 |
||
768 |
"Modified: 20.4.1996 / 23:26:26 / cg" |
|
769 |
! |
|
770 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
771 |
restored |
578 | 772 |
"flush device handles when restored" |
773 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
774 |
device := nil. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
775 |
fontId := nil. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
776 |
replacementFont := nil |
578 | 777 |
|
778 |
"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
|
779 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
780 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
781 |
setDevice:aDevice |
578 | 782 |
"set the device handle" |
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 := aDevice |
578 | 785 |
|
786 |
"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
|
787 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
788 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
789 |
setDevice:aDevice fontId:aFontId |
578 | 790 |
"set the device and font handles" |
791 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
792 |
device := aDevice. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
793 |
fontId := aFontId |
578 | 794 |
|
795 |
"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
|
796 |
! |
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 |
setFamily:familyString face:faceString style:styleString size:sizeNum encoding:encodingSym device:aDevice |
5186 | 799 |
<resource: #obsolete> |
6109 | 800 |
self obsoleteMethodWarning:'2013-07-25'. |
5186 | 801 |
|
802 |
self |
|
803 |
setFamily:familyString |
|
804 |
face:faceString |
|
805 |
style:styleString |
|
806 |
size:sizeNum |
|
807 |
sizeUnit:#pt |
|
808 |
encoding:encodingSym |
|
809 |
device:aDevice |
|
810 |
! |
|
811 |
||
812 |
setFamily:familyString face:faceString style:styleString size:sizeArg sizeUnit:sizeUnitArg encoding:encodingSym device:aDevice |
|
578 | 813 |
"set my instance attributes" |
814 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
815 |
family := familyString. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
816 |
face := faceString. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
817 |
style := styleString. |
5253 | 818 |
sizeUnit := (sizeUnitArg ? #pt). |
819 |
sizeUnit == #pt ifTrue:[ |
|
820 |
size := sizeArg |
|
821 |
] ifFalse:[ |
|
822 |
sizeUnit == #px ifTrue:[ |
|
823 |
pixelSize := sizeArg |
|
824 |
] ifFalse:[ |
|
825 |
self error:'invalid sizeUnit' mayProceed:true. |
|
826 |
size := 12. |
|
827 |
sizeUnit := #pt |
|
828 |
]. |
|
829 |
]. |
|
5167 | 830 |
encoding := encodingSym. |
831 |
device := aDevice |
|
832 |
||
833 |
"Modified: 20.4.1996 / 23:26:56 / cg" |
|
834 |
! |
|
835 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
836 |
setFontId:aFontId |
578 | 837 |
"set my font handle" |
838 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
839 |
fontId := aFontId |
578 | 840 |
|
841 |
"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
|
842 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
843 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
844 |
setReplacementFont:aFont |
578 | 845 |
"set my replacement font" |
846 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
847 |
replacementFont := aFont |
578 | 848 |
|
849 |
"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
|
850 |
! ! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
851 |
|
2545 | 852 |
!Font methodsFor:'queries-deviceFonts'! |
853 |
||
854 |
fullName |
|
855 |
"return the full (device specific) name of the receiver. |
|
856 |
This is query only valid if the receiver is associated to a device" |
|
857 |
||
858 |
device isNil ifTrue:[ |
|
859 |
^ nil |
|
860 |
]. |
|
3415
5318d7f58d35
Rename #fullNameOf: to #fullFontNameOf:
Stefan Vogel <sv@exept.de>
parents:
3213
diff
changeset
|
861 |
^ device fullFontNameOf:fontId. |
2545 | 862 |
|
863 |
" |
|
864 |
((Font name:'6x10') on:Display) fullName |
|
865 |
" |
|
866 |
||
867 |
"Modified: 30.4.1996 / 17:30:10 / cg" |
|
868 |
! |
|
869 |
||
870 |
isFixedWidth |
|
871 |
"return true, if all characters have same width (as in courier). |
|
872 |
The receiver must be associated to a device, |
|
873 |
for this query to be legal." |
|
874 |
||
875 |
device isNil ifTrue:[ |
|
876 |
self errorNoDevice. |
|
877 |
]. |
|
878 |
replacementFont notNil ifTrue:[ |
|
879 |
^ replacementFont isFixedWidth |
|
880 |
]. |
|
881 |
^ isFixedWidth |
|
6932 | 882 |
! |
883 |
||
884 |
maxWidth |
|
885 |
"return the width of the widest character; |
|
886 |
if the receiver is a fixed width font its the width of every character. |
|
887 |
The receiver must be associated to a device, |
|
888 |
for this query to be legal." |
|
889 |
||
890 |
device isNil ifTrue:[ |
|
891 |
self errorNoDevice |
|
892 |
]. |
|
893 |
replacementFont notNil ifTrue:[ |
|
894 |
^ replacementFont maxWidth |
|
895 |
]. |
|
896 |
^ maxWidth |
|
2545 | 897 |
! ! |
898 |
||
899 |
!Font methodsFor:'queries-dimensions'! |
|
900 |
||
901 |
ascent |
|
902 |
"return the font-ascent (i.e. the normal average of all characters); |
|
903 |
That is the number of units (usually pixels) above the baseline. |
|
904 |
The receiver must be associated to a device, |
|
905 |
for this query to be legal." |
|
906 |
||
907 |
device isNil ifTrue:[ |
|
908 |
self errorNoDevice |
|
909 |
]. |
|
910 |
replacementFont notNil ifTrue:[ |
|
911 |
^ replacementFont ascent |
|
912 |
]. |
|
913 |
^ ascent |
|
914 |
! |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
915 |
|
628
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
916 |
ascentOn:aDevice |
7346 | 917 |
"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
|
918 |
|
2321
75a179c343cf
try replacement forn first if nonnil in queries
Claus Gittinger <cg@exept.de>
parents:
2096
diff
changeset
|
919 |
replacementFont notNil ifTrue:[ |
75a179c343cf
try replacement forn first if nonnil in queries
Claus Gittinger <cg@exept.de>
parents:
2096
diff
changeset
|
920 |
^ replacementFont ascentOn:aDevice |
75a179c343cf
try replacement forn first if nonnil in queries
Claus Gittinger <cg@exept.de>
parents:
2096
diff
changeset
|
921 |
]. |
628
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
922 |
device == aDevice ifTrue:[ |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
923 |
^ ascent |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
924 |
]. |
2833 | 925 |
^ (self onDevice:aDevice) ascent |
628
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
926 |
|
2321
75a179c343cf
try replacement forn first if nonnil in queries
Claus Gittinger <cg@exept.de>
parents:
2096
diff
changeset
|
927 |
"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
|
928 |
"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
|
929 |
! |
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
930 |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
931 |
descent |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
932 |
"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
|
933 |
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
|
934 |
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
|
935 |
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
|
936 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
937 |
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
|
938 |
self errorNoDevice |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
939 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
940 |
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
|
941 |
^ replacementFont descent |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
942 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
943 |
^ descent |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
944 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
945 |
|
2545 | 946 |
descentOn:aDevice |
7346 | 947 |
"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
|
948 |
|
2545 | 949 |
replacementFont notNil ifTrue:[ |
950 |
^ replacementFont descentOn:aDevice |
|
438 | 951 |
]. |
2545 | 952 |
device == aDevice ifTrue:[ |
953 |
^ descent |
|
954 |
]. |
|
2833 | 955 |
^ (self onDevice:aDevice) descent |
438 | 956 |
|
2545 | 957 |
"Created: / 30.4.1996 / 16:41:43 / cg" |
958 |
"Modified: / 10.9.1998 / 12:09:30 / cg" |
|
438 | 959 |
! |
960 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
961 |
height |
7346 | 962 |
"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
|
963 |
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
|
964 |
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
|
965 |
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
|
966 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
967 |
device isNil ifTrue:[ |
7346 | 968 |
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
|
969 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
970 |
replacementFont notNil ifTrue:[ |
7346 | 971 |
^ 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
|
972 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
973 |
^ descent + ascent. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
974 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
975 |
|
667
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
976 |
heightOf:textOrString |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
977 |
"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
|
978 |
the argument must be a String. |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
979 |
CAVEAT: |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
980 |
currently only constant height fonts are supported." |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
981 |
|
5981 | 982 |
|sum| |
983 |
||
667
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
984 |
device isNil ifTrue:[ |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
985 |
self errorNoDevice. |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
986 |
^ 0 |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
987 |
]. |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
988 |
replacementFont notNil ifTrue:[ |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
989 |
^ replacementFont heightOf:textOrString |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
990 |
]. |
5981 | 991 |
device supportsVariableHeightFonts ifFalse:[ |
992 |
^ descent + ascent |
|
993 |
]. |
|
667
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
994 |
|
5981 | 995 |
(textOrString isString) ifTrue:[ |
996 |
^ device heightOf:textOrString string inFont:fontId |
|
997 |
]. |
|
998 |
(textOrString isCharacter) ifTrue:[ |
|
999 |
^ device heightOf:textOrString asString inFont:fontId |
|
1000 |
]. |
|
1001 |
||
1002 |
sum := 0. |
|
1003 |
textOrString do:[:lineString | |
|
1004 |
lineString isString ifTrue:[ |
|
1005 |
sum := sum + (device heightOf:lineString asString inFont:fontId). |
|
1006 |
] |
|
1007 |
]. |
|
1008 |
^ sum |
|
667
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
1009 |
|
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
1010 |
"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
|
1011 |
! |
091cc1707848
height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
1012 |
|
2545 | 1013 |
heightOf:aString on:aDevice |
1014 |
"return the height of aString, if displayed on aDevice. |
|
1015 |
The argument must be a string-like object." |
|
1016 |
||
1017 |
replacementFont notNil ifTrue:[ |
|
1018 |
^ replacementFont heightOf:aString on:aDevice |
|
1019 |
]. |
|
1020 |
device == aDevice ifTrue:[ |
|
1021 |
^ self heightOf:aString |
|
1022 |
]. |
|
2833 | 1023 |
^ (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
|
1024 |
|
2545 | 1025 |
"Created: / 30.4.1996 / 17:14:18 / cg" |
1026 |
"Modified: / 10.9.1998 / 12:09:47 / cg" |
|
1027 |
! |
|
1028 |
||
1029 |
heightOn:aDevice |
|
7346 | 1030 |
"return the font's height (average), if used on aDevice." |
2545 | 1031 |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1032 |
replacementFont notNil ifTrue:[ |
2545 | 1033 |
^ replacementFont heightOn:aDevice |
1034 |
]. |
|
1035 |
device == aDevice ifTrue:[ |
|
1036 |
^ 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
|
1037 |
]. |
2833 | 1038 |
^ (self onDevice:aDevice) height |
2545 | 1039 |
|
1040 |
"Created: / 30.4.1996 / 16:41:59 / cg" |
|
1041 |
"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
|
1042 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1043 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1044 |
maxAscent |
7346 | 1045 |
"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
|
1046 |
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
|
1047 |
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
|
1048 |
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
|
1049 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1050 |
device isNil ifTrue:[ |
7346 | 1051 |
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
|
1052 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1053 |
replacementFont notNil ifTrue:[ |
7346 | 1054 |
^ 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
|
1055 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1056 |
^ maxAscent |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1057 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1058 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1059 |
maxDescent |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1060 |
"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
|
1061 |
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
|
1062 |
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
|
1063 |
for this query to be legal." |
2 | 1064 |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1065 |
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
|
1066 |
self errorNoDevice |
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 |
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
|
1069 |
^ replacementFont maxDescent |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1070 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1071 |
^ maxDescent |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1072 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1073 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1074 |
maxHeight |
7346 | 1075 |
"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
|
1076 |
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
|
1077 |
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
|
1078 |
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
|
1079 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1080 |
device isNil ifTrue:[ |
7346 | 1081 |
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
|
1082 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1083 |
replacementFont notNil ifTrue:[ |
7346 | 1084 |
^ 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
|
1085 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1086 |
^ maxDescent + maxAscent. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1087 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1088 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1089 |
minWidth |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1090 |
"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
|
1091 |
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
|
1092 |
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
|
1093 |
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
|
1094 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1095 |
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
|
1096 |
self errorNoDevice |
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 |
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
|
1099 |
^ replacementFont minWidth |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1100 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1101 |
^ minWidth |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1102 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1103 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1104 |
width |
7346 | 1105 |
"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
|
1106 |
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
|
1107 |
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
|
1108 |
For fixed fonts, this is the same as minWidth or maxWidth (or any character). |
2545 | 1109 |
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
|
1110 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1111 |
device isNil ifTrue:[ |
628
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
1112 |
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
|
1113 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1114 |
replacementFont notNil ifTrue:[ |
628
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
1115 |
^ 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
|
1116 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1117 |
^ width |
628
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
1118 |
|
4ac28f9d9c7b
added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents:
611
diff
changeset
|
1119 |
"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
|
1120 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1121 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1122 |
widthOf:textOrString |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1123 |
"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
|
1124 |
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
|
1125 |
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
|
1126 |
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
|
1127 |
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
|
1128 |
|
3483 | 1129 |
|this max string| |
2 | 1130 |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1131 |
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
|
1132 |
self errorNoDevice. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1133 |
^ 0 |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1134 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1135 |
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
|
1136 |
^ 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
|
1137 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1138 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1139 |
(textOrString isString) ifTrue:[ |
3483 | 1140 |
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
|
1141 |
isFixedWidth ifFalse:[ |
3483 | 1142 |
^ 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
|
1143 |
]. |
3483 | 1144 |
^ 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
|
1145 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1146 |
(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
|
1147 |
isFixedWidth ifFalse:[ |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1148 |
^ 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
|
1149 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1150 |
^ width |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1151 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1152 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1153 |
max := 0. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1154 |
isFixedWidth ifFalse:[ |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1155 |
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
|
1156 |
line notNil ifTrue:[ |
435
5288c637512e
care for nonStrings when asked for the size
Claus Gittinger <cg@exept.de>
parents:
434
diff
changeset
|
1157 |
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
|
1158 |
(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
|
1159 |
] |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1160 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1161 |
^ max |
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 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1164 |
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
|
1165 |
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
|
1166 |
(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
|
1167 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1168 |
^ max * width |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1169 |
|
1087
1e5a93e03d7f
handle text-argument in withOf:
Claus Gittinger <cg@exept.de>
parents:
1067
diff
changeset
|
1170 |
"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
|
1171 |
! |
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 |
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
|
1174 |
"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
|
1175 |
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
|
1176 |
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
|
1177 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1178 |
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
|
1179 |
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
|
1180 |
^ 0 |
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 |
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
|
1183 |
^ 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
|
1184 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1185 |
(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
|
1186 |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1187 |
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
|
1188 |
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
|
1189 |
^ (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
|
1190 |
]. |
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
|
1191 |
^ 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
|
1192 |
]. |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1193 |
^ (stop - start + 1) * width |
2545 | 1194 |
! |
1195 |
||
1196 |
widthOf:aString from:startIndex to:endIndex on:aDevice |
|
1197 |
"return the width of substring, if displayed on aDevice. |
|
1198 |
The argument may be a Character, String or some Text; |
|
1199 |
in the last case the width of the longest line in the text is returned." |
|
1200 |
||
1201 |
replacementFont notNil ifTrue:[ |
|
1202 |
^ replacementFont widthOf:aString from:startIndex to:endIndex on:aDevice |
|
1203 |
]. |
|
1204 |
device == aDevice ifTrue:[ |
|
1205 |
^ self widthOf:aString from:startIndex to:endIndex |
|
1206 |
]. |
|
2833 | 1207 |
^ (self onDevice:aDevice) widthOf:aString from:startIndex to:endIndex |
2545 | 1208 |
|
1209 |
"Created: / 30.4.1996 / 17:15:20 / cg" |
|
1210 |
"Modified: / 10.9.1998 / 12:10:11 / cg" |
|
1211 |
! |
|
1212 |
||
1213 |
widthOf:aString on:aDevice |
|
1214 |
"return the width of aString, if displayed on aDevice. |
|
1215 |
The argument may be a Character, String or some Text; |
|
1216 |
in the last case the width of the longest line in the text is returned." |
|
1217 |
||
1218 |
replacementFont notNil ifTrue:[ |
|
1219 |
^ replacementFont widthOf:aString on:aDevice |
|
1220 |
]. |
|
1221 |
device == aDevice ifTrue:[ |
|
1222 |
^ self widthOf:aString |
|
1223 |
]. |
|
2833 | 1224 |
^ (self onDevice:aDevice) widthOf:aString |
2545 | 1225 |
|
1226 |
"Created: / 30.4.1996 / 17:14:18 / cg" |
|
1227 |
"Modified: / 10.9.1998 / 12:10:26 / cg" |
|
1228 |
! |
|
1229 |
||
1230 |
widthOn:aDevice |
|
7346 | 1231 |
"return the font's width, if used on aDevice. |
2545 | 1232 |
For variable pitch fonts, the width of the space character is returned. |
1233 |
For fixed fonts, this is the same as minWidth or maxWidth (or any character)." |
|
1234 |
||
1235 |
replacementFont notNil ifTrue:[ |
|
1236 |
^ replacementFont widthOn:aDevice |
|
1237 |
]. |
|
1238 |
device == aDevice ifTrue:[ |
|
1239 |
^ self width |
|
1240 |
]. |
|
2833 | 1241 |
^ (self onDevice:aDevice) width |
2545 | 1242 |
|
1243 |
"Created: / 30.4.1996 / 16:42:28 / cg" |
|
1244 |
"Modified: / 10.9.1998 / 12:11:33 / cg" |
|
2 | 1245 |
! ! |
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1246 |
|
4023 | 1247 |
!Font methodsFor:'queries-misc'! |
1248 |
||
1249 |
direction |
|
1250 |
device isNil ifTrue:[ |
|
1251 |
self errorNoDevice |
|
1252 |
]. |
|
1253 |
replacementFont notNil ifTrue:[ |
|
1254 |
^ replacementFont direction |
|
1255 |
]. |
|
1256 |
^ direction |
|
1257 |
! |
|
1258 |
||
4205 | 1259 |
maxAscii |
1260 |
"squeak compatibility" |
|
1261 |
||
1262 |
^ self maxCode |
|
1263 |
! |
|
1264 |
||
4023 | 1265 |
maxCode |
1266 |
device isNil ifTrue:[ |
|
1267 |
self errorNoDevice |
|
1268 |
]. |
|
1269 |
replacementFont notNil ifTrue:[ |
|
1270 |
^ replacementFont maxCode |
|
1271 |
]. |
|
1272 |
^ maxCode |
|
1273 |
! |
|
1274 |
||
4205 | 1275 |
minAscii |
1276 |
"squeak compatibility" |
|
1277 |
||
1278 |
^ self minCode |
|
1279 |
! |
|
1280 |
||
4023 | 1281 |
minCode |
1282 |
device isNil ifTrue:[ |
|
1283 |
self errorNoDevice |
|
1284 |
]. |
|
1285 |
replacementFont notNil ifTrue:[ |
|
1286 |
^ replacementFont minCode |
|
1287 |
]. |
|
1288 |
^ minCode |
|
1289 |
! ! |
|
1290 |
||
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1291 |
!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
|
1292 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1293 |
fixedWidth |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1294 |
"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
|
1295 |
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
|
1296 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1297 |
^ self isFixedWidth |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1298 |
! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1299 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1300 |
pixelSize |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1301 |
"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
|
1302 |
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
|
1303 |
|
5197 | 1304 |
^ 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
|
1305 |
! ! |
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1306 |
|
6104 | 1307 |
!Font methodsFor:'testing'! |
1308 |
||
1309 |
isAlienFont |
|
1310 |
"answer true, if this is an alien font which does not have a device representation" |
|
1311 |
||
1312 |
^ false |
|
1313 |
! ! |
|
1314 |
||
2433
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1315 |
!Font::DeviceFontHandle class methodsFor:'documentation'! |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1316 |
|
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1317 |
documentation |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1318 |
" |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1319 |
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
|
1320 |
|
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1321 |
[author:] |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1322 |
Stefan Vogel (stefan@nilpferd) |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1323 |
|
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1324 |
[see also:] |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1325 |
Font |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1326 |
|
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1327 |
[instance variables:] |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1328 |
|
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1329 |
[class variables:] |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1330 |
" |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1331 |
! ! |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1332 |
|
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1333 |
!Font::DeviceFontHandle methodsFor:'accessing'! |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1334 |
|
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1335 |
setDevice:aDevice fontId:anId |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1336 |
"set the handles contents" |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1337 |
|
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1338 |
device := aDevice. |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1339 |
fontId := anId. |
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 |
"Created: / 3.2.1999 / 16:08:31 / stefan" |
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 |
|
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1344 |
!Font::DeviceFontHandle methodsFor:'finalization'! |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1345 |
|
3611
8b4384c9e660
Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents:
3527
diff
changeset
|
1346 |
finalize |
2433
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1347 |
"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
|
1348 |
|
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1349 |
|id| |
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 |
(id := fontId) notNil ifTrue:[ |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1352 |
fontId := nil. |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1353 |
device releaseFont:id. |
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 |
|
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1356 |
"Created: / 3.2.1999 / 16:09:25 / stefan" |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1357 |
! ! |
b2d7a24db748
New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
1358 |
|
1087
1e5a93e03d7f
handle text-argument in withOf:
Claus Gittinger <cg@exept.de>
parents:
1067
diff
changeset
|
1359 |
!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
|
1360 |
|
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1361 |
version |
6932 | 1362 |
^ '$Header$' |
5442
218a6ae3e112
changed: #family:face:style:size:sizeUnit:encoding:
Claus Gittinger <cg@exept.de>
parents:
5253
diff
changeset
|
1363 |
! |
218a6ae3e112
changed: #family:face:style:size:sizeUnit:encoding:
Claus Gittinger <cg@exept.de>
parents:
5253
diff
changeset
|
1364 |
|
218a6ae3e112
changed: #family:face:style:size:sizeUnit:encoding:
Claus Gittinger <cg@exept.de>
parents:
5253
diff
changeset
|
1365 |
version_CVS |
6932 | 1366 |
^ '$Header$' |
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1367 |
! ! |
3739
909fefa92b5a
Raise #drawingOnClosedDeviceSignal instead of #error
Stefan Vogel <sv@exept.de>
parents:
3663
diff
changeset
|
1368 |
|
5981 | 1369 |
|
434
d1697f2ff1ec
care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents:
414
diff
changeset
|
1370 |
Font initialize! |