author | Claus Gittinger <cg@exept.de> |
Tue, 17 Feb 2009 19:16:21 +0100 | |
changeset 5169 | ad531e713603 |
parent 5166 | a9cd84083df5 |
child 5185 | c807ae478014 |
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 |
" |
|
3246 | 12 |
"{ Package: 'stx:libview' }" |
13 |
||
52 | 14 |
Object subclass:#FontDescription |
1275 | 15 |
instanceVariableNames:'family face style size encoding manufacturer name flags masks |
16 |
pixelSize' |
|
1265
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
17 |
classVariableNames:'BoldnessMask FixedFlag ItalicFlag OutlineFlag SerifFlag |
3987 | 18 |
ShadowFlag StrikeoutFlag UnderlineFlag CharacterSetToFontMapping |
19 |
CharacterEncodingToCharacterSetMapping' |
|
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) |
|
3991 | 49 |
encoding <Symbol> the fonts encoding (usually #iso8859-1) |
611 | 50 |
|
3991 | 51 |
manufacturer <nil|String|Array> |
52 |
the fonts origin - if known |
|
53 |
name <nil|String|Array> |
|
54 |
the platform specific name |
|
1265
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
55 |
|
3991 | 56 |
flags <SmallInteger> holds serif/italic etc. as flag bits |
57 |
masks <SmallInteger> currently dummy; to allow ST-80 compatible subclassing |
|
58 |
pixelSize <SmallInteger> currently dummy; to allow ST-80 compatible subclassing |
|
1265
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:] |
3991 | 61 |
BoldnessMask currently dummy; to allow ST-80 compatible subclassing |
62 |
FixedFlag currently dummy; to allow ST-80 compatible subclassing |
|
63 |
ItalicFlag currently dummy; to allow ST-80 compatible subclassing |
|
64 |
OutlineFlag currently dummy; to allow ST-80 compatible subclassing |
|
65 |
SerifFlag currently dummy; to allow ST-80 compatible subclassing |
|
66 |
ShadowFlag currently dummy; to allow ST-80 compatible subclassing |
|
67 |
StrikeoutFlag currently dummy; to allow ST-80 compatible subclassing |
|
68 |
UnderlineFlag currently dummy; to allow ST-80 compatible subclassing |
|
1265
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 |
|
3827
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
86 |
BoldnessMask := 2r0000000111. "/ allows for 8 boldnesses to be encoded |
1265
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. |
3827
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
94 |
|
3987 | 95 |
self initializeCharacterEncodingToCharacterSetMapping. |
3827
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
96 |
self initializeCharacterSetToFontMapping. |
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
97 |
! |
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
98 |
|
3987 | 99 |
initializeCharacterEncodingToCharacterSetMapping |
100 |
"character encoding" |
|
101 |
||
102 |
CharacterEncodingToCharacterSetMapping isNil ifTrue:[ |
|
103 |
CharacterEncodingToCharacterSetMapping := Dictionary new |
|
104 |
]. |
|
105 |
||
106 |
#( |
|
107 |
'utf7' 'unicode' |
|
4011 | 108 |
'utf-7' 'unicode' |
3987 | 109 |
'utf8' 'unicode' |
4011 | 110 |
'utf-8' 'unicode' |
3987 | 111 |
) pairWiseDo:[:encoding :fontEncoding| |
112 |
CharacterEncodingToCharacterSetMapping at:encoding put:fontEncoding |
|
113 |
]. |
|
114 |
! |
|
115 |
||
3827
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
116 |
initializeCharacterSetToFontMapping |
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
117 |
"character sets" |
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
118 |
|
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
119 |
CharacterSetToFontMapping isNil ifTrue:[ |
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
120 |
CharacterSetToFontMapping := Dictionary new |
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
121 |
]. |
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
122 |
|
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
123 |
#( |
3987 | 124 |
'unicode' 'iso10646-*' |
125 |
||
126 |
'koi8-r' 'iso8859-5' |
|
127 |
||
3827
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
128 |
'iso2022-jp' 'jis*0208*' |
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
129 |
'x-iso2022-jp' 'jis*0208*' |
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
130 |
'x-euc-jp' 'jis*0208*' |
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
131 |
'x-shift-jis' 'jis*0208*' |
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
132 |
'x-sjis' 'jis*0208*' |
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
133 |
'x-jis7' 'jis*0208*' |
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
134 |
'jis7' 'jis*0208*' |
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
135 |
'euc' 'jis*0208*' |
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
136 |
'euc-jp' 'jis*0208*' |
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
137 |
'sjis' 'jis*0208*' |
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
138 |
|
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
139 |
'big5' 'big5*' |
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
140 |
|
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
141 |
'gb2312' 'gb*' |
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
142 |
'hz-gb-2312' 'gb*' |
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
143 |
'x-gbk' 'gb*' |
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
144 |
|
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
145 |
'iso2022-kr' 'ksc*' |
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
146 |
'x-euc-kr' 'ksc*' |
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
147 |
) pairWiseDo:[:charSet :fontEncoding| |
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
148 |
CharacterSetToFontMapping at:charSet put:fontEncoding |
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
149 |
]. |
1265
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
150 |
! ! |
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
151 |
|
1275 | 152 |
!FontDescription class methodsFor:'instance creation'! |
52 | 153 |
|
153 | 154 |
family:familyString |
155 |
"returns a font for given family and default (12pt) size |
|
3996 | 156 |
with default encoding. |
629 | 157 |
The new fonts face defaults `medium', its style to `roman'. |
153 | 158 |
The returned font is not associated to a specific device" |
159 |
||
5169 | 160 |
^ self |
161 |
family:familyString |
|
162 |
face:(self defaultFace) |
|
163 |
style:(self defaultStyle) |
|
164 |
size:(self defaultSize) |
|
165 |
pixelSize:nil |
|
166 |
encoding:(self defaultEncoding) |
|
153 | 167 |
|
168 |
" |
|
169 |
Font family:'helvetica' |
|
170 |
Font family:'courier' |
|
171 |
" |
|
629 | 172 |
|
173 |
"Modified: 30.4.1996 / 17:20:44 / cg" |
|
153 | 174 |
! |
175 |
||
109 | 176 |
family:familyString face:faceString size:sizeNum |
3996 | 177 |
"returns a font for given family and size with default encoding. |
629 | 178 |
The new fonts style defaults to `roman'. |
109 | 179 |
The returned font is not associated to a specific device" |
180 |
||
5169 | 181 |
^ self |
182 |
family:familyString |
|
183 |
face:faceString |
|
184 |
style:(self defaultStyle) |
|
185 |
size:sizeNum |
|
186 |
pixelSize:nil |
|
187 |
encoding:(self defaultEncoding) |
|
109 | 188 |
|
189 |
" |
|
190 |
Font family:'helvetica' face:'medium' size:10 |
|
191 |
Font family:'helvetica' face:'bold' size:10 |
|
192 |
Font family:'courier' face:'bold' size:10 |
|
193 |
" |
|
629 | 194 |
|
195 |
"Modified: 30.4.1996 / 17:21:07 / cg" |
|
109 | 196 |
! |
197 |
||
198 |
family:familyString face:faceString style:styleString size:sizeNum |
|
3996 | 199 |
"returns a font for given family, face, style and size with default encoding. |
109 | 200 |
The returned font is not associated to a specific device" |
201 |
||
5169 | 202 |
^ self |
203 |
family:familyString |
|
204 |
face:faceString |
|
205 |
style:styleString |
|
206 |
size:sizeNum |
|
207 |
pixelSize:nil |
|
208 |
encoding:(self defaultEncoding) |
|
109 | 209 |
|
210 |
" |
|
211 |
Font family:'helvetica' face:'medium' style:'roman' size:10 |
|
212 |
Font family:'helvetica' face:'medium' style:'italic' size:10 |
|
213 |
Font family:'helvetica' face:'bold' style:'roman' size:10 |
|
214 |
Font family:'courier' face:'bold' style:'italic' size:10 |
|
215 |
" |
|
216 |
! |
|
217 |
||
3993
7fc0939208e2
defaultEncoding is now 8859-1
Claus Gittinger <cg@exept.de>
parents:
3991
diff
changeset
|
218 |
family:familyString face:faceString style:styleString size:sizeNum encoding:encoding |
3996 | 219 |
"returns a font for given family, face, style, size and the specified encoding. |
576 | 220 |
The returned font is not associated to a specific device" |
221 |
||
5169 | 222 |
^ self |
223 |
family:familyString |
|
224 |
face:faceString |
|
225 |
style:styleString |
|
226 |
size:sizeNum |
|
227 |
pixelSize:nil |
|
228 |
encoding:encoding |
|
229 |
||
230 |
"Modified: 20.4.1996 / 23:19:04 / cg" |
|
231 |
! |
|
232 |
||
233 |
family:familyString face:faceString style:styleString size:sizeOrNil pixelSize:pixelSizeOrNil encoding:encoding |
|
234 |
"returns a font for given family, face, style, size and the specified encoding. |
|
235 |
The returned font is not associated to a specific device" |
|
236 |
||
52 | 237 |
^ self new |
576 | 238 |
family:familyString |
239 |
face:faceString |
|
240 |
style:styleString |
|
5169 | 241 |
size:sizeOrNil |
242 |
pixelSize:pixelSizeOrNil |
|
3993
7fc0939208e2
defaultEncoding is now 8859-1
Claus Gittinger <cg@exept.de>
parents:
3991
diff
changeset
|
243 |
encoding:encoding |
576 | 244 |
|
245 |
"Modified: 20.4.1996 / 23:19:04 / cg" |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
246 |
! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
247 |
|
5169 | 248 |
family:familyString pixelSize:sizeNum |
249 |
"returns a font for given family and pixelSize with default encoding. |
|
250 |
The new fonts face defaults to `medium', its style to `roman'. |
|
251 |
Notice: the returned font will typically only be usable on a screen, |
|
252 |
and will not scale as to the devices resolution. |
|
253 |
Use #family:size: for resolution-independent sizing." |
|
254 |
||
255 |
^ self |
|
256 |
family:familyString |
|
257 |
face:(self defaultFace) |
|
258 |
style:(self defaultStyle) |
|
259 |
size:nil |
|
260 |
pixelSize:sizeNum |
|
261 |
encoding:(self defaultEncoding) |
|
262 |
||
263 |
" |
|
264 |
(Font family:'helvetica' size:10) onDevice:Screen current |
|
265 |
(Font family:'helvetica' pixelSize:10) onDevice:Screen current |
|
266 |
" |
|
267 |
! |
|
268 |
||
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
269 |
family:familyString size:sizeNum |
3996 | 270 |
"returns a font for given family and size with default encoding. |
629 | 271 |
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
|
272 |
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
|
273 |
|
5169 | 274 |
^ self |
275 |
family:familyString |
|
276 |
face:(self defaultFace) |
|
277 |
style:(self defaultStyle) |
|
278 |
size:sizeNum |
|
279 |
pixelSize:nil |
|
280 |
encoding:(self defaultEncoding) |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
281 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
282 |
" |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
283 |
Font family:'helvetica' size:10 |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
284 |
Font family:'courier' size:10 |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
285 |
" |
629 | 286 |
|
287 |
"Modified: 30.4.1996 / 17:21:40 / cg" |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
288 |
! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
289 |
|
4005 | 290 |
family:familyString size:sizeNum encoding:encoding |
291 |
"returns a font for given family and size with default encoding. |
|
292 |
The new fonts face defaults to `medium', its style to `roman'. |
|
293 |
The returned font is not associated to a specific device" |
|
294 |
||
5169 | 295 |
^ self |
296 |
family:familyString |
|
297 |
face:(self defaultFace) |
|
298 |
style:(self defaultStyle) |
|
299 |
size:sizeNum |
|
300 |
pixelSize:nil |
|
301 |
encoding:encoding |
|
4005 | 302 |
|
303 |
" |
|
304 |
Font family:'helvetica' size:10 encoding:#'iso8859-1' |
|
305 |
Font family:'courier' size:10 encoding:#'iso8859-1' |
|
306 |
" |
|
307 |
||
308 |
"Modified: 30.4.1996 / 17:21:40 / cg" |
|
309 |
! |
|
310 |
||
1071 | 311 |
family:familyString style:aStyle size:sizeNum |
3996 | 312 |
"returns a font for given family and size with default encoding. |
1071 | 313 |
The new fonts face defaults to `medium', its style to `roman'. |
314 |
The returned font is not associated to a specific device" |
|
315 |
||
5169 | 316 |
^ self |
317 |
family:familyString |
|
318 |
face:(self defaultFace) |
|
319 |
style:aStyle |
|
320 |
size:sizeNum |
|
321 |
pixelSize:nil |
|
322 |
encoding:(self defaultEncoding) |
|
1071 | 323 |
|
324 |
" |
|
325 |
Font family:'helvetica' style:#roman size:48 |
|
326 |
Font family:'courier' style:#roman size:10 |
|
327 |
" |
|
328 |
||
329 |
"Modified: 30.4.1996 / 17:21:40 / cg" |
|
330 |
"Created: 8.10.1996 / 18:33:55 / cg" |
|
331 |
! |
|
332 |
||
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
333 |
name:aFontName |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
334 |
"returns a font with the given explicit name. |
629 | 335 |
WARNING: |
336 |
You shuld not use explicit naming, since font names vary |
|
337 |
with operatingSystems, devices and architecture. |
|
338 |
||
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
339 |
This interface is provided for special purposes only. |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
340 |
On X, the name given should be according the X fontname conventions; |
629 | 341 |
i.e. something like: '-*-times-bold-r-normal-*-*-240-*-*-*-*-iso8859-1'. |
342 |
||
343 |
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
|
344 |
|
5169 | 345 |
^ self |
346 |
family:aFontName |
|
347 |
face:nil |
|
348 |
style:nil |
|
349 |
size:nil |
|
350 |
pixelSize:nil |
|
351 |
encoding:nil |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
352 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
353 |
" |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
354 |
Font name:'-*-times-bold-r-normal-*-*-240-*-*-*-*-iso8859-1' |
629 | 355 |
Font name:'6x10' |
356 |
Font name:'k14' |
|
357 |
((Font name:'k14') on:Display) encoding |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
358 |
" |
629 | 359 |
|
360 |
"Modified: 30.4.1996 / 17:23:09 / cg" |
|
52 | 361 |
! ! |
362 |
||
3993
7fc0939208e2
defaultEncoding is now 8859-1
Claus Gittinger <cg@exept.de>
parents:
3991
diff
changeset
|
363 |
!FontDescription class methodsFor:'defaults'! |
7fc0939208e2
defaultEncoding is now 8859-1
Claus Gittinger <cg@exept.de>
parents:
3991
diff
changeset
|
364 |
|
7fc0939208e2
defaultEncoding is now 8859-1
Claus Gittinger <cg@exept.de>
parents:
3991
diff
changeset
|
365 |
defaultEncoding |
7fc0939208e2
defaultEncoding is now 8859-1
Claus Gittinger <cg@exept.de>
parents:
3991
diff
changeset
|
366 |
^ #'iso8859-1' |
3996 | 367 |
! |
368 |
||
369 |
defaultFace |
|
370 |
^ 'medium' |
|
371 |
! |
|
372 |
||
373 |
defaultSize |
|
374 |
^ 12 |
|
375 |
! |
|
376 |
||
377 |
defaultStyle |
|
378 |
^ 'roman' |
|
3993
7fc0939208e2
defaultEncoding is now 8859-1
Claus Gittinger <cg@exept.de>
parents:
3991
diff
changeset
|
379 |
! ! |
7fc0939208e2
defaultEncoding is now 8859-1
Claus Gittinger <cg@exept.de>
parents:
3991
diff
changeset
|
380 |
|
3827
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
381 |
!FontDescription class methodsFor:'queries'! |
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
382 |
|
3987 | 383 |
characterSetForCharacterEncoding:encodingName |
384 |
"return the font-encoding for a character encoding" |
|
385 |
||
4018 | 386 |
^ CharacterEncodingToCharacterSetMapping at:encodingName ifAbsent:encodingName |
3987 | 387 |
|
388 |
" |
|
4018 | 389 |
FontDescription characterSetForCharacterEncoding:'utf8' |
390 |
FontDescription characterSetForCharacterEncoding:'koi8-r' |
|
391 |
FontDescription characterSetForCharacterEncoding:'unicode' |
|
3987 | 392 |
" |
393 |
! |
|
394 |
||
3827
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
395 |
fontNamePatternForCharset:aCharSetName |
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
396 |
"return the font-encoding for an iso-charset" |
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
397 |
|
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
398 |
^ CharacterSetToFontMapping at:aCharSetName ifAbsent:nil |
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
399 |
|
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
400 |
" |
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
401 |
FontDescription fontNamePatternForCharset:'iso2022-jp' |
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
402 |
FontDescription fontNamePatternForCharset:'euc-jp' |
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
403 |
" |
4010
7f899eceaf2d
preferredFontEncodingFor moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents:
4005
diff
changeset
|
404 |
! |
7f899eceaf2d
preferredFontEncodingFor moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents:
4005
diff
changeset
|
405 |
|
7f899eceaf2d
preferredFontEncodingFor moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents:
4005
diff
changeset
|
406 |
preferredFontEncodingFor:fileEncoding |
7f899eceaf2d
preferredFontEncodingFor moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents:
4005
diff
changeset
|
407 |
"given a file encoding, return a corresponding match pattern for a preferred fontEncoding" |
7f899eceaf2d
preferredFontEncodingFor moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents:
4005
diff
changeset
|
408 |
|
7f899eceaf2d
preferredFontEncodingFor moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents:
4005
diff
changeset
|
409 |
|ce fe| |
7f899eceaf2d
preferredFontEncodingFor moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents:
4005
diff
changeset
|
410 |
|
7f899eceaf2d
preferredFontEncodingFor moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents:
4005
diff
changeset
|
411 |
ce := FontDescription characterSetForCharacterEncoding:fileEncoding. |
7f899eceaf2d
preferredFontEncodingFor moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents:
4005
diff
changeset
|
412 |
ce isNil ifTrue:[ |
7f899eceaf2d
preferredFontEncodingFor moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents:
4005
diff
changeset
|
413 |
ce := fileEncoding. |
7f899eceaf2d
preferredFontEncodingFor moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents:
4005
diff
changeset
|
414 |
]. |
7f899eceaf2d
preferredFontEncodingFor moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents:
4005
diff
changeset
|
415 |
|
7f899eceaf2d
preferredFontEncodingFor moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents:
4005
diff
changeset
|
416 |
fe := FontDescription fontNamePatternForCharset:ce. |
7f899eceaf2d
preferredFontEncodingFor moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents:
4005
diff
changeset
|
417 |
fe notNil ifTrue:[^ fe]. |
7f899eceaf2d
preferredFontEncodingFor moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents:
4005
diff
changeset
|
418 |
^ ce ? 'iso8859*' |
3827
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
419 |
! ! |
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
420 |
|
3880 | 421 |
!FontDescription methodsFor:'Compatibility-ST80'! |
1277 | 422 |
|
423 |
boldness:aNumber |
|
424 |
"added for ST-80 compatibility; actually ignored currently" |
|
425 |
||
426 |
|val| |
|
427 |
||
428 |
flags isNil ifTrue:[ |
|
429 |
flags := masks := 0 |
|
430 |
]. |
|
431 |
||
432 |
"/ scale from 0..1 to 0..BoldnessMask |
|
433 |
val := (aNumber max:0.0) min:1.0. |
|
434 |
val := (BoldnessMask * val) rounded. |
|
435 |
||
436 |
flags := flags bitOr:val. |
|
437 |
masks := masks bitOr:BoldnessMask |
|
438 |
||
439 |
"Created: 25.1.1997 / 03:20:05 / cg" |
|
440 |
"Modified: 25.1.1997 / 03:20:47 / cg" |
|
441 |
! |
|
442 |
||
443 |
color:aColor |
|
444 |
"added for ST-80 compatibility; actually ignored currently" |
|
445 |
||
446 |
"Created: 25.1.1997 / 03:21:28 / cg" |
|
447 |
! |
|
448 |
||
1760
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
449 |
encodings:aCollectionOfEncodings |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
450 |
"added for ST-80 compatibility; actually ignored currently" |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
451 |
|
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
452 |
"Created: 20.6.1997 / 09:52:46 / cg" |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
453 |
! |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
454 |
|
1277 | 455 |
fixedWidth:aBoolean |
456 |
"added for ST-80 compatibility; actually ignored currently" |
|
457 |
||
458 |
flags isNil ifTrue:[ |
|
459 |
flags := masks := 0 |
|
460 |
]. |
|
461 |
flags := flags bitOr:FixedFlag. |
|
462 |
masks := masks bitOr:FixedFlag |
|
463 |
||
464 |
"Created: 25.1.1997 / 03:14:06 / cg" |
|
465 |
"Modified: 25.1.1997 / 03:21:03 / cg" |
|
466 |
! |
|
467 |
||
468 |
italic:aBoolean |
|
469 |
"added for ST-80 compatibility; actually ignored currently" |
|
470 |
||
471 |
flags isNil ifTrue:[ |
|
472 |
flags := masks := 0 |
|
473 |
]. |
|
474 |
flags := flags bitOr:ItalicFlag. |
|
475 |
masks := masks bitOr:ItalicFlag |
|
476 |
||
477 |
"Created: 25.1.1997 / 03:15:37 / cg" |
|
478 |
"Modified: 25.1.1997 / 03:20:55 / cg" |
|
479 |
! |
|
480 |
||
1760
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
481 |
outline:aBoolean |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
482 |
"added for ST-80 compatibility; actually ignored currently" |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
483 |
|
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
484 |
flags isNil ifTrue:[ |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
485 |
flags := masks := 0 |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
486 |
]. |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
487 |
flags := flags bitOr:OutlineFlag. |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
488 |
masks := masks bitOr:OutlineFlag |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
489 |
|
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
490 |
"Modified: 25.1.1997 / 03:20:55 / cg" |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
491 |
"Created: 20.6.1997 / 09:50:06 / cg" |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
492 |
! |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
493 |
|
5165 | 494 |
pixelSize |
495 |
^ pixelSize |
|
496 |
! |
|
497 |
||
1277 | 498 |
pixelSize:aNumber |
5165 | 499 |
"if specified as non-nil, the size is ignored, and a pixel-sized font is chosen." |
1277 | 500 |
|
501 |
pixelSize := aNumber |
|
502 |
! |
|
503 |
||
504 |
serif:aBoolean |
|
505 |
"added for ST-80 compatibility; actually ignored currently" |
|
506 |
||
507 |
flags isNil ifTrue:[ |
|
508 |
flags := masks := 0 |
|
509 |
]. |
|
510 |
flags := flags bitOr:SerifFlag. |
|
511 |
masks := masks bitOr:SerifFlag |
|
512 |
||
513 |
"Created: 25.1.1997 / 03:15:17 / cg" |
|
514 |
"Modified: 25.1.1997 / 03:20:59 / cg" |
|
1760
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
515 |
! |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
516 |
|
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
517 |
shadow:aBoolean |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
518 |
"added for ST-80 compatibility; actually ignored currently" |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
519 |
|
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
520 |
flags isNil ifTrue:[ |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
521 |
flags := masks := 0 |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
522 |
]. |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
523 |
flags := flags bitOr:ShadowFlag. |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
524 |
masks := masks bitOr:ShadowFlag |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
525 |
|
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
526 |
"Modified: 25.1.1997 / 03:20:55 / cg" |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
527 |
"Created: 20.6.1997 / 09:51:03 / cg" |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
528 |
! |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
529 |
|
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
530 |
strikeout:aBoolean |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
531 |
"added for ST-80 compatibility; actually ignored currently" |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
532 |
|
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
533 |
flags isNil ifTrue:[ |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
534 |
flags := masks := 0 |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
535 |
]. |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
536 |
flags := flags bitOr:StrikeoutFlag. |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
537 |
masks := masks bitOr:StrikeoutFlag |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
538 |
|
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
539 |
"Modified: 25.1.1997 / 03:20:55 / cg" |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
540 |
"Created: 20.6.1997 / 09:51:36 / cg" |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
541 |
! |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
542 |
|
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
543 |
underline:aBoolean |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
544 |
"added for ST-80 compatibility; actually ignored currently" |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
545 |
|
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
546 |
flags isNil ifTrue:[ |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
547 |
flags := masks := 0 |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
548 |
]. |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
549 |
flags := flags bitOr:UnderlineFlag. |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
550 |
masks := masks bitOr:UnderlineFlag |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
551 |
|
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
552 |
"Modified: 25.1.1997 / 03:20:55 / cg" |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
553 |
"Created: 20.6.1997 / 09:51:18 / cg" |
1277 | 554 |
! ! |
555 |
||
52 | 556 |
!FontDescription methodsFor:'accessing'! |
557 |
||
2544 | 558 |
device |
559 |
"return the device I am on" |
|
560 |
||
4146 | 561 |
<resource:#obsolete> |
562 |
||
3661 | 563 |
self obsoleteMethodWarning:'use #graphicsDevice'. |
564 |
^ self graphicsDevice |
|
2544 | 565 |
! |
566 |
||
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
567 |
encoding |
575 | 568 |
"return the fonts encoding, as a symbol |
456 | 569 |
such as #'iso8859', #'jis0208.1983' or #ascii. |
570 |
If the fonts encoding is not known, return nil; |
|
571 |
You should assume ascii-encoding then." |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
572 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
573 |
^ encoding |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
574 |
|
575 | 575 |
"Modified: 20.4.1996 / 23:14:36 / cg" |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
576 |
! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
577 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
578 |
face |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
579 |
"return the face, a string" |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
580 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
581 |
^ face |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
582 |
! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
583 |
|
4892
9b15605f58ff
check: bad change of attributes of a REAL font
Claus Gittinger <cg@exept.de>
parents:
4627
diff
changeset
|
584 |
face:aString |
9b15605f58ff
check: bad change of attributes of a REAL font
Claus Gittinger <cg@exept.de>
parents:
4627
diff
changeset
|
585 |
"set the face, a string such as 'bold'" |
9b15605f58ff
check: bad change of attributes of a REAL font
Claus Gittinger <cg@exept.de>
parents:
4627
diff
changeset
|
586 |
|
9b15605f58ff
check: bad change of attributes of a REAL font
Claus Gittinger <cg@exept.de>
parents:
4627
diff
changeset
|
587 |
self assert:(self fontId isNil). "/ cannot change an instanciated font |
9b15605f58ff
check: bad change of attributes of a REAL font
Claus Gittinger <cg@exept.de>
parents:
4627
diff
changeset
|
588 |
face := aString |
9b15605f58ff
check: bad change of attributes of a REAL font
Claus Gittinger <cg@exept.de>
parents:
4627
diff
changeset
|
589 |
|
9b15605f58ff
check: bad change of attributes of a REAL font
Claus Gittinger <cg@exept.de>
parents:
4627
diff
changeset
|
590 |
"Created: 25.1.1997 / 03:12:12 / cg" |
9b15605f58ff
check: bad change of attributes of a REAL font
Claus Gittinger <cg@exept.de>
parents:
4627
diff
changeset
|
591 |
! |
9b15605f58ff
check: bad change of attributes of a REAL font
Claus Gittinger <cg@exept.de>
parents:
4627
diff
changeset
|
592 |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
593 |
family |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
594 |
"return the family, a string" |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
595 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
596 |
^ family |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
597 |
! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
598 |
|
1277 | 599 |
family:aString |
600 |
"set the family, a string" |
|
601 |
||
4892
9b15605f58ff
check: bad change of attributes of a REAL font
Claus Gittinger <cg@exept.de>
parents:
4627
diff
changeset
|
602 |
self assert:(self fontId isNil). "/ cannot change an instanciated font |
1277 | 603 |
family := aString |
604 |
||
605 |
"Created: 25.1.1997 / 03:12:12 / cg" |
|
606 |
! |
|
607 |
||
89 | 608 |
family:familyString face:faceString style:styleString size:sizeNum encoding:encodingString |
5169 | 609 |
<resource: #obsolete> |
610 |
"set the instance values" |
|
611 |
||
612 |
self |
|
613 |
family:familyString |
|
614 |
face:faceString |
|
615 |
style:styleString |
|
616 |
size:sizeNum |
|
617 |
pixelSize:nil |
|
618 |
encoding:encodingString |
|
619 |
! |
|
620 |
||
621 |
family:familyString face:faceString style:styleString size:sizeOrNil pixelSize:pixelSizeOrNil encoding:encodingString |
|
576 | 622 |
"set the instance values" |
623 |
||
4892
9b15605f58ff
check: bad change of attributes of a REAL font
Claus Gittinger <cg@exept.de>
parents:
4627
diff
changeset
|
624 |
self assert:(self fontId isNil). "/ cannot change an instanciated font |
89 | 625 |
family := familyString asSymbol. |
229
099543e5d779
handle empty family/style/encoding strings
Claus Gittinger <cg@exept.de>
parents:
219
diff
changeset
|
626 |
(faceString notNil and:[faceString notEmpty]) ifTrue:[ |
576 | 627 |
face := faceString asSymbol. |
89 | 628 |
]. |
229
099543e5d779
handle empty family/style/encoding strings
Claus Gittinger <cg@exept.de>
parents:
219
diff
changeset
|
629 |
(styleString notNil and:[styleString notEmpty]) ifTrue:[ |
576 | 630 |
style := styleString asSymbol. |
89 | 631 |
]. |
5169 | 632 |
size := sizeOrNil. |
633 |
pixelSize := pixelSizeOrNil. |
|
229
099543e5d779
handle empty family/style/encoding strings
Claus Gittinger <cg@exept.de>
parents:
219
diff
changeset
|
634 |
(encodingString notNil and:[encodingString notEmpty]) ifTrue:[ |
576 | 635 |
encoding := encodingString asSymbol. |
89 | 636 |
] |
229
099543e5d779
handle empty family/style/encoding strings
Claus Gittinger <cg@exept.de>
parents:
219
diff
changeset
|
637 |
|
576 | 638 |
"Modified: 20.4.1996 / 23:19:25 / cg" |
52 | 639 |
! |
640 |
||
2544 | 641 |
fontId |
642 |
"return the device-dependent font-id" |
|
643 |
||
644 |
^ nil |
|
645 |
||
646 |
||
647 |
! |
|
648 |
||
3661 | 649 |
graphicsDevice |
650 |
"return the device I am on" |
|
651 |
||
652 |
^ nil |
|
653 |
! |
|
654 |
||
1277 | 655 |
manufacturer |
656 |
"return the value of the instance variable 'manufacturer' (automatically generated)" |
|
657 |
||
658 |
^ manufacturer |
|
659 |
||
660 |
"Created: 25.1.1997 / 03:12:43 / cg" |
|
661 |
! |
|
662 |
||
663 |
manufacturer:something |
|
664 |
"set the value of the instance variable 'manufacturer' (automatically generated)" |
|
665 |
||
666 |
manufacturer := something. |
|
667 |
||
668 |
"Created: 25.1.1997 / 03:12:43 / cg" |
|
669 |
! |
|
670 |
||
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
671 |
style |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
672 |
"return the style, a string" |
109 | 673 |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
674 |
^ style |
109 | 675 |
! ! |
676 |
||
677 |
!FontDescription methodsFor:'comparing'! |
|
678 |
||
679 |
= aFont |
|
680 |
"two fonts are considered equal, if the font-name components are; |
|
681 |
independent of the device, the font is on" |
|
682 |
||
683 |
(aFont species == self species) ifTrue:[ |
|
684 |
(size == aFont size) ifTrue:[ |
|
685 |
(family = aFont family) ifTrue:[ |
|
686 |
(face = aFont face) ifTrue:[ |
|
687 |
(style = aFont style) ifTrue:[ |
|
688 |
(encoding == aFont encoding) ifTrue:[ |
|
689 |
^ true |
|
690 |
] |
|
691 |
] |
|
692 |
] |
|
693 |
] |
|
694 |
] |
|
695 |
]. |
|
696 |
^ false |
|
2160 | 697 |
! |
698 |
||
699 |
hash |
|
700 |
"return a number for hashing - req'd since = is redefined." |
|
701 |
||
2771
25c96682a2f3
really avoid LargeInteger arithmetic
Claus Gittinger <cg@exept.de>
parents:
2770
diff
changeset
|
702 |
^ ( (family hash bitAnd:16r1FFFFFFF) |
25c96682a2f3
really avoid LargeInteger arithmetic
Claus Gittinger <cg@exept.de>
parents:
2770
diff
changeset
|
703 |
+ (face hash bitAnd:16r1FFFFFFF) |
25c96682a2f3
really avoid LargeInteger arithmetic
Claus Gittinger <cg@exept.de>
parents:
2770
diff
changeset
|
704 |
+ (style hash bitAnd:16r1FFFFFFF) |
3019
6dc6821c111c
oops - care for fractional size in #hash
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
705 |
+ (size ? 0) asInteger) bitAnd:16r3FFFFFFF |
2160 | 706 |
|
707 |
"Created: / 19.6.1998 / 04:19:06 / cg" |
|
2164 | 708 |
"Modified: / 20.6.1998 / 17:04:00 / cg" |
5166 | 709 |
! |
710 |
||
711 |
sameDeviceFontAs:aFont |
|
712 |
(family = aFont family) ifFalse:[ ^ false ]. |
|
713 |
(face = aFont face) ifFalse:[ ^ false ]. |
|
714 |
((style = aFont style) |
|
715 |
or:[ (style = 'italic' and:[aFont style = 'oblique']) |
|
716 |
or:[ style = 'oblique' and:[aFont style = 'italic']]]) ifFalse:[ ^ false ]. |
|
717 |
(encoding isNil or:[encoding = aFont encoding]) ifFalse:[ ^ false ]. |
|
718 |
((pixelSize notNil and:[pixelSize == aFont pixelSize]) |
|
719 |
or:[pixelSize isNil and:[ size = aFont size ]]) ifFalse:[ ^ false ]. |
|
720 |
^ true |
|
109 | 721 |
! ! |
722 |
||
723 |
!FontDescription methodsFor:'converting'! |
|
724 |
||
725 |
asBold |
|
726 |
"return the bold font corresponding to the receiver" |
|
727 |
||
5169 | 728 |
^ self asFace:'bold' |
4627
c3992b15969c
asBold / asItalic return device fonts, if the receiver is one.
Claus Gittinger <cg@exept.de>
parents:
4626
diff
changeset
|
729 |
! |
c3992b15969c
asBold / asItalic return device fonts, if the receiver is one.
Claus Gittinger <cg@exept.de>
parents:
4626
diff
changeset
|
730 |
|
5169 | 731 |
asFace:anotherFace |
4894 | 732 |
"return the bold font corresponding to the receiver" |
733 |
||
734 |
family isNil ifTrue:[ |
|
735 |
"CompoundFonts do not have a family" |
|
736 |
^ self |
|
737 |
]. |
|
738 |
^ (self class |
|
739 |
family:family |
|
5169 | 740 |
face:anotherFace |
4894 | 741 |
style:style |
742 |
size:size |
|
5169 | 743 |
pixelSize:pixelSize |
4894 | 744 |
encoding:encoding) onDevice:self graphicsDevice. |
745 |
||
746 |
"Modified: / 27-09-2006 / 13:08:11 / cg" |
|
747 |
! |
|
748 |
||
5169 | 749 |
asFamily:anotherFamily |
4894 | 750 |
"return another font corresponding to the receiver face, style and size but |
751 |
with another family" |
|
752 |
||
753 |
family isNil ifTrue:[ |
|
754 |
"CompoundFonts do not have a family" |
|
755 |
^ self |
|
756 |
]. |
|
757 |
^ (self class |
|
5169 | 758 |
family:anotherFamily |
4894 | 759 |
face:face |
760 |
style:style |
|
761 |
size:size |
|
5169 | 762 |
pixelSize:pixelSize |
4894 | 763 |
encoding:encoding) onDevice:self graphicsDevice. |
764 |
! |
|
765 |
||
4627
c3992b15969c
asBold / asItalic return device fonts, if the receiver is one.
Claus Gittinger <cg@exept.de>
parents:
4626
diff
changeset
|
766 |
asItalic |
c3992b15969c
asBold / asItalic return device fonts, if the receiver is one.
Claus Gittinger <cg@exept.de>
parents:
4626
diff
changeset
|
767 |
"return the italic font corresponding to the receiver" |
4626
a763ec04e1f3
asBold / asItalic return device fonts, if the receiver is one.
Claus Gittinger <cg@exept.de>
parents:
4532
diff
changeset
|
768 |
|
5169 | 769 |
^ self asFace:'oblique' |
109 | 770 |
! |
771 |
||
5169 | 772 |
asSize:anotherSize |
4894 | 773 |
"return another font corresponding to the receivers family, face and style but |
774 |
with another size" |
|
775 |
||
776 |
family isNil ifTrue:[ |
|
777 |
"CompoundFonts do not have a family" |
|
778 |
^ self |
|
779 |
]. |
|
780 |
^ (self class |
|
781 |
family:family |
|
782 |
face:face |
|
783 |
style:style |
|
5169 | 784 |
size:anotherSize |
785 |
pixelSize:nil |
|
4894 | 786 |
encoding:encoding) onDevice:self graphicsDevice. |
787 |
! |
|
788 |
||
5169 | 789 |
asStyle:anotherStyle |
4894 | 790 |
family isNil ifTrue:[ |
791 |
"CompoundFonts do not have a family" |
|
792 |
^ self |
|
793 |
]. |
|
794 |
^ (self class |
|
795 |
family:family |
|
796 |
face:face |
|
5169 | 797 |
style:anotherStyle |
4894 | 798 |
size:size |
5169 | 799 |
pixelSize:pixelSize |
4894 | 800 |
encoding:encoding) onDevice:self graphicsDevice. |
801 |
||
802 |
"Modified: / 27-09-2006 / 13:08:11 / cg" |
|
803 |
! |
|
804 |
||
4297
10b461a37e26
added encoding to literal vector
Claus Gittinger <cg@exept.de>
parents:
4146
diff
changeset
|
805 |
fromLiteralArrayEncoding:literalEncoding |
2436 | 806 |
"read my contents from a aLiteralEncodedArray. |
807 |
Must match to what is generated in #literalArrayEncoding" |
|
1740 | 808 |
|
4297
10b461a37e26
added encoding to literal vector
Claus Gittinger <cg@exept.de>
parents:
4146
diff
changeset
|
809 |
family := literalEncoding at:2. |
10b461a37e26
added encoding to literal vector
Claus Gittinger <cg@exept.de>
parents:
4146
diff
changeset
|
810 |
face := literalEncoding at:3. |
10b461a37e26
added encoding to literal vector
Claus Gittinger <cg@exept.de>
parents:
4146
diff
changeset
|
811 |
style := literalEncoding at:4. |
10b461a37e26
added encoding to literal vector
Claus Gittinger <cg@exept.de>
parents:
4146
diff
changeset
|
812 |
size := literalEncoding at:5. |
5169 | 813 |
"/ the following kludge is for backward compatibility |
814 |
"/ do not cleanup !! |
|
4297
10b461a37e26
added encoding to literal vector
Claus Gittinger <cg@exept.de>
parents:
4146
diff
changeset
|
815 |
literalEncoding size > 5 ifTrue:[ |
5169 | 816 |
literalEncoding size > 6 ifTrue:[ |
817 |
pixelSize := literalEncoding at:7 |
|
818 |
]. |
|
4297
10b461a37e26
added encoding to literal vector
Claus Gittinger <cg@exept.de>
parents:
4146
diff
changeset
|
819 |
encoding := literalEncoding at:6 |
4298 | 820 |
] ifFalse:[ |
821 |
encoding := #'iso8859-1' |
|
4297
10b461a37e26
added encoding to literal vector
Claus Gittinger <cg@exept.de>
parents:
4146
diff
changeset
|
822 |
]. |
1740 | 823 |
! |
824 |
||
825 |
literalArrayEncoding |
|
2436 | 826 |
"return myself encoded as a literal array. |
827 |
Must match to what is expected in #fromLiteralArrayEncoding:" |
|
1740 | 828 |
|
4298 | 829 |
|myName| |
830 |
||
4532 | 831 |
myName := self class name. |
5169 | 832 |
"/ see comment in #fromLiteralArrayEncoding |
833 |
"/ do not cleanup !! |
|
834 |
(pixelSize isNil |
|
835 |
and:[ encoding == #'iso8859-1' ]) ifTrue:[ |
|
4298 | 836 |
^ Array |
837 |
with:myName |
|
838 |
with:family |
|
839 |
with:face |
|
840 |
with:style |
|
841 |
with:size |
|
842 |
]. |
|
5169 | 843 |
pixelSize isNil ifTrue:[ |
844 |
^ Array |
|
845 |
with:myName |
|
846 |
with:family |
|
847 |
with:face |
|
848 |
with:style |
|
849 |
with:size |
|
850 |
with:encoding |
|
851 |
]. |
|
1740 | 852 |
^ Array |
4298 | 853 |
with:myName |
1740 | 854 |
with:family |
855 |
with:face |
|
856 |
with:style |
|
857 |
with:size |
|
4297
10b461a37e26
added encoding to literal vector
Claus Gittinger <cg@exept.de>
parents:
4146
diff
changeset
|
858 |
with:encoding |
5169 | 859 |
with:pixelSize |
1740 | 860 |
! |
861 |
||
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
862 |
on:aDevice |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
863 |
"given the receiver, return a device Font" |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
864 |
|
3623 | 865 |
"/ send out a warning: #on: is typically used to create views |
866 |
"/ operating on a model. |
|
867 |
"/ Please use #onDevice: to avoid confusion. |
|
868 |
||
869 |
<resource:#obsolete> |
|
870 |
||
871 |
self obsoleteMethodWarning:'use #onDevice:'. |
|
3629 | 872 |
^ self onDevice:aDevice. |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
873 |
! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
874 |
|
1497
697ac9b15962
added #onDevice: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
1277
diff
changeset
|
875 |
onDevice:aDevice |
697ac9b15962
added #onDevice: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
1277
diff
changeset
|
876 |
"given the receiver, return a device Font" |
697ac9b15962
added #onDevice: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
1277
diff
changeset
|
877 |
|
2980
409e9547a45c
ignore nil device in #onDevice:
Claus Gittinger <cg@exept.de>
parents:
2934
diff
changeset
|
878 |
aDevice isNil ifTrue:[^ self]. |
3629 | 879 |
^ (Font |
880 |
family:family |
|
881 |
face:face |
|
882 |
style:style |
|
883 |
size:size |
|
5169 | 884 |
pixelSize:pixelSize |
3629 | 885 |
encoding:encoding) onDevice:aDevice |
1497
697ac9b15962
added #onDevice: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
1277
diff
changeset
|
886 |
|
697ac9b15962
added #onDevice: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
1277
diff
changeset
|
887 |
"Created: 28.3.1997 / 16:09:30 / cg" |
697ac9b15962
added #onDevice: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
1277
diff
changeset
|
888 |
! |
697ac9b15962
added #onDevice: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
1277
diff
changeset
|
889 |
|
5169 | 890 |
size:anotherSize |
891 |
<resource: #obsolete> |
|
892 |
||
109 | 893 |
"return a font corresponding to the receiver, but with different size." |
894 |
||
5169 | 895 |
self obsoleteMethodWarning:'use #asSize:'. |
896 |
||
109 | 897 |
^ self class |
5169 | 898 |
family:family |
899 |
face:face |
|
900 |
style:style |
|
901 |
size:anotherSize |
|
902 |
pixelSize:nil |
|
903 |
encoding:encoding |
|
109 | 904 |
! ! |
905 |
||
2544 | 906 |
!FontDescription methodsFor:'displaying'! |
907 |
||
908 |
displayOpaqueString:aString from:index1 to:index2 x:x y:y in:aGC |
|
3663 | 909 |
"display a partial string at some position in aGC. |
910 |
- display part of a string, drawing both fore- and background pixels" |
|
2544 | 911 |
|
3663 | 912 |
self displayString:aString from:index1 to:index2 x:x y:y in:aGC opaque:true |
2544 | 913 |
! |
914 |
||
915 |
displayOpaqueString:aString x:x y:y in:aGC |
|
916 |
"display a string at some position in aGC." |
|
917 |
||
918 |
self displayOpaqueString:aString from:1 to:aString size x:x y:y in:aGC |
|
919 |
! |
|
920 |
||
921 |
displayString:aString from:index1 to:index2 x:x y:y in:aGC |
|
922 |
"display a partial string at some position in aGC." |
|
923 |
||
3663 | 924 |
self displayString:aString from:index1 to:index2 x:x y:y in:aGC opaque:false |
925 |
! |
|
926 |
||
927 |
displayString:aString from:index1 to:index2 x:x y:y in:aGC opaque:opaque |
|
928 |
"display a partial string at some position in aGC." |
|
929 |
||
2544 | 930 |
self subclassResponsibility |
931 |
! |
|
932 |
||
933 |
displayString:aString x:x y:y in:aGC |
|
934 |
"display a string at some position in aGC." |
|
935 |
||
936 |
self displayString:aString from:1 to:aString size x:x y:y in:aGC |
|
937 |
||
938 |
! ! |
|
939 |
||
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
940 |
!FontDescription methodsFor:'errors'! |
109 | 941 |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
942 |
errorNoDevice |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
943 |
"a query was made for device-specific info" |
109 | 944 |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
945 |
" |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
946 |
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
|
947 |
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
|
948 |
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
|
949 |
associated to a device. |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
950 |
You should always use |
3159 | 951 |
font := font on:someDevice |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
952 |
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
|
953 |
" |
3159 | 954 |
self error:'query device independent font for device specific info' |
955 |
||
956 |
"Modified: / 27.1.2000 / 16:55:05 / stefan" |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
957 |
! ! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
958 |
|
3785 | 959 |
!FontDescription methodsFor:'getting a device font'! |
960 |
||
961 |
onDevice:aDevice ifAbsent:exceptionBlock |
|
962 |
"create a new Font representing the same font as |
|
963 |
myself on aDevice. This does NOT try to look for existing |
|
964 |
or replacement fonts (i.e. can be used to get physical fonts)." |
|
965 |
||
966 |
|newFont id| |
|
967 |
||
968 |
"ask that device for the font" |
|
5166 | 969 |
id := aDevice |
970 |
getFontWithFamily:family |
|
971 |
face:face |
|
972 |
style:style |
|
973 |
size:size |
|
974 |
pixelSize:pixelSize |
|
975 |
encoding:encoding. |
|
3785 | 976 |
id isNil ifTrue:[ |
977 |
"oops did not work - (device has no such font)" |
|
978 |
||
979 |
^ exceptionBlock value |
|
980 |
]. |
|
981 |
||
982 |
newFont := (Font basicNew) |
|
983 |
setFamily:family |
|
984 |
face:face |
|
985 |
style:style |
|
986 |
size:size |
|
5166 | 987 |
pixelSize:pixelSize |
3785 | 988 |
encoding:encoding |
989 |
device:aDevice. |
|
990 |
newFont setFontId:id. |
|
991 |
newFont getFontInfos. |
|
992 |
aDevice registerFont:newFont. |
|
993 |
^ newFont |
|
994 |
! ! |
|
995 |
||
1618 | 996 |
!FontDescription methodsFor:'printing & storing'! |
997 |
||
3991 | 998 |
printOn:aStream |
999 |
"append a user-friendly representation of the receiver to aStream" |
|
1000 |
||
1001 |
aStream nextPutAll:self userFriendlyName |
|
1002 |
! |
|
1003 |
||
1618 | 1004 |
userFriendlyName |
1005 |
"return a user-friendly printed representation of the receiver" |
|
1006 |
||
1007 |
|nm| |
|
1008 |
||
1009 |
nm := family. |
|
1010 |
face notNil ifTrue:[ |
|
1011 |
nm := nm , '-', face. |
|
1012 |
]. |
|
1013 |
style notNil ifTrue:[ |
|
1014 |
nm := nm , '-', style. |
|
1015 |
]. |
|
1016 |
size notNil ifTrue:[ |
|
1017 |
nm := nm , '-', size printString. |
|
1018 |
]. |
|
1019 |
encoding notNil ifTrue:[ |
|
3991 | 1020 |
nm := nm , '(', encoding , ')'. |
1618 | 1021 |
]. |
1022 |
^ nm |
|
1023 |
||
1024 |
" |
|
1025 |
View defaultFont userFriendlyName |
|
1026 |
Button defaultFont userFriendlyName |
|
1027 |
" |
|
1028 |
||
1029 |
"Modified: 20.4.1996 / 23:25:36 / cg" |
|
1030 |
"Created: 19.4.1997 / 18:09:25 / cg" |
|
1031 |
! ! |
|
1032 |
||
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1033 |
!FontDescription methodsFor:'queries'! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1034 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1035 |
bold |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1036 |
"return true, if the receiver is a bold font - |
1585 | 1037 |
Added for st-80 compatibility." |
1038 |
||
1039 |
"/ 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
|
1040 |
|
1275 | 1041 |
^ face = 'bold' |
1042 |
||
1585 | 1043 |
"Modified: 11.4.1997 / 21:31:25 / cg" |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1044 |
! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1045 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1046 |
boldness |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1047 |
"return the boldness of the characters in this font 0 .. 1 - |
1275 | 1048 |
Added for st-80 compatibility" |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1049 |
|
1585 | 1050 |
"/ Currently, this implementation is a dirty hack and will be changed soon. |
1051 |
||
1052 |
face = 'roman' ifTrue:[^ 0.5]. |
|
1053 |
face = 'normal' ifTrue:[^ 0.5]. |
|
1054 |
face = 'bold' ifTrue:[^ 0.75]. |
|
1055 |
face = 'light' ifTrue:[^ 0.25]. |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1056 |
^ 0.5 |
1275 | 1057 |
|
1585 | 1058 |
"Modified: 11.4.1997 / 21:31:31 / cg" |
1275 | 1059 |
! |
1060 |
||
1061 |
color |
|
1062 |
"return the default color in which this font is to be rendered. |
|
1063 |
Added for st-80 compatibility. |
|
1064 |
For now always black." |
|
1065 |
||
1066 |
^ Color black |
|
1067 |
||
1068 |
"Created: 25.1.1997 / 02:59:15 / cg" |
|
1069 |
"Modified: 25.1.1997 / 03:02:14 / cg" |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1070 |
! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1071 |
|
2544 | 1072 |
existsOn:aDevice |
1073 |
"return true, if the recevier is available on aDevice; |
|
1074 |
false otherwise. This is a kludge method; its better to |
|
1075 |
ask a device for its available fonts and use this info ... |
|
1076 |
Notice, that if you simply use a font by name, the system |
|
1077 |
will automatically take a replacement font." |
|
1078 |
||
3629 | 1079 |
^ ((Font |
1080 |
family:family |
|
1081 |
face:face |
|
1082 |
style:style |
|
1083 |
size:size |
|
5169 | 1084 |
pixelSize:pixelSize |
3629 | 1085 |
encoding:encoding) onDevice:aDevice ifAbsent:nil) notNil |
2544 | 1086 |
! |
1087 |
||
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1088 |
fullName |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1089 |
^ nil |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1090 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1091 |
"Created: 23.2.1996 / 00:45:45 / cg" |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1092 |
! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1093 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1094 |
italic |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1095 |
"return true if this is an italic font - |
1585 | 1096 |
Added for st-80 compatibility" |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1097 |
|
1585 | 1098 |
"/ Currently, this implementation is a dirty hack and will be changed soon. |
1099 |
||
1100 |
style = 'italic' ifTrue:[^ true]. |
|
3246 | 1101 |
style = 'oblique' ifTrue:[^ true]. |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1102 |
^ false |
1275 | 1103 |
|
1585 | 1104 |
"Modified: 11.4.1997 / 21:31:42 / cg" |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1105 |
! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1106 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1107 |
serif |
1275 | 1108 |
"return true, if this font has serifs. |
1585 | 1109 |
Added for st-80 compatibility" |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1110 |
|
1585 | 1111 |
"/ 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
|
1112 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1113 |
family = 'Times' ifTrue:[^ true]. |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1114 |
family = 'times' ifTrue:[^ true]. |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1115 |
^ false. |
1275 | 1116 |
|
1585 | 1117 |
"Modified: 11.4.1997 / 21:31:51 / cg" |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1118 |
! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1119 |
|
3265 | 1120 |
size |
1121 |
"return the size, a number" |
|
1122 |
||
1123 |
^ size |
|
1124 |
! |
|
1125 |
||
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1126 |
species |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1127 |
^ Font |
1275 | 1128 |
! |
1129 |
||
1130 |
underline |
|
1131 |
"return true if this is an underlined font - |
|
1132 |
Added for st-80 compatibility |
|
1133 |
(always false here)" |
|
1134 |
||
1135 |
^ false |
|
1136 |
||
1137 |
"Created: 25.1.1997 / 02:58:30 / cg" |
|
1138 |
"Modified: 25.1.1997 / 03:01:12 / cg" |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1139 |
! ! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1140 |
|
2544 | 1141 |
!FontDescription methodsFor:'queries-dimensions'! |
1142 |
||
1143 |
ascent |
|
1144 |
"return the ascent - the number of pixels above the baseLine." |
|
1145 |
||
1146 |
^ self subclassResponsibility |
|
1147 |
! |
|
1148 |
||
1149 |
ascentOn:aDevice |
|
1150 |
"return the ascent - the number of pixels above the baseLine." |
|
1151 |
||
1152 |
^ (self onDevice:aDevice) ascent |
|
1153 |
! |
|
1154 |
||
1155 |
descent |
|
1156 |
"return the descent - the number of pixels below the baseLine." |
|
1157 |
||
1158 |
^ self subclassResponsibility |
|
1159 |
! |
|
1160 |
||
1161 |
descentOn:aDevice |
|
1162 |
"return the ascent - the number of pixels above the baseLine." |
|
1163 |
||
1164 |
^ (self onDevice:aDevice) descent |
|
1165 |
||
1166 |
||
1167 |
! |
|
1168 |
||
1169 |
height |
|
1170 |
"return the height - the number of pixels above plus below the baseLine." |
|
1171 |
||
1172 |
^ self subclassResponsibility |
|
1173 |
! |
|
1174 |
||
1175 |
heightOf:aString |
|
1176 |
"return the height of the given string. |
|
1177 |
Here, assume the characters are of constant height" |
|
1178 |
||
1179 |
^ self height |
|
1180 |
! |
|
1181 |
||
1182 |
heightOf:aString on:aDevice |
|
1183 |
"return the height of the given string on the given device." |
|
1184 |
||
1185 |
^ (self onDevice:aDevice) heightOf:aString |
|
1186 |
! |
|
1187 |
||
1188 |
heightOn:aDevice |
|
1189 |
"return the height - the number of pixels above PLUS below the baseLine." |
|
1190 |
||
1191 |
^ (self onDevice:aDevice) height |
|
1192 |
! |
|
1193 |
||
1194 |
isFixedWidth |
|
1195 |
"return true, if this is a fixed pitch font (i.e. all characters |
|
1196 |
are of the same width)" |
|
1197 |
||
1198 |
self subclassResponsibility |
|
1199 |
! |
|
1200 |
||
1201 |
maxAscent |
|
1202 |
"return the fonts maximum-ascent (i.e. the maximum of all characters); |
|
1203 |
That is the number of units (usually pixels) above the baseline." |
|
1204 |
||
1205 |
^ self subclassResponsibility |
|
1206 |
||
1207 |
! |
|
1208 |
||
1209 |
maxDescent |
|
1210 |
"return the fonts maximum-descent (i.e. the maximum of all characters); |
|
1211 |
That is the number of units (usually pixels) below the baseline." |
|
1212 |
||
1213 |
^ self subclassResponsibility |
|
1214 |
||
1215 |
! |
|
1216 |
||
1217 |
maxHeight |
|
1218 |
"return the fonts characters maximum height; |
|
1219 |
That is the number of units (usually pixels)." |
|
1220 |
||
1221 |
^ self maxAscent + self maxDescent |
|
1222 |
||
1223 |
! |
|
1224 |
||
1225 |
maxWidth |
|
1226 |
"return the fonts maximum-width character (i.e. the maximum of all characters); |
|
1227 |
That is a number of units (usually pixels)." |
|
1228 |
||
1229 |
^ self subclassResponsibility |
|
1230 |
||
1231 |
! |
|
1232 |
||
1233 |
width |
|
1234 |
"return the fonts characters width; |
|
1235 |
That is a number of units (usually pixels). |
|
1236 |
For variable pitch fonts, the width of the space character is returned. |
|
1237 |
For fixed fonts, this is the same as minWidth or maxWidth (or any character). |
|
1238 |
The receiver must be associated to a device, for this query to be legal." |
|
1239 |
||
1240 |
^ self widthOf:' ' |
|
1241 |
||
1242 |
"Modified: 30.4.1996 / 16:43:45 / cg" |
|
1243 |
||
1244 |
||
1245 |
! |
|
1246 |
||
1247 |
widthOf:aString |
|
1248 |
"return the width of a string" |
|
1249 |
||
3667 | 1250 |
^ self widthOf:aString string from:1 to:aString size |
2544 | 1251 |
|
1252 |
||
1253 |
! |
|
1254 |
||
1255 |
widthOf:aString from:start to:stop |
|
1256 |
"return the width of a sub string" |
|
1257 |
||
1258 |
^ self subclassResponsibility |
|
1259 |
||
1260 |
||
1261 |
! |
|
1262 |
||
1263 |
widthOf:aString from:start to:stop on:aDevice |
|
1264 |
"return the width of a sub string. |
|
1265 |
Here, assume that this fonts width is device independent." |
|
1266 |
||
1267 |
^ (self onDevice:aDevice) widthOf:aString from:start to:stop |
|
1268 |
||
1269 |
||
1270 |
! |
|
1271 |
||
1272 |
widthOf:aString on:aDevice |
|
1273 |
"return the width of a string" |
|
1274 |
||
1275 |
^ (self onDevice:aDevice) widthOf:aString |
|
1276 |
||
1277 |
||
1278 |
||
1279 |
||
1280 |
||
1281 |
! |
|
1282 |
||
1283 |
widthOn:aDevice |
|
1284 |
"return the width on some device; that is the width of the space character |
|
1285 |
(which is the width of any character iff the font is a fixed pitch font)" |
|
1286 |
||
1287 |
^ (self onDevice:aDevice) width |
|
1288 |
! ! |
|
1289 |
||
456 | 1290 |
!FontDescription methodsFor:'queries-encoding'! |
1291 |
||
1292 |
isASCII |
|
576 | 1293 |
"return true, if the receivers encoding is |
1294 |
compatible with ascii (i.e. its ascii or iso8859)" |
|
1295 |
||
456 | 1296 |
^ (encoding == #iso8859) or:[encoding == #ascii] |
1297 |
||
1298 |
"Created: 24.2.1996 / 22:47:30 / cg" |
|
576 | 1299 |
"Modified: 20.4.1996 / 23:20:01 / cg" |
456 | 1300 |
! |
1301 |
||
1302 |
isISO8859 |
|
576 | 1303 |
"return true, if the receivers encoding is |
1304 |
compatible with iso8859 (i.e. iso8859)" |
|
1305 |
||
456 | 1306 |
^ encoding == #iso8859 |
1307 |
||
1308 |
"Created: 24.2.1996 / 22:47:12 / cg" |
|
576 | 1309 |
"Modified: 20.4.1996 / 23:20:13 / cg" |
456 | 1310 |
! |
1311 |
||
1312 |
isJIS |
|
576 | 1313 |
"return true, if the receivers encoding is |
1314 |
compatible with jis (i.e. jisXXX)" |
|
1315 |
||
456 | 1316 |
^ (encoding startsWith:'jis') |
1317 |
||
1318 |
"Created: 24.2.1996 / 22:47:47 / cg" |
|
576 | 1319 |
"Modified: 20.4.1996 / 23:20:30 / cg" |
456 | 1320 |
! ! |
1321 |
||
1275 | 1322 |
!FontDescription class methodsFor:'documentation'! |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1323 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1324 |
version |
5169 | 1325 |
^ '$Header: /cvs/stx/stx/libview/FontDescription.st,v 1.67 2009-02-17 18:16:21 cg Exp $' |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1326 |
! ! |
3785 | 1327 |
|
1275 | 1328 |
FontDescription initialize! |