CompoundFont.st
author matilk
Wed, 13 Sep 2017 09:40:34 +0200
changeset 8174 2704c965b97b
parent 7946 6ed11ca75246
permissions -rw-r--r--
#BUGFIX by Maren class: DeviceGraphicsContext changed: #displayDeviceOpaqueForm:x:y: nil check
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
"
7946
6ed11ca75246 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 7608
diff changeset
     2
 COPYRIGHT (c) 1999 by Claus Gittinger / eXept Software AG
2547
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
"
7946
6ed11ca75246 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 7608
diff changeset
    42
 COPYRIGHT (c) 1999 by Claus Gittinger / eXept Software AG
2547
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
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
documentation
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
"
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
    a CompountFont is a font which consists of character glyphs from multiple
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
    other (base-)fonts; for each character code, an individual font may be given.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
    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
    74
    by defining a mixedFont, which has an EURO-glyph at the desired character
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
    position.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
    Do not hardCode usage of MixedFonts into your application, since they
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
    might disappear in the future (when Unicode support has been fully 
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
    implemented in ST/X, and Unicode fonts are generally available under X).
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
    I.e. to use these fonts, add appropriate setup to the styleSheet,
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
    or private.rc and use those fonts transparently.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
    [Instance variables:]
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
      baseFont                  <Font>          fallback (default-) font
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
      characterToFontMapping    <Dictionary>    maps characters to a fonts
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
    [class variables:]
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
    [see also:]
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
        Font BitmapFont
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
        DeviceDrawable GraphicsContext
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
    [author:]
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
        Claus Gittinger
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
"
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
examples
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
"
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
    a mixed font; all vowels are displayed in times;
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
    the rest in helvetica.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
                                                                        [exBegin]
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
    |font top list|
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
3659
26bd2ef5f0ed on -> onDevice
Michael Beyl <mb@exept.de>
parents: 2547
diff changeset
   107
    font := CompoundFont basedOn:(Font family:'courier' size:18).
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
    #($a $e $i $o $u) do:[:char |
3659
26bd2ef5f0ed on -> onDevice
Michael Beyl <mb@exept.de>
parents: 2547
diff changeset
   109
        font glyphAt:char putFont:(Font family:'times' size:18).
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
    ].
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
    top := ScrollableView forView:(list := EditTextView new).
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
    list font:font.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
    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
   114
    top extent:200@200.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
    top open.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
                                                                        [exEnd]
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
3671
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   118
                                                                        [exBegin]
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   119
    |font font2 top list|
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   120
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   121
    font := CompoundFont basedOn:(Font family:'courier' size:18).
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   122
    font2 := Font family:'times' size:24.
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   123
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   124
    #($a $e $i $o $u $j) do:[:char |
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   125
        font glyphAt:char putFont:font2.
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   126
        font glyphAt:char asUppercase putFont:font2.
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   127
    ].
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   128
    top := ScrollableView forView:(list := EditTextView new).
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   129
    list font:font.
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   130
    list list:#('hello' 'abcdefghijklmnopqrstuvwxyz' 'xyz'
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   131
                'HELLO' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'XYZ').
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   132
    top extent:200@200.
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   133
    top open.
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   134
                                                                        [exEnd]
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
    a mixed font; the dollar character is replaced by the european
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
    EURO symbol; the rest is helvetica
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
    (this is a hack - we really need a resizable font for this):
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
                                                                        [exBegin]
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
    |font baseFont euroGlyph glyphs euroFont top list|
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
    baseFont := Font family:'helvetica' size:12.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
    baseFont := baseFont onDevice:Display.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
    glyphs := Array new:256.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
    euroGlyph := Form 
3659
26bd2ef5f0ed on -> onDevice
Michael Beyl <mb@exept.de>
parents: 2547
diff changeset
   147
                    width:12 
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
                    height:16 
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
                    fromArray:#( 
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
                                2r00000000 2r00000000
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
                                2r00000111 2r11000000
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
                                2r00001000 2r00100000
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
                                2r00010000 2r00000000
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
                                2r01111111 2r10000000
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
                                2r00010000 2r00000000
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
                                2r01111111 2r10000000
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
                                2r00010000 2r00000000
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
                                2r00001000 2r00100000
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
                                2r00000111 2r11000000
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
                                2r00000000 2r00000000
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
                                2r00000000 2r00000000
3659
26bd2ef5f0ed on -> onDevice
Michael Beyl <mb@exept.de>
parents: 2547
diff changeset
   164
                                2r00000000 2r00000000
