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