0
|
1 |
"
|
6
|
2 |
COPYRIGHT (c) 1992 by Claus Gittinger
|
71
|
3 |
All Rights Reserved
|
0
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
|
109
|
13 |
FontDescription subclass:#Font
|
|
14 |
instanceVariableNames:'device fontId replacementFont
|
71
|
15 |
ascent descent height width isFixedWidth
|
|
16 |
minWidth maxWidth'
|
23
|
17 |
classVariableNames:'Lobby Replacements'
|
0
|
18 |
poolDictionaries:''
|
|
19 |
category:'Graphics-Support'
|
|
20 |
!
|
|
21 |
|
|
22 |
Font comment:'
|
6
|
23 |
COPYRIGHT (c) 1992 by Claus Gittinger
|
71
|
24 |
All Rights Reserved
|
54
|
25 |
|
149
|
26 |
$Header: /cvs/stx/stx/libview/Font.st,v 1.20 1995-05-19 13:41:39 claus Exp $
|
0
|
27 |
'!
|
|
28 |
|
|
29 |
!Font class methodsFor:'documentation'!
|
|
30 |
|
46
|
31 |
copyright
|
|
32 |
"
|
|
33 |
COPYRIGHT (c) 1992 by Claus Gittinger
|
71
|
34 |
All Rights Reserved
|
46
|
35 |
|
|
36 |
This software is furnished under a license and may be used
|
|
37 |
only in accordance with the terms of that license and with the
|
|
38 |
inclusion of the above copyright notice. This software may not
|
|
39 |
be provided or otherwise made available to, or used by, any
|
|
40 |
other person. No title to or ownership of the software is
|
|
41 |
hereby transferred.
|
|
42 |
"
|
|
43 |
!
|
0
|
44 |
|
46
|
45 |
version
|
|
46 |
"
|
149
|
47 |
$Header: /cvs/stx/stx/libview/Font.st,v 1.20 1995-05-19 13:41:39 claus Exp $
|
46
|
48 |
"
|
|
49 |
!
|
0
|
50 |
|
46
|
51 |
documentation
|
|
52 |
"
|
|
53 |
Font represents fonts in a device independent manner; after being
|
|
54 |
created using 'Font family:family face:face style:style size:size',
|
|
55 |
the returned font is not associated to a specific device.
|
0
|
56 |
|
46
|
57 |
To get a device font, any font can be sent the message
|
|
58 |
'aFont on:aDevice' which returns an instance of Font which is
|
|
59 |
associated to a device (it returns the receiver, if that is already
|
|
60 |
associated to that device).
|
0
|
61 |
|
46
|
62 |
For proper operation, each graphics operation working with fonts
|
|
63 |
must get a device font before doing the draw.
|
|
64 |
Most draw methods in DeviceDrawable do that automatically for you,
|
|
65 |
before doing the draw.
|
|
66 |
|
81
|
67 |
However, some operations require explicit conversion to a device font
|
|
68 |
before being allowed. For example, a query for a fonts height (in device
|
|
69 |
units) can only be done if the font being asked is associated to
|
|
70 |
a device (which should be clear, since a 'courier-roman-12' font may
|
|
71 |
have a different number of pixels on a 75dpi vs. a 120dpi display. And
|
|
72 |
a total number of device units on a 600dpi laser printer.
|
|
73 |
Thus, to query a font for its height (or ascent, or descent, or width),
|
|
74 |
use something like:
|
|
75 |
|
|
76 |
myFont := Font family:'courier' ... size:12.
|
|
77 |
...
|
|
78 |
|
|
79 |
'want to know its height on the Display'
|
|
80 |
|
|
81 |
h := (myFont on:Display) height.
|
|
82 |
|
|
83 |
|
|
84 |
'want to know its height on a printer'
|
|
85 |
|
|
86 |
h := (myFont on:aPrinter) height.
|
|
87 |
|
|
88 |
Keep in mind, that each device is free to think in whatever units it
|
|
89 |
likes - a display may return units of pixels, a postscript printer may
|
|
90 |
think in (fractions of) inches, a dot matrix printer may think in dots.
|
|
91 |
Also, notice that currently only graphic displays are really supported;
|
|
92 |
printer devices are being developped and may or may not be in the current
|
|
93 |
system.
|
|
94 |
|
46
|
95 |
Sometimes, a font cannot be represented on a device, then a replacement
|
|
96 |
font is chosen and kept in the replacementFont instance variable.
|
0
|
97 |
|
46
|
98 |
Instance variables:
|
|
99 |
|
109
|
100 |
family <String> the fonts family ('courier', 'helvetica' etc)
|
|
101 |
face <String> the fonts face ('bold', 'medium' etc)
|
|
102 |
style <String> the fonts style ('roman', 'italic', 'oblique')
|
|
103 |
size <String> the fonts size (not in pixels)
|
|
104 |
encoding <Symbol> the fonts encoding (usually #iso8859)
|
0
|
105 |
|
109
|
106 |
device <Object> the device the font is associated to, or nil
|
|
107 |
fontId <Object> the id of the font on that device, or nil
|
|
108 |
replacement <Font> the replacement font or nil
|
0
|
109 |
|
109
|
110 |
ascent <Integer> the fonts ascent in device units on device
|
|
111 |
descent <Integer> the fonts descent in device units on device
|
|
112 |
height <Integer> the fonts height in device units on device
|
|
113 |
width <Integer> the character width in device units on device
|
|
114 |
(for variable fonts, its the width of a space)
|
|
115 |
isFixedWidth <Boolean> true if font is a fixed width font
|
|
116 |
minWidth <Integer> width of the smallest-width character in
|
|
117 |
in device units on device
|
|
118 |
maxWidth <Integer> width of the largest-width character in
|
|
119 |
in device units on device
|
0
|
120 |
|
46
|
121 |
class variables:
|
0
|
122 |
|
109
|
123 |
Lobby <Registry> keeps track of all known fonts
|
46
|
124 |
|
109
|
125 |
Replacements <Dictionary> replacement fonts
|
46
|
126 |
"
|
0
|
127 |
! !
|
|
128 |
|
|
129 |
!Font class methodsFor:'initialization'!
|
|
130 |
|
|
131 |
initialize
|
|
132 |
"initialize the font tracking array"
|
|
133 |
|
23
|
134 |
Lobby isNil ifTrue:[
|
71
|
135 |
Lobby := Registry new.
|
0
|
136 |
|
71
|
137 |
"
|
|
138 |
want to be informed when returning from snapshot
|
|
139 |
"
|
|
140 |
ObjectMemory addDependent:self.
|
0
|
141 |
|
71
|
142 |
"
|
|
143 |
replacement handling is not yet finished
|
|
144 |
"
|
|
145 |
Replacements := Dictionary new.
|
|
146 |
|
|
147 |
Replacements at:'clean' put:'courier'.
|
|
148 |
Replacements at:'fixed' put:'courier'.
|
|
149 |
Replacements at:'new century schoolbook' put:'times'.
|
|
150 |
Replacements at:'lucida' put:'helvetica'.
|
|
151 |
Replacements at:'lucidabright' put:'helvetica'.
|
|
152 |
Replacements at:'lucidatypewriter' put:'courier'.
|
|
153 |
Replacements at:'charter' put:'times'.
|
|
154 |
Replacements at:'terminal' put:'courier'.
|
0
|
155 |
]
|
|
156 |
!
|
|
157 |
|
|
158 |
flushDeviceFonts
|
|
159 |
"unassign all fonts from their device"
|
|
160 |
|
115
|
161 |
Lobby do:[:aFont |
|
71
|
162 |
aFont restored.
|
|
163 |
Lobby changed:aFont
|
0
|
164 |
]
|
|
165 |
!
|
|
166 |
|
|
167 |
update:something
|
|
168 |
(something == #restarted) ifTrue:[
|
71
|
169 |
"
|
|
170 |
this is sent by ObjectMemory when restarting from
|
|
171 |
an image. All device specific information (especially device
|
|
172 |
handles) are now invalid and have to be flushed
|
|
173 |
"
|
|
174 |
self flushDeviceFonts
|
0
|
175 |
]
|
|
176 |
! !
|
|
177 |
|
|
178 |
!Font class methodsFor:'instance creation'!
|
|
179 |
|
|
180 |
family:familyString face:faceString style:styleString size:sizeNum encoding:encodingSym
|
|
181 |
"returns a font for given family, face, style, size and encoding.
|
71
|
182 |
The returned font is not associated to a specific device"
|
0
|
183 |
|
54
|
184 |
|family newFont|
|
0
|
185 |
|
|
186 |
(familyString at:1) isUppercase ifTrue:[
|
71
|
187 |
family := familyString asLowercase
|
0
|
188 |
] ifFalse:[
|
71
|
189 |
family := familyString
|
0
|
190 |
].
|
|
191 |
|
|
192 |
"look if this font is already known"
|
|
193 |
|
115
|
194 |
Lobby do:[:aFont |
|
71
|
195 |
(aFont family = family) ifTrue:[
|
|
196 |
(aFont face = faceString) ifTrue:[
|
|
197 |
(aFont style = styleString) ifTrue:[
|
|
198 |
(aFont size == sizeNum) ifTrue:[
|
|
199 |
(encodingSym isNil or:[aFont encoding == encodingSym]) ifTrue:[
|
|
200 |
^ aFont
|
|
201 |
]
|
|
202 |
]
|
|
203 |
]
|
|
204 |
]
|
|
205 |
]
|
0
|
206 |
].
|
12
|
207 |
newFont := self basicNew setFamily:familyString
|
71
|
208 |
face:faceString
|
|
209 |
style:styleString
|
|
210 |
size:sizeNum
|
|
211 |
encoding:encodingSym
|
|
212 |
device:nil.
|
23
|
213 |
Lobby register:newFont.
|
0
|
214 |
^ newFont
|
|
215 |
! !
|
|
216 |
|
|
217 |
!Font methodsFor:'instance release'!
|
|
218 |
|
71
|
219 |
shallowCopyForFinalization
|
|
220 |
|aCopy|
|
|
221 |
|
|
222 |
aCopy := self class basicNew.
|
|
223 |
aCopy setDevice:device fontId:fontId.
|
|
224 |
^ aCopy
|
|
225 |
!
|
|
226 |
|
0
|
227 |
disposed
|
|
228 |
"some Font has been collected - tell it to the x-server"
|
|
229 |
|
|
230 |
fontId notNil ifTrue:[
|
71
|
231 |
device releaseFont:fontId.
|
127
|
232 |
fontId := nil
|
0
|
233 |
]
|
|
234 |
! !
|
|
235 |
|
|
236 |
!Font methodsFor:'getting a device font'!
|
|
237 |
|
|
238 |
on:aDevice
|
|
239 |
"create a new Font representing the same font as
|
|
240 |
myself on aDevice; if one already exists, return the one."
|
|
241 |
|
23
|
242 |
|newFont id rep|
|
0
|
243 |
|
|
244 |
"if I am already assigned to that device ..."
|
|
245 |
(device == aDevice) ifTrue:[^ self].
|
|
246 |
|
|
247 |
"first look if not already there"
|
115
|
248 |
Lobby do:[:aFont |
|
71
|
249 |
(aDevice == aFont device) ifTrue:[
|
|
250 |
(size == aFont size) ifTrue:[
|
|
251 |
(family = aFont family) ifTrue:[
|
|
252 |
(face = aFont face) ifTrue:[
|
|
253 |
(style = aFont style) ifTrue:[
|
89
|
254 |
(encoding isNil or:[encoding == aFont encoding]) ifTrue:[
|
71
|
255 |
^ aFont
|
|
256 |
]
|
|
257 |
]
|
|
258 |
]
|
|
259 |
]
|
|
260 |
]
|
|
261 |
]
|
0
|
262 |
].
|
|
263 |
|
|
264 |
"ask that device for the font"
|
|
265 |
id := aDevice getFontWithFamily:family face:face style:style size:size encoding:encoding.
|
|
266 |
id isNil ifTrue:[
|
71
|
267 |
"oops did not work - (device has no such font)"
|
0
|
268 |
|
71
|
269 |
rep := self replacementFontOn:aDevice.
|
|
270 |
device isNil ifTrue:[
|
|
271 |
device := aDevice.
|
|
272 |
replacementFont := rep.
|
|
273 |
Lobby changed:self.
|
|
274 |
^ self
|
|
275 |
].
|
|
276 |
newFont := (self class basicNew)
|
|
277 |
setFamily:family face:face style:style size:size encoding:encoding device:aDevice.
|
|
278 |
newFont setReplacementFont:rep.
|
|
279 |
Lobby register:newFont.
|
|
280 |
^ newFont
|
0
|
281 |
].
|
|
282 |
|
|
283 |
"receiver was not associated - do it now"
|
|
284 |
device isNil ifTrue:[
|
71
|
285 |
device := aDevice.
|
|
286 |
fontId := id.
|
0
|
287 |
|
71
|
288 |
self getFontInfos.
|
|
289 |
Lobby changed:self.
|
|
290 |
^ self
|
0
|
291 |
].
|
|
292 |
|
|
293 |
"receiver was already associated to another device - need a new font"
|
12
|
294 |
newFont := (self class basicNew) setFamily:family
|
71
|
295 |
face:face
|
|
296 |
style:style
|
|
297 |
size:size
|
|
298 |
encoding:encoding
|
|
299 |
device:aDevice.
|
0
|
300 |
newFont setFontId:id.
|
|
301 |
newFont getFontInfos.
|
23
|
302 |
Lobby register:newFont.
|
0
|
303 |
^ newFont
|
|
304 |
!
|
|
305 |
|
|
306 |
replacementFontOn:aDevice
|
12
|
307 |
"return a replacement font for the receiver - this is needed, if
|
|
308 |
an image is restored on another type of display, or one which has
|
|
309 |
a different set of fonts."
|
0
|
310 |
|
|
311 |
|id f alternative|
|
|
312 |
|
144
|
313 |
alternative := Replacements at:family ifAbsent:nil.
|
0
|
314 |
alternative notNil ifTrue:[
|
71
|
315 |
id := aDevice getFontWithFamily:alternative
|
|
316 |
face:face
|
|
317 |
style:style
|
|
318 |
size:size
|
|
319 |
encoding:encoding.
|
144
|
320 |
].
|
|
321 |
id notNil ifTrue:[
|
149
|
322 |
('replaced ' , family , '- with ' , alternative , '-font') errorPrintNL.
|
144
|
323 |
] ifFalse:[
|
|
324 |
id := aDevice getDefaultFont.
|
149
|
325 |
('replaced ' , family , '- with default-font') errorPrintNL.
|
0
|
326 |
].
|
|
327 |
id isNil ifTrue:[
|
71
|
328 |
"oops did not work - this is a serious an error"
|
|
329 |
self error:'cannot get default font'.
|
|
330 |
^ nil
|
0
|
331 |
].
|
|
332 |
f := self class basicNew.
|
|
333 |
f setDevice:aDevice fontId:id.
|
|
334 |
f getFontInfos.
|
23
|
335 |
Lobby register:f.
|
0
|
336 |
^ f
|
|
337 |
! !
|
|
338 |
|
|
339 |
!Font methodsFor:'private'!
|
|
340 |
|
|
341 |
setFamily:familyString face:faceString style:styleString size:sizeNum encoding:encodingSym device:aDevice
|
|
342 |
family := familyString.
|
|
343 |
face := faceString.
|
|
344 |
style := styleString.
|
|
345 |
size := sizeNum.
|
|
346 |
encoding := encodingSym.
|
|
347 |
device := aDevice
|
|
348 |
!
|
|
349 |
|
2
|
350 |
restored
|
0
|
351 |
device := nil.
|
|
352 |
fontId := nil.
|
|
353 |
replacementFont := nil
|
|
354 |
!
|
|
355 |
|
|
356 |
setReplacementFont:aFont
|
|
357 |
replacementFont := aFont
|
|
358 |
!
|
|
359 |
|
|
360 |
setDevice:aDevice
|
|
361 |
device := aDevice
|
|
362 |
!
|
|
363 |
|
|
364 |
setFontId:aFontId
|
|
365 |
fontId := aFontId
|
|
366 |
!
|
|
367 |
|
|
368 |
setDevice:aDevice fontId:aFontId
|
|
369 |
device := aDevice.
|
|
370 |
fontId := aFontId
|
|
371 |
!
|
|
372 |
|
|
373 |
getFontInfos
|
|
374 |
replacementFont isNil ifTrue:[
|
71
|
375 |
ascent := device ascentOf:fontId.
|
|
376 |
descent := device descentOf:fontId.
|
|
377 |
height := descent + ascent.
|
|
378 |
width := device widthOf:' ' inFont:fontId.
|
|
379 |
minWidth := device minWidthOfFont:fontId.
|
|
380 |
maxWidth := device maxWidthOfFont:fontId.
|
0
|
381 |
] ifFalse:[
|
71
|
382 |
ascent := replacementFont ascent.
|
|
383 |
descent := replacementFont descent.
|
|
384 |
height := descent + ascent.
|
|
385 |
width := replacementFont width.
|
|
386 |
minWidth := replacementFont minWidth.
|
|
387 |
maxWidth := replacementFont maxWidth.
|
0
|
388 |
].
|
|
389 |
isFixedWidth := minWidth == maxWidth
|
|
390 |
! !
|
|
391 |
|
|
392 |
!Font methodsFor:'accessing'!
|
|
393 |
|
|
394 |
fontId
|
|
395 |
"return the device-dependent font-id"
|
|
396 |
|
|
397 |
^ fontId
|
|
398 |
!
|
|
399 |
|
|
400 |
device
|
|
401 |
"return the device I am on"
|
|
402 |
|
|
403 |
^ device
|
|
404 |
! !
|
|
405 |
|
|
406 |
!Font methodsFor:'queries'!
|
|
407 |
|
|
408 |
isFixedWidth
|
|
409 |
"return true, if all characters have same width (as in courier"
|
|
410 |
|
|
411 |
device isNil ifTrue:[
|
71
|
412 |
self errorNoDevice
|
0
|
413 |
].
|
148
|
414 |
replacementFont notNil ifTrue:[
|
|
415 |
^ replacementFont isFixedWidth
|
|
416 |
].
|
0
|
417 |
^ isFixedWidth
|
|
418 |
!
|
|
419 |
|
|
420 |
height
|
|
421 |
"return the characters maximum height;
|
|
422 |
That is the number of units (usually pixels) on the device"
|
|
423 |
|
|
424 |
device isNil ifTrue:[
|
71
|
425 |
self errorNoDevice
|
0
|
426 |
].
|
148
|
427 |
replacementFont notNil ifTrue:[
|
|
428 |
^ replacementFont height
|
|
429 |
].
|
0
|
430 |
^ height
|
|
431 |
!
|
|
432 |
|
|
433 |
width
|
|
434 |
"return the characters width;
|
|
435 |
That is the number of units (usually pixels) on the device.
|
|
436 |
For variable pitch fonts, the width of the space character is returned"
|
|
437 |
|
|
438 |
device isNil ifTrue:[
|
71
|
439 |
self errorNoDevice
|
0
|
440 |
].
|
148
|
441 |
replacementFont notNil ifTrue:[
|
|
442 |
^ replacementFont width
|
|
443 |
].
|
0
|
444 |
^ width
|
|
445 |
!
|
|
446 |
|
|
447 |
minWidth
|
|
448 |
"return the width of the smallest character;
|
|
449 |
if the receiver is a fixed width font its the width of every character"
|
|
450 |
|
|
451 |
device isNil ifTrue:[
|
71
|
452 |
self errorNoDevice
|
0
|
453 |
].
|
148
|
454 |
replacementFont notNil ifTrue:[
|
|
455 |
^ replacementFont minWidth
|
|
456 |
].
|
0
|
457 |
^ minWidth
|
|
458 |
!
|
|
459 |
|
|
460 |
maxWidth
|
|
461 |
"return the width of the widest character;
|
|
462 |
if the receiver is a fixed width font its the width of every character"
|
|
463 |
|
|
464 |
device isNil ifTrue:[
|
71
|
465 |
self errorNoDevice
|
0
|
466 |
].
|
148
|
467 |
replacementFont notNil ifTrue:[
|
|
468 |
^ replacementFont maxWidth
|
|
469 |
].
|
0
|
470 |
^ maxWidth
|
|
471 |
!
|
|
472 |
|
|
473 |
ascent
|
|
474 |
"return the font-ascent i.e. the maximum of all characters;
|
|
475 |
That is the number of units (usually pixels) above the baseline"
|
|
476 |
|
|
477 |
device isNil ifTrue:[
|
71
|
478 |
self errorNoDevice
|
0
|
479 |
].
|
148
|
480 |
replacementFont notNil ifTrue:[
|
|
481 |
^ replacementFont ascent
|
|
482 |
].
|
0
|
483 |
^ ascent
|
|
484 |
!
|
|
485 |
|
|
486 |
descent
|
|
487 |
"return the font-descent i.e. the maximum of all characters;
|
|
488 |
That is the number of units (usually pixels) below the baseline"
|
|
489 |
|
|
490 |
device isNil ifTrue:[
|
71
|
491 |
self errorNoDevice
|
0
|
492 |
].
|
148
|
493 |
replacementFont notNil ifTrue:[
|
|
494 |
^ replacementFont descent
|
|
495 |
].
|
0
|
496 |
^ descent
|
|
497 |
!
|
|
498 |
|
71
|
499 |
widthOf:textOrString
|
0
|
500 |
"return the width (device specific) of the argument;
|
|
501 |
the argument may be a String or some Text;
|
|
502 |
in the later case the width of the longest line in the text is returned"
|
|
503 |
|
|
504 |
|this max|
|
|
505 |
|
|
506 |
device isNil ifTrue:[
|
71
|
507 |
self errorNoDevice.
|
|
508 |
^ 0
|
0
|
509 |
].
|
|
510 |
replacementFont notNil ifTrue:[
|
71
|
511 |
^ replacementFont widthOf:textOrString
|
0
|
512 |
].
|
|
513 |
|
71
|
514 |
(textOrString isString) ifTrue:[
|
|
515 |
isFixedWidth ifFalse:[
|
|
516 |
^ device widthOf:textOrString inFont:fontId
|
|
517 |
].
|
|
518 |
^ width * textOrString size
|
0
|
519 |
].
|
|
520 |
|
|
521 |
max := 0.
|
|
522 |
isFixedWidth ifFalse:[
|
71
|
523 |
textOrString do:[:line |
|
|
524 |
line notNil ifTrue:[
|
|
525 |
this := device widthOf:line inFont:fontId.
|
|
526 |
(this > max) ifTrue:[max := this]
|
|
527 |
]
|
|
528 |
].
|
|
529 |
^ max
|
0
|
530 |
].
|
|
531 |
|
71
|
532 |
textOrString do:[:lineString |
|
|
533 |
this := lineString size.
|
|
534 |
(this > max) ifTrue:[max := this]
|
0
|
535 |
].
|
|
536 |
^ max * width
|
|
537 |
!
|
|
538 |
|
|
539 |
widthOf:aString from:start to:stop
|
|
540 |
"return the width of a substring"
|
|
541 |
|
|
542 |
device isNil ifTrue:[
|
71
|
543 |
self errorNoDevice.
|
|
544 |
^ 0
|
0
|
545 |
].
|
|
546 |
replacementFont notNil ifTrue:[
|
71
|
547 |
^ replacementFont widthOf:aString from:start to:stop
|
0
|
548 |
].
|
|
549 |
(stop < start) ifTrue:[^ 0].
|
|
550 |
isFixedWidth ifFalse:[
|
71
|
551 |
^ device widthOf:aString from:start to:stop inFont:fontId
|
0
|
552 |
].
|
|
553 |
^ (stop - start + 1) * width
|
|
554 |
! !
|
|
555 |
|
148
|
556 |
!Font methodsFor:'displaying'!
|
|
557 |
|
|
558 |
displayString:aString x:x y:y in:aGC
|
|
559 |
"this is only called for fonts which have a nil fontId,
|
|
560 |
and therefore use the replacementFont"
|
|
561 |
|
|
562 |
replacementFont isNil ifTrue:[
|
|
563 |
'FONT: oops should not happen' errorPrintNL.
|
|
564 |
^ self
|
|
565 |
].
|
|
566 |
aGC font:replacementFont.
|
|
567 |
aGC displayString:aString x:x y:y
|
|
568 |
!
|
|
569 |
|
|
570 |
displayString:aString from:index1 to:index2 x:x y:y in:aGC
|
|
571 |
"this is only called for fonts which have a nil fontId,
|
|
572 |
and therefore use the replacementFont"
|
|
573 |
|
|
574 |
replacementFont isNil ifTrue:[
|
|
575 |
'FONT: oops should not happen' errorPrintNL.
|
|
576 |
^ self
|
|
577 |
].
|
|
578 |
aGC font:replacementFont.
|
|
579 |
aGC displayString:aString from:index1 to:index2 x:x y:y
|
|
580 |
! !
|
|
581 |
|
2
|
582 |
!Font methodsFor:'st-80 queries'!
|
|
583 |
|
|
584 |
fixedWidth
|
|
585 |
"return true, if this font is a fixed width font -
|
|
586 |
for st-80 compatibility"
|
|
587 |
|
|
588 |
^ self isFixedWidth
|
|
589 |
!
|
|
590 |
|
|
591 |
pixelSize
|
|
592 |
"return the height of the font in pixels -
|
|
593 |
for st-80 compatibility"
|
|
594 |
|
|
595 |
^ self height
|
|
596 |
! !
|
|
597 |
|
0
|
598 |
!Font methodsFor:'printing & storing'!
|
|
599 |
|
109
|
600 |
printOn:aStream
|
46
|
601 |
face isNil ifTrue:[
|
109
|
602 |
aStream nextPutAll:('a ' , family , '-Font')
|
46
|
603 |
].
|
109
|
604 |
aStream nextPutAll:('a ' , family , '-' ,
|
|
605 |
face , '-' ,
|
|
606 |
style , '-' ,
|
|
607 |
size printString , '-Font')
|
0
|
608 |
!
|
|
609 |
|
109
|
610 |
storeOn:aStream
|
|
611 |
"append a character sequence to the argument, aStream from which the
|
|
612 |
receiver can be reconstructed using readFrom:."
|
0
|
613 |
|
109
|
614 |
aStream nextPutAll:'(Font family:'. family storeOn:aStream.
|
|
615 |
aStream nextPutAll:' face:'. face storeOn:aStream.
|
|
616 |
aStream nextPutAll:' style:'. style storeOn:aStream.
|
|
617 |
aStream nextPutAll:' size:'. size storeOn:aStream.
|
|
618 |
aStream nextPutAll:' encoding:'. encoding storeOn:aStream.
|
|
619 |
aStream nextPut:$)
|
|
620 |
|
|
621 |
"
|
|
622 |
(Font family:'helvetica' size:10) storeString
|
|
623 |
"
|
0
|
624 |
! !
|
2
|
625 |
|
|
626 |
!Font methodsFor: 'binary storage'!
|
|
627 |
|
|
628 |
readBinaryContentsFrom: stream manager: manager
|
|
629 |
"tell the newly restored Font about restoration"
|
|
630 |
|
|
631 |
super readBinaryContentsFrom: stream manager: manager.
|
|
632 |
self restored
|
|
633 |
! !
|