CompoundFont.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Wed, 06 Sep 2017 10:04:18 +0200
branchjv
changeset 8180 25149dfd68e0
parent 7608 0f8d92a9c1e7
child 7946 6ed11ca75246
permissions -rw-r--r--
Build files: removed a bunch of make rules for long-dead unsupported systems ...in order to unify and simplify the build. If a need to support this ancient systems arose, these hacks may ni longer be needed (due to new versions of tools) or the hacks would have to be written again (better) or retrieved from SCM (worse). Time will show.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2547
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
     1
"
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
     2
 COPYRIGHT (c) 1999 by eXept Software AG
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
     3
              All Rights Reserved
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
     4
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
     5
 This software is furnished under a license and may be used
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
     6
 only in accordance with the terms of that license and with the
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
     8
 be provided or otherwise made available to, or used by, any
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
     9
 other person.  No title to or ownership of the software is
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
    10
 hereby transferred.
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
    11
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
    12
 This is a demo example:
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
    13
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
    14
 THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTOR ``AS IS'' AND
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
    15
 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
    16
 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
    17
 ARE DISCLAIMED.  IN NO EVENT SHALL THE CONTRIBUTOR BE LIABLE
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
    18
 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
    19
 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
    20
 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
    21
 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
    22
 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
    23
 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
    24
 SUCH DAMAGE.
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
    25
"
7608
0f8d92a9c1e7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4525
diff changeset
    26
"{ Package: 'stx:libview' }"
2547
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
    27
7608
0f8d92a9c1e7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4525
diff changeset
    28
"{ NameSpace: Smalltalk }"
3659
26bd2ef5f0ed on -> onDevice
Michael Beyl <mb@exept.de>
parents: 2547
diff changeset
    29
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
FontDescription subclass:#CompoundFont
3663
d40999d6cd1e refactored
Michael Beyl <mb@exept.de>
parents: 3660
diff changeset
    31
	instanceVariableNames:'baseFont characterToFontMapping maxAscent maxDescent maxHeight
d40999d6cd1e refactored
Michael Beyl <mb@exept.de>
parents: 3660
diff changeset
    32
		device'
d40999d6cd1e refactored
Michael Beyl <mb@exept.de>
parents: 3660
diff changeset
    33
	classVariableNames:''
d40999d6cd1e refactored
Michael Beyl <mb@exept.de>
parents: 3660
diff changeset
    34
	poolDictionaries:''
d40999d6cd1e refactored
Michael Beyl <mb@exept.de>
parents: 3660
diff changeset
    35
	category:'Graphics-Support'
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
!
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
!CompoundFont class methodsFor:'documentation'!
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
2547
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
    40
copyright
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
    41
"
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
    42
 COPYRIGHT (c) 1999 by eXept Software AG
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
    43
              All Rights Reserved
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
    44
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
    45
 This software is furnished under a license and may be used
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
    46
 only in accordance with the terms of that license and with the
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
    47
 inclusion of the above copyright notice.   This software may not
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
    48
 be provided or otherwise made available to, or used by, any
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
    49
 other person.  No title to or ownership of the software is
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
    50
 hereby transferred.
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
    51
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
    52
 This is a demo example:
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
    53
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
    54
 THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTOR ``AS IS'' AND
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
    55
 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
    56
 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
    57
 ARE DISCLAIMED.  IN NO EVENT SHALL THE CONTRIBUTOR BE LIABLE
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
    58
 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
    59
 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
    60
 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
    61
 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
    62
 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
    63
 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
    64
 SUCH DAMAGE.
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
    65
"
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
    66
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
    67
!
7d6695ce3833 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2546
diff changeset
    68
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
documentation
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
"
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
    a CompountFont is a font which consists of character glyphs from multiple
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
    other (base-)fonts; for each character code, an individual font may be given.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
    This has been mostly added to allow for non-EURO fonts to be used with ST/X,
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
    by defining a mixedFont, which has an EURO-glyph at the desired character
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
    position.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
    Do not hardCode usage of MixedFonts into your application, since they
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
    might disappear in the future (when Unicode support has been fully 
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
    implemented in ST/X, and Unicode fonts are generally available under X).
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
    I.e. to use these fonts, add appropriate setup to the styleSheet,
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
    or private.rc and use those fonts transparently.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
    [Instance variables:]
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
      baseFont                  <Font>          fallback (default-) font
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
      characterToFontMapping    <Dictionary>    maps characters to a fonts
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
    [class variables:]
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
    [see also:]
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
        Font BitmapFont
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
        DeviceDrawable GraphicsContext
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
    [author:]
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
        Claus Gittinger
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
"
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
!
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
examples
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
"
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
    a mixed font; all vowels are displayed in times;
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
    the rest in helvetica.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
                                                                        [exBegin]
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
    |font top list|
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
3659
26bd2ef5f0ed on -> onDevice
Michael Beyl <mb@exept.de>
parents: 2547
diff changeset
   108
    font := CompoundFont basedOn:(Font family:'courier' size:18).
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
    #($a $e $i $o $u) do:[:char |
