author | Claus Gittinger <cg@exept.de> |
Tue, 22 Aug 2000 15:56:47 +0200 | |
changeset 3265 | 408fac627dc4 |
parent 3254 | 984d6c2f0f79 |
child 3623 | 16665d9b7263 |
permissions | -rw-r--r-- |
52 | 1 |
" |
2 |
COPYRIGHT (c) 1994 by Claus Gittinger |
|
89 | 3 |
All Rights Reserved |
52 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
3246 | 13 |
"{ Package: 'stx:libview' }" |
14 |
||
52 | 15 |
Object subclass:#FontDescription |
1275 | 16 |
instanceVariableNames:'family face style size encoding manufacturer name flags masks |
17 |
pixelSize' |
|
1265
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
18 |
classVariableNames:'BoldnessMask FixedFlag ItalicFlag OutlineFlag SerifFlag |
1275 | 19 |
ShadowFlag StrikeoutFlag UnderlineFlag' |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
20 |
poolDictionaries:'' |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
21 |
category:'Graphics-Support' |
52 | 22 |
! |
23 |
||
1275 | 24 |
!FontDescription class methodsFor:'documentation'! |
52 | 25 |
|
26 |
copyright |
|
27 |
" |
|
28 |
COPYRIGHT (c) 1994 by Claus Gittinger |
|
89 | 29 |
All Rights Reserved |
52 | 30 |
|
31 |
This software is furnished under a license and may be used |
|
32 |
only in accordance with the terms of that license and with the |
|
33 |
inclusion of the above copyright notice. This software may not |
|
34 |
be provided or otherwise made available to, or used by, any |
|
35 |
other person. No title to or ownership of the software is |
|
36 |
hereby transferred. |
|
37 |
" |
|
38 |
! |
|
39 |
||
40 |
documentation |
|
41 |
" |
|
42 |
FontDescription is just a place-holder for scanned font names. |
|
43 |
||
611 | 44 |
[Instance variables:] |
45 |
family <String> the fonts family ('courier', 'helvetica' etc) |
|
46 |
face <String> the fonts face ('bold', 'medium' etc) |
|
47 |
style <String> the fonts style ('roman', 'italic', 'oblique') |
|
48 |
size <String> the fonts size (not in pixels) |
|
49 |
encoding <Symbol> the fonts encoding (usually #iso8859) |
|
50 |
||
1265
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
51 |
manufacturer <nil|String|Array> |
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
52 |
the fonts origin - if known |
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
53 |
name <nil|String|Array> |
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
54 |
the platform specific name |
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
55 |
|
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
56 |
flags <SmallInteger> holds serif/italic etc. as flag bits |
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
57 |
masks <SmallInteger> currently dummy; to allow ST-80 compatible subclassing |
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
58 |
pixelSize <SmallInteger> currently dummy; to allow ST-80 compatible subclassing |
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
59 |
|
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
60 |
[class variables:] |
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
61 |
BoldnessMask currently dummy; to allow ST-80 compatible subclassing |
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
62 |
FixedFlag currently dummy; to allow ST-80 compatible subclassing |
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
63 |
ItalicFlag currently dummy; to allow ST-80 compatible subclassing |
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
64 |
OutlineFlag currently dummy; to allow ST-80 compatible subclassing |
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
65 |
SerifFlag currently dummy; to allow ST-80 compatible subclassing |
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
66 |
ShadowFlag currently dummy; to allow ST-80 compatible subclassing |
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
67 |
StrikeoutFlag currently dummy; to allow ST-80 compatible subclassing |
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
68 |
UnderlineFlag currently dummy; to allow ST-80 compatible subclassing |
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
69 |
|
611 | 70 |
[author:] |
71 |
Claus Gittinger |
|
629 | 72 |
|
73 |
[see also:] |
|
74 |
Font |
|
75 |
FontPanel |
|
76 |
GraphicsContext |
|
77 |
( introduction to view programming :html: programming/viewintro.html#FONTS ) |
|
52 | 78 |
" |
79 |
! ! |
|
80 |
||
1265
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
81 |
!FontDescription class methodsFor:'initialization'! |
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
82 |
|
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
83 |
initialize |
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
84 |
"initialize class variables" |
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
85 |
|
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
86 |
BoldnessMask := 2r0000000111. "/ allows for 8 boldnesses to be encoded |
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
87 |
FixedFlag := 2r0000001000. |
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
88 |
ItalicFlag := 2r0000010000. |
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
89 |
OutlineFlag := 2r0000100000. |
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
90 |
SerifFlag := 2r0001000000. |
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
91 |
ShadowFlag := 2r0010000000. |
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
92 |
StrikeoutFlag := 2r0100000000. |
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
93 |
UnderlineFlag := 2r1000000000. |
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
94 |
! ! |
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
95 |
|
1275 | 96 |
!FontDescription class methodsFor:'instance creation'! |
52 | 97 |
|
153 | 98 |
family:familyString |
99 |
"returns a font for given family and default (12pt) size |
|
100 |
with unspecified encoding. |
|
629 | 101 |
The new fonts face defaults `medium', its style to `roman'. |
153 | 102 |
The returned font is not associated to a specific device" |
103 |
||
104 |
^ self family:familyString |
|
629 | 105 |
face:'medium' |
106 |
style:'roman' |
|
107 |
size:12 |
|
108 |
encoding:nil |
|
153 | 109 |
|
110 |
" |
|
111 |
Font family:'helvetica' |
|
112 |
Font family:'courier' |
|
113 |
" |
|
629 | 114 |
|
115 |
"Modified: 30.4.1996 / 17:20:44 / cg" |
|
153 | 116 |
! |
117 |
||
109 | 118 |
family:familyString face:faceString size:sizeNum |
119 |
"returns a font for given family and size with unspecified encoding. |
|
629 | 120 |
The new fonts style defaults to `roman'. |
109 | 121 |
The returned font is not associated to a specific device" |
122 |
||
123 |
^ self family:familyString |
|
629 | 124 |
face:faceString |
125 |
style:'roman' |
|
126 |
size:sizeNum |
|
127 |
encoding:nil |
|
109 | 128 |
|
129 |
" |
|
130 |
Font family:'helvetica' face:'medium' size:10 |
|
131 |
Font family:'helvetica' face:'bold' size:10 |
|
132 |
Font family:'courier' face:'bold' size:10 |
|
133 |
" |
|
629 | 134 |
|
135 |
"Modified: 30.4.1996 / 17:21:07 / cg" |
|
109 | 136 |
! |
137 |
||
138 |
family:familyString face:faceString style:styleString size:sizeNum |
|
139 |
"returns a font for given family, face, style and size with |
|
140 |
unspecified encoding. |
|
141 |
The returned font is not associated to a specific device" |
|
142 |
||
143 |
^ self family:familyString |
|
144 |
face:faceString |
|
145 |
style:styleString |
|
146 |
size:sizeNum |
|
147 |
encoding:nil |
|
148 |
||
149 |
" |
|
150 |
Font family:'helvetica' face:'medium' style:'roman' size:10 |
|
151 |
Font family:'helvetica' face:'medium' style:'italic' size:10 |
|
152 |
Font family:'helvetica' face:'bold' style:'roman' size:10 |
|
153 |
Font family:'courier' face:'bold' style:'italic' size:10 |
|
154 |
" |
|
155 |
! |
|
156 |
||
52 | 157 |
family:familyString face:faceString style:styleString size:sizeNum encoding:encodingSym |
576 | 158 |
"returns a font for given family, face, style, size and |
159 |
the specified encoding. |
|
160 |
The returned font is not associated to a specific device" |
|
161 |
||
52 | 162 |
^ self new |
576 | 163 |
family:familyString |
164 |
face:faceString |
|
165 |
style:styleString |
|
166 |
size:sizeNum |
|
167 |
encoding:encodingSym |
|
168 |
||
169 |
"Modified: 20.4.1996 / 23:19:04 / cg" |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
170 |
! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
171 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
172 |
family:familyString size:sizeNum |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
173 |
"returns a font for given family and size with unspecified encoding. |
629 | 174 |
The new fonts face defaults to `medium', its style to `roman'. |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
175 |
The returned font is not associated to a specific device" |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
176 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
177 |
^ self family:familyString |
629 | 178 |
face:'medium' |
179 |
style:'roman' |
|
180 |
size:sizeNum |
|
181 |
encoding:nil |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
182 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
183 |
" |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
184 |
Font family:'helvetica' size:10 |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
185 |
Font family:'courier' size:10 |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
186 |
" |
629 | 187 |
|
188 |
"Modified: 30.4.1996 / 17:21:40 / cg" |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
189 |
! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
190 |
|
1071 | 191 |
family:familyString style:aStyle size:sizeNum |
192 |
"returns a font for given family and size with unspecified encoding. |
|
193 |
The new fonts face defaults to `medium', its style to `roman'. |
|
194 |
The returned font is not associated to a specific device" |
|
195 |
||
196 |
^ self family:familyString |
|
197 |
face:'medium' |
|
198 |
style:aStyle |
|
199 |
size:sizeNum |
|
200 |
encoding:nil |
|
201 |
||
202 |
" |
|
203 |
Font family:'helvetica' style:#roman size:48 |
|
204 |
Font family:'courier' style:#roman size:10 |
|
205 |
" |
|
206 |
||
207 |
"Modified: 30.4.1996 / 17:21:40 / cg" |
|
208 |
"Created: 8.10.1996 / 18:33:55 / cg" |
|
209 |
! |
|
210 |
||
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
211 |
name:aFontName |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
212 |
"returns a font with the given explicit name. |
629 | 213 |
WARNING: |
214 |
You shuld not use explicit naming, since font names vary |
|
215 |
with operatingSystems, devices and architecture. |
|
216 |
||
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
217 |
This interface is provided for special purposes only. |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
218 |
On X, the name given should be according the X fontname conventions; |
629 | 219 |
i.e. something like: '-*-times-bold-r-normal-*-*-240-*-*-*-*-iso8859-1'. |
220 |
||
221 |
On other devices, font naming may be completely different." |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
222 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
223 |
^ self family:aFontName |
629 | 224 |
face:nil |
225 |
style:nil |
|
226 |
size:nil |
|
227 |
encoding:nil |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
228 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
229 |
" |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
230 |
Font name:'-*-times-bold-r-normal-*-*-240-*-*-*-*-iso8859-1' |
629 | 231 |
Font name:'6x10' |
232 |
Font name:'k14' |
|
233 |
((Font name:'k14') on:Display) encoding |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
234 |
" |
629 | 235 |
|
236 |
"Modified: 30.4.1996 / 17:23:09 / cg" |
|
52 | 237 |
! ! |
238 |
||
3144 | 239 |
!FontDescription methodsFor:'Compatibility - ST80'! |
1277 | 240 |
|
241 |
boldness:aNumber |
|
242 |
"added for ST-80 compatibility; actually ignored currently" |
|
243 |
||
244 |
|val| |
|
245 |
||
246 |
flags isNil ifTrue:[ |
|
247 |
flags := masks := 0 |
|
248 |
]. |
|
249 |
||
250 |
"/ scale from 0..1 to 0..BoldnessMask |
|
251 |
val := (aNumber max:0.0) min:1.0. |
|
252 |
val := (BoldnessMask * val) rounded. |
|
253 |
||
254 |
flags := flags bitOr:val. |
|
255 |
masks := masks bitOr:BoldnessMask |
|
256 |
||
257 |
"Created: 25.1.1997 / 03:20:05 / cg" |
|
258 |
"Modified: 25.1.1997 / 03:20:47 / cg" |
|
259 |
! |
|
260 |
||
261 |
color:aColor |
|
262 |
"added for ST-80 compatibility; actually ignored currently" |
|
263 |
||
264 |
"Created: 25.1.1997 / 03:21:28 / cg" |
|
265 |
! |
|
266 |
||
1760
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
267 |
encodings:aCollectionOfEncodings |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
268 |
"added for ST-80 compatibility; actually ignored currently" |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
269 |
|
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
270 |
"Created: 20.6.1997 / 09:52:46 / cg" |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
271 |
! |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
272 |
|
1277 | 273 |
fixedWidth:aBoolean |
274 |
"added for ST-80 compatibility; actually ignored currently" |
|
275 |
||
276 |
flags isNil ifTrue:[ |
|
277 |
flags := masks := 0 |
|
278 |
]. |
|
279 |
flags := flags bitOr:FixedFlag. |
|
280 |
masks := masks bitOr:FixedFlag |
|
281 |
||
282 |
"Created: 25.1.1997 / 03:14:06 / cg" |
|
283 |
"Modified: 25.1.1997 / 03:21:03 / cg" |
|
284 |
! |
|
285 |
||
286 |
italic:aBoolean |
|
287 |
"added for ST-80 compatibility; actually ignored currently" |
|
288 |
||
289 |
flags isNil ifTrue:[ |
|
290 |
flags := masks := 0 |
|
291 |
]. |
|
292 |
flags := flags bitOr:ItalicFlag. |
|
293 |
masks := masks bitOr:ItalicFlag |
|
294 |
||
295 |
"Created: 25.1.1997 / 03:15:37 / cg" |
|
296 |
"Modified: 25.1.1997 / 03:20:55 / cg" |
|
297 |
! |
|
298 |
||
1760
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
299 |
outline:aBoolean |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
300 |
"added for ST-80 compatibility; actually ignored currently" |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
301 |
|
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
302 |
flags isNil ifTrue:[ |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
303 |
flags := masks := 0 |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
304 |
]. |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
305 |
flags := flags bitOr:OutlineFlag. |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
306 |
masks := masks bitOr:OutlineFlag |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
307 |
|
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
308 |
"Modified: 25.1.1997 / 03:20:55 / cg" |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
309 |
"Created: 20.6.1997 / 09:50:06 / cg" |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
310 |
! |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
311 |
|
1277 | 312 |
pixelSize:aNumber |
313 |
"added for ST-80 compatibility; actually ignored currently" |
|
314 |
||
315 |
pixelSize := aNumber |
|
316 |
||
317 |
"Modified: 25.1.1997 / 03:20:47 / cg" |
|
318 |
"Created: 25.1.1997 / 03:21:47 / cg" |
|
319 |
! |
|
320 |
||
321 |
serif:aBoolean |
|
322 |
"added for ST-80 compatibility; actually ignored currently" |
|
323 |
||
324 |
flags isNil ifTrue:[ |
|
325 |
flags := masks := 0 |
|
326 |
]. |
|
327 |
flags := flags bitOr:SerifFlag. |
|
328 |
masks := masks bitOr:SerifFlag |
|
329 |
||
330 |
"Created: 25.1.1997 / 03:15:17 / cg" |
|
331 |
"Modified: 25.1.1997 / 03:20:59 / cg" |
|
1760
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
332 |
! |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
333 |
|
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
334 |
shadow:aBoolean |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
335 |
"added for ST-80 compatibility; actually ignored currently" |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
336 |
|
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
337 |
flags isNil ifTrue:[ |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
338 |
flags := masks := 0 |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
339 |
]. |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
340 |
flags := flags bitOr:ShadowFlag. |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
341 |
masks := masks bitOr:ShadowFlag |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
342 |
|
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
343 |
"Modified: 25.1.1997 / 03:20:55 / cg" |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
344 |
"Created: 20.6.1997 / 09:51:03 / cg" |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
345 |
! |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
346 |
|
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
347 |
strikeout:aBoolean |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
348 |
"added for ST-80 compatibility; actually ignored currently" |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
349 |
|
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
350 |
flags isNil ifTrue:[ |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
351 |
flags := masks := 0 |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
352 |
]. |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
353 |
flags := flags bitOr:StrikeoutFlag. |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
354 |
masks := masks bitOr:StrikeoutFlag |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
355 |
|
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
356 |
"Modified: 25.1.1997 / 03:20:55 / cg" |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
357 |
"Created: 20.6.1997 / 09:51:36 / cg" |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
358 |
! |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
359 |
|
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
360 |
underline:aBoolean |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
361 |
"added for ST-80 compatibility; actually ignored currently" |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
362 |
|
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
363 |
flags isNil ifTrue:[ |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
364 |
flags := masks := 0 |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
365 |
]. |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
366 |
flags := flags bitOr:UnderlineFlag. |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
367 |
masks := masks bitOr:UnderlineFlag |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
368 |
|
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
369 |
"Modified: 25.1.1997 / 03:20:55 / cg" |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
370 |
"Created: 20.6.1997 / 09:51:18 / cg" |
1277 | 371 |
! ! |
372 |
||
52 | 373 |
!FontDescription methodsFor:'accessing'! |
374 |
||
2544 | 375 |
device |
376 |
"return the device I am on" |
|
377 |
||
378 |
^ nil |
|
379 |
||
380 |
||
381 |
! |
|
382 |
||
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
383 |
encoding |
575 | 384 |
"return the fonts encoding, as a symbol |
456 | 385 |
such as #'iso8859', #'jis0208.1983' or #ascii. |
386 |
If the fonts encoding is not known, return nil; |
|
387 |
You should assume ascii-encoding then." |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
388 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
389 |
^ encoding |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
390 |
|
575 | 391 |
"Modified: 20.4.1996 / 23:14:36 / cg" |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
392 |
! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
393 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
394 |
face |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
395 |
"return the face, a string" |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
396 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
397 |
^ face |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
398 |
! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
399 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
400 |
family |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
401 |
"return the family, a string" |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
402 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
403 |
^ family |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
404 |
! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
405 |
|
1277 | 406 |
family:aString |
407 |
"set the family, a string" |
|
408 |
||
409 |
family := aString |
|
410 |
||
411 |
"Created: 25.1.1997 / 03:12:12 / cg" |
|
412 |
! |
|
413 |
||
89 | 414 |
family:familyString face:faceString style:styleString size:sizeNum encoding:encodingString |
576 | 415 |
"set the instance values" |
416 |
||
89 | 417 |
family := familyString asSymbol. |
229
099543e5d779
handle empty family/style/encoding strings
Claus Gittinger <cg@exept.de>
parents:
219
diff
changeset
|
418 |
(faceString notNil and:[faceString notEmpty]) ifTrue:[ |
576 | 419 |
face := faceString asSymbol. |
89 | 420 |
]. |
229
099543e5d779
handle empty family/style/encoding strings
Claus Gittinger <cg@exept.de>
parents:
219
diff
changeset
|
421 |
(styleString notNil and:[styleString notEmpty]) ifTrue:[ |
576 | 422 |
style := styleString asSymbol. |
89 | 423 |
]. |
52 | 424 |
size := sizeNum. |
229
099543e5d779
handle empty family/style/encoding strings
Claus Gittinger <cg@exept.de>
parents:
219
diff
changeset
|
425 |
(encodingString notNil and:[encodingString notEmpty]) ifTrue:[ |
576 | 426 |
encoding := encodingString asSymbol. |
89 | 427 |
] |
229
099543e5d779
handle empty family/style/encoding strings
Claus Gittinger <cg@exept.de>
parents:
219
diff
changeset
|
428 |
|
576 | 429 |
"Modified: 20.4.1996 / 23:19:25 / cg" |
52 | 430 |
! |
431 |
||
2544 | 432 |
fontId |
433 |
"return the device-dependent font-id" |
|
434 |
||
435 |
^ nil |
|
436 |
||
437 |
||
438 |
! |
|
439 |
||
1277 | 440 |
manufacturer |
441 |
"return the value of the instance variable 'manufacturer' (automatically generated)" |
|
442 |
||
443 |
^ manufacturer |
|
444 |
||
445 |
"Created: 25.1.1997 / 03:12:43 / cg" |
|
446 |
! |
|
447 |
||
448 |
manufacturer:something |
|
449 |
"set the value of the instance variable 'manufacturer' (automatically generated)" |
|
450 |
||
451 |
manufacturer := something. |
|
452 |
||
453 |
"Created: 25.1.1997 / 03:12:43 / cg" |
|
454 |
! |
|
455 |
||
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
456 |
style |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
457 |
"return the style, a string" |
109 | 458 |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
459 |
^ style |
109 | 460 |
! ! |
461 |
||
462 |
!FontDescription methodsFor:'comparing'! |
|
463 |
||
464 |
= aFont |
|
465 |
"two fonts are considered equal, if the font-name components are; |
|
466 |
independent of the device, the font is on" |
|
467 |
||
468 |
(aFont species == self species) ifTrue:[ |
|
469 |
(size == aFont size) ifTrue:[ |
|
470 |
(family = aFont family) ifTrue:[ |
|
471 |
(face = aFont face) ifTrue:[ |
|
472 |
(style = aFont style) ifTrue:[ |
|
473 |
(encoding == aFont encoding) ifTrue:[ |
|
474 |
^ true |
|
475 |
] |
|
476 |
] |
|
477 |
] |
|
478 |
] |
|
479 |
] |
|
480 |
]. |
|
481 |
^ false |
|
2160 | 482 |
! |
483 |
||
484 |
hash |
|
485 |
"return a number for hashing - req'd since = is redefined." |
|
486 |
||
2771
25c96682a2f3
really avoid LargeInteger arithmetic
Claus Gittinger <cg@exept.de>
parents:
2770
diff
changeset
|
487 |
^ ( (family hash bitAnd:16r1FFFFFFF) |
25c96682a2f3
really avoid LargeInteger arithmetic
Claus Gittinger <cg@exept.de>
parents:
2770
diff
changeset
|
488 |
+ (face hash bitAnd:16r1FFFFFFF) |
25c96682a2f3
really avoid LargeInteger arithmetic
Claus Gittinger <cg@exept.de>
parents:
2770
diff
changeset
|
489 |
+ (style hash bitAnd:16r1FFFFFFF) |
3019
6dc6821c111c
oops - care for fractional size in #hash
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
490 |
+ (size ? 0) asInteger) bitAnd:16r3FFFFFFF |
2160 | 491 |
|
492 |
"Created: / 19.6.1998 / 04:19:06 / cg" |
|
2164 | 493 |
"Modified: / 20.6.1998 / 17:04:00 / cg" |
109 | 494 |
! ! |
495 |
||
496 |
!FontDescription methodsFor:'converting'! |
|
497 |
||
498 |
asBold |
|
499 |
"return the bold font corresponding to the receiver" |
|
500 |
||
3254
984d6c2f0f79
asBold: care if not boldifyanle
Claus Gittinger <cg@exept.de>
parents:
3246
diff
changeset
|
501 |
family isNil ifTrue:[ |
984d6c2f0f79
asBold: care if not boldifyanle
Claus Gittinger <cg@exept.de>
parents:
3246
diff
changeset
|
502 |
^ self |
984d6c2f0f79
asBold: care if not boldifyanle
Claus Gittinger <cg@exept.de>
parents:
3246
diff
changeset
|
503 |
]. |
109 | 504 |
^ self class |
3254
984d6c2f0f79
asBold: care if not boldifyanle
Claus Gittinger <cg@exept.de>
parents:
3246
diff
changeset
|
505 |
family:family |
984d6c2f0f79
asBold: care if not boldifyanle
Claus Gittinger <cg@exept.de>
parents:
3246
diff
changeset
|
506 |
face:'bold' |
984d6c2f0f79
asBold: care if not boldifyanle
Claus Gittinger <cg@exept.de>
parents:
3246
diff
changeset
|
507 |
style:style |
984d6c2f0f79
asBold: care if not boldifyanle
Claus Gittinger <cg@exept.de>
parents:
3246
diff
changeset
|
508 |
size:size |
984d6c2f0f79
asBold: care if not boldifyanle
Claus Gittinger <cg@exept.de>
parents:
3246
diff
changeset
|
509 |
encoding:encoding |
109 | 510 |
! |
511 |
||
512 |
asItalic |
|
513 |
"return the italic font corresponding to the receiver" |
|
514 |
||
515 |
^ self class |
|
516 |
family:family |
|
517 |
face:face |
|
518 |
style:'oblique' |
|
519 |
size:size |
|
520 |
encoding:encoding |
|
521 |
! |
|
522 |
||
1740 | 523 |
fromLiteralArrayEncoding:encoding |
2436 | 524 |
"read my contents from a aLiteralEncodedArray. |
525 |
Must match to what is generated in #literalArrayEncoding" |
|
1740 | 526 |
|
527 |
family := encoding at:2. |
|
528 |
face := encoding at:3. |
|
529 |
style := encoding at:4. |
|
530 |
size := encoding at:5. |
|
531 |
! |
|
532 |
||
533 |
literalArrayEncoding |
|
2436 | 534 |
"return myself encoded as a literal array. |
535 |
Must match to what is expected in #fromLiteralArrayEncoding:" |
|
1740 | 536 |
|
537 |
^ Array |
|
538 |
with:self class name asSymbol |
|
539 |
with:family |
|
540 |
with:face |
|
541 |
with:style |
|
542 |
with:size |
|
543 |
! |
|
544 |
||
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
545 |
on:aDevice |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
546 |
"given the receiver, return a device Font" |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
547 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
548 |
^ (Font |
478
91a8a5889bf2
oops - always returned a bold font
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
549 |
family:family |
91a8a5889bf2
oops - always returned a bold font
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
550 |
face:face |
91a8a5889bf2
oops - always returned a bold font
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
551 |
style:style |
91a8a5889bf2
oops - always returned a bold font
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
552 |
size:size |
91a8a5889bf2
oops - always returned a bold font
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
553 |
encoding:encoding) on:aDevice |
91a8a5889bf2
oops - always returned a bold font
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
554 |
|
91a8a5889bf2
oops - always returned a bold font
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
555 |
"Modified: 29.2.1996 / 04:45:11 / cg" |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
556 |
! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
557 |
|
1497
697ac9b15962
added #onDevice: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
1277
diff
changeset
|
558 |
onDevice:aDevice |
697ac9b15962
added #onDevice: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
1277
diff
changeset
|
559 |
"given the receiver, return a device Font" |
697ac9b15962
added #onDevice: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
1277
diff
changeset
|
560 |
|
2980
409e9547a45c
ignore nil device in #onDevice:
Claus Gittinger <cg@exept.de>
parents:
2934
diff
changeset
|
561 |
aDevice isNil ifTrue:[^ self]. |
1497
697ac9b15962
added #onDevice: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
1277
diff
changeset
|
562 |
^ self on:aDevice |
697ac9b15962
added #onDevice: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
1277
diff
changeset
|
563 |
|
697ac9b15962
added #onDevice: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
1277
diff
changeset
|
564 |
"Created: 28.3.1997 / 16:09:30 / cg" |
697ac9b15962
added #onDevice: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
1277
diff
changeset
|
565 |
! |
697ac9b15962
added #onDevice: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
1277
diff
changeset
|
566 |
|
109 | 567 |
size:newSize |
568 |
"return a font corresponding to the receiver, but with different size." |
|
569 |
||
570 |
^ self class |
|
571 |
family:family |
|
572 |
face:face |
|
573 |
style:style |
|
574 |
size:newSize |
|
575 |
encoding:encoding |
|
576 |
! ! |
|
577 |
||
2544 | 578 |
!FontDescription methodsFor:'displaying'! |
579 |
||
580 |
displayOpaqueString:aString from:index1 to:index2 x:x y:y in:aGC |
|
581 |
"display a partial string at some position in aGC." |
|
582 |
||
583 |
self subclassResponsibility |
|
584 |
||
585 |
! |
|
586 |
||
587 |
displayOpaqueString:aString x:x y:y in:aGC |
|
588 |
"display a string at some position in aGC." |
|
589 |
||
590 |
self displayOpaqueString:aString from:1 to:aString size x:x y:y in:aGC |
|
591 |
! |
|
592 |
||
593 |
displayString:aString from:index1 to:index2 x:x y:y in:aGC |
|
594 |
"display a partial string at some position in aGC." |
|
595 |
||
596 |
self subclassResponsibility |
|
597 |
||
598 |
! |
|
599 |
||
600 |
displayString:aString x:x y:y in:aGC |
|
601 |
"display a string at some position in aGC." |
|
602 |
||
603 |
self displayString:aString from:1 to:aString size x:x y:y in:aGC |
|
604 |
||
605 |
! ! |
|
606 |
||
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
607 |
!FontDescription methodsFor:'errors'! |
109 | 608 |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
609 |
errorNoDevice |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
610 |
"a query was made for device-specific info" |
109 | 611 |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
612 |
" |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
613 |
this happens, when you ask a font for its height or width, |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
614 |
ascent or any other dimension which depends on the device on |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
615 |
which the font is rendered, AND the receiver font is not (yet) |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
616 |
associated to a device. |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
617 |
You should always use |
3159 | 618 |
font := font on:someDevice |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
619 |
to get a device font, before asking for device specifics. |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
620 |
" |
3159 | 621 |
self error:'query device independent font for device specific info' |
622 |
||
623 |
"Modified: / 27.1.2000 / 16:55:05 / stefan" |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
624 |
! ! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
625 |
|
1618 | 626 |
!FontDescription methodsFor:'printing & storing'! |
627 |
||
628 |
userFriendlyName |
|
629 |
"return a user-friendly printed representation of the receiver" |
|
630 |
||
631 |
|nm| |
|
632 |
||
633 |
nm := family. |
|
634 |
face notNil ifTrue:[ |
|
635 |
nm := nm , '-', face. |
|
636 |
]. |
|
637 |
style notNil ifTrue:[ |
|
638 |
nm := nm , '-', style. |
|
639 |
]. |
|
640 |
size notNil ifTrue:[ |
|
641 |
nm := nm , '-', size printString. |
|
642 |
]. |
|
643 |
encoding notNil ifTrue:[ |
|
644 |
nm := nm , '-', encoding . |
|
645 |
]. |
|
646 |
^ nm |
|
647 |
||
648 |
" |
|
649 |
View defaultFont userFriendlyName |
|
650 |
Button defaultFont userFriendlyName |
|
651 |
" |
|
652 |
||
653 |
"Modified: 20.4.1996 / 23:25:36 / cg" |
|
654 |
"Created: 19.4.1997 / 18:09:25 / cg" |
|
655 |
! ! |
|
656 |
||
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
657 |
!FontDescription methodsFor:'queries'! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
658 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
659 |
bold |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
660 |
"return true, if the receiver is a bold font - |
1585 | 661 |
Added for st-80 compatibility." |
662 |
||
663 |
"/ Currently, this implementation is a dirty hack and will be changed soon. |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
664 |
|
1275 | 665 |
^ face = 'bold' |
666 |
||
1585 | 667 |
"Modified: 11.4.1997 / 21:31:25 / cg" |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
668 |
! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
669 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
670 |
boldness |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
671 |
"return the boldness of the characters in this font 0 .. 1 - |
1275 | 672 |
Added for st-80 compatibility" |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
673 |
|
1585 | 674 |
"/ Currently, this implementation is a dirty hack and will be changed soon. |
675 |
||
676 |
face = 'roman' ifTrue:[^ 0.5]. |
|
677 |
face = 'normal' ifTrue:[^ 0.5]. |
|
678 |
face = 'bold' ifTrue:[^ 0.75]. |
|
679 |
face = 'light' ifTrue:[^ 0.25]. |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
680 |
^ 0.5 |
1275 | 681 |
|
1585 | 682 |
"Modified: 11.4.1997 / 21:31:31 / cg" |
1275 | 683 |
! |
684 |
||
685 |
color |
|
686 |
"return the default color in which this font is to be rendered. |
|
687 |
Added for st-80 compatibility. |
|
688 |
For now always black." |
|
689 |
||
690 |
^ Color black |
|
691 |
||
692 |
"Created: 25.1.1997 / 02:59:15 / cg" |
|
693 |
"Modified: 25.1.1997 / 03:02:14 / cg" |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
694 |
! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
695 |
|
2544 | 696 |
existsOn:aDevice |
697 |
"return true, if the recevier is available on aDevice; |
|
698 |
false otherwise. This is a kludge method; its better to |
|
699 |
ask a device for its available fonts and use this info ... |
|
700 |
Notice, that if you simply use a font by name, the system |
|
701 |
will automatically take a replacement font." |
|
702 |
||
703 |
^ (self on:aDevice ifAbsent:nil) notNil |
|
704 |
! |
|
705 |
||
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
706 |
fullName |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
707 |
^ nil |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
708 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
709 |
"Created: 23.2.1996 / 00:45:45 / cg" |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
710 |
! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
711 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
712 |
italic |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
713 |
"return true if this is an italic font - |
1585 | 714 |
Added for st-80 compatibility" |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
715 |
|
1585 | 716 |
"/ Currently, this implementation is a dirty hack and will be changed soon. |
717 |
||
718 |
style = 'italic' ifTrue:[^ true]. |
|
3246 | 719 |
style = 'oblique' ifTrue:[^ true]. |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
720 |
^ false |
1275 | 721 |
|
1585 | 722 |
"Modified: 11.4.1997 / 21:31:42 / cg" |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
723 |
! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
724 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
725 |
serif |
1275 | 726 |
"return true, if this font has serifs. |
1585 | 727 |
Added for st-80 compatibility" |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
728 |
|
1585 | 729 |
"/ Currently, this implementation is a dirty hack and will be changed soon. |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
730 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
731 |
family = 'Times' ifTrue:[^ true]. |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
732 |
family = 'times' ifTrue:[^ true]. |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
733 |
^ false. |
1275 | 734 |
|
1585 | 735 |
"Modified: 11.4.1997 / 21:31:51 / cg" |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
736 |
! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
737 |
|
3265 | 738 |
size |
739 |
"return the size, a number" |
|
740 |
||
741 |
^ size |
|
742 |
! |
|
743 |
||
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
744 |
species |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
745 |
^ Font |
1275 | 746 |
! |
747 |
||
748 |
underline |
|
749 |
"return true if this is an underlined font - |
|
750 |
Added for st-80 compatibility |
|
751 |
(always false here)" |
|
752 |
||
753 |
^ false |
|
754 |
||
755 |
"Created: 25.1.1997 / 02:58:30 / cg" |
|
756 |
"Modified: 25.1.1997 / 03:01:12 / cg" |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
757 |
! ! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
758 |
|
2544 | 759 |
!FontDescription methodsFor:'queries-dimensions'! |
760 |
||
761 |
ascent |
|
762 |
"return the ascent - the number of pixels above the baseLine." |
|
763 |
||
764 |
^ self subclassResponsibility |
|
765 |
! |
|
766 |
||
767 |
ascentOn:aDevice |
|
768 |
"return the ascent - the number of pixels above the baseLine." |
|
769 |
||
770 |
^ (self onDevice:aDevice) ascent |
|
771 |
! |
|
772 |
||
773 |
descent |
|
774 |
"return the descent - the number of pixels below the baseLine." |
|
775 |
||
776 |
^ self subclassResponsibility |
|
777 |
! |
|
778 |
||
779 |
descentOn:aDevice |
|
780 |
"return the ascent - the number of pixels above the baseLine." |
|
781 |
||
782 |
^ (self onDevice:aDevice) descent |
|
783 |
||
784 |
||
785 |
! |
|
786 |
||
787 |
height |
|
788 |
"return the height - the number of pixels above plus below the baseLine." |
|
789 |
||
790 |
^ self subclassResponsibility |
|
791 |
! |
|
792 |
||
793 |
heightOf:aString |
|
794 |
"return the height of the given string. |
|
795 |
Here, assume the characters are of constant height" |
|
796 |
||
797 |
^ self height |
|
798 |
! |
|
799 |
||
800 |
heightOf:aString on:aDevice |
|
801 |
"return the height of the given string on the given device." |
|
802 |
||
803 |
^ (self onDevice:aDevice) heightOf:aString |
|
804 |
! |
|
805 |
||
806 |
heightOn:aDevice |
|
807 |
"return the height - the number of pixels above PLUS below the baseLine." |
|
808 |
||
809 |
^ (self onDevice:aDevice) height |
|
810 |
! |
|
811 |
||
812 |
isFixedWidth |
|
813 |
"return true, if this is a fixed pitch font (i.e. all characters |
|
814 |
are of the same width)" |
|
815 |
||
816 |
self subclassResponsibility |
|
817 |
! |
|
818 |
||
819 |
maxAscent |
|
820 |
"return the fonts maximum-ascent (i.e. the maximum of all characters); |
|
821 |
That is the number of units (usually pixels) above the baseline." |
|
822 |
||
823 |
^ self subclassResponsibility |
|
824 |
||
825 |
! |
|
826 |
||
827 |
maxDescent |
|
828 |
"return the fonts maximum-descent (i.e. the maximum of all characters); |
|
829 |
That is the number of units (usually pixels) below the baseline." |
|
830 |
||
831 |
^ self subclassResponsibility |
|
832 |
||
833 |
! |
|
834 |
||
835 |
maxHeight |
|
836 |
"return the fonts characters maximum height; |
|
837 |
That is the number of units (usually pixels)." |
|
838 |
||
839 |
^ self maxAscent + self maxDescent |
|
840 |
||
841 |
! |
|
842 |
||
843 |
maxWidth |
|
844 |
"return the fonts maximum-width character (i.e. the maximum of all characters); |
|
845 |
That is a number of units (usually pixels)." |
|
846 |
||
847 |
^ self subclassResponsibility |
|
848 |
||
849 |
! |
|
850 |
||
851 |
width |
|
852 |
"return the fonts characters width; |
|
853 |
That is a number of units (usually pixels). |
|
854 |
For variable pitch fonts, the width of the space character is returned. |
|
855 |
For fixed fonts, this is the same as minWidth or maxWidth (or any character). |
|
856 |
The receiver must be associated to a device, for this query to be legal." |
|
857 |
||
858 |
^ self widthOf:' ' |
|
859 |
||
860 |
"Modified: 30.4.1996 / 16:43:45 / cg" |
|
861 |
||
862 |
||
863 |
! |
|
864 |
||
865 |
widthOf:aString |
|
866 |
"return the width of a string" |
|
867 |
||
868 |
^ self widthOf:aString from:1 to:aString size |
|
869 |
||
870 |
||
871 |
! |
|
872 |
||
873 |
widthOf:aString from:start to:stop |
|
874 |
"return the width of a sub string" |
|
875 |
||
876 |
^ self subclassResponsibility |
|
877 |
||
878 |
||
879 |
! |
|
880 |
||
881 |
widthOf:aString from:start to:stop on:aDevice |
|
882 |
"return the width of a sub string. |
|
883 |
Here, assume that this fonts width is device independent." |
|
884 |
||
885 |
^ (self onDevice:aDevice) widthOf:aString from:start to:stop |
|
886 |
||
887 |
||
888 |
! |
|
889 |
||
890 |
widthOf:aString on:aDevice |
|
891 |
"return the width of a string" |
|
892 |
||
893 |
^ (self onDevice:aDevice) widthOf:aString |
|
894 |
||
895 |
||
896 |
||
897 |
||
898 |
||
899 |
! |
|
900 |
||
901 |
widthOn:aDevice |
|
902 |
"return the width on some device; that is the width of the space character |
|
903 |
(which is the width of any character iff the font is a fixed pitch font)" |
|
904 |
||
905 |
^ (self onDevice:aDevice) width |
|
906 |
! ! |
|
907 |
||
456 | 908 |
!FontDescription methodsFor:'queries-encoding'! |
909 |
||
910 |
isASCII |
|
576 | 911 |
"return true, if the receivers encoding is |
912 |
compatible with ascii (i.e. its ascii or iso8859)" |
|
913 |
||
456 | 914 |
^ (encoding == #iso8859) or:[encoding == #ascii] |
915 |
||
916 |
"Created: 24.2.1996 / 22:47:30 / cg" |
|
576 | 917 |
"Modified: 20.4.1996 / 23:20:01 / cg" |
456 | 918 |
! |
919 |
||
920 |
isISO8859 |
|
576 | 921 |
"return true, if the receivers encoding is |
922 |
compatible with iso8859 (i.e. iso8859)" |
|
923 |
||
456 | 924 |
^ encoding == #iso8859 |
925 |
||
926 |
"Created: 24.2.1996 / 22:47:12 / cg" |
|
576 | 927 |
"Modified: 20.4.1996 / 23:20:13 / cg" |
456 | 928 |
! |
929 |
||
930 |
isJIS |
|
576 | 931 |
"return true, if the receivers encoding is |
932 |
compatible with jis (i.e. jisXXX)" |
|
933 |
||
456 | 934 |
^ (encoding startsWith:'jis') |
935 |
||
936 |
"Created: 24.2.1996 / 22:47:47 / cg" |
|
576 | 937 |
"Modified: 20.4.1996 / 23:20:30 / cg" |
456 | 938 |
! ! |
939 |
||
1275 | 940 |
!FontDescription class methodsFor:'documentation'! |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
941 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
942 |
version |
3265 | 943 |
^ '$Header: /cvs/stx/stx/libview/FontDescription.st,v 1.38 2000-08-22 13:56:47 cg Exp $' |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
944 |
! ! |
1275 | 945 |
FontDescription initialize! |