BitmapFont.st
author Michael Beyl <mb@exept.de>
Wed, 24 Jul 2002 20:48:36 +0200
changeset 3673 49e583135bf2
parent 3672 d627bfa7b9a2
child 4039 e4a7687582d6
permissions -rw-r--r--
it works !
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1088
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
 COPYRIGHT (c) 1994 by Claus Gittinger
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
	      All Rights Reserved
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
 This software is furnished under a license and may be used
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 hereby transferred.
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
 This is a demo example:
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
 THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTOR ``AS IS'' AND
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
 ARE DISCLAIMED.  IN NO EVENT SHALL THE CONTRIBUTOR BE LIABLE
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
 SUCH DAMAGE.
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
"
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
3659
26bd2ef5f0ed on -> onDevice
Michael Beyl <mb@exept.de>
parents: 2545
diff changeset
    27
"{ Package: 'stx:libview' }"
26bd2ef5f0ed on -> onDevice
Michael Beyl <mb@exept.de>
parents: 2545
diff changeset
    28
1088
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
FontDescription subclass:#BitmapFont
3672
d627bfa7b9a2 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
    30
	instanceVariableNames:'characterBitmaps ascent descent maxWidth maxHeight'
1088
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
	classVariableNames:''
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
	poolDictionaries:''
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
	category:'Graphics-Support'
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
!
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
!BitmapFont class methodsFor:'documentation'!
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
copyright
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
"
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
 COPYRIGHT (c) 1994 by Claus Gittinger
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
	      All Rights Reserved
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
 This software is furnished under a license and may be used
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
 only in accordance with the terms of that license and with the
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
 inclusion of the above copyright notice.   This software may not
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
 be provided or otherwise made available to, or used by, any
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
 other person.  No title to or ownership of the software is
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
 hereby transferred.
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
 This is a demo example:
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
 THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTOR ``AS IS'' AND
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
 ARE DISCLAIMED.  IN NO EVENT SHALL THE CONTRIBUTOR BE LIABLE
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
 SUCH DAMAGE.
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
"
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
!
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
documentation
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
"
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
    This class demonstrates, that it is possible to define your own
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
    renderers for fonts - you could even write a class which reads 
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
    a truetype font from a ttf file and display those 
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
    (maybe someone finds the time to do this 
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
     and provides the code to the public domain ?)
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
    Here is a simple & sample implementation of private bitmap fonts;
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
    Glyphs for each character are stored in the instance variable
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
    'characterBitmaps'.
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
    Some sample glyphs can be created with the class' sampleGlyphs method.
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
    The required protocol is found in drawing and accessing.
1154
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
    79
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
    80
    [author:]
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
    81
        Claus Gittinger
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
    82
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
    83
    [see also:]
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
    84
        Font GraphicsContext
1088
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
"
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
!
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
examples
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
"
2545
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
    90
  a label showing characters in a new bitmap font:
1154
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
    91
                                                                [exBegin]
1088
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
    |font l|
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
    font := (BitmapFont new glyphs:(BitmapFont sampleGlyhps)).
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
    font setAscent:13; setDescent:3.
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
    l := Label new.
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
    l font:font.
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
    l label:'aazzazaz'.
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
    l open.
1154
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   101
                                                                [exEnd]
1088
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
  a label showing characters in a new smily font:
1154
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   105
                                                                [exBegin]
1088
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
    |font l|
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
    font := (BitmapFont new glyphs:(BitmapFont smilyGlyhps)).
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
    font setAscent:16; setDescent:0.
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
    l := Label new.
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
    l font:font.
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
    l label:'aabbaaa'.
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
    l open.
1154
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   115
                                                                [exEnd]
1088
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
2545
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   118
  demonstrate, that this font can be used in listViews just as any other font:
1088
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
  (well, missing character glyphs are blanked)
1154
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   120
                                                                [exBegin]
1088
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
    |font top list|
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
    font := (BitmapFont new glyphs:(BitmapFont sampleGlyhps)).
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
    font setAscent:13; setDescent:3.
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
    top := ScrollableView forView:(list := SelectionInListView new).
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
    list font:font.
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
    list list:#('a' 'z' 'aaa' 'zzz' 'azaz' 'zaza' 'aa' 'az' 'za' 'hello' 'abcdef' 'xyz').
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
    top extent:200@200.
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
    top open.
1154
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   131
                                                                [exEnd]
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   132
1088
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
  demonstrate, that this font can be used in textViews just as any other font:
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
  (well, missing character glyphs are blanked)
1154
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   136
                                                                [exBegin]