3659
26bd2ef5f0ed on -> onDevice
Michael Beyl <mb@exept.de>
parents: 2547
diff changeset
   110
        font glyphAt:char putFont:(Font family:'times' size:18).
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
    ].
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
    top := ScrollableView forView:(list := EditTextView new).
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
    list font:font.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
    list list:#('a' 'z' 'aaa' 'zzz' 'azaz' 'zaza' 'aa' 'az' 'za' 'hello' 'abcdef' 'xyz').
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
    top extent:200@200.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
    top open.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
                                                                        [exEnd]
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
3671
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   119
                                                                        [exBegin]
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   120
    |font font2 top list|
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   121
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   122
    font := CompoundFont basedOn:(Font family:'courier' size:18).
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   123
    font2 := Font family:'times' size:24.
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   124
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   125
    #($a $e $i $o $u $j) do:[:char |
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   126
        font glyphAt:char putFont:font2.
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   127
        font glyphAt:char asUppercase putFont:font2.
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   128
    ].
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   129
    top := ScrollableView forView:(list := EditTextView new).
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   130
    list font:font.
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   131
    list list:#('hello' 'abcdefghijklmnopqrstuvwxyz' 'xyz'
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   132
                'HELLO' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'XYZ').
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   133
    top extent:200@200.
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   134
    top open.
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   135
                                                                        [exEnd]
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
    a mixed font; the dollar character is replaced by the european
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
    EURO symbol; the rest is helvetica
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
    (this is a hack - we really need a resizable font for this):
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
                                                                        [exBegin]
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
    |font baseFont euroGlyph glyphs euroFont top list|
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
    baseFont := Font family:'helvetica' size:12.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
    baseFont := baseFont onDevice:Display.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
    glyphs := Array new:256.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
    euroGlyph := Form 
3659
26bd2ef5f0ed on -> onDevice
Michael Beyl <mb@exept.de>
parents: 2547
diff changeset
   148
                    width:12 
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
                    height:16 
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
                    fromArray:#( 
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
                                2r00000000 2r00000000
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
                                2r00000000 2r00000000
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
                                2r00000000 2r00000000
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
                                2r00000111 2r11000000
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
                                2r00001000 2r00100000
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
                                2r00010000 2r00000000
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
                                2r01111111 2r10000000
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
                                2r00010000 2r00000000
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
                                2r01111111 2r10000000
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
                                2r00010000 2r00000000
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
                                2r00001000 2r00100000
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
                                2r00000111 2r11000000
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
                                2r00000000 2r00000000
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
                                2r00000000 2r00000000
3659
26bd2ef5f0ed on -> onDevice
Michael Beyl <mb@exept.de>
parents: 2547
diff changeset
   165
                                2r00000000 2r00000000
26bd2ef5f0ed on -> onDevice
Michael Beyl <mb@exept.de>
parents: 2547
diff changeset
   166
                                2r00000000 2r00000000
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   167
                               ).
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   168
    glyphs at:($$ asciiValue+1) put:euroGlyph.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
    euroFont := BitmapFont new glyphs:glyphs.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
    euroFont setAscent:(baseFont ascent).
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   172
    euroFont setDescent:(baseFont descent).
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
    font := CompoundFont basedOn:baseFont.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
    font glyphAt:$$ putFont:euroFont.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
    top := ScrollableView forView:(list := EditTextView new).
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
    list font:font.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
    list list:#('100 $' '193 DM').
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
    top extent:200@200.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
    top open.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
                                                                        [exEnd]
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
"
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
! !
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
!CompoundFont class methodsFor:'instance creation'!
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   188
basedOn:aRealFont
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   189
    ^ self new baseFont:aRealFont
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
! !
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
!CompoundFont methodsFor:'accessing'!
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
baseFont
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
    "return the value of the instance variable 'baseFont' (automatically generated)"
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
3659
26bd2ef5f0ed on -> onDevice
Michael Beyl <mb@exept.de>
parents: 2547
diff changeset
   197
    ^ baseFont