26bd2ef5f0ed on -> onDevice
Michael Beyl <mb@exept.de>
parents: 2547
diff changeset
   165
                                2r00000000 2r00000000
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
                               ).
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   167
    glyphs at:($$ asciiValue+1) put:euroGlyph.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   168
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
    euroFont := BitmapFont new glyphs:glyphs.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
    euroFont setAscent:(baseFont ascent).
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
    euroFont setDescent:(baseFont descent).
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   172
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
    font := CompoundFont basedOn:baseFont.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
    font glyphAt:$$ putFont:euroFont.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
    top := ScrollableView forView:(list := EditTextView new).
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
    list font:font.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
    list list:#('100 $' '193 DM').
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
    top extent:200@200.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
    top open.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
                                                                        [exEnd]
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
"
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
!CompoundFont class methodsFor:'instance creation'!
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
basedOn:aRealFont
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   188
    ^ self new baseFont:aRealFont
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   189
! !
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
!CompoundFont methodsFor:'accessing'!
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
baseFont
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
    "return the value of the instance variable 'baseFont' (automatically generated)"
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
3659
26bd2ef5f0ed on -> onDevice
Michael Beyl <mb@exept.de>
parents: 2547
diff changeset
   196
    ^ baseFont
26bd2ef5f0ed on -> onDevice
Michael Beyl <mb@exept.de>
parents: 2547
diff changeset
   197
!
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   198
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   199
baseFont:something
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
    "set the value of the instance variable 'baseFont' (automatically generated)"
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
    baseFont := something.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
    maxAscent := maxDescent := nil.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
!
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
glyphAt:char putFont:aFont
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   207
    characterToFontMapping isNil ifTrue:[
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
        characterToFontMapping := Dictionary new.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
    ].
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
    characterToFontMapping at:char put:aFont.
3673
49e583135bf2 it works !
Michael Beyl <mb@exept.de>
parents: 3671
diff changeset
   212
    maxAscent := maxDescent := maxHeight := nil.
3660
30c7ab561a68 various fixes
Michael Beyl <mb@exept.de>
parents: 3659
diff changeset
   213
!
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
graphicsDevice
30c7ab561a68 various fixes
Michael Beyl <mb@exept.de>
parents: 3659
diff changeset
   216
    "return the device I am on"
30c7ab561a68 various fixes
Michael Beyl <mb@exept.de>
parents: 3659
diff changeset
   217
30c7ab561a68 various fixes
Michael Beyl <mb@exept.de>
parents: 3659
diff changeset
   218
    ^ device
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
! !
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
!CompoundFont methodsFor:'displaying'!
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
3663
d40999d6cd1e refactored
Michael Beyl <mb@exept.de>
parents: 3660
diff changeset
   223
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
   224
    "this is only called for fonts which have a nil fontId,
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
     and therefore use the replacementFont. Should never be called
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
     for non-replacement fonts."
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
    |x y|
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
    x := x0.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
    y := y0.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   233
    self 
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   234
        substringPartsOf:aString from:index1 to:index2 
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
        do:[:s :i1 :i2 :font |
3671
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   236
            |wString|
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   237
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   238
            wString := font widthOf:aString from:i1 to:i2.
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   239
            opaque ifTrue:[
3673
49e583135bf2 it works !
Michael Beyl <mb@exept.de>
parents: 3671
diff changeset
   240
"/                (font ascent < maxAscent 
49e583135bf2 it works !
Michael Beyl <mb@exept.de>
parents: 3671
diff changeset
   241
"/                or:[font descent < maxDescent]) 
49e583135bf2 it works !
Michael Beyl <mb@exept.de>
parents: 3671
diff changeset
   242
"/                ifTrue:[       
3671
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   243
                    aGC 
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   244
                        fillRectangleX:x 
3673
49e583135bf2 it works !
Michael Beyl <mb@exept.de>
parents: 3671
diff changeset
   245
                        y:y-maxAscent      
3671
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   246
                        width:wString 
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   247
                        height:maxAscent+maxDescent 
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   248
                        color:aGC backgroundPaint.
3673
49e583135bf2 it works !
Michael Beyl <mb@exept.de>
parents: 3671
diff changeset
   249
"/                ].
3671
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   250
            ].
3663
d40999d6cd1e refactored
Michael Beyl <mb@exept.de>
parents: 3660
diff changeset
   251
            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
   252
            x := x + wString.
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   253
        ].
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   254
! !
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   255
4525
30fa1d24ca43 fix #userFriendlyName and #printOn:
Stefan Vogel <sv@exept.de>
parents: 3673
diff changeset
   256
!CompoundFont methodsFor:'printing'!
30fa1d24ca43 fix #userFriendlyName and #printOn:
Stefan Vogel <sv@exept.de>
parents: 3673
diff changeset
   257