1088
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
    |font top list|
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
    font := (BitmapFont new glyphs:(BitmapFont sampleGlyhps)).
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
    font setAscent:13; setDescent:3.
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
    top := ScrollableView forView:(list := EditTextView new).
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
    list font:font.
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
    list list:#('a' 'z' 'aaa' 'zzz' 'azaz' 'zaza' 'aa' 'az' 'za' 'hello' 'abcdef' 'xyz').
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
    top extent:200@200.
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
    top open.
1154
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   147
                                                                [exEnd]
1088
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
"
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
! !
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
!BitmapFont class methodsFor:'instance creation'!
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
new
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
    |newFont|
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
    newFont := super new 
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
		  family:'private' 
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
		  face:nil
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
		  style:nil
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
		  size:nil
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
		  encoding:nil. 
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
    ^ newFont
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
    "
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
     BitmapFont new glyphs:(self sampleGlyhps).
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   167
    "
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   168
! !
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
!BitmapFont class methodsFor:'private'!
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   172
sampleGlyhps
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
    "return the bitmap array for a sample font
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
     (only contains glyphs for $a and $z)"
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
    |characters|
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
    characters := Array new:256.
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
    characters 
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
	at:(Character space asciiValue + 1) 
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
	put:(Form 
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
		width:16 
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
		height:16 
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
		fromArray:#[2r00000000 2r00000000
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
			    2r00000000 2r00000000
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
			    2r00000000 2r00000000
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
			    2r00000000 2r00000000
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   188
			    2r00000000 2r00000000
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   189
			    2r00000000 2r00000000
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
			    2r00000000 2r00000000
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
			    2r00000000 2r00000000
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
			    2r00000000 2r00000000
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
			    2r00000000 2r00000000
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
			    2r00000000 2r00000000
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
			    2r00000000 2r00000000
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
			    2r00000000 2r00000000
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
			    2r00000000 2r00000000
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   198
			    2r00000000 2r00000000
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   199
			    2r00000000 2r00000000]).
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
    characters 
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
	at:($a asciiValue + 1) 
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
	put:(Form 
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
		width:16 
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
		height:16 
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
		fromArray:#[2r00000000 2r00000000
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   207
			    2r00000000 2r00000000
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
			    2r00000000 2r00000000
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
			    2r00011111 2r11111000
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
			    2r00011111 2r11111000
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
			    2r00011000 2r00011000
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
			    2r00011000 2r00011000
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
			    2r00011000 2r00011000
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
			    2r00011000 2r00011000
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
			    2r00011000 2r00011000
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
			    2r00011000 2r00011000
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
			    2r00011111 2r11111110
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
			    2r00011111 2r11111110
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
			    2r00000000 2r00000000
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
			    2r00000000 2r00000000
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
			    2r00000000 2r00000000]).
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   223
    characters 
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   224
	at:($z asciiValue + 1) 
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
	put:(Form 
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
		width:16 
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
		height:16 
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
		fromArray:#[2r00000000 2r00000000
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
			    2r00000000 2r00000000
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
			    2r00000000 2r00000000
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
			    2r00011111 2r11111000
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
			    2r00011111 2r11111000
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   233
			    2r00000000 2r00110000
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   234
			    2r00000000 2r01100000
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
			    2r00011111 2r11111000
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   236
			    2r00011111 2r11111000
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   237
			    2r00000110 2r00000000
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   238
			    2r00001100 2r00000000
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   239
			    2r00011111 2r11111000
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   240
			    2r00011111 2r11111000
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   241
			    2r00000000 2r00000000
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
			    2r00000000 2r00000000
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   243
			    2r00000000 2r00000000]).
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   244
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   245
    ^ characters
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   246
!
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   247
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   248
smilyGlyhps
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   249
    "return the bitmap array for a smily font
2545
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   250
     (only contains glyphs for $a, $b and $c)"
1088
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   251
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   252
    |characters|
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   253
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   254
    characters := Array new:256.
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   255
    characters 
2545
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   256
        at:(Character space asciiValue + 1) 
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   257
        put:(Form 
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   258
                width:16 
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   259
                height:16 
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   260
                fromArray:#[2r00000000 2r00000000
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   261
                            2r00000000 2r00000000
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   262
                            2r00000000 2r00000000
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   263
                            2r00000000 2r00000000
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   264
                            2r00000000 2r00000000
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   265
                            2r00000000 2r00000000
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   266
                            2r00000000 2r00000000
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   267
                            2r00000000 2r00000000
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   268
                            2r00000000 2r00000000
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   269
                            2r00000000 2r00000000
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   270
                            2r00000000 2r00000000
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   271
                            2r00000000 2r00000000
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   272
                            2r00000000 2r00000000
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   273
                            2r00000000 2r00000000
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   274
                            2r00000000 2r00000000
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   275
                            2r00000000 2r00000000]).
