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