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