author | Stefan Vogel <sv@exept.de> |
Tue, 17 Mar 2009 18:56:05 +0100 | |
changeset 5223 | 36e00ebd27fc |
parent 5196 | 90aeedb2a2b7 |
child 5441 | 04ebe289a7e0 |
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 |
5185 | 16 |
sizeUnit 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) |
|
5185 | 165 |
sizeUnit:#pt |
5169 | 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 |
|
5185 | 186 |
sizeUnit:#pt |
5169 | 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 |
|
5185 | 207 |
sizeUnit:#pt |
5169 | 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 |
|
5185 | 227 |
sizeUnit:#pt |
5169 | 228 |
encoding:encoding |
229 |
||
230 |
"Modified: 20.4.1996 / 23:19:04 / cg" |
|
231 |
! |
|
232 |
||
5185 | 233 |
family:familyString face:faceString style:styleString size:size sizeUnit:sizeUnit encoding:encoding |
5169 | 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 |
|
5185 | 241 |
size:size |
242 |
sizeUnit:sizeUnit |
|
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) |
|
5185 | 259 |
size:sizeNum |
260 |
sizeUnit:#px |
|
5169 | 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 |
|
5185 | 279 |
sizeUnit:#pt |
5169 | 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 |
|
5185 | 300 |
sizeUnit:#pt |
5169 | 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 |
|
5185 | 321 |
sizeUnit:#pt |
5169 | 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 |
|
5185 | 350 |
sizeUnit:#px |
5169 | 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 |
5185 | 499 |
"if specified, the size is ignored, and a pixel-sized font is chosen." |
1277 | 500 |
|
5185 | 501 |
pixelSize := aNumber. |
502 |
sizeUnit := #px. |
|
1277 | 503 |
! |
504 |
||
505 |
serif:aBoolean |
|
506 |
"added for ST-80 compatibility; actually ignored currently" |
|
507 |
||
508 |
flags isNil ifTrue:[ |
|
509 |
flags := masks := 0 |
|
510 |
]. |
|
511 |
flags := flags bitOr:SerifFlag. |
|
512 |
masks := masks bitOr:SerifFlag |
|
513 |
||
514 |
"Created: 25.1.1997 / 03:15:17 / cg" |
|
515 |
"Modified: 25.1.1997 / 03:20:59 / cg" |
|
1760
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 |
|
5196 | 518 |
setPixelSize:aNumber |
519 |
pixelSize := aNumber. |
|
520 |
! |
|
521 |
||
1760
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
522 |
shadow:aBoolean |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
523 |
"added for ST-80 compatibility; actually ignored currently" |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
524 |
|
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
525 |
flags isNil ifTrue:[ |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
526 |
flags := masks := 0 |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
527 |
]. |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
528 |
flags := flags bitOr:ShadowFlag. |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
529 |
masks := masks bitOr:ShadowFlag |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
530 |
|
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
531 |
"Modified: 25.1.1997 / 03:20:55 / cg" |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
532 |
"Created: 20.6.1997 / 09:51:03 / cg" |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
533 |
! |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
534 |
|
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
535 |
strikeout:aBoolean |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
536 |
"added for ST-80 compatibility; actually ignored currently" |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
537 |
|
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
538 |
flags isNil ifTrue:[ |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
539 |
flags := masks := 0 |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
540 |
]. |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
541 |
flags := flags bitOr:StrikeoutFlag. |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
542 |
masks := masks bitOr:StrikeoutFlag |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
543 |
|
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
544 |
"Modified: 25.1.1997 / 03:20:55 / cg" |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
545 |
"Created: 20.6.1997 / 09:51:36 / cg" |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
546 |
! |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
547 |
|
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
548 |
underline:aBoolean |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
549 |
"added for ST-80 compatibility; actually ignored currently" |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
550 |
|
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
551 |
flags isNil ifTrue:[ |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
552 |
flags := masks := 0 |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
553 |
]. |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
554 |
flags := flags bitOr:UnderlineFlag. |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
555 |
masks := masks bitOr:UnderlineFlag |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
556 |
|
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
557 |
"Modified: 25.1.1997 / 03:20:55 / cg" |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
558 |
"Created: 20.6.1997 / 09:51:18 / cg" |
1277 | 559 |
! ! |
560 |
||
52 | 561 |
!FontDescription methodsFor:'accessing'! |
562 |
||
2544 | 563 |
device |
564 |
"return the device I am on" |
|
565 |
||
4146 | 566 |
<resource:#obsolete> |
567 |
||
3661 | 568 |
self obsoleteMethodWarning:'use #graphicsDevice'. |
569 |
^ self graphicsDevice |
|
2544 | 570 |
! |
571 |
||
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
572 |
encoding |
575 | 573 |
"return the fonts encoding, as a symbol |
456 | 574 |
such as #'iso8859', #'jis0208.1983' or #ascii. |
575 |
If the fonts encoding is not known, return nil; |
|
576 |
You should assume ascii-encoding then." |
|
437
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 |
^ encoding |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
579 |
|
575 | 580 |
"Modified: 20.4.1996 / 23:14:36 / cg" |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
581 |
! |
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 |
face |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
584 |
"return the face, a string" |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
585 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
586 |
^ face |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
587 |
! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
588 |
|
4892
9b15605f58ff
check: bad change of attributes of a REAL font
Claus Gittinger <cg@exept.de>
parents:
4627
diff
changeset
|
589 |
face:aString |
9b15605f58ff
check: bad change of attributes of a REAL font
Claus Gittinger <cg@exept.de>
parents:
4627
diff
changeset
|
590 |
"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
|
591 |
|
9b15605f58ff
check: bad change of attributes of a REAL font
Claus Gittinger <cg@exept.de>
parents:
4627
diff
changeset
|
592 |
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
|
593 |
face := aString |
9b15605f58ff
check: bad change of attributes of a REAL font
Claus Gittinger <cg@exept.de>
parents:
4627
diff
changeset
|
594 |
|
9b15605f58ff
check: bad change of attributes of a REAL font
Claus Gittinger <cg@exept.de>
parents:
4627
diff
changeset
|
595 |
"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
|
596 |
! |
9b15605f58ff
check: bad change of attributes of a REAL font
Claus Gittinger <cg@exept.de>
parents:
4627
diff
changeset
|
597 |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
598 |
family |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
599 |
"return the family, a string" |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
600 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
601 |
^ family |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
602 |
! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
603 |
|
1277 | 604 |
family:aString |
605 |
"set the family, a string" |
|
606 |
||
4892
9b15605f58ff
check: bad change of attributes of a REAL font
Claus Gittinger <cg@exept.de>
parents:
4627
diff
changeset
|
607 |
self assert:(self fontId isNil). "/ cannot change an instanciated font |
1277 | 608 |
family := aString |
609 |
||
610 |
"Created: 25.1.1997 / 03:12:12 / cg" |
|
611 |
! |
|
612 |
||
89 | 613 |
family:familyString face:faceString style:styleString size:sizeNum encoding:encodingString |
5169 | 614 |
<resource: #obsolete> |
615 |
"set the instance values" |
|
616 |
||
617 |
self |
|
618 |
family:familyString |
|
619 |
face:faceString |
|
620 |
style:styleString |
|
621 |
size:sizeNum |
|
5185 | 622 |
sizeUnit:#pt |
5169 | 623 |
encoding:encodingString |
624 |
! |
|
625 |
||
5185 | 626 |
family:familyString face:faceString style:styleString size:sizeArg sizeUnit:sizeUnitArg encoding:encodingString |
576 | 627 |
"set the instance values" |
628 |
||
4892
9b15605f58ff
check: bad change of attributes of a REAL font
Claus Gittinger <cg@exept.de>
parents:
4627
diff
changeset
|
629 |
self assert:(self fontId isNil). "/ cannot change an instanciated font |
5185 | 630 |
|
89 | 631 |
family := familyString asSymbol. |
229
099543e5d779
handle empty family/style/encoding strings
Claus Gittinger <cg@exept.de>
parents:
219
diff
changeset
|
632 |
(faceString notNil and:[faceString notEmpty]) ifTrue:[ |
576 | 633 |
face := faceString asSymbol. |
89 | 634 |
]. |
229
099543e5d779
handle empty family/style/encoding strings
Claus Gittinger <cg@exept.de>
parents:
219
diff
changeset
|
635 |
(styleString notNil and:[styleString notEmpty]) ifTrue:[ |
576 | 636 |
style := styleString asSymbol. |
89 | 637 |
]. |
5185 | 638 |
sizeUnit := sizeUnitArg. |
639 |
sizeUnit == #px ifTrue:[ |
|
640 |
pixelSize := sizeArg. |
|
641 |
] ifFalse:[ |
|
642 |
size := sizeArg. |
|
643 |
]. |
|
229
099543e5d779
handle empty family/style/encoding strings
Claus Gittinger <cg@exept.de>
parents:
219
diff
changeset
|
644 |
(encodingString notNil and:[encodingString notEmpty]) ifTrue:[ |
576 | 645 |
encoding := encodingString asSymbol. |
89 | 646 |
] |
229
099543e5d779
handle empty family/style/encoding strings
Claus Gittinger <cg@exept.de>
parents:
219
diff
changeset
|
647 |
|
576 | 648 |
"Modified: 20.4.1996 / 23:19:25 / cg" |
52 | 649 |
! |
650 |
||
2544 | 651 |
fontId |
652 |
"return the device-dependent font-id" |
|
653 |
||
654 |
^ nil |
|
655 |
||
656 |
||
657 |
! |
|
658 |
||
3661 | 659 |
graphicsDevice |
660 |
"return the device I am on" |
|
661 |
||
662 |
^ nil |
|
663 |
! |
|
664 |
||
1277 | 665 |
manufacturer |
666 |
"return the value of the instance variable 'manufacturer' (automatically generated)" |
|
667 |
||
668 |
^ manufacturer |
|
669 |
||
670 |
"Created: 25.1.1997 / 03:12:43 / cg" |
|
671 |
! |
|
672 |
||
673 |
manufacturer:something |
|
674 |
"set the value of the instance variable 'manufacturer' (automatically generated)" |
|
675 |
||
676 |
manufacturer := something. |
|
677 |
||
678 |
"Created: 25.1.1997 / 03:12:43 / cg" |
|
679 |
! |
|
680 |
||
5185 | 681 |
sizeUnit |
682 |
"currently returns one of #pt or #px (internal use only)" |
|
683 |
||
684 |
^ sizeUnit ? #pt |
|
685 |
! |
|
686 |
||
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
687 |
style |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
688 |
"return the style, a string" |
109 | 689 |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
690 |
^ style |
109 | 691 |
! ! |
692 |
||
693 |
!FontDescription methodsFor:'comparing'! |
|
694 |
||
695 |
= aFont |
|
696 |
"two fonts are considered equal, if the font-name components are; |
|
697 |
independent of the device, the font is on" |
|
698 |
||
699 |
(aFont species == self species) ifTrue:[ |
|
700 |
(size == aFont size) ifTrue:[ |
|
701 |
(family = aFont family) ifTrue:[ |
|
702 |
(face = aFont face) ifTrue:[ |
|
703 |
(style = aFont style) ifTrue:[ |
|
704 |
(encoding == aFont encoding) ifTrue:[ |
|
705 |
^ true |
|
706 |
] |
|
707 |
] |
|
708 |
] |
|
709 |
] |
|
710 |
] |
|
711 |
]. |
|
712 |
^ false |
|
2160 | 713 |
! |
714 |
||
715 |
hash |
|
716 |
"return a number for hashing - req'd since = is redefined." |
|
717 |
||
2771
25c96682a2f3
really avoid LargeInteger arithmetic
Claus Gittinger <cg@exept.de>
parents:
2770
diff
changeset
|
718 |
^ ( (family hash bitAnd:16r1FFFFFFF) |
25c96682a2f3
really avoid LargeInteger arithmetic
Claus Gittinger <cg@exept.de>
parents:
2770
diff
changeset
|
719 |
+ (face hash bitAnd:16r1FFFFFFF) |
25c96682a2f3
really avoid LargeInteger arithmetic
Claus Gittinger <cg@exept.de>
parents:
2770
diff
changeset
|
720 |
+ (style hash bitAnd:16r1FFFFFFF) |
3019
6dc6821c111c
oops - care for fractional size in #hash
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
721 |
+ (size ? 0) asInteger) bitAnd:16r3FFFFFFF |
2160 | 722 |
|
723 |
"Created: / 19.6.1998 / 04:19:06 / cg" |
|
2164 | 724 |
"Modified: / 20.6.1998 / 17:04:00 / cg" |
5166 | 725 |
! |
726 |
||
727 |
sameDeviceFontAs:aFont |
|
728 |
(family = aFont family) ifFalse:[ ^ false ]. |
|
729 |
(face = aFont face) ifFalse:[ ^ false ]. |
|
730 |
((style = aFont style) |
|
731 |
or:[ (style = 'italic' and:[aFont style = 'oblique']) |
|
732 |
or:[ style = 'oblique' and:[aFont style = 'italic']]]) ifFalse:[ ^ false ]. |
|
733 |
(encoding isNil or:[encoding = aFont encoding]) ifFalse:[ ^ false ]. |
|
5185 | 734 |
(sizeUnit ? #pt) = aFont sizeUnit ifFalse:[ ^ false ]. |
5191 | 735 |
(sizeUnit ? #pt) == #pt ifTrue:[ |
736 |
(size = aFont size) ifFalse:[ ^ false ]. |
|
737 |
] ifFalse:[ |
|
738 |
(pixelSize = aFont pixelSize) ifFalse:[ ^ false ]. |
|
739 |
]. |
|
5166 | 740 |
^ true |
109 | 741 |
! ! |
742 |
||
743 |
!FontDescription methodsFor:'converting'! |
|
744 |
||
745 |
asBold |
|
746 |
"return the bold font corresponding to the receiver" |
|
747 |
||
5169 | 748 |
^ self asFace:'bold' |
4627
c3992b15969c
asBold / asItalic return device fonts, if the receiver is one.
Claus Gittinger <cg@exept.de>
parents:
4626
diff
changeset
|
749 |
! |
c3992b15969c
asBold / asItalic return device fonts, if the receiver is one.
Claus Gittinger <cg@exept.de>
parents:
4626
diff
changeset
|
750 |
|
5169 | 751 |
asFace:anotherFace |
4894 | 752 |
"return the bold font corresponding to the receiver" |
753 |
||
754 |
family isNil ifTrue:[ |
|
755 |
"CompoundFonts do not have a family" |
|
756 |
^ self |
|
757 |
]. |
|
758 |
^ (self class |
|
759 |
family:family |
|
5169 | 760 |
face:anotherFace |
4894 | 761 |
style:style |
5185 | 762 |
size:(sizeUnit == #px ifTrue:[pixelSize] ifFalse:[size]) |
763 |
sizeUnit:sizeUnit |
|
4894 | 764 |
encoding:encoding) onDevice:self graphicsDevice. |
765 |
! |
|
766 |
||
5169 | 767 |
asFamily:anotherFamily |
4894 | 768 |
"return another font corresponding to the receiver face, style and size but |
769 |
with another family" |
|
770 |
||
771 |
family isNil ifTrue:[ |
|
772 |
"CompoundFonts do not have a family" |
|
773 |
^ self |
|
774 |
]. |
|
775 |
^ (self class |
|
5169 | 776 |
family:anotherFamily |
4894 | 777 |
face:face |
778 |
style:style |
|
5185 | 779 |
size:(sizeUnit == #px ifTrue:[pixelSize] ifFalse:[size]) |
780 |
sizeUnit:sizeUnit |
|
4894 | 781 |
encoding:encoding) onDevice:self graphicsDevice. |
782 |
! |
|
783 |
||
5196 | 784 |
asFontWithPixelSize:anotherSize |
5185 | 785 |
"return another font corresponding to the receivers family, face and style but |
786 |
with another pixel size" |
|
787 |
||
788 |
family isNil ifTrue:[ |
|
789 |
"CompoundFonts do not have a family" |
|
790 |
^ self |
|
791 |
]. |
|
792 |
^ (self class |
|
793 |
family:family |
|
794 |
face:face |
|
795 |
style:style |
|
796 |
size:anotherSize |
|
797 |
sizeUnit:#px |
|
798 |
encoding:encoding) onDevice:self graphicsDevice. |
|
799 |
! |
|
800 |
||
5196 | 801 |
asItalic |
802 |
"return the italic font corresponding to the receiver" |
|
803 |
||
5223
36e00ebd27fc
changed #asItalic - have to change style instead of face
Stefan Vogel <sv@exept.de>
parents:
5196
diff
changeset
|
804 |
^ self asStyle:'oblique' |
5196 | 805 |
! |
806 |
||
5169 | 807 |
asSize:anotherSize |
4894 | 808 |
"return another font corresponding to the receivers family, face and style but |
809 |
with another size" |
|
810 |
||
811 |
family isNil ifTrue:[ |
|
812 |
"CompoundFonts do not have a family" |
|
813 |
^ self |
|
814 |
]. |
|
815 |
^ (self class |
|
816 |
family:family |
|
817 |
face:face |
|
818 |
style:style |
|
5169 | 819 |
size:anotherSize |
5185 | 820 |
sizeUnit:#pt |
4894 | 821 |
encoding:encoding) onDevice:self graphicsDevice. |
822 |
! |
|
823 |
||
5169 | 824 |
asStyle:anotherStyle |
4894 | 825 |
family isNil ifTrue:[ |
826 |
"CompoundFonts do not have a family" |
|
827 |
^ self |
|
828 |
]. |
|
829 |
^ (self class |
|
830 |
family:family |
|
831 |
face:face |
|
5169 | 832 |
style:anotherStyle |
5185 | 833 |
size:(sizeUnit == #px ifTrue:[pixelSize] ifFalse:[size]) |
834 |
sizeUnit:sizeUnit |
|
4894 | 835 |
encoding:encoding) onDevice:self graphicsDevice. |
836 |
||
837 |
"Modified: / 27-09-2006 / 13:08:11 / cg" |
|
838 |
! |
|
839 |
||
4297
10b461a37e26
added encoding to literal vector
Claus Gittinger <cg@exept.de>
parents:
4146
diff
changeset
|
840 |
fromLiteralArrayEncoding:literalEncoding |
2436 | 841 |
"read my contents from a aLiteralEncodedArray. |
842 |
Must match to what is generated in #literalArrayEncoding" |
|
1740 | 843 |
|
4297
10b461a37e26
added encoding to literal vector
Claus Gittinger <cg@exept.de>
parents:
4146
diff
changeset
|
844 |
family := literalEncoding at:2. |
10b461a37e26
added encoding to literal vector
Claus Gittinger <cg@exept.de>
parents:
4146
diff
changeset
|
845 |
face := literalEncoding at:3. |
10b461a37e26
added encoding to literal vector
Claus Gittinger <cg@exept.de>
parents:
4146
diff
changeset
|
846 |
style := literalEncoding at:4. |
10b461a37e26
added encoding to literal vector
Claus Gittinger <cg@exept.de>
parents:
4146
diff
changeset
|
847 |
size := literalEncoding at:5. |
5169 | 848 |
"/ the following kludge is for backward compatibility |
849 |
"/ do not cleanup !! |
|
4297
10b461a37e26
added encoding to literal vector
Claus Gittinger <cg@exept.de>
parents:
4146
diff
changeset
|
850 |
literalEncoding size > 5 ifTrue:[ |
5169 | 851 |
literalEncoding size > 6 ifTrue:[ |
5185 | 852 |
sizeUnit := literalEncoding at:7. |
853 |
literalEncoding size > 7 ifTrue:[ |
|
854 |
pixelSize := literalEncoding at:8. |
|
855 |
]. |
|
5169 | 856 |
]. |
4297
10b461a37e26
added encoding to literal vector
Claus Gittinger <cg@exept.de>
parents:
4146
diff
changeset
|
857 |
encoding := literalEncoding at:6 |
4298 | 858 |
] ifFalse:[ |
859 |
encoding := #'iso8859-1' |
|
4297
10b461a37e26
added encoding to literal vector
Claus Gittinger <cg@exept.de>
parents:
4146
diff
changeset
|
860 |
]. |
1740 | 861 |
! |
862 |
||
863 |
literalArrayEncoding |
|
2436 | 864 |
"return myself encoded as a literal array. |
865 |
Must match to what is expected in #fromLiteralArrayEncoding:" |
|
1740 | 866 |
|
4298 | 867 |
|myName| |
868 |
||
4532 | 869 |
myName := self class name. |
5169 | 870 |
"/ see comment in #fromLiteralArrayEncoding |
871 |
"/ do not cleanup !! |
|
872 |
(pixelSize isNil |
|
873 |
and:[ encoding == #'iso8859-1' ]) ifTrue:[ |
|
4298 | 874 |
^ Array |
875 |
with:myName |
|
876 |
with:family |
|
877 |
with:face |
|
878 |
with:style |
|
879 |
with:size |
|
880 |
]. |
|
5185 | 881 |
(pixelSize isNil and:[self sizeUnit == #pt]) ifTrue:[ |
5169 | 882 |
^ Array |
883 |
with:myName |
|
884 |
with:family |
|
885 |
with:face |
|
886 |
with:style |
|
887 |
with:size |
|
888 |
with:encoding |
|
889 |
]. |
|
1740 | 890 |
^ Array |
4298 | 891 |
with:myName |
1740 | 892 |
with:family |
893 |
with:face |
|
894 |
with:style |
|
895 |
with:size |
|
4297
10b461a37e26
added encoding to literal vector
Claus Gittinger <cg@exept.de>
parents:
4146
diff
changeset
|
896 |
with:encoding |
5185 | 897 |
with:sizeUnit |
5169 | 898 |
with:pixelSize |
1740 | 899 |
! |
900 |
||
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
901 |
on:aDevice |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
902 |
"given the receiver, return a device Font" |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
903 |
|
3623 | 904 |
"/ send out a warning: #on: is typically used to create views |
905 |
"/ operating on a model. |
|
906 |
"/ Please use #onDevice: to avoid confusion. |
|
907 |
||
908 |
<resource:#obsolete> |
|
909 |
||
910 |
self obsoleteMethodWarning:'use #onDevice:'. |
|
3629 | 911 |
^ self onDevice:aDevice. |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
912 |
! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
913 |
|
1497
697ac9b15962
added #onDevice: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
1277
diff
changeset
|
914 |
onDevice:aDevice |
697ac9b15962
added #onDevice: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
1277
diff
changeset
|
915 |
"given the receiver, return a device Font" |
697ac9b15962
added #onDevice: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
1277
diff
changeset
|
916 |
|
2980
409e9547a45c
ignore nil device in #onDevice:
Claus Gittinger <cg@exept.de>
parents:
2934
diff
changeset
|
917 |
aDevice isNil ifTrue:[^ self]. |
3629 | 918 |
^ (Font |
919 |
family:family |
|
920 |
face:face |
|
921 |
style:style |
|
5185 | 922 |
size:(sizeUnit == #px ifTrue:[pixelSize] ifFalse:[size]) |
923 |
sizeUnit:sizeUnit |
|
3629 | 924 |
encoding:encoding) onDevice:aDevice |
1497
697ac9b15962
added #onDevice: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
1277
diff
changeset
|
925 |
|
697ac9b15962
added #onDevice: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
1277
diff
changeset
|
926 |
"Created: 28.3.1997 / 16:09:30 / cg" |
697ac9b15962
added #onDevice: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
1277
diff
changeset
|
927 |
! |
697ac9b15962
added #onDevice: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
1277
diff
changeset
|
928 |
|
5169 | 929 |
size:anotherSize |
930 |
<resource: #obsolete> |
|
931 |
||
109 | 932 |
"return a font corresponding to the receiver, but with different size." |
933 |
||
5169 | 934 |
self obsoleteMethodWarning:'use #asSize:'. |
935 |
||
109 | 936 |
^ self class |
5169 | 937 |
family:family |
938 |
face:face |
|
939 |
style:style |
|
5185 | 940 |
size:anotherSize |
941 |
sizeUnit:#pt |
|
5169 | 942 |
encoding:encoding |
109 | 943 |
! ! |
944 |
||
2544 | 945 |
!FontDescription methodsFor:'displaying'! |
946 |
||
947 |
displayOpaqueString:aString from:index1 to:index2 x:x y:y in:aGC |
|
3663 | 948 |
"display a partial string at some position in aGC. |
949 |
- display part of a string, drawing both fore- and background pixels" |
|
2544 | 950 |
|
3663 | 951 |
self displayString:aString from:index1 to:index2 x:x y:y in:aGC opaque:true |
2544 | 952 |
! |
953 |
||
954 |
displayOpaqueString:aString x:x y:y in:aGC |
|
955 |
"display a string at some position in aGC." |
|
956 |
||
957 |
self displayOpaqueString:aString from:1 to:aString size x:x y:y in:aGC |
|
958 |
! |
|
959 |
||
960 |
displayString:aString from:index1 to:index2 x:x y:y in:aGC |
|
961 |
"display a partial string at some position in aGC." |
|
962 |
||
3663 | 963 |
self displayString:aString from:index1 to:index2 x:x y:y in:aGC opaque:false |
964 |
! |
|
965 |
||
966 |
displayString:aString from:index1 to:index2 x:x y:y in:aGC opaque:opaque |
|
967 |
"display a partial string at some position in aGC." |
|
968 |
||
2544 | 969 |
self subclassResponsibility |
970 |
! |
|
971 |
||
972 |
displayString:aString x:x y:y in:aGC |
|
973 |
"display a string at some position in aGC." |
|
974 |
||
975 |
self displayString:aString from:1 to:aString size x:x y:y in:aGC |
|
976 |
||
977 |
! ! |
|
978 |
||
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
979 |
!FontDescription methodsFor:'errors'! |
109 | 980 |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
981 |
errorNoDevice |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
982 |
"a query was made for device-specific info" |
109 | 983 |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
984 |
" |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
985 |
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
|
986 |
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
|
987 |
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
|
988 |
associated to a device. |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
989 |
You should always use |
3159 | 990 |
font := font on:someDevice |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
991 |
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
|
992 |
" |
3159 | 993 |
self error:'query device independent font for device specific info' |
994 |
||
995 |
"Modified: / 27.1.2000 / 16:55:05 / stefan" |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
996 |
! ! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
997 |
|
3785 | 998 |
!FontDescription methodsFor:'getting a device font'! |
999 |
||
1000 |
onDevice:aDevice ifAbsent:exceptionBlock |
|
1001 |
"create a new Font representing the same font as |
|
1002 |
myself on aDevice. This does NOT try to look for existing |
|
1003 |
or replacement fonts (i.e. can be used to get physical fonts)." |
|
1004 |
||
1005 |
|newFont id| |
|
1006 |
||
1007 |
"ask that device for the font" |
|
5166 | 1008 |
id := aDevice |
1009 |
getFontWithFamily:family |
|
1010 |
face:face |
|
1011 |
style:style |
|
5185 | 1012 |
size:(sizeUnit == #px ifTrue:[pixelSize] ifFalse:[size]) |
1013 |
sizeUnit:sizeUnit |
|
5166 | 1014 |
encoding:encoding. |
3785 | 1015 |
id isNil ifTrue:[ |
1016 |
"oops did not work - (device has no such font)" |
|
1017 |
||
1018 |
^ exceptionBlock value |
|
1019 |
]. |
|
1020 |
||
1021 |
newFont := (Font basicNew) |
|
1022 |
setFamily:family |
|
1023 |
face:face |
|
1024 |
style:style |
|
5185 | 1025 |
size:(sizeUnit == #px ifTrue:[pixelSize] ifFalse:[size]) |
1026 |
sizeUnit:sizeUnit |
|
3785 | 1027 |
encoding:encoding |
1028 |
device:aDevice. |
|
1029 |
newFont setFontId:id. |
|
1030 |
newFont getFontInfos. |
|
1031 |
aDevice registerFont:newFont. |
|
1032 |
^ newFont |
|
1033 |
! ! |
|
1034 |
||
1618 | 1035 |
!FontDescription methodsFor:'printing & storing'! |
1036 |
||
3991 | 1037 |
printOn:aStream |
1038 |
"append a user-friendly representation of the receiver to aStream" |
|
1039 |
||
1040 |
aStream nextPutAll:self userFriendlyName |
|
1041 |
! |
|
1042 |
||
1618 | 1043 |
userFriendlyName |
1044 |
"return a user-friendly printed representation of the receiver" |
|
1045 |
||
1046 |
|nm| |
|
1047 |
||
1048 |
nm := family. |
|
1049 |
face notNil ifTrue:[ |
|
1050 |
nm := nm , '-', face. |
|
1051 |
]. |
|
1052 |
style notNil ifTrue:[ |
|
1053 |
nm := nm , '-', style. |
|
1054 |
]. |
|
1055 |
size notNil ifTrue:[ |
|
1056 |
nm := nm , '-', size printString. |
|
1057 |
]. |
|
1058 |
encoding notNil ifTrue:[ |
|
3991 | 1059 |
nm := nm , '(', encoding , ')'. |
1618 | 1060 |
]. |
1061 |
^ nm |
|
1062 |
||
1063 |
" |
|
1064 |
View defaultFont userFriendlyName |
|
1065 |
Button defaultFont userFriendlyName |
|
1066 |
" |
|
1067 |
||
1068 |
"Modified: 20.4.1996 / 23:25:36 / cg" |
|
1069 |
"Created: 19.4.1997 / 18:09:25 / cg" |
|
1070 |
! ! |
|
1071 |
||
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1072 |
!FontDescription methodsFor:'queries'! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1073 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1074 |
bold |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1075 |
"return true, if the receiver is a bold font - |
1585 | 1076 |
Added for st-80 compatibility." |
1077 |
||
1078 |
"/ 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
|
1079 |
|
1275 | 1080 |
^ face = 'bold' |
1081 |
||
1585 | 1082 |
"Modified: 11.4.1997 / 21:31:25 / cg" |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1083 |
! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1084 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1085 |
boldness |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1086 |
"return the boldness of the characters in this font 0 .. 1 - |
1275 | 1087 |
Added for st-80 compatibility" |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1088 |
|
1585 | 1089 |
"/ Currently, this implementation is a dirty hack and will be changed soon. |
1090 |
||
1091 |
face = 'roman' ifTrue:[^ 0.5]. |
|
1092 |
face = 'normal' ifTrue:[^ 0.5]. |
|
1093 |
face = 'bold' ifTrue:[^ 0.75]. |
|
1094 |
face = 'light' ifTrue:[^ 0.25]. |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1095 |
^ 0.5 |
1275 | 1096 |
|
1585 | 1097 |
"Modified: 11.4.1997 / 21:31:31 / cg" |
1275 | 1098 |
! |
1099 |
||
1100 |
color |
|
1101 |
"return the default color in which this font is to be rendered. |
|
1102 |
Added for st-80 compatibility. |
|
1103 |
For now always black." |
|
1104 |
||
1105 |
^ Color black |
|
1106 |
||
1107 |
"Created: 25.1.1997 / 02:59:15 / cg" |
|
1108 |
"Modified: 25.1.1997 / 03:02:14 / cg" |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1109 |
! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1110 |
|
2544 | 1111 |
existsOn:aDevice |
1112 |
"return true, if the recevier is available on aDevice; |
|
1113 |
false otherwise. This is a kludge method; its better to |
|
1114 |
ask a device for its available fonts and use this info ... |
|
1115 |
Notice, that if you simply use a font by name, the system |
|
1116 |
will automatically take a replacement font." |
|
1117 |
||
3629 | 1118 |
^ ((Font |
1119 |
family:family |
|
1120 |
face:face |
|
1121 |
style:style |
|
5185 | 1122 |
size:(sizeUnit == #px ifTrue:[pixelSize] ifFalse:[size]) |
1123 |
sizeUnit:sizeUnit |
|
3629 | 1124 |
encoding:encoding) onDevice:aDevice ifAbsent:nil) notNil |
2544 | 1125 |
! |
1126 |
||
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1127 |
fullName |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1128 |
^ nil |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1129 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1130 |
"Created: 23.2.1996 / 00:45:45 / cg" |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1131 |
! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1132 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1133 |
italic |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1134 |
"return true if this is an italic font - |
1585 | 1135 |
Added for st-80 compatibility" |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1136 |
|
1585 | 1137 |
"/ Currently, this implementation is a dirty hack and will be changed soon. |
1138 |
||
1139 |
style = 'italic' ifTrue:[^ true]. |
|
3246 | 1140 |
style = 'oblique' ifTrue:[^ true]. |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1141 |
^ false |
1275 | 1142 |
|
1585 | 1143 |
"Modified: 11.4.1997 / 21:31:42 / cg" |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1144 |
! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1145 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1146 |
serif |
1275 | 1147 |
"return true, if this font has serifs. |
1585 | 1148 |
Added for st-80 compatibility" |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1149 |
|
1585 | 1150 |
"/ 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
|
1151 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1152 |
family = 'Times' ifTrue:[^ true]. |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1153 |
family = 'times' ifTrue:[^ true]. |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1154 |
^ false. |
1275 | 1155 |
|
1585 | 1156 |
"Modified: 11.4.1997 / 21:31:51 / cg" |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1157 |
! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1158 |
|
3265 | 1159 |
size |
1160 |
"return the size, a number" |
|
1161 |
||
1162 |
^ size |
|
1163 |
! |
|
1164 |
||
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1165 |
species |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1166 |
^ Font |
1275 | 1167 |
! |
1168 |
||
1169 |
underline |
|
1170 |
"return true if this is an underlined font - |
|
1171 |
Added for st-80 compatibility |
|
1172 |
(always false here)" |
|
1173 |
||
1174 |
^ false |
|
1175 |
||
1176 |
"Created: 25.1.1997 / 02:58:30 / cg" |
|
1177 |
"Modified: 25.1.1997 / 03:01:12 / cg" |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1178 |
! ! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1179 |
|
2544 | 1180 |
!FontDescription methodsFor:'queries-dimensions'! |
1181 |
||
1182 |
ascent |
|
1183 |
"return the ascent - the number of pixels above the baseLine." |
|
1184 |
||
1185 |
^ self subclassResponsibility |
|
1186 |
! |
|
1187 |
||
1188 |
ascentOn:aDevice |
|
1189 |
"return the ascent - the number of pixels above the baseLine." |
|
1190 |
||
1191 |
^ (self onDevice:aDevice) ascent |
|
1192 |
! |
|
1193 |
||
1194 |
descent |
|
1195 |
"return the descent - the number of pixels below the baseLine." |
|
1196 |
||
1197 |
^ self subclassResponsibility |
|
1198 |
! |
|
1199 |
||
1200 |
descentOn:aDevice |
|
1201 |
"return the ascent - the number of pixels above the baseLine." |
|
1202 |
||
1203 |
^ (self onDevice:aDevice) descent |
|
1204 |
||
1205 |
||
1206 |
! |
|
1207 |
||
1208 |
height |
|
1209 |
"return the height - the number of pixels above plus below the baseLine." |
|
1210 |
||
1211 |
^ self subclassResponsibility |
|
1212 |
! |
|
1213 |
||
1214 |
heightOf:aString |
|
1215 |
"return the height of the given string. |
|
1216 |
Here, assume the characters are of constant height" |
|
1217 |
||
1218 |
^ self height |
|
1219 |
! |
|
1220 |
||
1221 |
heightOf:aString on:aDevice |
|
1222 |
"return the height of the given string on the given device." |
|
1223 |
||
1224 |
^ (self onDevice:aDevice) heightOf:aString |
|
1225 |
! |
|
1226 |
||
1227 |
heightOn:aDevice |
|
1228 |
"return the height - the number of pixels above PLUS below the baseLine." |
|
1229 |
||
1230 |
^ (self onDevice:aDevice) height |
|
1231 |
! |
|
1232 |
||
1233 |
isFixedWidth |
|
1234 |
"return true, if this is a fixed pitch font (i.e. all characters |
|
1235 |
are of the same width)" |
|
1236 |
||
1237 |
self subclassResponsibility |
|
1238 |
! |
|
1239 |
||
1240 |
maxAscent |
|
1241 |
"return the fonts maximum-ascent (i.e. the maximum of all characters); |
|
1242 |
That is the number of units (usually pixels) above the baseline." |
|
1243 |
||
1244 |
^ self subclassResponsibility |
|
1245 |
||
1246 |
! |
|
1247 |
||
1248 |
maxDescent |
|
1249 |
"return the fonts maximum-descent (i.e. the maximum of all characters); |
|
1250 |
That is the number of units (usually pixels) below the baseline." |
|
1251 |
||
1252 |
^ self subclassResponsibility |
|
1253 |
||
1254 |
! |
|
1255 |
||
1256 |
maxHeight |
|
1257 |
"return the fonts characters maximum height; |
|
1258 |
That is the number of units (usually pixels)." |
|
1259 |
||
1260 |
^ self maxAscent + self maxDescent |
|
1261 |
||
1262 |
! |
|
1263 |
||
1264 |
maxWidth |
|
1265 |
"return the fonts maximum-width character (i.e. the maximum of all characters); |
|
1266 |
That is a number of units (usually pixels)." |
|
1267 |
||
1268 |
^ self subclassResponsibility |
|
1269 |
||
1270 |
! |
|
1271 |
||
1272 |
width |
|
1273 |
"return the fonts characters width; |
|
1274 |
That is a number of units (usually pixels). |
|
1275 |
For variable pitch fonts, the width of the space character is returned. |
|
1276 |
For fixed fonts, this is the same as minWidth or maxWidth (or any character). |
|
1277 |
The receiver must be associated to a device, for this query to be legal." |
|
1278 |
||
1279 |
^ self widthOf:' ' |
|
1280 |
||
1281 |
"Modified: 30.4.1996 / 16:43:45 / cg" |
|
1282 |
||
1283 |
||
1284 |
! |
|
1285 |
||
1286 |
widthOf:aString |
|
1287 |
"return the width of a string" |
|
1288 |
||
3667 | 1289 |
^ self widthOf:aString string from:1 to:aString size |
2544 | 1290 |
|
1291 |
||
1292 |
! |
|
1293 |
||
1294 |
widthOf:aString from:start to:stop |
|
1295 |
"return the width of a sub string" |
|
1296 |
||
1297 |
^ self subclassResponsibility |
|
1298 |
||
1299 |
||
1300 |
! |
|
1301 |
||
1302 |
widthOf:aString from:start to:stop on:aDevice |
|
1303 |
"return the width of a sub string. |
|
1304 |
Here, assume that this fonts width is device independent." |
|
1305 |
||
1306 |
^ (self onDevice:aDevice) widthOf:aString from:start to:stop |
|
1307 |
||
1308 |
||
1309 |
! |
|
1310 |
||
1311 |
widthOf:aString on:aDevice |
|
1312 |
"return the width of a string" |
|
1313 |
||
1314 |
^ (self onDevice:aDevice) widthOf:aString |
|
1315 |
||
1316 |
||
1317 |
||
1318 |
||
1319 |
||
1320 |
! |
|
1321 |
||
1322 |
widthOn:aDevice |
|
1323 |
"return the width on some device; that is the width of the space character |
|
1324 |
(which is the width of any character iff the font is a fixed pitch font)" |
|
1325 |
||
1326 |
^ (self onDevice:aDevice) width |
|
1327 |
! ! |
|
1328 |
||
456 | 1329 |
!FontDescription methodsFor:'queries-encoding'! |
1330 |
||
1331 |
isASCII |
|
576 | 1332 |
"return true, if the receivers encoding is |
1333 |
compatible with ascii (i.e. its ascii or iso8859)" |
|
1334 |
||
456 | 1335 |
^ (encoding == #iso8859) or:[encoding == #ascii] |
1336 |
||
1337 |
"Created: 24.2.1996 / 22:47:30 / cg" |
|
576 | 1338 |
"Modified: 20.4.1996 / 23:20:01 / cg" |
456 | 1339 |
! |
1340 |
||
1341 |
isISO8859 |
|
576 | 1342 |
"return true, if the receivers encoding is |
1343 |
compatible with iso8859 (i.e. iso8859)" |
|
1344 |
||
456 | 1345 |
^ encoding == #iso8859 |
1346 |
||
1347 |
"Created: 24.2.1996 / 22:47:12 / cg" |
|
576 | 1348 |
"Modified: 20.4.1996 / 23:20:13 / cg" |
456 | 1349 |
! |
1350 |
||
1351 |
isJIS |
|
576 | 1352 |
"return true, if the receivers encoding is |
1353 |
compatible with jis (i.e. jisXXX)" |
|
1354 |
||
456 | 1355 |
^ (encoding startsWith:'jis') |
1356 |
||
1357 |
"Created: 24.2.1996 / 22:47:47 / cg" |
|
576 | 1358 |
"Modified: 20.4.1996 / 23:20:30 / cg" |
456 | 1359 |
! ! |
1360 |
||
1275 | 1361 |
!FontDescription class methodsFor:'documentation'! |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1362 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1363 |
version |
5223
36e00ebd27fc
changed #asItalic - have to change style instead of face
Stefan Vogel <sv@exept.de>
parents:
5196
diff
changeset
|
1364 |
^ '$Header: /cvs/stx/stx/libview/FontDescription.st,v 1.71 2009-03-17 17:56:05 stefan Exp $' |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1365 |
! ! |
3785 | 1366 |
|
1275 | 1367 |
FontDescription initialize! |