author | Stefan Vogel <sv@exept.de> |
Sun, 04 Oct 2015 22:47:48 +0200 | |
changeset 6961 | 29c66fcf1f94 |
parent 6960 | d26b0f5856db |
child 6962 | e310074c6d77 |
permissions | -rw-r--r-- |
6825 | 1 |
"{ Encoding: utf8 }" |
2 |
||
52 | 3 |
" |
4 |
COPYRIGHT (c) 1994 by Claus Gittinger |
|
89 | 5 |
All Rights Reserved |
52 | 6 |
|
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
3246 | 14 |
"{ Package: 'stx:libview' }" |
15 |
||
6723 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
52 | 18 |
Object subclass:#FontDescription |
1275 | 19 |
instanceVariableNames:'family face style size encoding manufacturer name flags masks |
6824 | 20 |
sizeUnit pixelSize weight slant' |
1265
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
21 |
classVariableNames:'BoldnessMask FixedFlag ItalicFlag OutlineFlag SerifFlag |
5511
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
22 |
ShadowFlag StrikeoutFlag UnderlineFlag GenericFlag GenericFonts |
5644 | 23 |
CharacterSetToFontMapping CharacterEncodingToCharacterSetMapping |
6260 | 24 |
IsTrueTypeFlag OverlappingCharactersFlag DefaultEncoding |
25 |
AntialiasedFlag ScalableFlag DecorativeFlag' |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
26 |
poolDictionaries:'' |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
27 |
category:'Graphics-Support' |
52 | 28 |
! |
29 |
||
1275 | 30 |
!FontDescription class methodsFor:'documentation'! |
52 | 31 |
|
32 |
copyright |
|
33 |
" |
|
34 |
COPYRIGHT (c) 1994 by Claus Gittinger |
|
89 | 35 |
All Rights Reserved |
52 | 36 |
|
37 |
This software is furnished under a license and may be used |
|
38 |
only in accordance with the terms of that license and with the |
|
39 |
inclusion of the above copyright notice. This software may not |
|
40 |
be provided or otherwise made available to, or used by, any |
|
41 |
other person. No title to or ownership of the software is |
|
42 |
hereby transferred. |
|
43 |
" |
|
44 |
! |
|
45 |
||
46 |
documentation |
|
47 |
" |
|
48 |
FontDescription is just a place-holder for scanned font names. |
|
49 |
||
611 | 50 |
[Instance variables:] |
51 |
family <String> the fonts family ('courier', 'helvetica' etc) |
|
52 |
face <String> the fonts face ('bold', 'medium' etc) |
|
53 |
style <String> the fonts style ('roman', 'italic', 'oblique') |
|
6825 | 54 |
size <String> the fonts size (by default, in points, not in pixels; but see sizeUnit) |
3991 | 55 |
encoding <Symbol> the fonts encoding (usually #iso8859-1) |
611 | 56 |
|
3991 | 57 |
manufacturer <nil|String|Array> |
58 |
the fonts origin - if known |
|
59 |
name <nil|String|Array> |
|
60 |
the platform specific name |
|
1265
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
61 |
|
3991 | 62 |
flags <SmallInteger> holds serif/italic etc. as flag bits |
63 |
masks <SmallInteger> currently dummy; to allow ST-80 compatible subclassing |
|
64 |
pixelSize <SmallInteger> currently dummy; to allow ST-80 compatible subclassing |
|
6825 | 65 |
sizeUnit <Symbol> #px or #pt; defines what size is measuring |
66 |
weight <SmallInteger> for real fonts, which support it |
|
67 |
slant <SmallInteger> for real fonts, which support it |
|
1265
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
68 |
|
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
69 |
[class variables:] |
3991 | 70 |
BoldnessMask currently dummy; to allow ST-80 compatible subclassing |
71 |
FixedFlag currently dummy; to allow ST-80 compatible subclassing |
|
72 |
ItalicFlag currently dummy; to allow ST-80 compatible subclassing |
|
73 |
OutlineFlag currently dummy; to allow ST-80 compatible subclassing |
|
74 |
SerifFlag currently dummy; to allow ST-80 compatible subclassing |
|
75 |
ShadowFlag currently dummy; to allow ST-80 compatible subclassing |
|
76 |
StrikeoutFlag currently dummy; to allow ST-80 compatible subclassing |
|
77 |
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
|
78 |
|
611 | 79 |
[author:] |
80 |
Claus Gittinger |
|
629 | 81 |
|
82 |
[see also:] |
|
83 |
Font |
|
84 |
FontPanel |
|
85 |
GraphicsContext |
|
86 |
( introduction to view programming :html: programming/viewintro.html#FONTS ) |
|
52 | 87 |
" |
88 |
! ! |
|
89 |
||
1265
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
90 |
!FontDescription class methodsFor:'initialization'! |
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
91 |
|
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
92 |
initialize |
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
93 |
"initialize class variables" |
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
94 |
|
6260 | 95 |
BoldnessMask := 2r000000000000111. "/ allows for 8 boldnesses to be encoded |
96 |
FixedFlag := 2r000000000001000. |
|
97 |
ItalicFlag := 2r000000000010000. |
|
98 |
OutlineFlag := 2r000000000100000. |
|
99 |
SerifFlag := 2r000000001000000. |
|
100 |
ShadowFlag := 2r000000010000000. |
|
101 |
StrikeoutFlag := 2r000000100000000. |
|
102 |
UnderlineFlag := 2r000001000000000. |
|
103 |
GenericFlag := 2r000010000000000. "/ This is a pseudo font |
|
104 |
OverlappingCharactersFlag := 2r000100000000000. "/ special for windows |
|
105 |
AntialiasedFlag := 2r001000000000000. "/ added for Xft |
|
106 |
ScalableFlag := 2r010000000000000. "/ added for Xft |
|
107 |
DecorativeFlag := 2r100000000000000. "/ added for Xft |
|
3827
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
108 |
|
5511
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
109 |
self initializeGenericFonts. |
3987 | 110 |
self initializeCharacterEncodingToCharacterSetMapping. |
3827
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
111 |
self initializeCharacterSetToFontMapping. |
5644 | 112 |
|
113 |
"Modified: / 08-11-2010 / 13:12:08 / cg" |
|
3827
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
114 |
! |
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
115 |
|
3987 | 116 |
initializeCharacterEncodingToCharacterSetMapping |
117 |
"character encoding" |
|
118 |
||
119 |
CharacterEncodingToCharacterSetMapping isNil ifTrue:[ |
|
5511
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
120 |
CharacterEncodingToCharacterSetMapping := Dictionary withKeysAndValues:#( |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
121 |
utf7 unicode |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
122 |
#'utf-7' unicode |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
123 |
utf8 unicode |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
124 |
#'utf-8' unicode |
5916 | 125 |
#utf16be unicode |
126 |
#utf16le unicode |
|
5511
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
127 |
). |
3987 | 128 |
]. |
129 |
! |
|
130 |
||
3827
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
131 |
initializeCharacterSetToFontMapping |
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
132 |
"character sets" |
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
133 |
|
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
134 |
CharacterSetToFontMapping isNil ifTrue:[ |
5511
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
135 |
CharacterSetToFontMapping := Dictionary withKeysAndValues: #( |
5916 | 136 |
unicode 'iso10646-1' |
5511
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
137 |
|
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
138 |
'koi8-r' 'iso8859-5' |
3827
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
139 |
|
5511
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
140 |
'iso2022-jp' 'jis*0208*' |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
141 |
'x-iso2022-jp' 'jis*0208*' |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
142 |
'x-euc-jp' 'jis*0208*' |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
143 |
'x-shift-jis' 'jis*0208*' |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
144 |
'x-sjis' 'jis*0208*' |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
145 |
'x-jis7' 'jis*0208*' |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
146 |
'jis7' 'jis*0208*' |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
147 |
'euc' 'jis*0208*' |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
148 |
'euc-jp' 'jis*0208*' |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
149 |
'sjis' 'jis*0208*' |
3987 | 150 |
|
5511
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
151 |
'big5' 'big5*' |
3987 | 152 |
|
5511
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
153 |
'gb2312' 'gb*' |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
154 |
'hz-gb-2312' 'gb*' |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
155 |
'x-gbk' 'gb*' |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
156 |
|
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
157 |
'iso2022-kr' 'ksc*' |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
158 |
'x-euc-kr' 'ksc*' |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
159 |
). |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
160 |
]. |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
161 |
! |
3827
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
162 |
|
5511
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
163 |
initializeGenericFonts |
6105 | 164 |
"generic fonts, that do not exist as a device font and are |
5511
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
165 |
replaced by a real font" |
3827
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
166 |
|
5511
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
167 |
GenericFonts isNil ifTrue:[ |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
168 |
GenericFonts := OrderedCollection new. |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
169 |
GenericFonts add:((self family:#serif face:nil style:nil size:0 sizeUnit:#pt encoding:nil) isGenericFont:true). |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
170 |
GenericFonts add:((self family:#'sans-serif' face:nil style:nil size:0 sizeUnit:#pt encoding:nil) isGenericFont:true). |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
171 |
GenericFonts add:((self family:#monospace face:nil style:nil size:0 sizeUnit:#pt encoding:nil) isGenericFont:true). |
3827
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
172 |
]. |
1265
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
173 |
! ! |
c8030e99f941
added ST-80 compatible instVars (currently ignored, though)
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
174 |
|
1275 | 175 |
!FontDescription class methodsFor:'instance creation'! |
52 | 176 |
|
153 | 177 |
family:familyString |
178 |
"returns a font for given family and default (12pt) size |
|
3996 | 179 |
with default encoding. |
629 | 180 |
The new fonts face defaults `medium', its style to `roman'. |
153 | 181 |
The returned font is not associated to a specific device" |
182 |
||
5169 | 183 |
^ self |
184 |
family:familyString |
|
185 |
face:(self defaultFace) |
|
186 |
style:(self defaultStyle) |
|
187 |
size:(self defaultSize) |
|
5185 | 188 |
sizeUnit:#pt |
5169 | 189 |
encoding:(self defaultEncoding) |
153 | 190 |
|
191 |
" |
|
192 |
Font family:'helvetica' |
|
193 |
Font family:'courier' |
|
194 |
" |
|
629 | 195 |
|
196 |
"Modified: 30.4.1996 / 17:20:44 / cg" |
|
153 | 197 |
! |
198 |
||
109 | 199 |
family:familyString face:faceString size:sizeNum |
3996 | 200 |
"returns a font for given family and size with default encoding. |
629 | 201 |
The new fonts style defaults to `roman'. |
109 | 202 |
The returned font is not associated to a specific device" |
203 |
||
5169 | 204 |
^ self |
205 |
family:familyString |
|
206 |
face:faceString |
|
207 |
style:(self defaultStyle) |
|
208 |
size:sizeNum |
|
5185 | 209 |
sizeUnit:#pt |
5169 | 210 |
encoding:(self defaultEncoding) |
109 | 211 |
|
212 |
" |
|
213 |
Font family:'helvetica' face:'medium' size:10 |
|
214 |
Font family:'helvetica' face:'bold' size:10 |
|
215 |
Font family:'courier' face:'bold' size:10 |
|
216 |
" |
|
629 | 217 |
|
218 |
"Modified: 30.4.1996 / 17:21:07 / cg" |
|
109 | 219 |
! |
220 |
||
221 |
family:familyString face:faceString style:styleString size:sizeNum |
|
3996 | 222 |
"returns a font for given family, face, style and size with default encoding. |
109 | 223 |
The returned font is not associated to a specific device" |
224 |
||
5169 | 225 |
^ self |
226 |
family:familyString |
|
227 |
face:faceString |
|
228 |
style:styleString |
|
229 |
size:sizeNum |
|
5185 | 230 |
sizeUnit:#pt |
5169 | 231 |
encoding:(self defaultEncoding) |
109 | 232 |
|
233 |
" |
|
234 |
Font family:'helvetica' face:'medium' style:'roman' size:10 |
|
235 |
Font family:'helvetica' face:'medium' style:'italic' size:10 |
|
236 |
Font family:'helvetica' face:'bold' style:'roman' size:10 |
|
237 |
Font family:'courier' face:'bold' style:'italic' size:10 |
|
238 |
" |
|
239 |
! |
|
240 |
||
3993
7fc0939208e2
defaultEncoding is now 8859-1
Claus Gittinger <cg@exept.de>
parents:
3991
diff
changeset
|
241 |
family:familyString face:faceString style:styleString size:sizeNum encoding:encoding |
3996 | 242 |
"returns a font for given family, face, style, size and the specified encoding. |
576 | 243 |
The returned font is not associated to a specific device" |
244 |
||
5169 | 245 |
^ self |
246 |
family:familyString |
|
247 |
face:faceString |
|
248 |
style:styleString |
|
249 |
size:sizeNum |
|
5185 | 250 |
sizeUnit:#pt |
5169 | 251 |
encoding:encoding |
252 |
||
253 |
"Modified: 20.4.1996 / 23:19:04 / cg" |
|
254 |
! |
|
255 |
||
5185 | 256 |
family:familyString face:faceString style:styleString size:size sizeUnit:sizeUnit encoding:encoding |
5169 | 257 |
"returns a font for given family, face, style, size and the specified encoding. |
258 |
The returned font is not associated to a specific device" |
|
259 |
||
52 | 260 |
^ self new |
576 | 261 |
family:familyString |
262 |
face:faceString |
|
263 |
style:styleString |
|
5185 | 264 |
size:size |
265 |
sizeUnit:sizeUnit |
|
3993
7fc0939208e2
defaultEncoding is now 8859-1
Claus Gittinger <cg@exept.de>
parents:
3991
diff
changeset
|
266 |
encoding:encoding |
576 | 267 |
|
268 |
"Modified: 20.4.1996 / 23:19:04 / cg" |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
269 |
! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
270 |
|
5169 | 271 |
family:familyString pixelSize:sizeNum |
272 |
"returns a font for given family and pixelSize with default encoding. |
|
273 |
The new fonts face defaults to `medium', its style to `roman'. |
|
274 |
Notice: the returned font will typically only be usable on a screen, |
|
275 |
and will not scale as to the devices resolution. |
|
276 |
Use #family:size: for resolution-independent sizing." |
|
277 |
||
278 |
^ self |
|
279 |
family:familyString |
|
280 |
face:(self defaultFace) |
|
281 |
style:(self defaultStyle) |
|
5185 | 282 |
size:sizeNum |
283 |
sizeUnit:#px |
|
5169 | 284 |
encoding:(self defaultEncoding) |
285 |
||
286 |
" |
|
287 |
(Font family:'helvetica' size:10) onDevice:Screen current |
|
288 |
(Font family:'helvetica' pixelSize:10) onDevice:Screen current |
|
289 |
" |
|
290 |
! |
|
291 |
||
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
292 |
family:familyString size:sizeNum |
3996 | 293 |
"returns a font for given family and size with default encoding. |
629 | 294 |
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
|
295 |
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
|
296 |
|
5169 | 297 |
^ self |
298 |
family:familyString |
|
299 |
face:(self defaultFace) |
|
300 |
style:(self defaultStyle) |
|
301 |
size:sizeNum |
|
5185 | 302 |
sizeUnit:#pt |
5169 | 303 |
encoding:(self defaultEncoding) |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
304 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
305 |
" |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
306 |
Font family:'helvetica' size:10 |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
307 |
Font family:'courier' size:10 |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
308 |
" |
629 | 309 |
|
310 |
"Modified: 30.4.1996 / 17:21:40 / cg" |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
311 |
! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
312 |
|
4005 | 313 |
family:familyString size:sizeNum encoding:encoding |
314 |
"returns a font for given family and size with default encoding. |
|
315 |
The new fonts face defaults to `medium', its style to `roman'. |
|
316 |
The returned font is not associated to a specific device" |
|
317 |
||
5169 | 318 |
^ self |
319 |
family:familyString |
|
320 |
face:(self defaultFace) |
|
321 |
style:(self defaultStyle) |
|
322 |
size:sizeNum |
|
5185 | 323 |
sizeUnit:#pt |
5169 | 324 |
encoding:encoding |
4005 | 325 |
|
326 |
" |
|
327 |
Font family:'helvetica' size:10 encoding:#'iso8859-1' |
|
328 |
Font family:'courier' size:10 encoding:#'iso8859-1' |
|
329 |
" |
|
330 |
||
331 |
"Modified: 30.4.1996 / 17:21:40 / cg" |
|
332 |
! |
|
333 |
||
1071 | 334 |
family:familyString style:aStyle size:sizeNum |
3996 | 335 |
"returns a font for given family and size with default encoding. |
1071 | 336 |
The new fonts face defaults to `medium', its style to `roman'. |
337 |
The returned font is not associated to a specific device" |
|
338 |
||
5169 | 339 |
^ self |
340 |
family:familyString |
|
341 |
face:(self defaultFace) |
|
342 |
style:aStyle |
|
343 |
size:sizeNum |
|
5185 | 344 |
sizeUnit:#pt |
5169 | 345 |
encoding:(self defaultEncoding) |
1071 | 346 |
|
347 |
" |
|
348 |
Font family:'helvetica' style:#roman size:48 |
|
349 |
Font family:'courier' style:#roman size:10 |
|
350 |
" |
|
351 |
||
352 |
"Modified: 30.4.1996 / 17:21:40 / cg" |
|
353 |
"Created: 8.10.1996 / 18:33:55 / cg" |
|
354 |
! |
|
355 |
||
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
356 |
name:aFontName |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
357 |
"returns a font with the given explicit name. |
629 | 358 |
WARNING: |
359 |
You shuld not use explicit naming, since font names vary |
|
360 |
with operatingSystems, devices and architecture. |
|
361 |
||
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
362 |
This interface is provided for special purposes only. |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
363 |
On X, the name given should be according the X fontname conventions; |
629 | 364 |
i.e. something like: '-*-times-bold-r-normal-*-*-240-*-*-*-*-iso8859-1'. |
365 |
||
366 |
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
|
367 |
|
5169 | 368 |
^ self |
369 |
family:aFontName |
|
370 |
face:nil |
|
371 |
style:nil |
|
372 |
size:nil |
|
5185 | 373 |
sizeUnit:#px |
5169 | 374 |
encoding:nil |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
375 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
376 |
" |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
377 |
Font name:'-*-times-bold-r-normal-*-*-240-*-*-*-*-iso8859-1' |
629 | 378 |
Font name:'6x10' |
379 |
Font name:'k14' |
|
380 |
((Font name:'k14') on:Display) encoding |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
381 |
" |
629 | 382 |
|
383 |
"Modified: 30.4.1996 / 17:23:09 / cg" |
|
52 | 384 |
! ! |
385 |
||
5511
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
386 |
!FontDescription class methodsFor:'accessing'! |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
387 |
|
5991 | 388 |
defaultEncoding:encodingSymbol |
389 |
DefaultEncoding := encodingSymbol |
|
390 |
! |
|
391 |
||
5511
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
392 |
genericFonts |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
393 |
^ GenericFonts |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
394 |
! ! |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
395 |
|
3993
7fc0939208e2
defaultEncoding is now 8859-1
Claus Gittinger <cg@exept.de>
parents:
3991
diff
changeset
|
396 |
!FontDescription class methodsFor:'defaults'! |
7fc0939208e2
defaultEncoding is now 8859-1
Claus Gittinger <cg@exept.de>
parents:
3991
diff
changeset
|
397 |
|
7fc0939208e2
defaultEncoding is now 8859-1
Claus Gittinger <cg@exept.de>
parents:
3991
diff
changeset
|
398 |
defaultEncoding |
5991 | 399 |
^ DefaultEncoding ? #'iso10646-1'. |
5906 | 400 |
"/ ^ #'iso8859-1' |
5894 | 401 |
|
402 |
"Modified: / 20-03-2012 / 23:48:24 / cg" |
|
3996 | 403 |
! |
404 |
||
405 |
defaultFace |
|
5906 | 406 |
^ #medium |
3996 | 407 |
! |
408 |
||
409 |
defaultSize |
|
410 |
^ 12 |
|
411 |
! |
|
412 |
||
413 |
defaultStyle |
|
5906 | 414 |
^ #roman |
3993
7fc0939208e2
defaultEncoding is now 8859-1
Claus Gittinger <cg@exept.de>
parents:
3991
diff
changeset
|
415 |
! ! |
7fc0939208e2
defaultEncoding is now 8859-1
Claus Gittinger <cg@exept.de>
parents:
3991
diff
changeset
|
416 |
|
3827
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
417 |
!FontDescription class methodsFor:'queries'! |
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
418 |
|
3987 | 419 |
characterSetForCharacterEncoding:encodingName |
420 |
"return the font-encoding for a character encoding" |
|
421 |
||
4018 | 422 |
^ CharacterEncodingToCharacterSetMapping at:encodingName ifAbsent:encodingName |
3987 | 423 |
|
424 |
" |
|
4018 | 425 |
FontDescription characterSetForCharacterEncoding:'utf8' |
426 |
FontDescription characterSetForCharacterEncoding:'koi8-r' |
|
427 |
FontDescription characterSetForCharacterEncoding:'unicode' |
|
3987 | 428 |
" |
429 |
! |
|
430 |
||
3827
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
431 |
fontNamePatternForCharset:aCharSetName |
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
432 |
"return the font-encoding for an iso-charset" |
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
433 |
|
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
434 |
^ CharacterSetToFontMapping at:aCharSetName ifAbsent:nil |
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
435 |
|
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
436 |
" |
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
437 |
FontDescription fontNamePatternForCharset:'iso2022-jp' |
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
438 |
FontDescription fontNamePatternForCharset:'euc-jp' |
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
439 |
" |
4010
7f899eceaf2d
preferredFontEncodingFor moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents:
4005
diff
changeset
|
440 |
! |
7f899eceaf2d
preferredFontEncodingFor moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents:
4005
diff
changeset
|
441 |
|
7f899eceaf2d
preferredFontEncodingFor moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents:
4005
diff
changeset
|
442 |
preferredFontEncodingFor:fileEncoding |
7f899eceaf2d
preferredFontEncodingFor moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents:
4005
diff
changeset
|
443 |
"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
|
444 |
|
7f899eceaf2d
preferredFontEncodingFor moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents:
4005
diff
changeset
|
445 |
|ce fe| |
7f899eceaf2d
preferredFontEncodingFor moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents:
4005
diff
changeset
|
446 |
|
7f899eceaf2d
preferredFontEncodingFor moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents:
4005
diff
changeset
|
447 |
ce := FontDescription characterSetForCharacterEncoding:fileEncoding. |
7f899eceaf2d
preferredFontEncodingFor moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents:
4005
diff
changeset
|
448 |
ce isNil ifTrue:[ |
7f899eceaf2d
preferredFontEncodingFor moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents:
4005
diff
changeset
|
449 |
ce := fileEncoding. |
7f899eceaf2d
preferredFontEncodingFor moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents:
4005
diff
changeset
|
450 |
]. |
7f899eceaf2d
preferredFontEncodingFor moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents:
4005
diff
changeset
|
451 |
|
7f899eceaf2d
preferredFontEncodingFor moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents:
4005
diff
changeset
|
452 |
fe := FontDescription fontNamePatternForCharset:ce. |
7f899eceaf2d
preferredFontEncodingFor moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents:
4005
diff
changeset
|
453 |
fe notNil ifTrue:[^ fe]. |
5906 | 454 |
^ ce ? self defaultEncoding. |
3827
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
455 |
! ! |
3390983893a2
font stuff moved from MIMETypes
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
456 |
|
3880 | 457 |
!FontDescription methodsFor:'Compatibility-ST80'! |
1277 | 458 |
|
459 |
boldness:aNumber |
|
460 |
"added for ST-80 compatibility; actually ignored currently" |
|
461 |
||
462 |
|val| |
|
463 |
||
464 |
flags isNil ifTrue:[ |
|
465 |
flags := masks := 0 |
|
466 |
]. |
|
467 |
||
468 |
"/ scale from 0..1 to 0..BoldnessMask |
|
469 |
val := (aNumber max:0.0) min:1.0. |
|
470 |
val := (BoldnessMask * val) rounded. |
|
471 |
||
472 |
flags := flags bitOr:val. |
|
473 |
masks := masks bitOr:BoldnessMask |
|
474 |
||
475 |
"Created: 25.1.1997 / 03:20:05 / cg" |
|
476 |
"Modified: 25.1.1997 / 03:20:47 / cg" |
|
477 |
! |
|
478 |
||
479 |
color:aColor |
|
480 |
"added for ST-80 compatibility; actually ignored currently" |
|
481 |
||
482 |
"Created: 25.1.1997 / 03:21:28 / cg" |
|
483 |
! |
|
484 |
||
1760
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
485 |
encodings:aCollectionOfEncodings |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
486 |
"added for ST-80 compatibility; actually ignored currently" |
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 |
"Created: 20.6.1997 / 09:52:46 / cg" |
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 |
|
1277 | 491 |
fixedWidth:aBoolean |
492 |
"added for ST-80 compatibility; actually ignored currently" |
|
493 |
||
494 |
flags isNil ifTrue:[ |
|
495 |
flags := masks := 0 |
|
496 |
]. |
|
5511
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
497 |
aBoolean ifTrue:[ |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
498 |
flags := flags bitOr:FixedFlag. |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
499 |
masks := masks bitOr:FixedFlag |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
500 |
] ifFalse:[ |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
501 |
flags := flags bitClear:FixedFlag. |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
502 |
masks := masks bitClear:FixedFlag. |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
503 |
]. |
1277 | 504 |
|
505 |
"Created: 25.1.1997 / 03:14:06 / cg" |
|
506 |
"Modified: 25.1.1997 / 03:21:03 / cg" |
|
507 |
! |
|
508 |
||
509 |
italic:aBoolean |
|
510 |
"added for ST-80 compatibility; actually ignored currently" |
|
511 |
||
512 |
flags isNil ifTrue:[ |
|
513 |
flags := masks := 0 |
|
514 |
]. |
|
5511
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
515 |
aBoolean ifTrue:[ |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
516 |
flags := flags bitOr:ItalicFlag. |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
517 |
masks := masks bitOr:ItalicFlag |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
518 |
] ifFalse:[ |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
519 |
flags := flags bitClear:ItalicFlag. |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
520 |
masks := masks bitClear:ItalicFlag. |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
521 |
]. |
1277 | 522 |
|
523 |
"Created: 25.1.1997 / 03:15:37 / cg" |
|
524 |
"Modified: 25.1.1997 / 03:20:55 / cg" |
|
525 |
! |
|
526 |
||
1760
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
527 |
outline:aBoolean |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
528 |
"added for ST-80 compatibility; actually ignored currently" |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
529 |
|
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
530 |
flags isNil ifTrue:[ |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
531 |
flags := masks := 0 |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
532 |
]. |
5511
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
533 |
aBoolean ifTrue:[ |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
534 |
flags := flags bitOr:OutlineFlag. |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
535 |
masks := masks bitOr:OutlineFlag |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
536 |
] ifFalse:[ |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
537 |
flags := flags bitClear:OutlineFlag. |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
538 |
masks := masks bitClear:OutlineFlag. |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
539 |
]. |
1760
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 |
"Modified: 25.1.1997 / 03:20:55 / cg" |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
542 |
"Created: 20.6.1997 / 09:50:06 / cg" |
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 |
|
5165 | 545 |
pixelSize |
546 |
^ pixelSize |
|
547 |
! |
|
548 |
||
1277 | 549 |
pixelSize:aNumber |
5185 | 550 |
"if specified, the size is ignored, and a pixel-sized font is chosen." |
1277 | 551 |
|
5185 | 552 |
pixelSize := aNumber. |
553 |
sizeUnit := #px. |
|
1277 | 554 |
! |
555 |
||
6475 | 556 |
pixelSizeOrNil "/ required by #= comparing |
557 |
^ pixelSize |
|
558 |
||
559 |
"Created: / 20-05-2014 / 11:18:03 / gg" |
|
560 |
! |
|
561 |
||
1277 | 562 |
serif:aBoolean |
563 |
"added for ST-80 compatibility; actually ignored currently" |
|
564 |
||
565 |
flags isNil ifTrue:[ |
|
566 |
flags := masks := 0 |
|
567 |
]. |
|
5511
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
568 |
aBoolean ifTrue:[ |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
569 |
flags := flags bitOr:SerifFlag. |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
570 |
masks := masks bitOr:SerifFlag |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
571 |
] ifFalse:[ |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
572 |
flags := flags bitClear:SerifFlag. |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
573 |
masks := masks bitClear:SerifFlag. |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
574 |
]. |
1277 | 575 |
|
576 |
"Created: 25.1.1997 / 03:15:17 / cg" |
|
577 |
"Modified: 25.1.1997 / 03:20:59 / cg" |
|
1760
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
578 |
! |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
579 |
|
5196 | 580 |
setPixelSize:aNumber |
581 |
pixelSize := aNumber. |
|
582 |
! |
|
583 |
||
6326 | 584 |
setSize:aNumber |
6960 | 585 |
size := aNumber ? 0. |
6326 | 586 |
! |
587 |
||
588 |
setSizeUnit:aSymbol |
|
589 |
sizeUnit := aSymbol. |
|
590 |
! |
|
591 |
||
1760
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
592 |
shadow:aBoolean |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
593 |
"added for ST-80 compatibility; actually ignored currently" |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
594 |
|
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
595 |
flags isNil ifTrue:[ |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
596 |
flags := masks := 0 |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
597 |
]. |
5511
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
598 |
aBoolean ifTrue:[ |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
599 |
flags := flags bitOr:ShadowFlag. |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
600 |
masks := masks bitOr:ShadowFlag |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
601 |
] ifFalse:[ |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
602 |
flags := flags bitClear:ShadowFlag. |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
603 |
masks := masks bitClear:ShadowFlag. |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
604 |
]. |
1760
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
605 |
|
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
606 |
"Modified: 25.1.1997 / 03:20:55 / cg" |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
607 |
"Created: 20.6.1997 / 09:51:03 / cg" |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
608 |
! |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
609 |
|
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
610 |
strikeout:aBoolean |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
611 |
"added for ST-80 compatibility; actually ignored currently" |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
612 |
|
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
613 |
flags isNil ifTrue:[ |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
614 |
flags := masks := 0 |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
615 |
]. |
5511
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
616 |
aBoolean ifTrue:[ |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
617 |
flags := flags bitOr:StrikeoutFlag. |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
618 |
masks := masks bitOr:StrikeoutFlag |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
619 |
] ifFalse:[ |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
620 |
flags := flags bitClear:StrikeoutFlag. |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
621 |
masks := masks bitClear:StrikeoutFlag. |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
622 |
]. |
1760
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
623 |
|
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
624 |
"Modified: 25.1.1997 / 03:20:55 / cg" |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
625 |
"Created: 20.6.1997 / 09:51:36 / cg" |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
626 |
! |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
627 |
|
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
628 |
underline:aBoolean |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
629 |
"added for ST-80 compatibility; actually ignored currently" |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
630 |
|
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
631 |
flags isNil ifTrue:[ |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
632 |
flags := masks := 0 |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
633 |
]. |
5511
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
634 |
aBoolean ifTrue:[ |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
635 |
flags := flags bitOr:UnderlineFlag. |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
636 |
masks := masks bitOr:UnderlineFlag |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
637 |
] ifFalse:[ |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
638 |
flags := flags bitClear:UnderlineFlag. |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
639 |
masks := masks bitClear:UnderlineFlag. |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
640 |
]. |
1760
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
641 |
|
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
642 |
"Modified: 25.1.1997 / 03:20:55 / cg" |
ccd221469891
more ST80 compatibility (partially dummy)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
643 |
"Created: 20.6.1997 / 09:51:18 / cg" |
1277 | 644 |
! ! |
645 |
||
52 | 646 |
!FontDescription methodsFor:'accessing'! |
647 |
||
2544 | 648 |
device |
649 |
"return the device I am on" |
|
650 |
||
4146 | 651 |
<resource:#obsolete> |
652 |
||
3661 | 653 |
self obsoleteMethodWarning:'use #graphicsDevice'. |
654 |
^ self graphicsDevice |
|
2544 | 655 |
! |
656 |
||
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
657 |
encoding |
575 | 658 |
"return the fonts encoding, as a symbol |
456 | 659 |
such as #'iso8859', #'jis0208.1983' or #ascii. |
660 |
If the fonts encoding is not known, return nil; |
|
661 |
You should assume ascii-encoding then." |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
662 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
663 |
^ encoding |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
664 |
|
575 | 665 |
"Modified: 20.4.1996 / 23:14:36 / cg" |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
666 |
! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
667 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
668 |
face |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
669 |
"return the face, a string" |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
670 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
671 |
^ face |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
672 |
! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
673 |
|
4892
9b15605f58ff
check: bad change of attributes of a REAL font
Claus Gittinger <cg@exept.de>
parents:
4627
diff
changeset
|
674 |
face:aString |
9b15605f58ff
check: bad change of attributes of a REAL font
Claus Gittinger <cg@exept.de>
parents:
4627
diff
changeset
|
675 |
"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
|
676 |
|
6262 | 677 |
self assert:(self fontId isNil). "/ cannot change an instantiated font |
4892
9b15605f58ff
check: bad change of attributes of a REAL font
Claus Gittinger <cg@exept.de>
parents:
4627
diff
changeset
|
678 |
face := aString |
9b15605f58ff
check: bad change of attributes of a REAL font
Claus Gittinger <cg@exept.de>
parents:
4627
diff
changeset
|
679 |
|
9b15605f58ff
check: bad change of attributes of a REAL font
Claus Gittinger <cg@exept.de>
parents:
4627
diff
changeset
|
680 |
"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
|
681 |
! |
9b15605f58ff
check: bad change of attributes of a REAL font
Claus Gittinger <cg@exept.de>
parents:
4627
diff
changeset
|
682 |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
683 |
family |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
684 |
"return the family, a string" |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
685 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
686 |
^ family |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
687 |
! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
688 |
|
1277 | 689 |
family:aString |
690 |
"set the family, a string" |
|
691 |
||
6262 | 692 |
self assert:(self fontId isNil). "/ cannot change an instantiated font |
1277 | 693 |
family := aString |
694 |
||
695 |
"Created: 25.1.1997 / 03:12:12 / cg" |
|
696 |
! |
|
697 |
||
89 | 698 |
family:familyString face:faceString style:styleString size:sizeNum encoding:encodingString |
5169 | 699 |
<resource: #obsolete> |
700 |
"set the instance values" |
|
701 |
||
702 |
self |
|
703 |
family:familyString |
|
704 |
face:faceString |
|
705 |
style:styleString |
|
706 |
size:sizeNum |
|
5185 | 707 |
sizeUnit:#pt |
5169 | 708 |
encoding:encodingString |
709 |
! |
|
710 |
||
5185 | 711 |
family:familyString face:faceString style:styleString size:sizeArg sizeUnit:sizeUnitArg encoding:encodingString |
576 | 712 |
"set the instance values" |
713 |
||
6262 | 714 |
self assert:(self fontId isNil). "/ cannot change an instantiated font |
5185 | 715 |
|
89 | 716 |
family := familyString asSymbol. |
6961 | 717 |
faceString notEmptyOrNil ifTrue:[ |
576 | 718 |
face := faceString asSymbol. |
89 | 719 |
]. |
6961 | 720 |
styleString notEmptyOrNil ifTrue:[ |
576 | 721 |
style := styleString asSymbol. |
89 | 722 |
]. |
5185 | 723 |
sizeUnit := sizeUnitArg. |
724 |
sizeUnit == #px ifTrue:[ |
|
725 |
pixelSize := sizeArg. |
|
726 |
] ifFalse:[ |
|
6961 | 727 |
sizeUnit isNil ifTrue:[ |
728 |
sizeUnit := #pt. |
|
729 |
]. |
|
6960 | 730 |
size := sizeArg ? 0. |
5185 | 731 |
]. |
6961 | 732 |
encodingString notEmptyOrNil ifTrue:[ |
576 | 733 |
encoding := encodingString asSymbol. |
89 | 734 |
] |
229
099543e5d779
handle empty family/style/encoding strings
Claus Gittinger <cg@exept.de>
parents:
219
diff
changeset
|
735 |
|
576 | 736 |
"Modified: 20.4.1996 / 23:19:25 / cg" |
52 | 737 |
! |
738 |
||
6262 | 739 |
file:aNumber |
740 |
"set the file" |
|
741 |
||
742 |
self assert:(self fontId isNil). "/ cannot change an instantiated font |
|
743 |
"/ file := aNumber |
|
744 |
! |
|
745 |
||
5511
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
746 |
flags |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
747 |
^ flags |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
748 |
! |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
749 |
|
6260 | 750 |
flags:anInteger |
751 |
flags := anInteger. |
|
5511
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
752 |
! |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
753 |
|
6262 | 754 |
fontFormat:aString |
755 |
"set the fontFormat" |
|
756 |
||
757 |
self assert:(self fontId isNil). "/ cannot change an instantiated font |
|
758 |
"/ fontFormat := aString |
|
759 |
! |
|
760 |
||
2544 | 761 |
fontId |
762 |
"return the device-dependent font-id" |
|
763 |
||
764 |
^ nil |
|
765 |
||
766 |
||
767 |
! |
|
768 |
||
6262 | 769 |
fontVersion:aNumber |
770 |
"set the fontVersion" |
|
771 |
||
772 |
self assert:(self fontId isNil). "/ cannot change an instantiated font |
|
773 |
"/ fontVersion := aNumber |
|
774 |
! |
|
775 |
||
6260 | 776 |
foundry |
777 |
"return the manufacturer/foundry" |
|
778 |
||
779 |
^ manufacturer |
|
780 |
||
781 |
"Created: 25.1.1997 / 03:12:43 / cg" |
|
782 |
! |
|
783 |
||
784 |
foundry:aString |
|
785 |
"set the value of the manufacturer/foundry" |
|
786 |
||
787 |
manufacturer := aString. |
|
788 |
||
789 |
"Created: 25.1.1997 / 03:12:43 / cg" |
|
790 |
! |
|
791 |
||
3661 | 792 |
graphicsDevice |
793 |
"return the device I am on" |
|
794 |
||
795 |
^ nil |
|
796 |
! |
|
797 |
||
5644 | 798 |
hasOverlappingCharacters:aBoolean |
6111 | 799 |
"set whether this has overlapping chars (for windows cleartype drawing only)" |
5644 | 800 |
|
801 |
flags := (flags ? 0) changeMask:OverlappingCharactersFlag to:aBoolean |
|
802 |
||
803 |
"Created: / 08-11-2010 / 13:16:23 / cg" |
|
804 |
! |
|
805 |
||
6260 | 806 |
isAntialiasedFont:aBoolean |
807 |
"set whether this is an antialiased font (currently for XftFonts only)" |
|
808 |
||
809 |
flags := (flags ? 0) changeMask:AntialiasedFlag to:aBoolean |
|
810 |
! |
|
811 |
||
812 |
isDecorativeFont:aBoolean |
|
813 |
"set whether this is a decorative font (currently for XftFonts only)" |
|
814 |
||
815 |
flags := (flags ? 0) changeMask:DecorativeFlag to:aBoolean |
|
816 |
! |
|
817 |
||
5511
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
818 |
isGenericFont:aBoolean |
6111 | 819 |
"set whether this is a pseudo font" |
5511
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
820 |
|
5644 | 821 |
flags := (flags ? 0) changeMask:GenericFlag to:aBoolean |
822 |
||
823 |
"Modified: / 08-11-2010 / 12:58:03 / cg" |
|
6111 | 824 |
"Modified (comment): / 27-07-2013 / 15:39:50 / cg" |
5511
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
825 |
! |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
826 |
|
6262 | 827 |
isOutlineFont:aBoolean |
828 |
"set whether this is an outline font (currently for XftFonts only)" |
|
829 |
||
830 |
flags := (flags ? 0) changeMask:OutlineFlag to:aBoolean |
|
831 |
! |
|
832 |
||
6260 | 833 |
isScalableFont:aBoolean |
834 |
"set whether this is a scalable font (currently for XftFonts only)" |
|
835 |
||
836 |
flags := (flags ? 0) changeMask:ScalableFlag to:aBoolean |
|
837 |
! |
|
838 |
||
1277 | 839 |
manufacturer |
6260 | 840 |
"return the manufacturer/foundry" |
1277 | 841 |
|
842 |
^ manufacturer |
|
843 |
||
844 |
"Created: 25.1.1997 / 03:12:43 / cg" |
|
845 |
! |
|
846 |
||
6260 | 847 |
manufacturer:aString |
848 |
"set the value of the manufacturer/foundry" |
|
1277 | 849 |
|
6260 | 850 |
manufacturer := aString. |
1277 | 851 |
|
852 |
"Created: 25.1.1997 / 03:12:43 / cg" |
|
853 |
! |
|
854 |
||
5511
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
855 |
masks |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
856 |
^ masks |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
857 |
! |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
858 |
|
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
859 |
masks:something |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
860 |
masks := something. |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
861 |
! |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
862 |
|
6723 | 863 |
name |
864 |
"the name (typically filename) if known" |
|
865 |
||
866 |
^ name |
|
867 |
! |
|
868 |
||
869 |
name:aString |
|
870 |
name := aString. |
|
871 |
! |
|
872 |
||
5185 | 873 |
sizeUnit |
874 |
"currently returns one of #pt or #px (internal use only)" |
|
875 |
||
6961 | 876 |
^ sizeUnit |
5185 | 877 |
! |
878 |
||
6260 | 879 |
slant |
880 |
"get the slant" |
|
881 |
||
882 |
^ 0 "/ slant |
|
883 |
! |
|
884 |
||
885 |
slant:aNumber |
|
886 |
"set the slant" |
|
887 |
||
6262 | 888 |
self assert:(self fontId isNil). "/ cannot change an instantiated font |
6260 | 889 |
"/ slant := aNumber |
890 |
! |
|
891 |
||
892 |
spacing |
|
893 |
"get the spacing" |
|
894 |
||
895 |
^ 100 "/ spacing |
|
896 |
! |
|
897 |
||
898 |
spacing:aNumber |
|
899 |
"set the spacing" |
|
900 |
||
6262 | 901 |
self assert:(self fontId isNil). "/ cannot change an instantiated font |
6260 | 902 |
"/ spacing := aNumber |
903 |
! |
|
904 |
||
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
905 |
style |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
906 |
"return the style, a string" |
109 | 907 |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
908 |
^ style |
6262 | 909 |
! |
910 |
||
911 |
style:aString |
|
912 |
"set the style" |
|
913 |
||
914 |
self assert:(self fontId isNil). "/ cannot change an instantiated font |
|
915 |
style := aString |
|
916 |
! |
|
917 |
||
918 |
weight:aNumber |
|
919 |
"set the weight" |
|
920 |
||
921 |
self assert:(self fontId isNil). "/ cannot change an instantiated font |
|
922 |
"/ weight := aNumber |
|
923 |
! |
|
924 |
||
925 |
width:aNumber |
|
926 |
"set the width" |
|
927 |
||
928 |
self assert:(self fontId isNil). "/ cannot change an instantiated font |
|
929 |
"/ width := aNumber |
|
109 | 930 |
! ! |
931 |
||
932 |
!FontDescription methodsFor:'comparing'! |
|
933 |
||
934 |
= aFont |
|
935 |
"two fonts are considered equal, if the font-name components are; |
|
936 |
independent of the device, the font is on" |
|
937 |
||
6541 | 938 |
(aFont species == self species) ifFalse:[^ false]. |
939 |
(size == aFont size) ifFalse:[^ false]. |
|
940 |
(family = aFont family) ifFalse:[^ false]. |
|
941 |
(face = aFont face) ifFalse:[^ false]. |
|
942 |
(style = aFont style) ifFalse:[^ false]. |
|
943 |
(encoding == aFont encoding) ifFalse:[^ false]. |
|
944 |
(sizeUnit == aFont sizeUnit) ifFalse:[^ false]. |
|
945 |
(pixelSize == aFont pixelSizeOrNil) ifFalse:[^ false]. |
|
946 |
^ true |
|
6474 | 947 |
|
6475 | 948 |
"Modified: / 20-05-2014 / 11:18:31 / gg" |
2160 | 949 |
! |
950 |
||
951 |
hash |
|
952 |
"return a number for hashing - req'd since = is redefined." |
|
953 |
||
2771
25c96682a2f3
really avoid LargeInteger arithmetic
Claus Gittinger <cg@exept.de>
parents:
2770
diff
changeset
|
954 |
^ ( (family hash bitAnd:16r1FFFFFFF) |
25c96682a2f3
really avoid LargeInteger arithmetic
Claus Gittinger <cg@exept.de>
parents:
2770
diff
changeset
|
955 |
+ (face hash bitAnd:16r1FFFFFFF) |
25c96682a2f3
really avoid LargeInteger arithmetic
Claus Gittinger <cg@exept.de>
parents:
2770
diff
changeset
|
956 |
+ (style hash bitAnd:16r1FFFFFFF) |
3019
6dc6821c111c
oops - care for fractional size in #hash
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
957 |
+ (size ? 0) asInteger) bitAnd:16r3FFFFFFF |
2160 | 958 |
|
959 |
"Created: / 19.6.1998 / 04:19:06 / cg" |
|
2164 | 960 |
"Modified: / 20.6.1998 / 17:04:00 / cg" |
5166 | 961 |
! |
962 |
||
963 |
sameDeviceFontAs:aFont |
|
6541 | 964 |
aFont species == self species ifFalse:[^ false]. |
965 |
||
5166 | 966 |
(family = aFont family) ifFalse:[ ^ false ]. |
967 |
(face = aFont face) ifFalse:[ ^ false ]. |
|
968 |
((style = aFont style) |
|
6388 | 969 |
or:[ (style = 'italic' and:[aFont style = 'oblique']) |
970 |
or:[ style = 'oblique' and:[aFont style = 'italic']]]) ifFalse:[ ^ false ]. |
|
5441 | 971 |
|
5166 | 972 |
(encoding isNil or:[encoding = aFont encoding]) ifFalse:[ ^ false ]. |
5185 | 973 |
(sizeUnit ? #pt) = aFont sizeUnit ifFalse:[ ^ false ]. |
5191 | 974 |
(sizeUnit ? #pt) == #pt ifTrue:[ |
975 |
(size = aFont size) ifFalse:[ ^ false ]. |
|
976 |
] ifFalse:[ |
|
977 |
(pixelSize = aFont pixelSize) ifFalse:[ ^ false ]. |
|
978 |
]. |
|
5166 | 979 |
^ true |
109 | 980 |
! ! |
981 |
||
982 |
!FontDescription methodsFor:'converting'! |
|
983 |
||
984 |
asBold |
|
985 |
"return the bold font corresponding to the receiver" |
|
986 |
||
5511
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
987 |
^ self asFace:#bold |
4627
c3992b15969c
asBold / asItalic return device fonts, if the receiver is one.
Claus Gittinger <cg@exept.de>
parents:
4626
diff
changeset
|
988 |
! |
c3992b15969c
asBold / asItalic return device fonts, if the receiver is one.
Claus Gittinger <cg@exept.de>
parents:
4626
diff
changeset
|
989 |
|
5906 | 990 |
asEncoding:anotherEncoding |
991 |
|newFont| |
|
992 |
||
993 |
family isNil ifTrue:[ |
|
994 |
"CompoundFonts do not have a family" |
|
995 |
^ self |
|
996 |
]. |
|
997 |
newFont := self class |
|
998 |
family:family |
|
999 |
face:face |
|
1000 |
style:style |
|
1001 |
size:(sizeUnit == #px ifTrue:[pixelSize] ifFalse:[size]) |
|
1002 |
sizeUnit:sizeUnit |
|
1003 |
encoding:anotherEncoding. |
|
1004 |
||
1005 |
newFont isGenericFont:self isGenericFont. |
|
1006 |
||
1007 |
^ newFont onDevice:self graphicsDevice. |
|
1008 |
"Modified: / 27-09-2006 / 13:08:11 / cg" |
|
1009 |
! |
|
1010 |
||
5169 | 1011 |
asFace:anotherFace |
4894 | 1012 |
"return the bold font corresponding to the receiver" |
1013 |
||
5511
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
1014 |
|newFont| |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
1015 |
|
4894 | 1016 |
family isNil ifTrue:[ |
1017 |
"CompoundFonts do not have a family" |
|
1018 |
^ self |
|
1019 |
]. |
|
5511
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
1020 |
newFont := self class |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
1021 |
family:family |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
1022 |
face:anotherFace |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
1023 |
style:style |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
1024 |
size:(sizeUnit == #px ifTrue:[pixelSize] ifFalse:[size]) |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
1025 |
sizeUnit:sizeUnit |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
1026 |
encoding:encoding. |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
1027 |
newFont isGenericFont:self isGenericFont. |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
1028 |
|
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
1029 |
^ newFont onDevice:self graphicsDevice. |
4894 | 1030 |
! |
1031 |
||
5169 | 1032 |
asFamily:anotherFamily |
4894 | 1033 |
"return another font corresponding to the receiver face, style and size but |
1034 |
with another family" |
|
1035 |
||
1036 |
family isNil ifTrue:[ |
|
1037 |
"CompoundFonts do not have a family" |
|
1038 |
^ self |
|
1039 |
]. |
|
1040 |
^ (self class |
|
5169 | 1041 |
family:anotherFamily |
4894 | 1042 |
face:face |
1043 |
style:style |
|
5185 | 1044 |
size:(sizeUnit == #px ifTrue:[pixelSize] ifFalse:[size]) |
1045 |
sizeUnit:sizeUnit |
|
4894 | 1046 |
encoding:encoding) onDevice:self graphicsDevice. |
1047 |
! |
|
1048 |
||
5560 | 1049 |
asFontDescription |
1050 |
^ self |
|
1051 |
! |
|
1052 |
||
5196 | 1053 |
asFontWithPixelSize:anotherSize |
5185 | 1054 |
"return another font corresponding to the receivers family, face and style but |
1055 |
with another pixel size" |
|
1056 |
||
5511
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
1057 |
|newFont| |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
1058 |
|
5185 | 1059 |
family isNil ifTrue:[ |
1060 |
"CompoundFonts do not have a family" |
|
1061 |
^ self |
|
1062 |
]. |
|
5511
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
1063 |
newFont := self class |
5185 | 1064 |
family:family |
1065 |
face:face |
|
1066 |
style:style |
|
1067 |
size:anotherSize |
|
1068 |
sizeUnit:#px |
|
5511
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
1069 |
encoding:encoding. |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
1070 |
|
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
1071 |
newFont isGenericFont:self isGenericFont. |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
1072 |
|
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
1073 |
^ newFont onDevice:self graphicsDevice. |
5185 | 1074 |
! |
1075 |
||
5196 | 1076 |
asItalic |
1077 |
"return the italic font corresponding to the receiver" |
|
1078 |
||
5511
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
1079 |
^ self asStyle:#oblique |
5196 | 1080 |
! |
1081 |
||
6629 | 1082 |
asPixelSize:anotherSize |
1083 |
"return another font corresponding to the receivers family, face and style but |
|
1084 |
with another pixel size" |
|
1085 |
||
1086 |
|newFont| |
|
1087 |
||
1088 |
family isNil ifTrue:[ |
|
1089 |
"CompoundFonts do not have a family" |
|
1090 |
^ self |
|
1091 |
]. |
|
1092 |
newFont := self class |
|
1093 |
family:family |
|
1094 |
face:face |
|
1095 |
style:style |
|
1096 |
size:anotherSize |
|
1097 |
sizeUnit:#px |
|
1098 |
encoding:encoding. |
|
1099 |
||
1100 |
newFont isGenericFont:self isGenericFont. |
|
1101 |
^ newFont onDevice:self graphicsDevice. |
|
1102 |
! |
|
1103 |
||
5169 | 1104 |
asSize:anotherSize |
4894 | 1105 |
"return another font corresponding to the receivers family, face and style but |
1106 |
with another size" |
|
1107 |
||
5511
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
1108 |
|newFont| |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
1109 |
|
4894 | 1110 |
family isNil ifTrue:[ |
1111 |
"CompoundFonts do not have a family" |
|
1112 |
^ self |
|
1113 |
]. |
|
5511
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
1114 |
newFont := self class |
4894 | 1115 |
family:family |
1116 |
face:face |
|
1117 |
style:style |
|
5169 | 1118 |
size:anotherSize |
5185 | 1119 |
sizeUnit:#pt |
5511
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
1120 |
encoding:encoding. |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
1121 |
|
6316 | 1122 |
newFont isGenericFont:self isGenericFont. |
5511
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
1123 |
^ newFont onDevice:self graphicsDevice. |
4894 | 1124 |
! |
1125 |
||
5169 | 1126 |
asStyle:anotherStyle |
5511
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
1127 |
|newFont| |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
1128 |
|
4894 | 1129 |
family isNil ifTrue:[ |
1130 |
"CompoundFonts do not have a family" |
|
1131 |
^ self |
|
1132 |
]. |
|
5511
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
1133 |
newFont := self class |
4894 | 1134 |
family:family |
1135 |
face:face |
|
5169 | 1136 |
style:anotherStyle |
5185 | 1137 |
size:(sizeUnit == #px ifTrue:[pixelSize] ifFalse:[size]) |
1138 |
sizeUnit:sizeUnit |
|
5511
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
1139 |
encoding:encoding. |
4894 | 1140 |
|
5511
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
1141 |
newFont isGenericFont:self isGenericFont. |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
1142 |
|
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
1143 |
^ newFont onDevice:self graphicsDevice. |
4894 | 1144 |
"Modified: / 27-09-2006 / 13:08:11 / cg" |
1145 |
! |
|
1146 |
||
4297
10b461a37e26
added encoding to literal vector
Claus Gittinger <cg@exept.de>
parents:
4146
diff
changeset
|
1147 |
fromLiteralArrayEncoding:literalEncoding |
2436 | 1148 |
"read my contents from a aLiteralEncodedArray. |
1149 |
Must match to what is generated in #literalArrayEncoding" |
|
1740 | 1150 |
|
4297
10b461a37e26
added encoding to literal vector
Claus Gittinger <cg@exept.de>
parents:
4146
diff
changeset
|
1151 |
family := literalEncoding at:2. |
10b461a37e26
added encoding to literal vector
Claus Gittinger <cg@exept.de>
parents:
4146
diff
changeset
|
1152 |
face := literalEncoding at:3. |
10b461a37e26
added encoding to literal vector
Claus Gittinger <cg@exept.de>
parents:
4146
diff
changeset
|
1153 |
style := literalEncoding at:4. |
10b461a37e26
added encoding to literal vector
Claus Gittinger <cg@exept.de>
parents:
4146
diff
changeset
|
1154 |
size := literalEncoding at:5. |
5169 | 1155 |
"/ the following kludge is for backward compatibility |
1156 |
"/ do not cleanup !! |
|
4297
10b461a37e26
added encoding to literal vector
Claus Gittinger <cg@exept.de>
parents:
4146
diff
changeset
|
1157 |
literalEncoding size > 5 ifTrue:[ |
5169 | 1158 |
literalEncoding size > 6 ifTrue:[ |
5185 | 1159 |
sizeUnit := literalEncoding at:7. |
1160 |
literalEncoding size > 7 ifTrue:[ |
|
1161 |
pixelSize := literalEncoding at:8. |
|
1162 |
]. |
|
5169 | 1163 |
]. |
5906 | 1164 |
encoding := literalEncoding at:6. |
4298 | 1165 |
] ifFalse:[ |
5906 | 1166 |
encoding := self class defaultEncoding. |
4297
10b461a37e26
added encoding to literal vector
Claus Gittinger <cg@exept.de>
parents:
4146
diff
changeset
|
1167 |
]. |
1740 | 1168 |
! |
1169 |
||
1170 |
literalArrayEncoding |
|
2436 | 1171 |
"return myself encoded as a literal array. |
1172 |
Must match to what is expected in #fromLiteralArrayEncoding:" |
|
1740 | 1173 |
|
4298 | 1174 |
|myName| |
1175 |
||
4532 | 1176 |
myName := self class name. |
5169 | 1177 |
"/ see comment in #fromLiteralArrayEncoding |
1178 |
"/ do not cleanup !! |
|
1179 |
(pixelSize isNil |
|
1180 |
and:[ encoding == #'iso8859-1' ]) ifTrue:[ |
|
4298 | 1181 |
^ Array |
1182 |
with:myName |
|
1183 |
with:family |
|
1184 |
with:face |
|
1185 |
with:style |
|
1186 |
with:size |
|
1187 |
]. |
|
5185 | 1188 |
(pixelSize isNil and:[self sizeUnit == #pt]) ifTrue:[ |
5169 | 1189 |
^ Array |
1190 |
with:myName |
|
1191 |
with:family |
|
1192 |
with:face |
|
1193 |
with:style |
|
1194 |
with:size |
|
1195 |
with:encoding |
|
1196 |
]. |
|
1740 | 1197 |
^ Array |
4298 | 1198 |
with:myName |
1740 | 1199 |
with:family |
1200 |
with:face |
|
1201 |
with:style |
|
1202 |
with:size |
|
4297
10b461a37e26
added encoding to literal vector
Claus Gittinger <cg@exept.de>
parents:
4146
diff
changeset
|
1203 |
with:encoding |
5185 | 1204 |
with:sizeUnit |
5169 | 1205 |
with:pixelSize |
1740 | 1206 |
! |
1207 |
||
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1208 |
on:aDevice |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1209 |
"given the receiver, return a device Font" |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1210 |
|
3623 | 1211 |
"/ send out a warning: #on: is typically used to create views |
1212 |
"/ operating on a model. |
|
1213 |
"/ Please use #onDevice: to avoid confusion. |
|
1214 |
||
1215 |
<resource:#obsolete> |
|
1216 |
||
1217 |
self obsoleteMethodWarning:'use #onDevice:'. |
|
3629 | 1218 |
^ self onDevice:aDevice. |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1219 |
! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1220 |
|
1497
697ac9b15962
added #onDevice: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
1277
diff
changeset
|
1221 |
onDevice:aDevice |
697ac9b15962
added #onDevice: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
1277
diff
changeset
|
1222 |
"given the receiver, return a device Font" |
697ac9b15962
added #onDevice: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
1277
diff
changeset
|
1223 |
|
5511
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
1224 |
|newFont| |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
1225 |
|
2980
409e9547a45c
ignore nil device in #onDevice:
Claus Gittinger <cg@exept.de>
parents:
2934
diff
changeset
|
1226 |
aDevice isNil ifTrue:[^ self]. |
5511
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
1227 |
newFont := Font |
3629 | 1228 |
family:family |
1229 |
face:face |
|
1230 |
style:style |
|
5185 | 1231 |
size:(sizeUnit == #px ifTrue:[pixelSize] ifFalse:[size]) |
1232 |
sizeUnit:sizeUnit |
|
5511
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
1233 |
encoding:encoding. |
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
1234 |
|
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
1235 |
newFont flags:flags. |
1497
697ac9b15962
added #onDevice: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
1277
diff
changeset
|
1236 |
|
5535 | 1237 |
"SR: |
1238 |
old code is commented below, |
|
1239 |
someone has forgotten to set the incoming argument device, |
|
1240 |
why using the device from the old font??? is this a mistake??? |
|
1241 |
at least the naming of this method wants a new font on given device...." |
|
1242 |
^ newFont onDevice:aDevice. |
|
1243 |
"/ ^ newFont onDevice:self graphicsDevice. |
|
5511
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
1244 |
|
bc18d5eb3527
Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents:
5441
diff
changeset
|
1245 |
"Created: 28.3.1997 / 16:09:30 / cg" |
1497
697ac9b15962
added #onDevice: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
1277
diff
changeset
|
1246 |
! |
697ac9b15962
added #onDevice: for protocol completeness.
Claus Gittinger <cg@exept.de>
parents:
1277
diff
changeset
|
1247 |
|
5169 | 1248 |
size:anotherSize |
1249 |
<resource: #obsolete> |
|
1250 |
||
109 | 1251 |
"return a font corresponding to the receiver, but with different size." |
1252 |
||
5169 | 1253 |
self obsoleteMethodWarning:'use #asSize:'. |
1254 |
||
109 | 1255 |
^ self class |
5169 | 1256 |
family:family |
1257 |
face:face |
|
1258 |
style:style |
|
5185 | 1259 |
size:anotherSize |
1260 |
sizeUnit:#pt |
|
5169 | 1261 |
encoding:encoding |
109 | 1262 |
! ! |
1263 |
||
2544 | 1264 |
!FontDescription methodsFor:'displaying'! |
1265 |
||
1266 |
displayOpaqueString:aString from:index1 to:index2 x:x y:y in:aGC |
|
3663 | 1267 |
"display a partial string at some position in aGC. |
1268 |
- display part of a string, drawing both fore- and background pixels" |
|
2544 | 1269 |
|
3663 | 1270 |
self displayString:aString from:index1 to:index2 x:x y:y in:aGC opaque:true |
2544 | 1271 |
! |
1272 |
||
1273 |
displayOpaqueString:aString x:x y:y in:aGC |
|
1274 |
"display a string at some position in aGC." |
|
1275 |
||
1276 |
self displayOpaqueString:aString from:1 to:aString size x:x y:y in:aGC |
|
1277 |
! |
|
1278 |
||
1279 |
displayString:aString from:index1 to:index2 x:x y:y in:aGC |
|
1280 |
"display a partial string at some position in aGC." |
|
1281 |
||
3663 | 1282 |
self displayString:aString from:index1 to:index2 x:x y:y in:aGC opaque:false |
1283 |
! |
|
1284 |
||
1285 |
displayString:aString from:index1 to:index2 x:x y:y in:aGC opaque:opaque |
|
1286 |
"display a partial string at some position in aGC." |
|
1287 |
||
2544 | 1288 |
self subclassResponsibility |
1289 |
! |
|
1290 |
||
6467 | 1291 |
displayString:aString from:index1 to:index2 x:x0 y:y0 in:aGC opaque:opaque maxWidth:maxWidth |
1292 |
"redefined for subclasses that do not implement maxWidth" |
|
1293 |
||
1294 |
self displayString:aString from:index1 to:index2 x:x0 y:y0 in:aGC opaque:opaque |
|
1295 |
! |
|
1296 |
||
2544 | 1297 |
displayString:aString x:x y:y in:aGC |
1298 |
"display a string at some position in aGC." |
|
1299 |
||
1300 |
self displayString:aString from:1 to:aString size x:x y:y in:aGC |
|
1301 |
||
1302 |
! ! |
|
1303 |
||
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1304 |
!FontDescription methodsFor:'errors'! |
109 | 1305 |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1306 |
errorNoDevice |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1307 |
"a query was made for device-specific info" |
109 | 1308 |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1309 |
" |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1310 |
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
|
1311 |
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
|
1312 |
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
|
1313 |
associated to a device. |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1314 |
You should always use |
3159 | 1315 |
font := font on:someDevice |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1316 |
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
|
1317 |
" |
3159 | 1318 |
self error:'query device independent font for device specific info' |
1319 |
||
1320 |
"Modified: / 27.1.2000 / 16:55:05 / stefan" |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1321 |
! ! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1322 |
|
3785 | 1323 |
!FontDescription methodsFor:'getting a device font'! |
1324 |
||
1325 |
onDevice:aDevice ifAbsent:exceptionBlock |
|
1326 |
"create a new Font representing the same font as |
|
1327 |
myself on aDevice. This does NOT try to look for existing |
|
1328 |
or replacement fonts (i.e. can be used to get physical fonts)." |
|
1329 |
||
1330 |
|newFont id| |
|
1331 |
||
1332 |
"ask that device for the font" |
|
5166 | 1333 |
id := aDevice |
1334 |
getFontWithFamily:family |
|
1335 |
face:face |
|
1336 |
style:style |
|
5185 | 1337 |
size:(sizeUnit == #px ifTrue:[pixelSize] ifFalse:[size]) |
1338 |
sizeUnit:sizeUnit |
|
5166 | 1339 |
encoding:encoding. |
3785 | 1340 |
id isNil ifTrue:[ |
1341 |
"oops did not work - (device has no such font)" |
|
1342 |
||
1343 |
^ exceptionBlock value |
|
1344 |
]. |
|
1345 |
||
1346 |
newFont := (Font basicNew) |
|
1347 |
setFamily:family |
|
1348 |
face:face |
|
1349 |
style:style |
|
5185 | 1350 |
size:(sizeUnit == #px ifTrue:[pixelSize] ifFalse:[size]) |
1351 |
sizeUnit:sizeUnit |
|
3785 | 1352 |
encoding:encoding |
1353 |
device:aDevice. |
|
1354 |
newFont setFontId:id. |
|
1355 |
newFont getFontInfos. |
|
1356 |
aDevice registerFont:newFont. |
|
1357 |
^ newFont |
|
1358 |
! ! |
|
1359 |
||
1618 | 1360 |
!FontDescription methodsFor:'printing & storing'! |
1361 |
||
3991 | 1362 |
printOn:aStream |
1363 |
"append a user-friendly representation of the receiver to aStream" |
|
1364 |
||
1365 |
aStream nextPutAll:self userFriendlyName |
|
1366 |
! |
|
1367 |
||
1618 | 1368 |
userFriendlyName |
1369 |
"return a user-friendly printed representation of the receiver" |
|
1370 |
||
1371 |
|nm| |
|
1372 |
||
6197 | 1373 |
nm := family ? 'nil font family'. |
1618 | 1374 |
face notNil ifTrue:[ |
1375 |
nm := nm , '-', face. |
|
1376 |
]. |
|
1377 |
style notNil ifTrue:[ |
|
1378 |
nm := nm , '-', style. |
|
1379 |
]. |
|
1380 |
size notNil ifTrue:[ |
|
6330 | 1381 |
nm := nm , '-', size printString,'pt'. |
6329 | 1382 |
] ifFalse:[ |
1383 |
pixelSize notNil ifTrue:[ |
|
1384 |
nm := nm , '-', pixelSize printString,'px'. |
|
1385 |
]. |
|
1618 | 1386 |
]. |
1387 |
encoding notNil ifTrue:[ |
|
3991 | 1388 |
nm := nm , '(', encoding , ')'. |
1618 | 1389 |
]. |
1390 |
^ nm |
|
1391 |
||
1392 |
" |
|
1393 |
View defaultFont userFriendlyName |
|
1394 |
Button defaultFont userFriendlyName |
|
1395 |
" |
|
1396 |
||
1397 |
"Modified: 20.4.1996 / 23:25:36 / cg" |
|
1398 |
"Created: 19.4.1997 / 18:09:25 / cg" |
|
1399 |
! ! |
|
1400 |
||
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1401 |
!FontDescription methodsFor:'queries'! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1402 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1403 |
bold |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1404 |
"return true, if the receiver is a bold font - |
1585 | 1405 |
Added for st-80 compatibility." |
1406 |
||
1407 |
"/ 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
|
1408 |
|
1275 | 1409 |
^ face = 'bold' |
1410 |
||
1585 | 1411 |
"Modified: 11.4.1997 / 21:31:25 / cg" |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1412 |
! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1413 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1414 |
boldness |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1415 |
"return the boldness of the characters in this font 0 .. 1 - |
1275 | 1416 |
Added for st-80 compatibility" |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1417 |
|
1585 | 1418 |
"/ Currently, this implementation is a dirty hack and will be changed soon. |
1419 |
||
1420 |
face = 'roman' ifTrue:[^ 0.5]. |
|
1421 |
face = 'normal' ifTrue:[^ 0.5]. |
|
1422 |
face = 'bold' ifTrue:[^ 0.75]. |
|
1423 |
face = 'light' ifTrue:[^ 0.25]. |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1424 |
^ 0.5 |
1275 | 1425 |
|
1585 | 1426 |
"Modified: 11.4.1997 / 21:31:31 / cg" |
1275 | 1427 |
! |
1428 |
||
1429 |
color |
|
1430 |
"return the default color in which this font is to be rendered. |
|
1431 |
Added for st-80 compatibility. |
|
1432 |
For now always black." |
|
1433 |
||
1434 |
^ Color black |
|
1435 |
||
1436 |
"Created: 25.1.1997 / 02:59:15 / cg" |
|
1437 |
"Modified: 25.1.1997 / 03:02:14 / cg" |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1438 |
! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1439 |
|
2544 | 1440 |
existsOn:aDevice |
1441 |
"return true, if the recevier is available on aDevice; |
|
1442 |
false otherwise. This is a kludge method; its better to |
|
1443 |
ask a device for its available fonts and use this info ... |
|
1444 |
Notice, that if you simply use a font by name, the system |
|
1445 |
will automatically take a replacement font." |
|
1446 |
||
3629 | 1447 |
^ ((Font |
1448 |
family:family |
|
1449 |
face:face |
|
1450 |
style:style |
|
5185 | 1451 |
size:(sizeUnit == #px ifTrue:[pixelSize] ifFalse:[size]) |
1452 |
sizeUnit:sizeUnit |
|
3629 | 1453 |
encoding:encoding) onDevice:aDevice ifAbsent:nil) notNil |
2544 | 1454 |
! |
1455 |
||
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1456 |
fullName |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1457 |
^ nil |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1458 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1459 |
"Created: 23.2.1996 / 00:45:45 / cg" |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1460 |
! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1461 |
|
5644 | 1462 |
hasOverlappingCharacters |
1463 |
"answer true, if this is a windows font where characters overlap" |
|
1464 |
||
1465 |
^ flags notNil and:[ flags bitTest:OverlappingCharactersFlag ]. |
|
1466 |
||
1467 |
"Created: / 08-11-2010 / 13:16:51 / cg" |
|
1468 |
! |
|
1469 |
||
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1470 |
italic |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1471 |
"return true if this is an italic font - |
1585 | 1472 |
Added for st-80 compatibility" |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1473 |
|
1585 | 1474 |
"/ Currently, this implementation is a dirty hack and will be changed soon. |
1475 |
||
1476 |
style = 'italic' ifTrue:[^ true]. |
|
3246 | 1477 |
style = 'oblique' ifTrue:[^ true]. |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1478 |
^ false |
1275 | 1479 |
|
1585 | 1480 |
"Modified: 11.4.1997 / 21:31:42 / cg" |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1481 |
! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1482 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1483 |
serif |
1275 | 1484 |
"return true, if this font has serifs. |
1585 | 1485 |
Added for st-80 compatibility" |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1486 |
|
1585 | 1487 |
"/ 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
|
1488 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1489 |
family = 'Times' ifTrue:[^ true]. |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1490 |
family = 'times' ifTrue:[^ true]. |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1491 |
^ false. |
1275 | 1492 |
|
1585 | 1493 |
"Modified: 11.4.1997 / 21:31:51 / cg" |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1494 |
! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1495 |
|
3265 | 1496 |
size |
1497 |
"return the size, a number" |
|
1498 |
||
1499 |
^ size |
|
1500 |
! |
|
1501 |
||
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1502 |
species |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1503 |
^ Font |
1275 | 1504 |
! |
1505 |
||
1506 |
underline |
|
1507 |
"return true if this is an underlined font - |
|
1508 |
Added for st-80 compatibility |
|
1509 |
(always false here)" |
|
1510 |
||
1511 |
^ false |
|
1512 |
||
1513 |
"Created: 25.1.1997 / 02:58:30 / cg" |
|
1514 |
"Modified: 25.1.1997 / 03:01:12 / cg" |
|
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1515 |
! ! |
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1516 |
|
2544 | 1517 |
!FontDescription methodsFor:'queries-dimensions'! |
1518 |
||
1519 |
ascent |
|
1520 |
"return the ascent - the number of pixels above the baseLine." |
|
1521 |
||
1522 |
^ self subclassResponsibility |
|
1523 |
! |
|
1524 |
||
1525 |
ascentOn:aDevice |
|
1526 |
"return the ascent - the number of pixels above the baseLine." |
|
1527 |
||
1528 |
^ (self onDevice:aDevice) ascent |
|
1529 |
! |
|
1530 |
||
1531 |
descent |
|
1532 |
"return the descent - the number of pixels below the baseLine." |
|
1533 |
||
1534 |
^ self subclassResponsibility |
|
1535 |
! |
|
1536 |
||
1537 |
descentOn:aDevice |
|
1538 |
"return the ascent - the number of pixels above the baseLine." |
|
1539 |
||
1540 |
^ (self onDevice:aDevice) descent |
|
1541 |
||
1542 |
||
1543 |
! |
|
1544 |
||
1545 |
height |
|
1546 |
"return the height - the number of pixels above plus below the baseLine." |
|
1547 |
||
1548 |
^ self subclassResponsibility |
|
1549 |
! |
|
1550 |
||
1551 |
heightOf:aString |
|
1552 |
"return the height of the given string. |
|
1553 |
Here, assume the characters are of constant height" |
|
1554 |
||
1555 |
^ self height |
|
1556 |
! |
|
1557 |
||
1558 |
heightOf:aString on:aDevice |
|
1559 |
"return the height of the given string on the given device." |
|
1560 |
||
1561 |
^ (self onDevice:aDevice) heightOf:aString |
|
1562 |
! |
|
1563 |
||
1564 |
heightOn:aDevice |
|
1565 |
"return the height - the number of pixels above PLUS below the baseLine." |
|
1566 |
||
1567 |
^ (self onDevice:aDevice) height |
|
1568 |
! |
|
1569 |
||
1570 |
isFixedWidth |
|
1571 |
"return true, if this is a fixed pitch font (i.e. all characters |
|
1572 |
are of the same width)" |
|
1573 |
||
1574 |
self subclassResponsibility |
|
1575 |
! |
|
1576 |
||
1577 |
maxAscent |
|
1578 |
"return the fonts maximum-ascent (i.e. the maximum of all characters); |
|
1579 |
That is the number of units (usually pixels) above the baseline." |
|
1580 |
||
1581 |
^ self subclassResponsibility |
|
1582 |
||
1583 |
! |
|
1584 |
||
6313 | 1585 |
maxCode |
1586 |
"return the biggest UCS code in font. |
|
1587 |
Dummy for now" |
|
1588 |
||
1589 |
^ 16rFFFF |
|
1590 |
! |
|
1591 |
||
2544 | 1592 |
maxDescent |
1593 |
"return the fonts maximum-descent (i.e. the maximum of all characters); |
|
1594 |
That is the number of units (usually pixels) below the baseline." |
|
1595 |
||
1596 |
^ self subclassResponsibility |
|
1597 |
||
1598 |
! |
|
1599 |
||
1600 |
maxHeight |
|
1601 |
"return the fonts characters maximum height; |
|
1602 |
That is the number of units (usually pixels)." |
|
1603 |
||
1604 |
^ self maxAscent + self maxDescent |
|
1605 |
||
1606 |
! |
|
1607 |
||
1608 |
maxWidth |
|
1609 |
"return the fonts maximum-width character (i.e. the maximum of all characters); |
|
1610 |
That is a number of units (usually pixels)." |
|
1611 |
||
1612 |
^ self subclassResponsibility |
|
1613 |
||
1614 |
! |
|
1615 |
||
6313 | 1616 |
minCode |
1617 |
"return the smallest UCS code in font. |
|
1618 |
Dummy for now" |
|
1619 |
||
1620 |
^ 0 |
|
1621 |
! |
|
1622 |
||
2544 | 1623 |
width |
1624 |
"return the fonts characters width; |
|
1625 |
That is a number of units (usually pixels). |
|
1626 |
For variable pitch fonts, the width of the space character is returned. |
|
1627 |
For fixed fonts, this is the same as minWidth or maxWidth (or any character). |
|
1628 |
The receiver must be associated to a device, for this query to be legal." |
|
1629 |
||
1630 |
^ self widthOf:' ' |
|
1631 |
||
1632 |
"Modified: 30.4.1996 / 16:43:45 / cg" |
|
1633 |
||
1634 |
||
1635 |
! |
|
1636 |
||
1637 |
widthOf:aString |
|
1638 |
"return the width of a string" |
|
1639 |
||
3667 | 1640 |
^ self widthOf:aString string from:1 to:aString size |
2544 | 1641 |
|
1642 |
||
1643 |
! |
|
1644 |
||
1645 |
widthOf:aString from:start to:stop |
|
1646 |
"return the width of a sub string" |
|
1647 |
||
1648 |
^ self subclassResponsibility |
|
1649 |
||
1650 |
||
1651 |
! |
|
1652 |
||
1653 |
widthOf:aString from:start to:stop on:aDevice |
|
1654 |
"return the width of a sub string. |
|
1655 |
Here, assume that this fonts width is device independent." |
|
1656 |
||
1657 |
^ (self onDevice:aDevice) widthOf:aString from:start to:stop |
|
1658 |
||
1659 |
||
1660 |
! |
|
1661 |
||
1662 |
widthOf:aString on:aDevice |
|
1663 |
"return the width of a string" |
|
1664 |
||
1665 |
^ (self onDevice:aDevice) widthOf:aString |
|
1666 |
||
1667 |
||
1668 |
||
1669 |
||
1670 |
||
1671 |
! |
|
1672 |
||
1673 |
widthOn:aDevice |
|
1674 |
"return the width on some device; that is the width of the space character |
|
1675 |
(which is the width of any character iff the font is a fixed pitch font)" |
|
1676 |
||
1677 |
^ (self onDevice:aDevice) width |
|
1678 |
! ! |
|
1679 |
||
456 | 1680 |
!FontDescription methodsFor:'queries-encoding'! |
1681 |
||
1682 |
isASCII |
|
576 | 1683 |
"return true, if the receivers encoding is |
1684 |
compatible with ascii (i.e. its ascii or iso8859)" |
|
1685 |
||
456 | 1686 |
^ (encoding == #iso8859) or:[encoding == #ascii] |
1687 |
||
1688 |
"Created: 24.2.1996 / 22:47:30 / cg" |
|
576 | 1689 |
"Modified: 20.4.1996 / 23:20:01 / cg" |
456 | 1690 |
! |
1691 |
||
1692 |
isISO8859 |
|
576 | 1693 |
"return true, if the receivers encoding is |
1694 |
compatible with iso8859 (i.e. iso8859)" |
|
1695 |
||
456 | 1696 |
^ encoding == #iso8859 |
1697 |
||
1698 |
"Created: 24.2.1996 / 22:47:12 / cg" |
|
576 | 1699 |
"Modified: 20.4.1996 / 23:20:13 / cg" |
456 | 1700 |
! |
1701 |
||
1702 |
isJIS |
|
576 | 1703 |
"return true, if the receivers encoding is |
1704 |
compatible with jis (i.e. jisXXX)" |
|
1705 |
||
456 | 1706 |
^ (encoding startsWith:'jis') |
1707 |
||
1708 |
"Created: 24.2.1996 / 22:47:47 / cg" |
|
576 | 1709 |
"Modified: 20.4.1996 / 23:20:30 / cg" |
456 | 1710 |
! ! |
1711 |
||
6105 | 1712 |
!FontDescription methodsFor:'testing'! |
1713 |
||
1714 |
isAlienFont |
|
1715 |
"answer true, if this is an alien font which does not have a device representation" |
|
1716 |
||
1717 |
^ true |
|
1718 |
! |
|
1719 |
||
6260 | 1720 |
isAntialiasedFont |
1721 |
"answer true, if this is an antialiased font (currently Xft only)" |
|
1722 |
||
1723 |
^ (flags ? 0) bitTest:AntialiasedFlag |
|
1724 |
! |
|
1725 |
||
6105 | 1726 |
isGenericFont |
1727 |
"answer true, if this is a pseudo font" |
|
1728 |
||
6260 | 1729 |
^ (flags ? 0) bitTest:GenericFlag |
1730 |
! |
|
1731 |
||
1732 |
isOutlineFont |
|
1733 |
"answer true, if this is an outline font (currently Xft only)" |
|
1734 |
||
1735 |
^ (flags ? 0) bitTest:OutlineFlag |
|
6105 | 1736 |
! |
1737 |
||
1738 |
isScaledFont |
|
6956 | 1739 |
"answer true, if this is a scalable font" |
6260 | 1740 |
|
6956 | 1741 |
^ (size = 0) or:[flags notNil and:[flags bitTest:ScalableFlag]] |
6320 | 1742 |
! |
1743 |
||
1744 |
isXftFont |
|
1745 |
"return false here; to be redefined in subclass(es)" |
|
1746 |
||
1747 |
^ false |
|
6105 | 1748 |
! ! |
1749 |
||
1275 | 1750 |
!FontDescription class methodsFor:'documentation'! |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1751 |
|
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1752 |
version |
6956 | 1753 |
^ '$Header$' |
5441 | 1754 |
! |
1755 |
||
1756 |
version_CVS |
|
6956 | 1757 |
^ '$Header$' |
437
a81ce3a8038b
return dummy default encoding & fullNames
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1758 |
! ! |
3785 | 1759 |
|
5991 | 1760 |
|
1275 | 1761 |
FontDescription initialize! |