30fa1d24ca43 fix #userFriendlyName and #printOn:
Stefan Vogel <sv@exept.de>
parents: 3673
diff changeset
   258
userFriendlyName
30fa1d24ca43 fix #userFriendlyName and #printOn:
Stefan Vogel <sv@exept.de>
parents: 3673
diff changeset
   259
    ^ 'CompoundFont(baseFont: ', baseFont userFriendlyName, ')'
30fa1d24ca43 fix #userFriendlyName and #printOn:
Stefan Vogel <sv@exept.de>
parents: 3673
diff changeset
   260
! !
30fa1d24ca43 fix #userFriendlyName and #printOn:
Stefan Vogel <sv@exept.de>
parents: 3673
diff changeset
   261
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   262
!CompoundFont methodsFor:'private'!
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   263
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   264
computeMaxBounds
3671
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   265
    maxAscent := baseFont maxAscent.
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   266
    maxDescent := baseFont maxDescent.
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   267
    maxHeight := baseFont maxHeight.
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   268
    characterToFontMapping notNil ifTrue:[
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   269
        characterToFontMapping keysAndValuesDo:[:char :aFont |
3671
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   270
            maxAscent := maxAscent max:aFont maxAscent.
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   271
            maxDescent := maxDescent max:aFont maxDescent.
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   272
            maxHeight := maxHeight max:aFont maxHeight.
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   273
        ]
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
substringPartsOf:aString from:index1 to:index2 do:aBlock
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   278
    "helper - evaluate aBlock for parts of a string, which use the same font.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   279
     aBlock is invoked for consecutive substrings, passing the string,
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   280
     the startIndex, endIndex and the font as arguments."
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   281
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   282
    |i1 i2 fn char currentFont|
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   283
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   284
    index2 < index1 ifTrue:[^ self].
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   285
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   286
    i1 := index1.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   287
    currentFont := characterToFontMapping at:(aString at:i1) ifAbsent:baseFont.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   288
    i2 := i1 + 1.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   289
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   290
    [i2 <= index2] whileTrue:[
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   291
        char := aString at:i2.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   292
        fn := characterToFontMapping at:char ifAbsent:baseFont.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   293
        fn ~~ currentFont ifTrue:[
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   294
            aBlock value:aString value:i1 value:(i2-1) value:currentFont.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   295
            currentFont := fn.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   296
            i1 := i2.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   297
        ].
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   298
        i2 := i2 + 1.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   299
    ].
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   300
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   301
    i1 < i2 ifTrue:[
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   302
        aBlock value:aString value:i1 value:(i2-1) value:currentFont.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   303
    ].
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
     |f|
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   307
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   308
     f := self new.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   309
     f baseFont:#baseFont.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   310
     f fontAt:$$ put:#font2.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   311
     f substringPartsOf:'ae$a' from:1 to:8 
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   312
       do:[:s :i1 :i2 :f |
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   313
             Transcript 
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   314
                     show:i1; space;
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   315
                     show:i2; space;
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   316
                     showCR:f
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   317
          ]
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
!CompoundFont methodsFor:'queries'!
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   322
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   323
ascent
3671
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   324
    ^ self maxAscent
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   325
!
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   326
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   327
descent
3671
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   328
    ^ self maxDescent
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   329
!
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   330
3660
30c7ab561a68 various fixes
Michael Beyl <mb@exept.de>
parents: 3659
diff changeset
   331
height
30c7ab561a68 various fixes
Michael Beyl <mb@exept.de>
parents: 3659
diff changeset
   332
    maxHeight isNil ifTrue:[
30c7ab561a68 various fixes
Michael Beyl <mb@exept.de>
parents: 3659
diff changeset
   333
        self computeMaxBounds
30c7ab561a68 various fixes
Michael Beyl <mb@exept.de>
parents: 3659
diff changeset
   334
    ].
30c7ab561a68 various fixes
Michael Beyl <mb@exept.de>
parents: 3659
diff changeset
   335
    ^ maxHeight.
30c7ab561a68 various fixes
Michael Beyl <mb@exept.de>
parents: 3659
diff changeset
   336
!
30c7ab561a68 various fixes
Michael Beyl <mb@exept.de>
parents: 3659
diff changeset
   337
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   338
isFixedWidth
7608
0f8d92a9c1e7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4525
diff changeset
   339
    "return true, if this is a fixed pitch font 
0f8d92a9c1e7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4525
diff changeset
   340
     (i.e. all characters are of the same width)"
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   341
3664
85de01ef2853 fixed #isFixedFont
Michael Beyl <mb@exept.de>
parents: 3663
diff changeset
   342
    |w|
85de01ef2853 fixed #isFixedFont
Michael Beyl <mb@exept.de>
parents: 3663
diff changeset
   343
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   344
    baseFont isFixedWidth ifFalse:[^ false].
3664
85de01ef2853 fixed #isFixedFont
Michael Beyl <mb@exept.de>
parents: 3663
diff changeset
   345
    w := baseFont width.
85de01ef2853 fixed #isFixedFont
Michael Beyl <mb@exept.de>
parents: 3663
diff changeset
   346
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   347
    characterToFontMapping keysAndValuesDo:[:char :font |
3664
85de01ef2853 fixed #isFixedFont
Michael Beyl <mb@exept.de>
parents: 3663
diff changeset
   348
        font isFixedWidth ifFalse:[^ false].
85de01ef2853 fixed #isFixedFont
Michael Beyl <mb@exept.de>
parents: 3663
diff changeset
   349
        font width ~~ w ifTrue:[^ false].
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   350
    ].
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   351
    ^ true
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   352
!
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   353
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   354
maxAscent
3671
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   355
    maxAscent isNil ifTrue:[
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   356
        self computeMaxBounds
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   357
    ].
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   358
    ^ maxAscent
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   359
!
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   360
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   361
maxDescent
3671
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   362
    maxDescent isNil ifTrue:[
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   363
        self computeMaxBounds
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   364
    ].
72a56e3c744a many changes but still buggy ?
Michael Beyl <mb@exept.de>
parents: 3664
diff changeset
   365
    ^ maxDescent
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   366
!
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   367
3659
26bd2ef5f0ed on -> onDevice
Michael Beyl <mb@exept.de>
parents: 2547
diff changeset
   368
onDevice:aDevice
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   369
    "return a device representation of the receiver.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   370
     Since I am device independent, return the receiver."
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   371
3660
30c7ab561a68 various fixes
Michael Beyl <mb@exept.de>
parents: 3659
diff changeset
   372
    |newFonts lastFont lastDeviceFont newFont|
30c7ab561a68 various fixes
Michael Beyl <mb@exept.de>
parents: 3659
diff changeset
   373
30c7ab561a68 various fixes
Michael Beyl <mb@exept.de>
parents: 3659
diff changeset
   374
    aDevice == device ifTrue:[ ^ self ].
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   375
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   376
    baseFont := baseFont onDevice:aDevice.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   377
    newFonts := Dictionary new.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   378
    characterToFontMapping keysAndValuesDo:[:char :font |
3660
30c7ab561a68 various fixes
Michael Beyl <mb@exept.de>
parents: 3659
diff changeset
   379
        font == lastFont ifTrue:[
30c7ab561a68 various fixes
Michael Beyl <mb@exept.de>
parents: 3659
diff changeset
   380
            newFont := lastDeviceFont
30c7ab561a68 various fixes
Michael Beyl <mb@exept.de>
parents: 3659
diff changeset
   381
        ] ifFalse:[
30c7ab561a68 various fixes
Michael Beyl <mb@exept.de>
parents: 3659
diff changeset
   382
            newFont := font onDevice:aDevice.
30c7ab561a68 various fixes
Michael Beyl <mb@exept.de>
parents: 3659
diff changeset
   383
            lastFont := font.
30c7ab561a68 various fixes
Michael Beyl <mb@exept.de>
parents: 3659
diff changeset
   384
            lastDeviceFont := newFont.
30c7ab561a68 various fixes
Michael Beyl <mb@exept.de>
parents: 3659
diff changeset
   385
        ].
30c7ab561a68 various fixes
Michael Beyl <mb@exept.de>
parents: 3659
diff changeset
   386
        newFonts at:char put:newFont
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   387
    ].
3660
30c7ab561a68 various fixes
Michael Beyl <mb@exept.de>
parents: 3659
diff changeset
   388
    characterToFontMapping := newFonts.
30c7ab561a68 various fixes
Michael Beyl <mb@exept.de>
parents: 3659
diff changeset
   389
    device := aDevice.
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   390
!
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   391
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   392
widthOf:aString from:index1 to:index2
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   393
    |w|
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   394
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   395
    w := 0.
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   396
    self 
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   397
        substringPartsOf:aString from:index1 to:index2 
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   398
        do:[:s :i1 :i2 :f |
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   399
             w := w + (f widthOf:s from:i1 to:i2)
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   400
           ].
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   401
    ^ w
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   402
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
!CompoundFont class methodsFor:'documentation'!
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   406
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   407
version
7608
0f8d92a9c1e7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4525
diff changeset
   408
    ^ '$Header$'
2546
6443abc93415 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   409
! !
7608
0f8d92a9c1e7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4525
diff changeset
   410