1088
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   276
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   277
    characters 
2545
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   278
        at:($a asciiValue + 1) 
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   279
        put:(Form 
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   280
                width:16 
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   281
                height:16 
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   282
                fromArray:#[2r00000001 2r10000000
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   283
                            2r00001110 2r01110000
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   284
                            2r00011000 2r00011000
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   285
                            2r00100000 2r00000100
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   286
                            2r01100110 2r01100110
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   287
                            2r01000110 2r01100010
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   288
                            2r01000000 2r00000010
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   289
                            2r10000001 2r00000001
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   290
                            2r10000001 2r00000001
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   291
                            2r01001000 2r00010010
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   292
                            2r01001100 2r00110010
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   293
                            2r01100111 2r11100110
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   294
                            2r00100001 2r10000100
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   295
                            2r00011000 2r00011000
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   296
                            2r00001110 2r01110000
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   297
                            2r00000001 2r10000000]).
1088
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   298
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   299
    characters 
2545
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   300
        at:($b asciiValue + 1) 
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   301
        put:(Form 
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   302
                width:16 
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   303
                height:16 
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   304
                fromArray:#[2r00000001 2r10000000
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   305
                            2r00001110 2r01110000
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   306
                            2r00011000 2r00011000
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   307
                            2r00100000 2r00000100
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   308
                            2r01100110 2r01100110
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   309
                            2r01000110 2r01100010
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   310
                            2r01000000 2r00000010
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   311
                            2r10000001 2r00000001
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   312
                            2r10000001 2r00000001
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   313
                            2r01000000 2r00000010
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   314
                            2r01000001 2r10000010
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   315
                            2r01100010 2r01000110
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   316
                            2r00100010 2r01000100
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   317
                            2r00011000 2r00011000
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   318
                            2r00001110 2r01110000
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   319
                            2r00000001 2r10000000]).
1088
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   320
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   321
    characters 
2545
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   322
        at:($c asciiValue + 1) 
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   323
        put:(Form 
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   324
                width:16 
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   325
                height:16 
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   326
                fromArray:#[2r00000001 2r10000000
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   327
                            2r00001110 2r01110000
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   328
                            2r00011000 2r00011000
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   329
                            2r00100000 2r00000100
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   330
                            2r01100110 2r01100110
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   331
                            2r01000110 2r01100010
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   332
                            2r01000000 2r00000010
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   333
                            2r10000001 2r00000001
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   334
                            2r10000001 2r00000001
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   335
                            2r01000000 2r00000010
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   336
                            2r01000001 2r10000010
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   337
                            2r01100011 2r11000110
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   338
                            2r00100011 2r11000100
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   339
                            2r00011001 2r10011000
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   340
                            2r00001110 2r01110000
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   341
                            2r00000001 2r10000000]).
1088
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   342
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   343
    ^ characters
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   344
! !
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   345
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   346
!BitmapFont methodsFor:'accessing'!
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   347
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   348
glyphs:aGlyphArray
1154
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   349
    "set the glyphs array; that is the collection of
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   350
     bitmaps - one for each character"
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   351
1088
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   352
    characterBitmaps := aGlyphArray.
2545
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   353
3672
d627bfa7b9a2 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   354
    maxWidth := maxHeight := 0. 
d627bfa7b9a2 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   355
    aGlyphArray do:[:glyph | glyph notNil ifTrue:[
d627bfa7b9a2 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   356
                                 maxWidth := maxWidth max:glyph width.
d627bfa7b9a2 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   357
                                 maxHeight := maxHeight max:glyph height.
d627bfa7b9a2 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   358
                             ]
d627bfa7b9a2 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   359
                   ]
1088
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   360
!
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   361
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   362
setAscent:aNumber
1154
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   363
    "set the fonts ascent; that is the number of pixels
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   364
     above the fonts baseline"
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   365
1088
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   366
    ascent := aNumber.
3672
d627bfa7b9a2 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   367
    maxHeight := self maxAscent + (self maxDescent max:0)
1088
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   368
!
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   369
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   370
setDescent:aNumber
1154
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   371
    "set the fonts ascent; that is the number of pixels
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   372
     below the fonts baseline"
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   373
1088
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   374
    descent := aNumber.
3672
d627bfa7b9a2 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   375
    maxHeight := self maxAscent + (self maxDescent max:0).
