Font.st
author Claus Gittinger <cg@exept.de>
Mon, 06 May 2002 08:04:18 +0200
changeset 3623 16665d9b7263
parent 3611 8b4384c9e660
child 3628 ddeeaa203e86
permissions -rw-r--r--
#on: -> #onDevice
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
48194c26a46c Initial revision
claus
parents:
diff changeset
     1
"
6
7ee0cfde237d *** empty log message ***
claus
parents: 5
diff changeset
     2
 COPYRIGHT (c) 1992 by Claus Gittinger
71
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
     3
	      All Rights Reserved
0
48194c26a46c Initial revision
claus
parents:
diff changeset
     4
48194c26a46c Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
48194c26a46c Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
48194c26a46c Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
48194c26a46c Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
48194c26a46c Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
48194c26a46c Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
48194c26a46c Initial revision
claus
parents:
diff changeset
    11
"
48194c26a46c Initial revision
claus
parents:
diff changeset
    12
3213
78add46c0f4b only init once
Claus Gittinger <cg@exept.de>
parents: 3060
diff changeset
    13
"{ Package: 'stx:libview' }"
78add46c0f4b only init once
Claus Gittinger <cg@exept.de>
parents: 3060
diff changeset
    14
109
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
    15
FontDescription subclass:#Font
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
    16
	instanceVariableNames:'device fontId replacementFont ascent descent width isFixedWidth
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
    17
		minWidth maxWidth maxAscent maxDescent'
1372
2b55617a712f keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
    18
	classVariableNames:'Replacements'
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
    19
	poolDictionaries:''
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
    20
	category:'Graphics-Support'
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    21
!
48194c26a46c Initial revision
claus
parents:
diff changeset
    22
2433
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
    23
Object subclass:#DeviceFontHandle
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
    24
	instanceVariableNames:'device fontId'
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
    25
	classVariableNames:''
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
    26
	poolDictionaries:''
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
    27
	privateIn:Font
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
    28
!
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
    29
1087
1e5a93e03d7f handle text-argument in withOf:
Claus Gittinger <cg@exept.de>
parents: 1067
diff changeset
    30
!Font class methodsFor:'documentation'!
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    31
46
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    32
copyright
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    33
"
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    34
 COPYRIGHT (c) 1992 by Claus Gittinger
71
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
    35
	      All Rights Reserved
46
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    36
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    37
 This software is furnished under a license and may be used
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    38
 only in accordance with the terms of that license and with the
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    39
 inclusion of the above copyright notice.   This software may not
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    40
 be provided or otherwise made available to, or used by, any
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    41
 other person.  No title to or ownership of the software is
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    42
 hereby transferred.
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    43
"
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    44
!
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    45
46
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    46
documentation
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    47
"
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    48
    Font represents fonts in a device independent manner; after being
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    49
    created using 'Font family:family face:face style:style size:size',
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    50
    the returned font is not associated to a specific device.
157
claus
parents: 151
diff changeset
    51
    (therefore, those fonts can be used to draw on any GC)
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    52
46
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    53
    To get a device font, any font can be sent the message
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    54
    'aFont on:aDevice' which returns an instance of Font which is
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    55
    associated to a device (it returns the receiver, if that is already
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    56
    associated to that device).
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    57
46
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    58
    For proper operation, each graphics operation working with fonts
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    59
    must get a device font before doing the draw.
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    60
    Most draw methods in DeviceDrawable do that automatically for you, 
157
claus
parents: 151
diff changeset
    61
    before doing the draw; so you do not have to care.