26bd2ef5f0ed on -> onDevice
Michael Beyl <mb@exept.de>
parents: 2547
diff changeset
   198
!
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   199
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
baseFont:something
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
    "set the value of the instance variable 'baseFont' (automatically generated)"
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
    baseFont := something.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
    maxAscent := maxDescent := nil.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
!
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   207
glyphAt:char putFont:aFont
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
    characterToFontMapping isNil ifTrue:[
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
        characterToFontMapping := Dictionary new.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
    ].
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
    characterToFontMapping at:char put:aFont.
3673
49e583135bf2 it works !
Michael Beyl <mb@exept.de>
parents: 3671
diff changeset
   213
    maxAscent := maxDescent := maxHeight := nil.
3660
30c7ab561a68 various fixes
Michael Beyl <mb@exept.de>
parents: 3659
diff changeset
   214
!
30c7ab561a68 various fixes
Michael Beyl <mb@exept.de>
parents: 3659
diff changeset
   215
30c7ab561a68 various fixes
Michael Beyl <mb@exept.de>
parents: 3659
diff changeset
   216
graphicsDevice
30c7ab561a68 various fixes
Michael Beyl <mb@exept.de>
parents: 3659
diff changeset
   217
    "return the device I am on"
30c7ab561a68 various fixes
Michael Beyl <mb@exept.de>
parents: 3659
diff changeset
   218
30c7ab561a68 various fixes
Michael Beyl <mb@exept.de>
parents: 3659
diff changeset
   219
    ^ device
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
! !
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
!CompoundFont methodsFor:'displaying'!
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   223
3663
d40999d6cd1e refactored
Michael Beyl <mb@exept.de>
parents: 3660
diff changeset
   224
displayString:aString from:index1 to:index2 x:x0 y:y0 in:aGC opaque:opaque
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
    "this is only called for fonts which have a nil fontId,
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
     and therefore use the replacementFont. Should never be called
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
     for non-replacement fonts."
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
    |x y|
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
    x := x0.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
    y := y0.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   233
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   234
    self 
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
        substringPartsOf:aString from:index1 to:index2 
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   236
        do:[:s :i1 :i2 :font |
3671
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   237
            |wString|
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   238
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   239
            wString := font widthOf:aString from:i1 to:i2.
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   240
            opaque ifTrue:[
3673
49e583135bf2 it works !
Michael Beyl <mb@exept.de>
parents: 3671
diff changeset
   241
"/                (font ascent < maxAscent 
49e583135bf2 it works !
Michael Beyl <mb@exept.de>
parents: 3671
diff changeset
   242
"/                or:[font descent < maxDescent]) 
49e583135bf2 it works !
Michael Beyl <mb@exept.de>
parents: 3671
diff changeset
   243
"/                ifTrue:[       
3671
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   244
                    aGC 
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   245
                        fillRectangleX:x 
3673
49e583135bf2 it works !
Michael Beyl <mb@exept.de>
parents: 3671
diff changeset
   246
                        y:y-maxAscent      
3671
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   247
                        width:wString 
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   248
                        height:maxAscent+maxDescent 
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   249
                        color:aGC backgroundPaint.
3673
49e583135bf2 it works !
Michael Beyl <mb@exept.de>
parents: 3671
diff changeset
   250
"/                ].
3671
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   251
            ].
3663
d40999d6cd1e refactored
Michael Beyl <mb@exept.de>
parents: 3660
diff changeset
   252
            font displayString:s from:i1 to:i2 x:x y:y in:aGC opaque:opaque.
3671
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   253
            x := x + wString.
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   254
        ].
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   255
! !
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   256
4525
30fa1d24ca43 fix #userFriendlyName and #printOn:
Stefan Vogel <sv@exept.de>
parents: 3673
diff changeset
   257
!CompoundFont methodsFor:'printing'!
30fa1d24ca43 fix #userFriendlyName and #printOn:
Stefan Vogel <sv@exept.de>
parents: 3673
diff changeset
   258
30fa1d24ca43 fix #userFriendlyName and #printOn:
Stefan Vogel <sv@exept.de>
parents: 3673
diff changeset
   259
userFriendlyName
30fa1d24ca43 fix #userFriendlyName and #printOn:
Stefan Vogel <sv@exept.de>
parents: 3673
diff changeset
   260
    ^ 'CompoundFont(baseFont: ', baseFont userFriendlyName, ')'
