author | Claus Gittinger <cg@exept.de> |
Thu, 23 Jan 1997 16:23:58 +0100 | |
changeset 1265 | c8030e99f941 |
parent 1071 | ae5b36b93cf3 |
child 1266 | be0c5104b056 |
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 |
||
13 |
Object subclass:#FontDescription |
|
1265
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
14 |
instanceVariableNames:'family face style size encoding |
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
15 |
flags masks pixelSize' |
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
16 |
classVariableNames:'BoldnessMask FixedFlag ItalicFlag OutlineFlag SerifFlag |
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
17 |
ShadowFlag StrikeoutFlag UnderlineFlag' |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
18 |
poolDictionaries:'' |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
19 |
category:'Graphics-Support' |
52 | 20 |
! |
21 |
||
1071 | 22 |
!FontDescription class methodsFor:'documentation'! |
52 | 23 |
|
24 |
copyright |
|
25 |
" |
|
26 |
COPYRIGHT (c) 1994 by Claus Gittinger |
|
89 | 27 |
All Rights Reserved |
52 | 28 |
|
29 |
This software is furnished under a license and may be used |
|
30 |
only in accordance with the terms of that license and with the |
|
31 |
inclusion of the above copyright notice. This software may not |
|
32 |
be provided or otherwise made available to, or used by, any |
|
33 |
other person. No title to or ownership of the software is |
|
34 |
hereby transferred. |
|
35 |
" |
|
36 |
! |
|
37 |
||
38 |
documentation |
|
39 |
" |
|
40 |
FontDescription is just a place-holder for scanned font names. |
|
41 |
||
611 | 42 |
[Instance variables:] |
43 |
family <String> the fonts family ('courier', 'helvetica' etc) |
|
44 |
face <String> the fonts face ('bold', 'medium' etc) |
|
45 |
style <String> the fonts style ('roman', 'italic', 'oblique') |
|
46 |
size <String> the fonts size (not in pixels) |
|
47 |
encoding <Symbol> the fonts encoding (usually #iso8859) |
|
48 |
||
1265
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
49 |
manufacturer <nil|String|Array> |
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
50 |
the fonts origin - if known |
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
51 |
name <nil|String|Array> |
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
52 |
the platform specific name |
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
53 |
|
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
54 |
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
|
55 |
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
|
56 |
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
|
57 |
|
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
58 |
[class variables:] |
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
59 |
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
|
60 |
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
|
61 |
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
|
62 |
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
|
63 |
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
|
64 |
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
|
65 |
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
|
66 |
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
|
67 |
|
611 | 68 |
[author:] |
69 |
Claus Gittinger |
|
629 | 70 |
|
71 |
[see also:] |
|
72 |
Font |
|
73 |
FontPanel |
|
74 |
GraphicsContext |
|
75 |
( introduction to view programming :html: programming/viewintro.html#FONTS ) |
|
52 | 76 |
" |
77 |
! ! |
|
78 |
||
1265
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
79 |
!FontDescription class methodsFor:'initialization'! |
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
80 |
|
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
81 |
initialize |
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
82 |
"initialize class variables" |
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
83 |
|
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
84 |
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
|
85 |
FixedFlag := 2r0000001000. |
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
86 |
ItalicFlag := 2r0000010000. |
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
87 |
OutlineFlag := 2r0000100000. |
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
88 |
SerifFlag := 2r0001000000. |
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
89 |
ShadowFlag := 2r0010000000. |
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
90 |
StrikeoutFlag := 2r0100000000. |
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
91 |
UnderlineFlag := 2r1000000000. |
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
92 |
! ! |
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
93 |
|
1071 | 94 |
!FontDescription class methodsFor:'instance creation'! |
52 | 95 |
|
153 | 96 |
family:familyString |
97 |
"returns a font for given family and default (12pt) size |
|
98 |
with unspecified encoding. |
|
629 | 99 |
The new fonts face defaults `medium', its style to `roman'. |
153 | 100 |
The returned font is not associated to a specific device" |
101 |
||
102 |
^ self family:familyString |
|
629 | 103 |
face:'medium' |
104 |
style:'roman' |
|
105 |
size:12 |
|
106 |
encoding:nil |
|
153 | 107 |
|
108 |
" |
|
109 |
Font family:'helvetica' |
|
110 |
Font family:'courier' |
|
111 |
" |
|
629 | 112 |
|
113 |
"Modified: 30.4.1996 / 17:20:44 / cg" |
|
153 | 114 |
! |
115 |
||
109 | 116 |
family:familyString face:faceString size:sizeNum |
117 |
"returns a font for given family and size with unspecified encoding. |
|
629 | 118 |
The new fonts style defaults to `roman'. |
109 | 119 |
The returned font is not associated to a specific device" |
120 |
||
121 |
^ self family:familyString |
|
629 | 122 |
face:faceString |
123 |
style:'roman' |
|
124 |
size:sizeNum |
|
125 |
encoding:nil |
|
109 | 126 |
|
127 |
" |
|
128 |
Font family:'helvetica' face:'medium' size:10 |
|
129 |
Font family:'helvetica' face:'bold' size:10 |
|
130 |
Font family:'courier' face:'bold' size:10 |
|
131 |
" |
|
629 | 132 |
|
133 |
"Modified: 30.4.1996 / 17:21:07 / cg" |
|
109 | 134 |
! |
135 |
||
136 |
family:familyString face:faceString style:styleString size:sizeNum |
|
137 |
"returns a font for given family, face, style and size with |
|
138 |
unspecified encoding. |
|
139 |
The returned font is not associated to a specific device" |
|
140 |
||
141 |
^ self family:familyString |
|
142 |
face:faceString |
|
143 |
style:styleString |
|
144 |
size:sizeNum |
|
145 |
encoding:nil |
|
146 |
||
147 |
" |
|
148 |
Font family:'helvetica' face:'medium' style:'roman' size:10 |
|
149 |
Font family:'helvetica' face:'medium' style:'italic' size:10 |
|
150 |
Font family:'helvetica' face:'bold' style:'roman' size:10 |
|
151 |
Font family:'courier' face:'bold' style:'italic' size:10 |
|
152 |
" |
|
153 |
! |
|
154 |
||
52 | 155 |
family:familyString face:faceString style:styleString size:sizeNum encoding:encodingSym |
576 | 156 |
"returns a font for given family, face, style, size and |
157 |
the specified encoding. |
|
158 |
The returned font is not associated to a specific device" |
|
159 |
||
52 | 160 |
^ self new |
576 | 161 |
family:familyString |
162 |
face:faceString |
|
163 |
style:styleString |
|
164 |
size:sizeNum |
|
165 |
encoding:encodingSym |
|
166 |
||
167 |
"Modified: 20.4.1996 / 23:19:04 / cg" |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
168 |
! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
169 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
170 |
family:familyString size:sizeNum |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
171 |
"returns a font for given family and size with unspecified encoding. |
629 | 172 |
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
|
173 |
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
|
174 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
175 |
^ self family:familyString |
629 | 176 |
face:'medium' |
177 |
style:'roman' |
|
178 |
size:sizeNum |
|
179 |
encoding:nil |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
180 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
181 |
" |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
182 |
Font family:'helvetica' size:10 |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
183 |
Font family:'courier' size:10 |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
184 |
" |
629 | 185 |
|
186 |
"Modified: 30.4.1996 / 17:21:40 / cg" |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
187 |
! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
188 |
|
1071 | 189 |
family:familyString style:aStyle size:sizeNum |
190 |
"returns a font for given family and size with unspecified encoding. |
|
191 |
The new fonts face defaults to `medium', its style to `roman'. |
|
192 |
The returned font is not associated to a specific device" |
|
193 |
||
194 |
^ self family:familyString |
|
195 |
face:'medium' |
|
196 |
style:aStyle |
|
197 |
size:sizeNum |
|
198 |
encoding:nil |
|
199 |
||
200 |
" |
|
201 |
Font family:'helvetica' style:#roman size:48 |
|
202 |
Font family:'courier' style:#roman size:10 |
|
203 |
" |
|
204 |
||
205 |
"Modified: 30.4.1996 / 17:21:40 / cg" |
|
206 |
"Created: 8.10.1996 / 18:33:55 / cg" |
|
207 |
! |
|
208 |
||
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
209 |
name:aFontName |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
210 |
"returns a font with the given explicit name. |
629 | 211 |
WARNING: |
212 |
You shuld not use explicit naming, since font names vary |
|
213 |
with operatingSystems, devices and architecture. |
|
214 |
||
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
215 |
This interface is provided for special purposes only. |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
216 |
On X, the name given should be according the X fontname conventions; |
629 | 217 |
i.e. something like: '-*-times-bold-r-normal-*-*-240-*-*-*-*-iso8859-1'. |
218 |
||
219 |
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
|
220 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
221 |
^ self family:aFontName |
629 | 222 |
face:nil |
223 |
style:nil |
|
224 |
size:nil |
|
225 |
encoding:nil |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
226 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
227 |
" |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
228 |
Font name:'-*-times-bold-r-normal-*-*-240-*-*-*-*-iso8859-1' |
629 | 229 |
Font name:'6x10' |
230 |
Font name:'k14' |
|
231 |
((Font name:'k14') on:Display) encoding |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
232 |
" |
629 | 233 |
|
234 |
"Modified: 30.4.1996 / 17:23:09 / cg" |
|
52 | 235 |
! ! |
236 |
||
237 |
!FontDescription methodsFor:'accessing'! |
|
238 |
||
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
239 |
encoding |
575 | 240 |
"return the fonts encoding, as a symbol |
456 | 241 |
such as #'iso8859', #'jis0208.1983' or #ascii. |
242 |
If the fonts encoding is not known, return nil; |
|
243 |
You should assume ascii-encoding then." |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
244 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
245 |
^ encoding |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
246 |
|
575 | 247 |
"Modified: 20.4.1996 / 23:14:36 / cg" |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
248 |
! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
249 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
250 |
face |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
251 |
"return the face, a string" |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
252 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
253 |
^ face |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
254 |
! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
255 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
256 |
family |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
257 |
"return the family, a string" |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
258 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
259 |
^ family |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
260 |
! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
261 |
|
89 | 262 |
family:familyString face:faceString style:styleString size:sizeNum encoding:encodingString |
576 | 263 |
"set the instance values" |
264 |
||
89 | 265 |
family := familyString asSymbol. |
229
099543e5d779
handle empty family/style/encoding strings
Claus Gittinger <cg@exept.de>
parents:
219
diff
changeset
|
266 |
(faceString notNil and:[faceString notEmpty]) ifTrue:[ |
576 | 267 |
face := faceString asSymbol. |
89 | 268 |
]. |
229
099543e5d779
handle empty family/style/encoding strings
Claus Gittinger <cg@exept.de>
parents:
219
diff
changeset
|
269 |
(styleString notNil and:[styleString notEmpty]) ifTrue:[ |
576 | 270 |
style := styleString asSymbol. |
89 | 271 |
]. |
52 | 272 |
size := sizeNum. |
229
099543e5d779
handle empty family/style/encoding strings
Claus Gittinger <cg@exept.de>
parents:
219
diff
changeset
|
273 |
(encodingString notNil and:[encodingString notEmpty]) ifTrue:[ |
576 | 274 |
encoding := encodingString asSymbol. |
89 | 275 |
] |
229
099543e5d779
handle empty family/style/encoding strings
Claus Gittinger <cg@exept.de>
parents:
219
diff
changeset
|
276 |
|
576 | 277 |
"Modified: 20.4.1996 / 23:19:25 / cg" |
52 | 278 |
! |
279 |
||
280 |
size |
|
281 |
"return the size, a number" |
|
282 |
||
283 |
^ size |
|
284 |
! |
|
285 |
||
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
286 |
style |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
287 |
"return the style, a string" |
109 | 288 |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
289 |
^ style |
109 | 290 |
! ! |
291 |
||
292 |
!FontDescription methodsFor:'comparing'! |
|
293 |
||
294 |
= aFont |
|
295 |
"two fonts are considered equal, if the font-name components are; |
|
296 |
independent of the device, the font is on" |
|
297 |
||
298 |
(aFont species == self species) ifTrue:[ |
|
299 |
(size == aFont size) ifTrue:[ |
|
300 |
(family = aFont family) ifTrue:[ |
|
301 |
(face = aFont face) ifTrue:[ |
|
302 |
(style = aFont style) ifTrue:[ |
|
303 |
(encoding == aFont encoding) ifTrue:[ |
|
304 |
^ true |
|
305 |
] |
|
306 |
] |
|
307 |
] |
|
308 |
] |
|
309 |
] |
|
310 |
]. |
|
311 |
^ false |
|
312 |
! ! |
|
313 |
||
314 |
!FontDescription methodsFor:'converting'! |
|
315 |
||
316 |
asBold |
|
317 |
"return the bold font corresponding to the receiver" |
|
318 |
||
319 |
^ self class |
|
320 |
family:family |
|
321 |
face:'bold' |
|
322 |
style:style |
|
323 |
size:size |
|
324 |
encoding:encoding |
|
325 |
! |
|
326 |
||
327 |
asItalic |
|
328 |
"return the italic font corresponding to the receiver" |
|
329 |
||
330 |
^ self class |
|
331 |
family:family |
|
332 |
face:face |
|
333 |
style:'oblique' |
|
334 |
size:size |
|
335 |
encoding:encoding |
|
336 |
! |
|
337 |
||
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
338 |
on:aDevice |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
339 |
"given the receiver, return a device Font" |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
340 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
341 |
^ (Font |
478
91a8a5889bf2
oops - always returned a bold font
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
342 |
family:family |
91a8a5889bf2
oops - always returned a bold font
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
343 |
face:face |
91a8a5889bf2
oops - always returned a bold font
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
344 |
style:style |
91a8a5889bf2
oops - always returned a bold font
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
345 |
size:size |
91a8a5889bf2
oops - always returned a bold font
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
346 |
encoding:encoding) on:aDevice |
91a8a5889bf2
oops - always returned a bold font
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
347 |
|
91a8a5889bf2
oops - always returned a bold font
Claus Gittinger <cg@exept.de>
parents:
456
diff
changeset
|
348 |
"Modified: 29.2.1996 / 04:45:11 / cg" |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
349 |
! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
350 |
|
109 | 351 |
size:newSize |
352 |
"return a font corresponding to the receiver, but with different size." |
|
353 |
||
354 |
^ self class |
|
355 |
family:family |
|
356 |
face:face |
|
357 |
style:style |
|
358 |
size:newSize |
|
359 |
encoding:encoding |
|
360 |
! ! |
|
361 |
||
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
362 |
!FontDescription methodsFor:'errors'! |
109 | 363 |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
364 |
errorNoDevice |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
365 |
"a query was made for device-specific info" |
109 | 366 |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
367 |
" |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
368 |
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
|
369 |
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
|
370 |
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
|
371 |
associated to a device. |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
372 |
You should always use |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
373 |
font := font on:someDevice |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
374 |
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
|
375 |
" |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
376 |
self error:'query device independent font for for device specific info' |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
377 |
! ! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
378 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
379 |
!FontDescription methodsFor:'queries'! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
380 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
381 |
bold |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
382 |
"return true, if the receiver is a bold font - |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
383 |
for st-80 compatibility" |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
384 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
385 |
^ face = 'bold' |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
386 |
! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
387 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
388 |
boldness |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
389 |
"return the boldness of the characters in this font 0 .. 1 - |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
390 |
for st-80 compatibility" |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
391 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
392 |
style = 'roman' ifTrue:[^ 0.5]. |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
393 |
style = 'normal' ifTrue:[^ 0.5]. |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
394 |
style = 'bold' ifTrue:[^ 0.75]. |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
395 |
style = 'light' ifTrue:[^ 0.25]. |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
396 |
^ 0.5 |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
397 |
! |
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 |
fullName |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
400 |
^ nil |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
401 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
402 |
"Created: 23.2.1996 / 00:45:45 / cg" |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
403 |
! |
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 |
italic |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
406 |
"return true if this is an italic font - |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
407 |
for st-80 compatibility" |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
408 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
409 |
face = 'italic' ifTrue:[^ true]. |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
410 |
face = 'obligue' ifTrue:[^ true]. |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
411 |
^ false |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
412 |
! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
413 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
414 |
serif |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
415 |
"return true, if this font has serifs" |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
416 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
417 |
"this should be done in a better way ..." |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
418 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
419 |
family = 'Times' ifTrue:[^ true]. |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
420 |
family = 'times' ifTrue:[^ true]. |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
421 |
^ false. |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
422 |
! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
423 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
424 |
species |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
425 |
^ Font |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
426 |
! ! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
427 |
|
456 | 428 |
!FontDescription methodsFor:'queries-encoding'! |
429 |
||
430 |
isASCII |
|
576 | 431 |
"return true, if the receivers encoding is |
432 |
compatible with ascii (i.e. its ascii or iso8859)" |
|
433 |
||
456 | 434 |
^ (encoding == #iso8859) or:[encoding == #ascii] |
435 |
||
436 |
"Created: 24.2.1996 / 22:47:30 / cg" |
|
576 | 437 |
"Modified: 20.4.1996 / 23:20:01 / cg" |
456 | 438 |
! |
439 |
||
440 |
isISO8859 |
|
576 | 441 |
"return true, if the receivers encoding is |
442 |
compatible with iso8859 (i.e. iso8859)" |
|
443 |
||
456 | 444 |
^ encoding == #iso8859 |
445 |
||
446 |
"Created: 24.2.1996 / 22:47:12 / cg" |
|
576 | 447 |
"Modified: 20.4.1996 / 23:20:13 / cg" |
456 | 448 |
! |
449 |
||
450 |
isJIS |
|
576 | 451 |
"return true, if the receivers encoding is |
452 |
compatible with jis (i.e. jisXXX)" |
|
453 |
||
456 | 454 |
^ (encoding startsWith:'jis') |
455 |
||
456 |
"Created: 24.2.1996 / 22:47:47 / cg" |
|
576 | 457 |
"Modified: 20.4.1996 / 23:20:30 / cg" |
456 | 458 |
! ! |
459 |
||
1071 | 460 |
!FontDescription class methodsFor:'documentation'! |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
461 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
462 |
version |
1265
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
463 |
^ '$Header: /cvs/stx/stx/libview/FontDescription.st,v 1.15 1997-01-23 15:23:58 cg Exp $' |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
464 |
! ! |