|
|
Class: CompoundFont
Object
|
+--FontDescription
|
+--CompoundFont
- Package:
- stx:libview
- Category:
- Graphics-Support
- Version:
- rev:
?
date: ? ?
- user: ?
- file: ? directory: libview
- module: stx stc-classLibrary: libview
- Author:
- Claus Gittinger
a CompountFont is a font which consists of character glyphs from multiple
other (base-)fonts; for each character code, an individual font may be given.
This has been mostly added to allow for non-EURO fonts to be used with ST/X,
by defining a mixedFont, which has an EURO-glyph at the desired character
position.
Do not hardCode usage of MixedFonts into your application, since they
might disappear in the future (when Unicode support has been fully
implemented in ST/X, and Unicode fonts are generally available under X).
I.e. to use these fonts, add appropriate setup to the styleSheet,
or private.rc and use those fonts transparently.
[Instance variables:]
baseFont <Font> fallback (default-) font
characterToFontMapping <Dictionary> maps characters to a fonts
[class variables:]
Font
BitmapFont
DeviceDrawable
GraphicsContext
a mixed font; all vowels are displayed in times;
the rest in helvetica.
|font top list|
font := CompoundFont basedOn:(Font family:'courier' size:18).
#($a $e $i $o $u) do:[:char |
font glyphAt:char putFont:(Font family:'times' size:18).
].
top := ScrollableView forView:(list := EditTextView new).
list font:font.
list list:#('a' 'z' 'aaa' 'zzz' 'azaz' 'zaza' 'aa' 'az' 'za' 'hello' 'abcdef' 'xyz').
top extent:200@200.
top open.
|
|font font2 top list|
font := CompoundFont basedOn:(Font family:'courier' size:18).
font2 := Font family:'times' size:24.
#($a $e $i $o $u $j) do:[:char |
font glyphAt:char putFont:font2.
font glyphAt:char asUppercase putFont:font2.
].
top := ScrollableView forView:(list := EditTextView new).
list font:font.
list list:#('hello' 'abcdefghijklmnopqrstuvwxyz' 'xyz'
'HELLO' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'XYZ').
top extent:200@200.
top open.
|
a mixed font; the dollar character is replaced by the european
EURO symbol; the rest is helvetica
(this is a hack - we really need a resizable font for this):
|font baseFont euroGlyph glyphs euroFont top list|
baseFont := Font family:'helvetica' size:12.
baseFont := baseFont onDevice:Display.
glyphs := Array new:256.
euroGlyph := Form
width:12
height:16
fromArray:#(
2r00000000 2r00000000
2r00000000 2r00000000
2r00000000 2r00000000
2r00000111 2r11000000
2r00001000 2r00100000
2r00010000 2r00000000
2r01111111 2r10000000
2r00010000 2r00000000
2r01111111 2r10000000
2r00010000 2r00000000
2r00001000 2r00100000
2r00000111 2r11000000
2r00000000 2r00000000
2r00000000 2r00000000
2r00000000 2r00000000
2r00000000 2r00000000
).
glyphs at:($$ asciiValue+1) put:euroGlyph.
euroFont := BitmapFont new glyphs:glyphs.
euroFont setAscent:(baseFont ascent).
euroFont setDescent:(baseFont descent).
font := CompoundFont basedOn:baseFont.
font glyphAt:$$ putFont:euroFont.
top := ScrollableView forView:(list := EditTextView new).
list font:font.
list list:#('100 $' '193 DM').
top extent:200@200.
top open.
|
|