30fa1d24ca43 fix #userFriendlyName and #printOn:
Stefan Vogel <sv@exept.de>
parents: 3673
diff changeset
   261
! !
30fa1d24ca43 fix #userFriendlyName and #printOn:
Stefan Vogel <sv@exept.de>
parents: 3673
diff changeset
   262
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   263
!CompoundFont methodsFor:'private'!
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   264
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   265
computeMaxBounds
3671
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   266
    maxAscent := baseFont maxAscent.
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   267
    maxDescent := baseFont maxDescent.
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   268
    maxHeight := baseFont maxHeight.
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   269
    characterToFontMapping notNil ifTrue:[
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   270
        characterToFontMapping keysAndValuesDo:[:char :aFont |
3671
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   271
            maxAscent := maxAscent max:aFont maxAscent.
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   272
            maxDescent := maxDescent max:aFont maxDescent.
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   273
            maxHeight := maxHeight max:aFont maxHeight.
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   274
        ]
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   275
    ].
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   276
!
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   277
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   278
substringPartsOf:aString from:index1 to:index2 do:aBlock
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   279
    "helper - evaluate aBlock for parts of a string, which use the same font.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   280
     aBlock is invoked for consecutive substrings, passing the string,
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   281
     the startIndex, endIndex and the font as arguments."
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   282
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   283
    |i1 i2 fn char currentFont|
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   284
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   285
    index2 < index1 ifTrue:[^ self].
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   286
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   287
    i1 := index1.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   288
    currentFont := characterToFontMapping at:(aString at:i1) ifAbsent:baseFont.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   289
    i2 := i1 + 1.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   290
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   291
    [i2 <= index2] whileTrue:[
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   292
        char := aString at:i2.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   293
        fn := characterToFontMapping at:char ifAbsent:baseFont.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   294
        fn ~~ currentFont ifTrue:[
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   295
            aBlock value:aString value:i1 value:(i2-1) value:currentFont.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   296
            currentFont := fn.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   297
            i1 := i2.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   298
        ].
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   299
        i2 := i2 + 1.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   300
    ].
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   301
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   302
    i1 < i2 ifTrue:[
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   303
        aBlock value:aString value:i1 value:(i2-1) value:currentFont.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   304
    ].
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   305
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   306
    "
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   307
     |f|
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   308
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   309
     f := self new.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   310
     f baseFont:#baseFont.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   311
     f fontAt:$$ put:#font2.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   312
     f substringPartsOf:'ae$a' from:1 to:8 
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   313
       do:[:s :i1 :i2 :f |
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   314
             Transcript 
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   315
                     show:i1; space;
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   316
                     show:i2; space;
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   317
                     showCR:f
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   318
          ]
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   319
    "
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   320
! !
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   321
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   322
!CompoundFont methodsFor:'queries'!
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   323
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   324
ascent
3671
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   325
    ^ self maxAscent
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   326
!
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   327
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   328
descent
3671
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   329
    ^ self maxDescent
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   330
!
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   331
3660
30c7ab561a68 various fixes
Michael Beyl <mb@exept.de>
parents: 3659
diff changeset
   332
height
30c7ab561a68 various fixes
Michael Beyl <mb@exept.de>
parents: 3659
diff changeset
   333
    maxHeight isNil ifTrue:[
30c7ab561a68 various fixes
Michael Beyl <mb@exept.de>
parents: 3659
diff changeset
   334
        self computeMaxBounds
30c7ab561a68 various fixes
Michael Beyl <mb@exept.de>
parents: 3659
diff changeset
   335
    ].
30c7ab561a68 various fixes
Michael Beyl <mb@exept.de>
parents: 3659
diff changeset
   336
    ^ maxHeight.
30c7ab561a68 various fixes
Michael Beyl <mb@exept.de>
parents: 3659
diff changeset
   337
!
30c7ab561a68 various fixes
Michael Beyl <mb@exept.de>
parents: 3659
diff changeset
   338
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   339
isFixedWidth
7608
0f8d92a9c1e7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4525
diff changeset
   340
    "return true, if this is a fixed pitch font 
0f8d92a9c1e7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4525
diff changeset
   341
     (i.e. all characters are of the same width)"
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   342
3664
85de01ef2853 fixed #isFixedFont
Michael Beyl <mb@exept.de>
parents: 3663
diff changeset
   343
    |w|
85de01ef2853 fixed #isFixedFont
Michael Beyl <mb@exept.de>
parents: 3663
diff changeset
   344
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   345
    baseFont isFixedWidth ifFalse:[^ false].
