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