d627bfa7b9a2 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   376
1088
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   377
! !
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   378
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   379
!BitmapFont methodsFor:'drawing'!
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   380
3663
d40999d6cd1e refactored
Michael Beyl <mb@exept.de>
parents: 3659
diff changeset
   381
displayString:aString from:index1 to:index2 x:x0 y:y in:aGC opaque:opaque
1154
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   382
    "required protocol for new fonts:
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   383
     - display part of a string, drawing foreground pixels only"
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   384
1088
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   385
    |x|
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   386
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   387
    x := x0.
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   388
    index1 to:index2 do:[:index |
3663
d40999d6cd1e refactored
Michael Beyl <mb@exept.de>
parents: 3659
diff changeset
   389
        self drawCharacter:(aString at:index) asciiValue in:aGC x:x y:y opaque:opaque.
1154
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   390
        x := x + (self widthOfCharacter:(aString at:index) asciiValue)
1088
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   391
    ]
1154
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   392
! !
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   393
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   394
!BitmapFont methodsFor:'private - drawing'!
1088
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   395
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   396
drawCharacter:ascii in:aGC x:x y:y opaque:opaque
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   397
    |glyph|
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   398
2545
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   399
    glyph := characterBitmaps at:(ascii + 1) ifAbsent:nil.
1088
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   400
    glyph isNil ifTrue:[^ self].
3673
49e583135bf2 it works !
Michael Beyl <mb@exept.de>
parents: 3672
diff changeset
   401
    aGC displayForm:glyph x:x y:y-glyph height+descent opaque:opaque
1088
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   402
! !
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   403
1154
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   404
!BitmapFont methodsFor:'private - queries'!
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   405
3672
d627bfa7b9a2 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   406
glyphOfCharacter:ascii
1154
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   407
    "return the height of a specific character"
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   408
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   409
    |glyph|
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   410
2545
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   411
    glyph := characterBitmaps at:(ascii + 1) ifAbsent:nil.
1154
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   412
    glyph isNil ifTrue:[
2545
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   413
        glyph := characterBitmaps at:(Character space asciiValue + 1).
1154
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   414
    ].
3672
d627bfa7b9a2 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   415
    ^ glyph
d627bfa7b9a2 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   416
!
d627bfa7b9a2 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   417
d627bfa7b9a2 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   418
heightOfCharacter:ascii
d627bfa7b9a2 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   419
    "return the height of a specific character"
d627bfa7b9a2 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   420
d627bfa7b9a2 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   421
    |glyph|
d627bfa7b9a2 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   422
d627bfa7b9a2 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   423
    glyph := self glyphOfCharacter:ascii.
1154
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   424
    glyph isNil ifTrue:[^ 0].
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   425
    ^ glyph height
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   426
!
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   427
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   428
widthOfCharacter:ascii
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   429
    "return the width of a specific character"
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   430
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   431
    |glyph|
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   432
3672
d627bfa7b9a2 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   433
    glyph := self glyphOfCharacter:ascii.
1154
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   434
    glyph isNil ifTrue:[^ 0].
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   435
    ^ glyph width
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   436
! !
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   437
1088
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   438
!BitmapFont methodsFor:'queries'!
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   439
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   440
ascent
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   441
    "return the ascent - the number of pixels above the baseLine"
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   442
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   443
    ^ ascent
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   444
!
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   445
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   446
ascentOn:aDevice
2545
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   447
    "return the descent - the number of pixels below the baseLine.
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   448
     Since I am not device dependent, return my pixel ascent."
1088
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   449
2545
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   450
    ^ descent
1088
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   451
!
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   452
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   453
descent
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   454
    "return the descent - the number of pixels below the baseLine"
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   455
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   456
    ^ descent
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   457
!
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   458
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   459
descentOn:aDevice
2545
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   460
    "return the descent - the number of pixels below the baseLine.
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   461
     Since I am not device dependent, return my pixel descent."
1088
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   462
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   463
    ^ descent
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   464
!
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   465
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   466
height
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   467
    "return the height - the height in pixels of the highest character"
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   468
3672
d627bfa7b9a2 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   469
    ^ self maxHeight
1088
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   470
!
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   471
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   472
heightOf:aString
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   473
    "return the height - the height in pixels of the highest character"
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   474
3672
d627bfa7b9a2 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   475
    ^ self maxHeight.
1088
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   476
!
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   477
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   478
heightOn:aDevice
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   479
    "return the height - the height in pixels of the highest character"
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   480
3672
d627bfa7b9a2 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   481
    ^ self maxHeight.
1088
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   482
!
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   483
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   484
isFixedWidth
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   485
    "return true if all of the fonts characters are equal in
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   486
     width."
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   487
3664
85de01ef2853 fixed #isFixedFont
Michael Beyl <mb@exept.de>
parents: 3663
diff changeset
   488
    |w|