3664
85de01ef2853 fixed #isFixedFont
Michael Beyl <mb@exept.de>
parents: 3663
diff changeset
   346
    w := baseFont width.
85de01ef2853 fixed #isFixedFont
Michael Beyl <mb@exept.de>
parents: 3663
diff changeset
   347
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   348
    characterToFontMapping keysAndValuesDo:[:char :font |
3664
85de01ef2853 fixed #isFixedFont
Michael Beyl <mb@exept.de>
parents: 3663
diff changeset
   349
        font isFixedWidth ifFalse:[^ false].
85de01ef2853 fixed #isFixedFont
Michael Beyl <mb@exept.de>
parents: 3663
diff changeset
   350
        font width ~~ w ifTrue:[^ false].
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   351
    ].
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   352
    ^ true
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   353
!
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   354
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   355
maxAscent
3671
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   356
    maxAscent isNil ifTrue:[
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   357
        self computeMaxBounds
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   358
    ].
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   359
    ^ maxAscent
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   360
!
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   361
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   362
maxDescent
3671
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   363
    maxDescent isNil ifTrue:[
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   364
        self computeMaxBounds
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   365
    ].
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   366
    ^ maxDescent
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   367
!
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   368
3659
26bd2ef5f0ed on -> onDevice
Michael Beyl <mb@exept.de>
parents: 2547
diff changeset
   369
onDevice:aDevice
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   370
    "return a device representation of the receiver.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   371
     Since I am device independent, return the receiver."
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   372
3660
30c7ab561a68 various fixes
Michael Beyl <mb@exept.de>
parents: 3659
diff changeset
   373
    |newFonts lastFont lastDeviceFont newFont|
30c7ab561a68 various fixes
Michael Beyl <mb@exept.de>
parents: 3659
diff changeset
   374
30c7ab561a68 various fixes
Michael Beyl <mb@exept.de>
parents: 3659
diff changeset
   375
    aDevice == device ifTrue:[ ^ self ].
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   376
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   377
    baseFont := baseFont onDevice:aDevice.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   378
    newFonts := Dictionary new.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   379
    characterToFontMapping keysAndValuesDo:[:char :font |
3660
30c7ab561a68 various fixes
Michael Beyl <mb@exept.de>
parents: 3659
diff changeset
   380
        font == lastFont ifTrue:[
30c7ab561a68 various fixes
Michael Beyl <mb@exept.de>
parents: 3659
diff changeset
   381
            newFont := lastDeviceFont
30c7ab561a68 various fixes
Michael Beyl <mb@exept.de>
parents: 3659
diff changeset
   382
        ] ifFalse:[
30c7ab561a68 various fixes
Michael Beyl <mb@exept.de>
parents: 3659
diff changeset
   383
            newFont := font onDevice:aDevice.
30c7ab561a68 various fixes
Michael Beyl <mb@exept.de>
parents: 3659
diff changeset
   384
            lastFont := font.
30c7ab561a68 various fixes
Michael Beyl <mb@exept.de>
parents: 3659
diff changeset
   385
            lastDeviceFont := newFont.
30c7ab561a68 various fixes
Michael Beyl <mb@exept.de>
parents: 3659
diff changeset
   386
        ].
30c7ab561a68 various fixes
Michael Beyl <mb@exept.de>
parents: 3659
diff changeset
   387
        newFonts at:char put:newFont
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   388
    ].
3660
30c7ab561a68 various fixes
Michael Beyl <mb@exept.de>
parents: 3659
diff changeset
   389
    characterToFontMapping := newFonts.
30c7ab561a68 various fixes
Michael Beyl <mb@exept.de>
parents: 3659
diff changeset
   390
    device := aDevice.
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   391
!
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   392
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   393
widthOf:aString from:index1 to:index2
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   394
    |w|
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   395
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   396
    w := 0.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   397
    self 
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   398
        substringPartsOf:aString from:index1 to:index2 
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   399
        do:[:s :i1 :i2 :f |
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   400
             w := w + (f widthOf:s from:i1 to:i2)
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   401
           ].
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   402
    ^ w
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   403
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   404
! !
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   405
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   406
!CompoundFont class methodsFor:'documentation'!
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   407
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   408
version
7608
0f8d92a9c1e7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4525
diff changeset
   409
    ^ '$Header$'
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   410
! !
7608
0f8d92a9c1e7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4525
diff changeset
   411