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