46
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    62
81
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    63
    However, some operations require explicit conversion to a device font
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    64
    before being allowed. For example, a query for a fonts height (in device
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    65
    units) can only be done if the font being asked is associated to
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    66
    a device (which should be clear, since a 'courier-roman-12' font may
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    67
    have a different number of pixels on a 75dpi vs. a 120dpi display. And
564
3ddccbec4ee7 commentary
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
    68
    a totally different number of device units on a 600dpi laser printer.
81
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    69
    Thus, to query a font for its height (or ascent, or descent, or width),
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    70
    use something like:
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    71
564
3ddccbec4ee7 commentary
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
    72
        myFont := Font family:'courier' ... size:12.
3ddccbec4ee7 commentary
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
    73
            ...
81
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    74
        
564
3ddccbec4ee7 commentary
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
    75
        'want to know its height on the Display'
81
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    76
        
564
3ddccbec4ee7 commentary
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
    77
        h := (myFont on:Display) height.
81
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    78
        
564
3ddccbec4ee7 commentary
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
    79
        'want to know its height on a printer'
81
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    80
        
564
3ddccbec4ee7 commentary
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
    81
        h := (myFont on:aPrinter) height.
2545
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
    82
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
    83
    there are alternative shortcuts for these operations:
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
    84
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
    85
        h := myFont heightOn:Display.
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
    86
        h := myFont heightOn:Printer.
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
    87
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
    88
        or:
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
    89
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
    90
        a := myFont ascentOn:Display.
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
    91
81
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    92
    Keep in mind, that each device is free to think in whatever units it
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    93
    likes - a display may return units of pixels, a postscript printer may
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    94
    think in (fractions of) inches, a dot matrix printer may think in dots.
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    95
    Also, notice that currently only graphic displays are really supported;
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    96
    printer devices are being developped and may or may not be in the current
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    97
    system.
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    98
564
3ddccbec4ee7 commentary
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
    99
    If a font cannot be represented on a device, a replacement
46
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
   100
    font is chosen and kept in the replacementFont instance variable. 
564
3ddccbec4ee7 commentary
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
   101
    This is done to preserve the original font information, in case the image
3ddccbec4ee7 commentary
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
   102
    is restarted later on another display which has that font available.
3ddccbec4ee7 commentary
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
   103
3ddccbec4ee7 commentary
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
   104
601
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
   105
    [Instance variables:]
46
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
   106
109
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   107
      family          <String>        the fonts family ('courier', 'helvetica' etc)
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   108
      face            <String>        the fonts face ('bold', 'medium' etc)
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   109
      style           <String>        the fonts style ('roman', 'italic', 'oblique')
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   110
      size            <String>        the fonts size (not in pixels) 
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   111
      encoding        <Symbol>        the fonts encoding (usually #iso8859)
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   112
109
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   113
      device          <Object>        the device the font is associated to, or nil
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   114
      fontId          <Object>        the id of the font on that device, or nil
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   115
      replacement     <Font>          the replacement font or nil
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   116
109
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   117
      ascent          <Integer>       the fonts ascent in device units on device
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   118
      descent         <Integer>       the fonts descent in device units on device
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   119
      width           <Integer>       the character width in device units on device
564
3ddccbec4ee7 commentary
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
   120
                                      (for variable fonts, its the width of a space)
109
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   121
      isFixedWidth    <Boolean>       true if font is a fixed width font
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   122
      minWidth        <Integer>       width of the smallest-width character in
564
3ddccbec4ee7 commentary
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
   123
                                      in device units on device
109
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   124
      maxWidth        <Integer>       width of the largest-width character in
564
3ddccbec4ee7 commentary
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
   125
                                      in device units on device
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   126
601
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
   127
    [class variables:]
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   128
109
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   129
      Replacements    <Dictionary>    replacement fonts
601
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
   130
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
   131
    [see also:]
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
   132
        DeviceWorkstation 
628
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   133
        DeviceDrawable GraphicsContext
601
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
   134
        Cursor Color
628
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   135
        ( introduction to view programming :html: programming/viewintro.html#FONTS )
611
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 601
diff changeset
   136
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 601
diff changeset
   137
    [author:]
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 601
diff changeset
   138
        Claus Gittinger
46
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
   139
"
628
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   140
!
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   141
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   142
examples
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   143
"
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   144
    standard fonts:
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   145
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   146
        aFont := Font family:'courier' size:12
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   147
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   148
        aFont := Font 
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   149
                     family:'helvetica' 
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   150
                     face:'roman' 
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   151
                     style:'bold' 
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   152
                     size:16
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   153
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   154
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   155
    special (non-portable displayType specific) fonts:
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   156
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   157
        aFont := Font name:'6x10'
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   158
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   159
        aFont := Font name:'k14'
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   160
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   161
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   162
    setting the font of a button:
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   163
                                                                        [exBegin]
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   164
        |b|
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   165
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   166
        b := Button new.
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   167
        b label:'hello'.
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   168
        b font:(Font family:'helvetica' 
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   169
                     face:'medium' 
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   170
                     style:'roman' 
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   171
                     size:16).
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   172
        b open
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   173
                                                                        [exEnd]
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   174
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   175
    asking a font about a strings size in pixels, 
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   176
    if it was used on some device:
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   177
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   178
        aFont widthOf:'hello' on:Display
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   179
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   180
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   181
    asking about the ascent, if used on some device:
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   182
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   183
        aFont ascentOn:Display
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   184
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   185
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   186
    if the font has been associated to a device, the following are 
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   187
    a bit faster:
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   188
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   189
        |aFont|
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   190
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   191
        ...
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   192
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   193
        aFont := aFont on:aDevice.
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   194
        ...
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   195
        aFont widthOf:'hello'
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   196
        ...
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   197
        aFont ascent
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   198
        ...
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   199
"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   200
! !
48194c26a46c Initial revision
claus
parents:
diff changeset
   201
1087
1e5a93e03d7f handle text-argument in withOf:
Claus Gittinger <cg@exept.de>
parents: 1067
diff changeset
   202
!Font class methodsFor:'initialization'!
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   203
48194c26a46c Initial revision
claus
parents:
diff changeset
   204
initialize
48194c26a46c Initial revision
claus
parents:
diff changeset
   205
    "initialize the font tracking array"
48194c26a46c Initial revision
claus
parents:
diff changeset
   206
1372
2b55617a712f keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   207
    "
2b55617a712f keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   208
     replacement handling is not yet finished
2b55617a712f keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   209
    "
3213
78add46c0f4b only init once
Claus Gittinger <cg@exept.de>
parents: 3060
diff changeset
   210
    Replacements isNil ifTrue:[
78add46c0f4b only init once
Claus Gittinger <cg@exept.de>
parents: 3060
diff changeset
   211
        Replacements := Dictionary new.
71
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   212
3213
78add46c0f4b only init once
Claus Gittinger <cg@exept.de>
parents: 3060
diff changeset
   213
        Replacements at:'clean'                  put:'courier'.
78add46c0f4b only init once
Claus Gittinger <cg@exept.de>
parents: 3060
diff changeset
   214
        Replacements at:'fixed'                  put:'courier'.
78add46c0f4b only init once
Claus Gittinger <cg@exept.de>
parents: 3060
diff changeset
   215
        Replacements at:'new century schoolbook' put:'times'.
78add46c0f4b only init once
Claus Gittinger <cg@exept.de>
parents: 3060
diff changeset
   216
        Replacements at:'lucida'                 put:'helvetica'.
78add46c0f4b only init once
Claus Gittinger <cg@exept.de>
parents: 3060
diff changeset
   217
        Replacements at:'lucidabright'           put:'helvetica'.
78add46c0f4b only init once
Claus Gittinger <cg@exept.de>
parents: 3060
diff changeset
   218
        Replacements at:'lucidatypewriter'       put:'courier'.
78add46c0f4b only init once
Claus Gittinger <cg@exept.de>
parents: 3060
diff changeset
   219
        Replacements at:'charter'                put:'times'.
78add46c0f4b only init once
Claus Gittinger <cg@exept.de>
parents: 3060
diff changeset
   220
        Replacements at:'terminal'               put:'courier'.
78add46c0f4b only init once
Claus Gittinger <cg@exept.de>
parents: 3060
diff changeset
   221
    ]
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   222
! !
48194c26a46c Initial revision
claus
parents:
diff changeset
   223
1087
1e5a93e03d7f handle text-argument in withOf:
Claus Gittinger <cg@exept.de>
parents: 1067
diff changeset
   224
!Font class methodsFor:'instance creation'!
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   225
48194c26a46c Initial revision
claus
parents:
diff changeset
   226
family:familyString face:faceString style:styleString size:sizeNum encoding:encodingSym
48194c26a46c Initial revision
claus
parents:
diff changeset
   227
    "returns a font for given family, face, style, size and encoding. 
71
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   228
     The returned font is not associated to a specific device"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   229
54
29a6b2f8e042 *** empty log message ***
claus
parents: 46
diff changeset
   230
    |family newFont|
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   231
48194c26a46c Initial revision
claus
parents:
diff changeset
   232
    (familyString at:1) isUppercase ifTrue:[
2925
fadcf27b8f99 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   233
        family := familyString asLowercase
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   234
    ] ifFalse:[
2925
fadcf27b8f99 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   235
        family := familyString
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   236
    ].
48194c26a46c Initial revision
claus
parents:
diff changeset
   237
1372
2b55617a712f keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   238
    "look if this font is already known on the default device
2b55617a712f keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   239
     (the most common case)"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   240
2767
04fdb969488a dont access DIsplay if its nil
Claus Gittinger <cg@exept.de>
parents: 2545
diff changeset
   241
    Display notNil ifTrue:[
04fdb969488a dont access DIsplay if its nil
Claus Gittinger <cg@exept.de>
parents: 2545
diff changeset
   242
        Display deviceFonts do:[:aFont |
2925
fadcf27b8f99 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   243
            (aFont family = family) ifTrue:[
fadcf27b8f99 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   244
                (aFont face = faceString) ifTrue:[
fadcf27b8f99 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   245
                    (aFont style = styleString
fadcf27b8f99 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   246
                    or:[styleString = 'italic' and:[aFont style = 'oblique']]) ifTrue:[
fadcf27b8f99 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   247
                         (aFont size == sizeNum) ifTrue:[
fadcf27b8f99 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   248
                            (encodingSym isNil or:[aFont encoding == encodingSym]) ifTrue:[
fadcf27b8f99 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   249
                                ^ aFont
fadcf27b8f99 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   250
                            ]
fadcf27b8f99 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   251
                        ]
fadcf27b8f99 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   252
                    ]
fadcf27b8f99 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   253
                ]
fadcf27b8f99 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   254
            ]
fadcf27b8f99 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   255
        ]
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   256
    ].
1372
2b55617a712f keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   257
2b55617a712f keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   258
    newFont := self basicNew 
2925
fadcf27b8f99 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   259
                    setFamily:familyString
fadcf27b8f99 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   260
                    face:faceString
fadcf27b8f99 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   261
                    style:styleString
fadcf27b8f99 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   262
                    size:sizeNum
fadcf27b8f99 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   263
                    encoding:encodingSym
fadcf27b8f99 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   264
                    device:nil.
1372
2b55617a712f keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   265
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   266
    ^ newFont
2925
fadcf27b8f99 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   267
fadcf27b8f99 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   268
    "Modified: / 26.9.1999 / 13:49:45 / cg"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   269
! !
48194c26a46c Initial revision
claus
parents:
diff changeset
   270
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   271
!Font methodsFor:'accessing'!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   272
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   273
device
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   274
    "return the device I am on"
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   275
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   276
    ^ device
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   277
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   278
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   279
fontId
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   280
    "return the device-dependent font-id"
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   281
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   282
    ^ fontId
731
8cac3347e13a added #graphicsDevice
Claus Gittinger <cg@exept.de>
parents: 710
diff changeset
   283
!
8cac3347e13a added #graphicsDevice
Claus Gittinger <cg@exept.de>
parents: 710
diff changeset
   284
8cac3347e13a added #graphicsDevice
Claus Gittinger <cg@exept.de>
parents: 710
diff changeset
   285
graphicsDevice
8cac3347e13a added #graphicsDevice
Claus Gittinger <cg@exept.de>
parents: 710
diff changeset
   286
    "same as #device, for ST-80 compatibility naming.
8cac3347e13a added #graphicsDevice
Claus Gittinger <cg@exept.de>
parents: 710
diff changeset
   287
     Return the device I am associated with."
8cac3347e13a added #graphicsDevice
Claus Gittinger <cg@exept.de>
parents: 710
diff changeset
   288
8cac3347e13a added #graphicsDevice
Claus Gittinger <cg@exept.de>
parents: 710
diff changeset
   289
    ^ device
8cac3347e13a added #graphicsDevice
Claus Gittinger <cg@exept.de>
parents: 710
diff changeset
   290
8cac3347e13a added #graphicsDevice
Claus Gittinger <cg@exept.de>
parents: 710
diff changeset
   291
    "Created: 28.5.1996 / 18:39:53 / cg"
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   292
! !
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   293
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   294
!Font methodsFor:'binary storage'!
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   295
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   296
readBinaryContentsFrom: stream manager: manager
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   297
    "tell the newly restored Font about restoration"
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   298
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   299
    super readBinaryContentsFrom: stream manager: manager.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   300
    self restored
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   301
! !
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   302
3027
efb7b0c760f5 blocked deepCopying of fonts
Claus Gittinger <cg@exept.de>
parents: 2980
diff changeset
   303
!Font methodsFor:'copying'!
efb7b0c760f5 blocked deepCopying of fonts
Claus Gittinger <cg@exept.de>
parents: 2980
diff changeset
   304
efb7b0c760f5 blocked deepCopying of fonts
Claus Gittinger <cg@exept.de>
parents: 2980
diff changeset
   305
deepCopyUsing:aDictionary
efb7b0c760f5 blocked deepCopying of fonts
Claus Gittinger <cg@exept.de>
parents: 2980
diff changeset
   306
    ^ self
efb7b0c760f5 blocked deepCopying of fonts
Claus Gittinger <cg@exept.de>
parents: 2980
diff changeset
   307
! !
efb7b0c760f5 blocked deepCopying of fonts
Claus Gittinger <cg@exept.de>
parents: 2980
diff changeset
   308
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   309
!Font methodsFor:'displaying'!
71
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   310
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   311
displayOpaqueString:aString from:index1 to:index2 x:x y:y in:aGC
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   312
    "this is only called for fonts which have a nil fontId,
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   313
     and therefore use the replacementFont. Should never be called
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   314
     for non-replacement fonts."
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   315
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   316
    |prevFont|
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   317
2545
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   318
    prevFont := aGC font.
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   319
    replacementFont isNil ifTrue:[
2545
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   320
        fontId notNil ifTrue:[
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   321
            aGC basicFont:self.
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   322
            aGC displayOpaqueString:aString from:index1 to:index2 x:x y:y.
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   323
        ] ifFalse:[
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   324
            'Font: [warning]: no replacementFont. should not happen' errorPrintCR.
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   325
        ].
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   326
    ] ifFalse:[
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   327
        aGC basicFont:replacementFont.
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   328
        aGC displayOpaqueString:aString from:index1 to:index2 x:x y:y.
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   329
    ].
442
eb4ee58f5f0a use #basicFont:
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   330
    aGC basicFont:prevFont
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   331
1176
e0e2c8cbb3c8 newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 1166
diff changeset
   332
    "Modified: 10.1.1997 / 17:51:10 / cg"
71
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   333
!
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   334
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   335
displayString:aString from:index1 to:index2 x:x y:y in:aGC
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   336
    "this is only called for fonts which have a nil fontId,
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   337
     and therefore use the replacementFont. Should never be called
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   338
     for non-replacement fonts."
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   339
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   340
    |prevFont|
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   341
2545
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   342
    prevFont := aGC font.
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   343
    replacementFont isNil ifTrue:[
2545
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   344
        fontId notNil ifTrue:[
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   345
            aGC basicFont:self.
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   346
            aGC displayString:aString from:index1 to:index2 x:x y:y.
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   347
        ] ifFalse:[
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   348
            'Font: [warning]: no replacementFont. should not happen' errorPrintCR.
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   349
        ].
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   350
    ] ifFalse:[
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   351
        aGC basicFont:replacementFont.
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   352
        aGC displayString:aString from:index1 to:index2 x:x y:y.
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   353
    ].
442
eb4ee58f5f0a use #basicFont:
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   354
    aGC basicFont:prevFont.
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   355
1176
e0e2c8cbb3c8 newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 1166
diff changeset
   356
    "Modified: 10.1.1997 / 17:51:17 / cg"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   357
! !
48194c26a46c Initial revision
claus
parents:
diff changeset
   358
48194c26a46c Initial revision
claus
parents:
diff changeset
   359
!Font methodsFor:'getting a device font'!
48194c26a46c Initial revision
claus
parents:
diff changeset
   360
48194c26a46c Initial revision
claus
parents:
diff changeset
   361
on:aDevice
48194c26a46c Initial revision
claus
parents:
diff changeset
   362
    "create a new Font representing the same font as
48194c26a46c Initial revision
claus
parents:
diff changeset
   363
     myself on aDevice; if one already exists, return the one."
48194c26a46c Initial revision
claus
parents:
diff changeset
   364
3623
16665d9b7263 #on: -> #onDevice
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
   365
    "/ send out a warning: #on: is typically used to create views
16665d9b7263 #on: -> #onDevice
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
   366
    "/ operating on a model.
16665d9b7263 #on: -> #onDevice
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
   367
    "/ Please use #onDevice: to avoid confusion.
16665d9b7263 #on: -> #onDevice
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
   368
16665d9b7263 #on: -> #onDevice
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
   369
    <resource:#obsolete>
16665d9b7263 #on: -> #onDevice
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
   370
16665d9b7263 #on: -> #onDevice
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
   371
    self obsoleteMethodWarning:'use #onDevice:'.
2848
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   372
    ^ self onDevice:aDevice
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   373
!
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   374
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   375
on:aDevice ifAbsent:exceptionBlock 
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   376
    "create a new Font representing the same font as
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   377
     myself on aDevice. This does NOT try to look for existing
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   378
     or replacement fonts (i.e. can be used to get physical fonts)."
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   379
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   380
    |newFont id|
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   381
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   382
    "ask that device for the font"
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   383
    id := aDevice getFontWithFamily:family face:face style:style size:size encoding:encoding.
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   384
    id isNil ifTrue:[
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   385
        "oops did not work - (device has no such font)"
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   386
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   387
        ^ exceptionBlock value
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   388
    ].
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   389
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   390
    "receiver was not associated - do it now"
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   391
    device isNil ifTrue:[
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   392
        device := aDevice.
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   393
        fontId := id.
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   394
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   395
        self getFontInfos.
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   396
        aDevice registerFont:self.
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   397
        ^ self
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   398
    ].
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   399
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   400
    "receiver was already associated to another device - need a new font"
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   401
    newFont := (self class basicNew) 
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   402
                        setFamily:family 
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   403
                        face:face
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   404
                        style:style
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   405
                        size:size
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   406
                        encoding:encoding
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   407
                        device:aDevice.
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   408
    newFont setFontId:id.
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   409
    newFont getFontInfos.
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   410
    aDevice registerFont:newFont.
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   411
    ^ newFont
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   412
!
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   413
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   414
onDevice:aDevice
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   415
    "create a new Font representing the same font as
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   416
     myself on aDevice; if one already exists, return the one."
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   417
336
fa55b8596c8c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   418
    |newFont rep|
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   419
48194c26a46c Initial revision
claus
parents:
diff changeset
   420
    "if I am already assigned to that device ..."
48194c26a46c Initial revision
claus
parents:
diff changeset
   421
    (device == aDevice) ifTrue:[^ self].
48194c26a46c Initial revision
claus
parents:
diff changeset
   422
2980
409e9547a45c ignore nil device in #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2925
diff changeset
   423
    aDevice isNil ifTrue:[^ self].
409e9547a45c ignore nil device in #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2925
diff changeset
   424
        
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   425
    "first look if not already there"
1372
2b55617a712f keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   426
    aDevice deviceFonts do:[:aFont |
2b55617a712f keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   427
        (size == aFont size) ifTrue:[
2b55617a712f keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   428
            (family = aFont family) ifTrue:[
2b55617a712f keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   429
                (face = aFont face) ifTrue:[
2b55617a712f keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   430
                    (style = aFont style) ifTrue:[
2b55617a712f keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   431
                        (encoding isNil or:[encoding == aFont encoding]) ifTrue:[
2b55617a712f keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   432
                            ^ aFont
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   433
                        ]
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   434
                    ]
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   435
                ]
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   436
            ]
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   437
        ]
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   438
    ].
48194c26a46c Initial revision
claus
parents:
diff changeset
   439
157
claus
parents: 151
diff changeset
   440
    newFont := self on:aDevice ifAbsent:nil.
claus
parents: 151
diff changeset
   441
    newFont isNil ifTrue:[
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   442
        "oops did not work - (device has no such font)"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   443
1596
579d2c28f824 raise an error, if trying to get a font from a disconnected
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
   444
        aDevice isOpen ifFalse:[
579d2c28f824 raise an error, if trying to get a font from a disconnected
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
   445
            "/ the display device is not connected
579d2c28f824 raise an error, if trying to get a font from a disconnected
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
   446
            "/ (or has a broken connection).
3060
9b16d027bf7b better debugMessage
Claus Gittinger <cg@exept.de>
parents: 3027
diff changeset
   447
            self error:'trying to get font from closed display:', aDevice printString.
1596
579d2c28f824 raise an error, if trying to get a font from a disconnected
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
   448
            ^ self.
579d2c28f824 raise an error, if trying to get a font from a disconnected
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
   449
        ].
579d2c28f824 raise an error, if trying to get a font from a disconnected
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
   450
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   451
        rep := self replacementFontOn:aDevice.
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   452
        device isNil ifTrue:[
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   453
            device := aDevice.
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   454
            replacementFont := rep.
1372
2b55617a712f keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   455
            aDevice registerFont:self.
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   456
            ^ self
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   457
        ].
1372
2b55617a712f keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   458
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   459
        newFont := (self class basicNew)
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   460
                     setFamily:family face:face style:style size:size encoding:encoding device:aDevice.
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   461
        newFont setReplacementFont:rep.
1372
2b55617a712f keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   462
        aDevice registerFont:newFont.
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   463
        ^ newFont
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   464
    ].
48194c26a46c Initial revision
claus
parents:
diff changeset
   465
48194c26a46c Initial revision
claus
parents:
diff changeset
   466
    ^ newFont
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   467
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   468
    "
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   469
     Font family:'foo' size:17
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   470
    "
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   471
1596
579d2c28f824 raise an error, if trying to get a font from a disconnected
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
   472
    "Modified: 14.4.1997 / 18:22:31 / cg"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   473
!
48194c26a46c Initial revision
claus
parents:
diff changeset
   474
48194c26a46c Initial revision
claus
parents:
diff changeset
   475
replacementFontOn:aDevice
12
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   476
    "return a replacement font for the receiver - this is needed, if
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   477
     an image is restored on another type of display, or one which has
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   478
     a different set of fonts."
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   479
48194c26a46c Initial revision
claus
parents:
diff changeset
   480
    |id f alternative|
48194c26a46c Initial revision
claus
parents:
diff changeset
   481
144
claus
parents: 127
diff changeset
   482
    alternative := Replacements at:family ifAbsent:nil.
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   483
    alternative notNil ifTrue:[
454
b31d0a7e5530 nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   484
        id := aDevice getFontWithFamily:alternative
b31d0a7e5530 nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   485
                                   face:face
b31d0a7e5530 nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   486
                                  style:style 
b31d0a7e5530 nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   487
                                   size:size
b31d0a7e5530 nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   488
                               encoding:encoding.
144
claus
parents: 127
diff changeset
   489
    ].
claus
parents: 127
diff changeset
   490
    id notNil ifTrue:[
1166
a3bd26b25dc3 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   491
        ('Font [info]: use alternative for ' , (self userFriendlyName)) infoPrintCR.
144
claus
parents: 127
diff changeset
   492
    ] ifFalse:[
454
b31d0a7e5530 nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   493
        id := aDevice getDefaultFont.
1166
a3bd26b25dc3 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   494
        ('Font [info]: use default for ' , (self userFriendlyName)) infoPrintCR.
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   495
    ].
48194c26a46c Initial revision
claus
parents:
diff changeset
   496
    id isNil ifTrue:[
454
b31d0a7e5530 nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   497
        "oops did not work - this is a serious an error"
b31d0a7e5530 nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   498
        self error:'cannot get default font'.
b31d0a7e5530 nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   499
        ^ nil
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   500
    ].
48194c26a46c Initial revision
claus
parents:
diff changeset
   501
    f := self class basicNew.
48194c26a46c Initial revision
claus
parents:
diff changeset
   502
    f setDevice:aDevice fontId:id.
48194c26a46c Initial revision
claus
parents:
diff changeset
   503
    f getFontInfos.
1372
2b55617a712f keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   504
    aDevice registerFont:f.
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   505
    ^ f
454
b31d0a7e5530 nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   506
1166
a3bd26b25dc3 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   507
    "Modified: 10.1.1997 / 15:40:21 / cg"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   508
! !
48194c26a46c Initial revision
claus
parents:
diff changeset
   509
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   510
!Font methodsFor:'instance release'!
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   511
2848
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   512
executor
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   513
    "redefined to return a lightweight copy 
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   514
     - all we need is the device handle"
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   515
2848
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   516
    ^ DeviceFontHandle basicNew setDevice:device fontId:fontId.
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   517
2433
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
   518
    "Modified: / 20.4.1996 / 23:23:04 / cg"
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
   519
    "Modified: / 3.2.1999 / 16:13:10 / stefan"
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   520
! !
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   521
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   522
!Font methodsFor:'printing & storing'!
48194c26a46c Initial revision
claus
parents:
diff changeset
   523
109
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   524
printOn:aStream
2805
2efe543c9788 comment
Claus Gittinger <cg@exept.de>
parents: 2767
diff changeset
   525
    "append a user printed representation of the receiver to aStream.
2efe543c9788 comment
Claus Gittinger <cg@exept.de>
parents: 2767
diff changeset
   526
     The format is suitable for a human - not meant to be read back.
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   527
     Redefined to print more about the fonts name"
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   528
46
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
   529
    face isNil ifTrue:[
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   530
        family isNil ifTrue:[
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   531
            aStream nextPutAll:('a replacement-Font').
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   532
            ^ self
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   533
        ].
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   534
        aStream nextPutAll:('a ' , family , '-Font').
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   535
        ^ self.
46
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
   536
    ].
109
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   537
    aStream nextPutAll:('a ' , family , '-' , 
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   538
                               face , '-' , 
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   539
                               style , '-' , 
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   540
                               size printString , '-Font')
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   541
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   542
    "Modified: 20.4.1996 / 23:25:11 / cg"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   543
!
48194c26a46c Initial revision
claus
parents:
diff changeset
   544
109
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   545
storeOn:aStream
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   546
    "append a character sequence to the argument, aStream from which the
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   547
     receiver can be reconstructed using readFrom:."
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   548
109
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   549
    aStream nextPutAll:'(Font family:'. family storeOn:aStream.
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   550
    aStream nextPutAll:' face:'.        face storeOn:aStream.
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   551
    aStream nextPutAll:' style:'.       style storeOn:aStream.
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   552
    aStream nextPutAll:' size:'.        size storeOn:aStream.
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   553
    aStream nextPutAll:' encoding:'.    encoding storeOn:aStream.
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   554
    aStream nextPut:$)
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   555
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   556
    "
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   557
     (Font family:'helvetica' size:10) storeString
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   558
    "
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   559
! !
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   560
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   561
!Font methodsFor:'private'!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   562
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   563
getFontInfos
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   564
    "ask the device about all of my actual attributes"
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   565
3479
e647bc300eba fontMetric stuff changed
Claus Gittinger <cg@exept.de>
parents: 3415
diff changeset
   566
    |b info|
991
b3a0b903bd7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   567
3479
e647bc300eba fontMetric stuff changed
Claus Gittinger <cg@exept.de>
parents: 3415
diff changeset
   568
    replacementFont notNil ifTrue:[
e647bc300eba fontMetric stuff changed
Claus Gittinger <cg@exept.de>
parents: 3415
diff changeset
   569
        replacementFont getFontInfos.
e647bc300eba fontMetric stuff changed
Claus Gittinger <cg@exept.de>
parents: 3415
diff changeset
   570
        ^ self
e647bc300eba fontMetric stuff changed
Claus Gittinger <cg@exept.de>
parents: 3415
diff changeset
   571
    ].
991
b3a0b903bd7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   572
3479
e647bc300eba fontMetric stuff changed
Claus Gittinger <cg@exept.de>
parents: 3415
diff changeset
   573
    info := device fontMetricsOf:fontId.
3527
cac44b80270e ps font fixes
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
   574
    encoding := info encoding.
cac44b80270e ps font fixes
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
   575
    encoding isNil ifTrue:[
cac44b80270e ps font fixes
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
   576
        encoding := device encodingOf:fontId.
cac44b80270e ps font fixes
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
   577
    ].
3479
e647bc300eba fontMetric stuff changed
Claus Gittinger <cg@exept.de>
parents: 3415
diff changeset
   578
    ascent := info ascent.
e647bc300eba fontMetric stuff changed
Claus Gittinger <cg@exept.de>
parents: 3415
diff changeset
   579
    descent := info descent.
e647bc300eba fontMetric stuff changed
Claus Gittinger <cg@exept.de>
parents: 3415
diff changeset
   580
    maxAscent := info maxAscent.
e647bc300eba fontMetric stuff changed
Claus Gittinger <cg@exept.de>
parents: 3415
diff changeset
   581
    maxDescent := info maxDescent.
e647bc300eba fontMetric stuff changed
Claus Gittinger <cg@exept.de>
parents: 3415
diff changeset
   582
    minWidth := info minWidth.
e647bc300eba fontMetric stuff changed
Claus Gittinger <cg@exept.de>
parents: 3415
diff changeset
   583
    maxWidth := info maxWidth.
e647bc300eba fontMetric stuff changed
Claus Gittinger <cg@exept.de>
parents: 3415
diff changeset
   584
    width := info averageWidth.
991
b3a0b903bd7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   585
b3a0b903bd7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   586
    width < minWidth ifTrue:[
b3a0b903bd7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   587
        "/ some systems/fonts return a wrong value (0) as width of a space
b3a0b903bd7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   588
        "/ - at least with X11 ...
b3a0b903bd7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   589
        width := minWidth
994
7e720b29c838 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 991
diff changeset
   590
    ].
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   591
    isFixedWidth := minWidth == maxWidth
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   592
710
f80fd1a73956 commentary
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
   593
    "Modified: 22.5.1996 / 13:08:40 / cg"
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   594
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   595
2846
05c5fdd17641 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2833
diff changeset
   596
releaseFromDevice
05c5fdd17641 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2833
diff changeset
   597
    "I am no longer available on the device"
05c5fdd17641 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2833
diff changeset
   598
05c5fdd17641 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2833
diff changeset
   599
    device := nil.
05c5fdd17641 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2833
diff changeset
   600
    fontId := nil.
05c5fdd17641 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2833
diff changeset
   601
    replacementFont := nil
05c5fdd17641 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2833
diff changeset
   602
05c5fdd17641 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2833
diff changeset
   603
    "Modified: 20.4.1996 / 23:26:26 / cg"
05c5fdd17641 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2833
diff changeset
   604
!
05c5fdd17641 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2833
diff changeset
   605
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   606
restored
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   607
    "flush device handles when restored"
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   608
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   609
    device := nil.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   610
    fontId := nil.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   611
    replacementFont := nil
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   612
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   613
    "Modified: 20.4.1996 / 23:26:26 / cg"
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   614
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   615
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   616
setDevice:aDevice
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   617
    "set the device handle"
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   618
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   619
    device := aDevice
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   620
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   621
    "Modified: 20.4.1996 / 23:26:35 / cg"
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   622
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   623
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   624
setDevice:aDevice fontId:aFontId
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   625
    "set the device and font handles"
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   626
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   627
    device := aDevice.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   628
    fontId := aFontId
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   629
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   630
    "Modified: 20.4.1996 / 23:26:43 / cg"
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   631
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   632
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   633
setFamily:familyString face:faceString style:styleString size:sizeNum encoding:encodingSym device:aDevice
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   634
    "set my instance attributes"
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   635
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   636
    family := familyString.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   637
    face := faceString.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   638
    style := styleString.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   639
    size := sizeNum.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   640
    encoding := encodingSym.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   641
    device := aDevice
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   642
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   643
    "Modified: 20.4.1996 / 23:26:56 / cg"
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   644
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   645
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   646
setFontId:aFontId
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   647
    "set my font handle"
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   648
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   649
    fontId := aFontId
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   650
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   651
    "Modified: 20.4.1996 / 23:27:05 / cg"
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   652
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   653
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   654
setReplacementFont:aFont
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   655
    "set my replacement font"
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   656
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   657
    replacementFont := aFont
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   658
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   659
    "Modified: 20.4.1996 / 23:27:16 / cg"
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   660
! !
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   661
2545
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   662
!Font methodsFor:'queries-deviceFonts'!
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   663
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   664
fullName
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   665
    "return the full (device specific) name of the receiver.
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   666
     This is query only valid if the receiver is associated to a device"
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   667
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   668
    device isNil ifTrue:[
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   669
        ^ nil
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   670
    ].
3415
5318d7f58d35 Rename #fullNameOf: to #fullFontNameOf:
Stefan Vogel <sv@exept.de>
parents: 3213
diff changeset
   671
    ^ device fullFontNameOf:fontId.
2545
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   672
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   673
    "
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   674
     ((Font name:'6x10') on:Display) fullName  
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   675
    "
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   676
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   677
    "Modified: 30.4.1996 / 17:30:10 / cg"
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   678
!
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   679
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   680
isFixedWidth
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   681
    "return true, if all characters have same width (as in courier).
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   682
     The receiver must be associated to a device,
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   683
     for this query to be legal."
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   684
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   685
    device isNil ifTrue:[
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   686
	self errorNoDevice.
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   687
    ].
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   688
    replacementFont notNil ifTrue:[
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   689
	^ replacementFont isFixedWidth
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   690
    ].
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   691
    ^ isFixedWidth
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   692
! !
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   693
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   694
!Font methodsFor:'queries-dimensions'!
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   695
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   696
ascent
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   697
    "return the font-ascent (i.e. the normal average of all characters);
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   698
     That is the number of units (usually pixels) above the baseline.
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   699
     The receiver must be associated to a device,
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   700
     for this query to be legal."
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   701
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   702
    device isNil ifTrue:[
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   703
	self errorNoDevice
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   704
    ].
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   705
    replacementFont notNil ifTrue:[
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   706
	^ replacementFont ascent
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   707
    ].
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   708
    ^ ascent
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   709
!
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   710
628
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   711
ascentOn:aDevice
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   712
    "return the fonts ascent (average), if used on aDevice."
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   713
2321
75a179c343cf try replacement forn first if nonnil in queries
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
   714
    replacementFont notNil ifTrue:[
75a179c343cf try replacement forn first if nonnil in queries
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
   715
        ^ replacementFont ascentOn:aDevice
75a179c343cf try replacement forn first if nonnil in queries
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
   716
    ].
628
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   717
    device == aDevice ifTrue:[
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   718
        ^ ascent
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   719
    ].
2833
90f9a9f6a05d #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2805
diff changeset
   720
    ^ (self onDevice:aDevice) ascent
628
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   721
2321
75a179c343cf try replacement forn first if nonnil in queries
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
   722
    "Created: / 30.4.1996 / 16:41:32 / cg"
75a179c343cf try replacement forn first if nonnil in queries
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
   723
    "Modified: / 10.9.1998 / 12:09:06 / cg"
628
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   724
!
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   725
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   726
descent
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   727
    "return the font-descent (i.e. the normal average of all characters);
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   728
     That is the number of units (usually pixels) below the baseline.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   729
     The receiver must be associated to a device,
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   730
     for this query to be legal."
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   731
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   732
    device isNil ifTrue:[
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   733
	self errorNoDevice
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   734
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   735
    replacementFont notNil ifTrue:[
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   736
	^ replacementFont descent
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   737
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   738
    ^ descent
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   739
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   740
2545
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   741
descentOn:aDevice
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   742
    "return the fonts descent (average), if used on aDevice."
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   743
2545
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   744
    replacementFont notNil ifTrue:[
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   745
        ^ replacementFont descentOn:aDevice
438
03e433e2be99 return encoding & fullNames
Claus Gittinger <cg@exept.de>
parents: 435
diff changeset
   746
    ].
2545
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   747
    device == aDevice ifTrue:[
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   748
        ^ descent
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   749
    ].
2833
90f9a9f6a05d #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2805
diff changeset
   750
    ^ (self onDevice:aDevice) descent
438
03e433e2be99 return encoding & fullNames
Claus Gittinger <cg@exept.de>
parents: 435
diff changeset
   751
2545
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   752
    "Created: / 30.4.1996 / 16:41:43 / cg"
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   753
    "Modified: / 10.9.1998 / 12:09:30 / cg"
438
03e433e2be99 return encoding & fullNames
Claus Gittinger <cg@exept.de>
parents: 435
diff changeset
   754
!
03e433e2be99 return encoding & fullNames
Claus Gittinger <cg@exept.de>
parents: 435
diff changeset
   755
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   756
height
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   757
    "return the fonts characters normal (average) height;
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   758
     That is the number of units (usually pixels) on the device.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   759
     The receiver must be associated to a device,
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   760
     for this query to be legal."
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   761
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   762
    device isNil ifTrue:[
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   763
	self errorNoDevice.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   764
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   765
    replacementFont notNil ifTrue:[
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   766
	^ replacementFont height
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   767
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   768
    ^ descent + ascent.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   769
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   770
667
091cc1707848 height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   771
heightOf:textOrString
091cc1707848 height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   772
    "return the height (device specific) of the argument;
091cc1707848 height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   773
     the argument must be a String.
091cc1707848 height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   774
     CAVEAT:
091cc1707848 height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   775
        currently only constant height fonts are supported."
091cc1707848 height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   776
091cc1707848 height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   777
    device isNil ifTrue:[
091cc1707848 height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   778
        self errorNoDevice.
091cc1707848 height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   779
        ^ 0
091cc1707848 height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   780
    ].
091cc1707848 height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   781
    replacementFont notNil ifTrue:[
091cc1707848 height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   782
        ^ replacementFont heightOf:textOrString
091cc1707848 height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   783
    ].
091cc1707848 height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   784
091cc1707848 height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   785
    ^ descent + ascent
091cc1707848 height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   786
091cc1707848 height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   787
    "Created: 12.5.1996 / 11:05:00 / cg"
091cc1707848 height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   788
!
091cc1707848 height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   789
2545
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   790
heightOf:aString on:aDevice
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   791
    "return the height of aString, if displayed on aDevice.
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   792
     The argument must be a string-like object."
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   793
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   794
    replacementFont notNil ifTrue:[
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   795
        ^ replacementFont heightOf:aString on:aDevice
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   796
    ].
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   797
    device == aDevice ifTrue:[
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   798
        ^ self heightOf:aString
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   799
    ].
2833
90f9a9f6a05d #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2805
diff changeset
   800
    ^ (self onDevice:aDevice) heightOf:aString
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   801
2545
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   802
    "Created: / 30.4.1996 / 17:14:18 / cg"
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   803
    "Modified: / 10.9.1998 / 12:09:47 / cg"
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   804
!
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   805
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   806
heightOn:aDevice
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   807
    "return the fonts height (average), if used on aDevice."
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   808
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   809
    replacementFont notNil ifTrue:[
2545
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   810
        ^ replacementFont heightOn:aDevice
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   811
    ].
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   812
    device == aDevice ifTrue:[
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   813
        ^ descent + ascent
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   814
    ].
2833
90f9a9f6a05d #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2805
diff changeset
   815
    ^ (self onDevice:aDevice) height
2545
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   816
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   817
    "Created: / 30.4.1996 / 16:41:59 / cg"
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   818
    "Modified: / 10.9.1998 / 12:08:18 / cg"
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   819
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   820
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   821
maxAscent
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   822
    "return the fonts maximum-ascent (i.e. the maximum of all characters);
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   823
     That is the number of units (usually pixels) above the baseline.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   824
     The receiver must be associated to a device,
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   825
     for this query to be legal."
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   826
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   827
    device isNil ifTrue:[
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   828
	self errorNoDevice
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   829
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   830
    replacementFont notNil ifTrue:[
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   831
	^ replacementFont maxAscent
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   832
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   833
    ^ maxAscent
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   834
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   835
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   836
maxDescent
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   837
    "return the font-descent (i.e. the maximum of all characters);
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   838
     That is the number of units (usually pixels) below the baseline.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   839
     The receiver must be associated to a device,
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   840
     for this query to be legal."
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   841
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   842
    device isNil ifTrue:[
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   843
	self errorNoDevice
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   844
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   845
    replacementFont notNil ifTrue:[
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   846
	^ replacementFont maxDescent
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   847
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   848
    ^ maxDescent
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   849
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   850
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   851
maxHeight
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   852
    "return the fonts characters maximum height;
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   853
     That is the number of units (usually pixels) on the device.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   854
     The receiver must be associated to a device,
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   855
     for this query to be legal."
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   856
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   857
    device isNil ifTrue:[
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   858
	self errorNoDevice.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   859
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   860
    replacementFont notNil ifTrue:[
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   861
	^ replacementFont maxHeight
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   862
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   863
    ^ maxDescent + maxAscent.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   864
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   865
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   866
maxWidth
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   867
    "return the width of the widest character;
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   868
     if the receiver is a fixed width font its the width of every character.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   869
     The receiver must be associated to a device,
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   870
     for this query to be legal."
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   871
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   872
    device isNil ifTrue:[
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   873
	self errorNoDevice
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   874
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   875
    replacementFont notNil ifTrue:[
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   876
	^ replacementFont maxWidth
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   877
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   878
    ^ maxWidth
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   879
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   880
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   881
minWidth
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   882
    "return the width of the smallest character;
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   883
     if the receiver is a fixed width font its the width of every character.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   884
     The receiver must be associated to a device,
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   885
     for this query to be legal."
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   886
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   887
    device isNil ifTrue:[
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   888
	self errorNoDevice
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   889
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   890
    replacementFont notNil ifTrue:[
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   891
	^ replacementFont minWidth
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   892
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   893
    ^ minWidth
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   894
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   895
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   896
width
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   897
    "return the fonts characters width;
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   898
     That is the number of units (usually pixels) on the device.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   899
     For variable pitch fonts, the width of the space character is returned.
628
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   900
     For fixed fonts, this is the same as minWidth or maxWidth (or any character).
2545
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   901
     The receiver must be associated to a device, for this query to be legal."
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   902
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   903
    device isNil ifTrue:[
628
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   904
        self errorNoDevice.
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   905
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   906
    replacementFont notNil ifTrue:[
628
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   907
        ^ replacementFont width
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   908
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   909
    ^ width
628
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   910
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   911
    "Modified: 30.4.1996 / 16:43:45 / cg"
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   912
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   913
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   914
widthOf:textOrString
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   915
    "return the width (device specific) of the argument;
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   916
     the argument may be a Character, String or some Text;
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   917
     in the last case the width of the longest line in the text is returned.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   918
     The receiver must be associated to a device,
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   919
     for this query to be legal."
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   920
3483
b5f133131653 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3479
diff changeset
   921
    |this max string|
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   922
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   923
    device isNil ifTrue:[
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   924
        self errorNoDevice.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   925
        ^ 0
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   926
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   927
    replacementFont notNil ifTrue:[
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   928
        ^ replacementFont widthOf:textOrString
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   929
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   930
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   931
    (textOrString isString) ifTrue:[
3483
b5f133131653 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3479
diff changeset
   932
        string := textOrString string.
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   933
        isFixedWidth ifFalse:[
3483
b5f133131653 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3479
diff changeset
   934
            ^ device widthOf:string inFont:fontId
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   935
        ].
3483
b5f133131653 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3479
diff changeset
   936
        ^ width * string size
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   937
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   938
    (textOrString isCharacter) ifTrue:[
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   939
        isFixedWidth ifFalse:[
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   940
            ^ device widthOf:textOrString asString inFont:fontId
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   941
        ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   942
        ^ width
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   943
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   944
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   945
    max := 0.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   946
    isFixedWidth ifFalse:[
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   947
        textOrString do:[:line |
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   948
            line notNil ifTrue:[
435
5288c637512e care for nonStrings when asked for the size
Claus Gittinger <cg@exept.de>
parents: 434
diff changeset
   949
                this := device widthOf:line asString inFont:fontId.
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   950
                (this > max) ifTrue:[max := this]
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   951
            ]
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   952
        ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   953
        ^ max
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   954
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   955
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   956
    textOrString do:[:lineString |
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   957
        this := lineString size.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   958
        (this > max) ifTrue:[max := this]
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   959
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   960
    ^ max * width
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   961
1087
1e5a93e03d7f handle text-argument in withOf:
Claus Gittinger <cg@exept.de>
parents: 1067
diff changeset
   962
    "Modified: 22.10.1996 / 17:11:14 / cg"
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   963
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   964
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   965
widthOf:aString from:start to:stop
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   966
    "return the width of a substring.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   967
     The receiver must be associated to a device,
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   968
     for this query to be legal."
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   969
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   970
    device isNil ifTrue:[
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   971
	self errorNoDevice.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   972
	^ 0
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   973
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   974
    replacementFont notNil ifTrue:[
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   975
	^ replacementFont widthOf:aString from:start to:stop
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   976
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   977
    (stop < start) ifTrue:[^ 0].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   978
    isFixedWidth ifFalse:[
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   979
	^ device widthOf:aString from:start to:stop inFont:fontId
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   980
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   981
    ^ (stop - start + 1) * width
2545
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   982
!
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   983
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   984
widthOf:aString from:startIndex to:endIndex on:aDevice
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   985
    "return the width of substring, if displayed on aDevice.
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   986
     The argument may be a Character, String or some Text;
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   987
     in the last case the width of the longest line in the text is returned."
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   988
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   989
    replacementFont notNil ifTrue:[
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   990
        ^ replacementFont widthOf:aString from:startIndex to:endIndex on:aDevice
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   991
    ].
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   992
    device == aDevice ifTrue:[
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   993
        ^ self widthOf:aString from:startIndex to:endIndex
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   994
    ].
2833
90f9a9f6a05d #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2805
diff changeset
   995
    ^ (self onDevice:aDevice) widthOf:aString from:startIndex to:endIndex
2545
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   996
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   997
    "Created: / 30.4.1996 / 17:15:20 / cg"
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   998
    "Modified: / 10.9.1998 / 12:10:11 / cg"
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   999
!
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1000
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1001
widthOf:aString on:aDevice
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1002
    "return the width of aString, if displayed on aDevice.
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1003
     The argument may be a Character, String or some Text;
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1004
     in the last case the width of the longest line in the text is returned."
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1005
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1006
    replacementFont notNil ifTrue:[
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1007
        ^ replacementFont widthOf:aString on:aDevice
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1008
    ].
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1009
    device == aDevice ifTrue:[
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1010
        ^ self widthOf:aString
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1011
    ].
2833
90f9a9f6a05d #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2805
diff changeset
  1012
    ^ (self onDevice:aDevice) widthOf:aString
2545
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1013
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1014
    "Created: / 30.4.1996 / 17:14:18 / cg"
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1015
    "Modified: / 10.9.1998 / 12:10:26 / cg"
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1016
!
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1017
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1018
widthOn:aDevice
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1019
    "return the fonts width, if used on aDevice.
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1020
     For variable pitch fonts, the width of the space character is returned.
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1021
     For fixed fonts, this is the same as minWidth or maxWidth (or any character)."
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1022
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1023
    replacementFont notNil ifTrue:[
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1024
        ^ replacementFont widthOn:aDevice
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1025
    ].
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1026
    device == aDevice ifTrue:[
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1027
        ^ self width
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1028
    ].
2833
90f9a9f6a05d #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2805
diff changeset
  1029
    ^ (self onDevice:aDevice) width
2545
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1030
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1031
    "Created: / 30.4.1996 / 16:42:28 / cg"
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1032
    "Modified: / 10.9.1998 / 12:11:33 / cg"
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
  1033
! !
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1034
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1035
!Font methodsFor:'st-80 queries'!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1036
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1037
fixedWidth
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1038
    "return true, if this font is a fixed width font -
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1039
     for st-80 compatibility"
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1040
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1041
    ^ self isFixedWidth
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1042
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1043
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1044
pixelSize
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1045
    "return the height of the font in pixels -
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1046
     for st-80 compatibility"
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1047
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1048
    ^ self height
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1049
! !
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1050
2433
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1051
!Font::DeviceFontHandle class methodsFor:'documentation'!
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1052
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1053
documentation
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1054
"
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1055
    This is used as a finalization handle for fonts.
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1056
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1057
    [author:]
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1058
        Stefan Vogel (stefan@nilpferd)
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1059
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1060
    [see also:]
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1061
        Font
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1062
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1063
    [instance variables:]
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1064
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1065
    [class variables:]
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1066
"
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1067
! !
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1068
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1069
!Font::DeviceFontHandle methodsFor:'accessing'!
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1070
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1071
setDevice:aDevice fontId:anId
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1072
    "set the handles contents"
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1073
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1074
    device := aDevice.
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1075
    fontId := anId.
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1076
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1077
    "Created: / 3.2.1999 / 16:08:31 / stefan"
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1078
! !
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1079
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1080
!Font::DeviceFontHandle methodsFor:'finalization'!
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1081
3611
8b4384c9e660 Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents: 3527
diff changeset
  1082
finalize
2433
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1083
    "some Font has been collected - tell it to the x-server"
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1084
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1085
    |id|
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1086
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1087
    (id := fontId) notNil ifTrue:[
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1088
        fontId := nil.
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1089
        device releaseFont:id.
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1090
    ]
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1091
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1092
    "Created: / 3.2.1999 / 16:09:25 / stefan"
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1093
! !
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1094
1087
1e5a93e03d7f handle text-argument in withOf:
Claus Gittinger <cg@exept.de>
parents: 1067
diff changeset
  1095
!Font class methodsFor:'documentation'!
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1096
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1097
version
3623
16665d9b7263 #on: -> #onDevice
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1098
    ^ '$Header: /cvs/stx/stx/libview/Font.st,v 1.82 2002-05-06 06:03:47 cg Exp $'
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1099
! !
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1100
Font initialize!