85de01ef2853 fixed #isFixedFont
Michael Beyl <mb@exept.de>
parents: 3663
diff changeset
   489
85de01ef2853 fixed #isFixedFont
Michael Beyl <mb@exept.de>
parents: 3663
diff changeset
   490
    characterBitmaps do:[:glyph | |wHere|
85de01ef2853 fixed #isFixedFont
Michael Beyl <mb@exept.de>
parents: 3663
diff changeset
   491
                                glyph notNil ifTrue:[
85de01ef2853 fixed #isFixedFont
Michael Beyl <mb@exept.de>
parents: 3663
diff changeset
   492
                                    wHere := glyph width.  
85de01ef2853 fixed #isFixedFont
Michael Beyl <mb@exept.de>
parents: 3663
diff changeset
   493
                                    w isNil 
85de01ef2853 fixed #isFixedFont
Michael Beyl <mb@exept.de>
parents: 3663
diff changeset
   494
                                        ifTrue:[ w := wHere ]
85de01ef2853 fixed #isFixedFont
Michael Beyl <mb@exept.de>
parents: 3663
diff changeset
   495
                                        ifFalse:[ w ~~ wHere ifTrue:[^ false]]
85de01ef2853 fixed #isFixedFont
Michael Beyl <mb@exept.de>
parents: 3663
diff changeset
   496
                                ]
85de01ef2853 fixed #isFixedFont
Michael Beyl <mb@exept.de>
parents: 3663
diff changeset
   497
                        ].
1088
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   498
    ^ true
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   499
!
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   500
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   501
maxAscent
1154
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   502
    "return the maximum ascent; thats the ascent of the highest
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   503
     character"
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   504
3672
d627bfa7b9a2 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   505
    ascent isNil ifTrue:[
d627bfa7b9a2 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   506
        ascent := (self maxHeight - descent) max:0
d627bfa7b9a2 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   507
    ].
1088
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   508
    ^ ascent.
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   509
!
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   510
1154
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   511
maxDescent
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   512
    "return the maximum descent; thats the descent of the highest
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   513
     character"
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   514
3672
d627bfa7b9a2 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   515
    descent isNil ifTrue:[
d627bfa7b9a2 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   516
        descent := (self maxHeight - ascent) max:0
d627bfa7b9a2 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   517
    ].
1154
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   518
    ^ descent.
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   519
!
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   520
1088
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   521
maxHeight
1154
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   522
    "return the maximum height; thats the height of the highest
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   523
     character"
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   524
3672
d627bfa7b9a2 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   525
    ^ maxHeight
1088
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   526
!
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   527
1154
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   528
maxWidth 
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   529
    "return the maximum width - the width of the widest character in pixels"
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   530
3672
d627bfa7b9a2 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   531
    ^ maxWidth
1154
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   532
!
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   533
2545
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   534
onDevice:aDevice
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   535
    "return a device representation of the receiver.
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   536
     Since I am device independent, return the receiver."
1088
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   537
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   538
    ^ self
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   539
!
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   540
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   541
width 
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   542
    "return the width - the average width in pixels"
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   543
3672
d627bfa7b9a2 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   544
    ^ self maxWidth
1088
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   545
!
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   546
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   547
widthOf:aString from:start to:stop
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   548
    "return the width of a substring"
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   549
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   550
    |sumW|
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   551
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   552
    (stop < start) ifTrue:[^ 0].
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   553
    sumW := 0.
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   554
    start to:stop do:[:index |
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   555
	sumW := sumW + (self widthOfCharacter:(aString at:index) asciiValue) 
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   556
    ].
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   557
    ^ sumW
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   558
!
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   559
1154
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   560
widthOf:aString from:startIndex to:endIndex on:aDevice
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   561
    "return the width of a substring"
1088
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   562
1154
07bc33341696 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   563
    ^ self widthOf:aString from:startIndex to:endIndex
1088
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   564
!
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   565
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   566
widthOn:aDevice
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   567
    "return the width - the average width in pixels"
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   568
3672
d627bfa7b9a2 *** empty log message ***
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   569
    ^ self maxWidth
1088
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   570
! !
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   571
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   572
!BitmapFont class methodsFor:'documentation'!
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   573
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   574
version
3673
49e583135bf2 it works !
Michael Beyl <mb@exept.de>
parents: 3672
diff changeset
   575
    ^ '$Header: /cvs/stx/stx/libview/BitmapFont.st,v 1.8 2002-07-24 18:48:36 mb Exp $'
1088
136b1b7996a0 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   576
! !