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