eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'BitmapFont':

Home

everywhere
www.exept.de
for:
[back]

Class: BitmapFont


Inheritance:

   Object
   |
   +--FontDescription
      |
      +--BitmapFont

Package:
stx:libview
Category:
Graphics-Support
Version:
rev: ? date: ? ?
user: ?
file: ? directory: libview
module: stx stc-classLibrary: libview
Author:
Claus Gittinger

Description:


This class demonstrates, that it is possible to define your own
renderers for fonts - you could even write a class which reads 
a truetype font from a ttf file and display those 
(maybe someone finds the time to do this 
 and provides the code to the public domain ?)

Here is a simple & sample implementation of private bitmap fonts;
Glyphs for each character are stored in the instance variable
'characterBitmaps'.
Some sample glyphs can be created with the class' sampleGlyphs method.
The required protocol is found in drawing and accessing.


Related information:

    Font
    GraphicsContext

Class protocol:

instance creation
o  new


Examples:


a label showing characters in a new bitmap font:


  |font l|

  font := (BitmapFont new glyphs:(BitmapFont sampleGlyhps)).
  font setAscent:13; setDescent:3.

  l := Label new.
  l font:font.
  l label:'aazzazaz'.
  l open.
a label showing characters in a new smily font:


  |font l|

  font := (BitmapFont new glyphs:(BitmapFont smilyGlyhps)).
  font setAscent:16; setDescent:0.

  l := Label new.
  l font:font.
  l label:'aabbaaa'.
  l open.
demonstrate, that this font can be used in listViews just as any other font: (well, missing character glyphs are blanked)


  |font top list|

  font := (BitmapFont new glyphs:(BitmapFont sampleGlyhps)).
  font setAscent:13; setDescent:3.

  top := ScrollableView forView:(list := SelectionInListView new).
  list font:font.
  list list:#('a' 'z' 'aaa' 'zzz' 'azaz' 'zaza' 'aa' 'az' 'za' 'hello' 'abcdef' 'xyz').
  top extent:200@200.
  top open.
demonstrate, that this font can be used in textViews just as any other font: (well, missing character glyphs are blanked)


  |font top list|

  font := (BitmapFont new glyphs:(BitmapFont sampleGlyhps)).
  font setAscent:13; setDescent:3.

  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.
another clock display:


  |glyphs f label|

  glyphs := Array new:256.
  glyphs 
      at:($0 asciiValue + 1) 
      put:(Image fromFile:'../../goodies/bitmaps/xpmBitmaps/misc_numbers/led0.xpm').
  glyphs 
      at:($1 asciiValue + 1) 
      put:(Image fromFile:'../../goodies/bitmaps/xpmBitmaps/misc_numbers/led1.xpm').
  glyphs 
      at:($2 asciiValue + 1) 
      put:(Image fromFile:'../../goodies/bitmaps/xpmBitmaps/misc_numbers/led2.xpm').
  glyphs 
      at:($3 asciiValue + 1) 
      put:(Image fromFile:'../../goodies/bitmaps/xpmBitmaps/misc_numbers/led3.xpm').
  glyphs 
      at:($4 asciiValue + 1) 
      put:(Image fromFile:'../../goodies/bitmaps/xpmBitmaps/misc_numbers/led4.xpm').
  glyphs 
      at:($5 asciiValue + 1) 
      put:(Image fromFile:'../../goodies/bitmaps/xpmBitmaps/misc_numbers/led5.xpm').
  glyphs 
      at:($6 asciiValue + 1) 
      put:(Image fromFile:'../../goodies/bitmaps/xpmBitmaps/misc_numbers/led6.xpm').
  glyphs 
      at:($7 asciiValue + 1) 
      put:(Image fromFile:'../../goodies/bitmaps/xpmBitmaps/misc_numbers/led7.xpm').
  glyphs 
      at:($8 asciiValue + 1) 
      put:(Image fromFile:'../../goodies/bitmaps/xpmBitmaps/misc_numbers/led8.xpm').
  glyphs 
      at:($9 asciiValue + 1) 
      put:(Image fromFile:'../../goodies/bitmaps/xpmBitmaps/misc_numbers/led9.xpm').
  glyphs 
      at:($: asciiValue + 1) 
      put:(Image fromFile:'../../goodies/bitmaps/xpmBitmaps/misc_numbers/ledCol.xpm').

  f := BitmapFont new glyphs:glyphs.

  label := Label new label:(Time now printString).
  label font:f.
  label open


ST/X 6.1.1; WebServer 1.620 at exept:8081; Wed, 23 May 2012 07:56:26 GMT