Font.st
author Claus Gittinger <cg@exept.de>
Tue, 30 Apr 1996 17:31:16 +0200
changeset 628 4ac28f9d9c7b
parent 611 e0442439a3c6
child 667 091cc1707848
permissions -rw-r--r--
added queries a-la #widthOn:aDevice
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
109
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
    13
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
    14
	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
    15
		minWidth maxWidth maxAscent maxDescent'
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
    16
	classVariableNames:'Lobby Replacements'
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
    17
	poolDictionaries:''
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
    18
	category:'Graphics-Support'
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    19
!
48194c26a46c Initial revision
claus
parents:
diff changeset
    20
48194c26a46c Initial revision
claus
parents:
diff changeset
    21
!Font class methodsFor:'documentation'!
48194c26a46c Initial revision
claus
parents:
diff changeset
    22
46
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    23
copyright
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    24
"
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    25
 COPYRIGHT (c) 1992 by Claus Gittinger
71
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
    26
	      All Rights Reserved
46
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    27
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    28
 This software is furnished under a license and may be used
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    29
 only in accordance with the terms of that license and with the
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    31
 be provided or otherwise made available to, or used by, any
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    32
 other person.  No title to or ownership of the software is
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    33
 hereby transferred.
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    34
"
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    35
!
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    36
46
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    37
documentation
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    38
"
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    39
    Font represents fonts in a device independent manner; after being
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    40
    created using 'Font family:family face:face style:style size:size',
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    41
    the returned font is not associated to a specific device.
157
claus
parents: 151
diff changeset
    42
    (therefore, those fonts can be used to draw on any GC)
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    43
46
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    44
    To get a device font, any font can be sent the message
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    45
    'aFont on:aDevice' which returns an instance of Font which is
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    46
    associated to a device (it returns the receiver, if that is already
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    47
    associated to that device).
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    48
46
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    49
    For proper operation, each graphics operation working with fonts
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    50
    must get a device font before doing the draw.
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    51
    Most draw methods in DeviceDrawable do that automatically for you, 
157
claus
parents: 151
diff changeset
    52
    before doing the draw; so you do not have to care.
46
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    53
81
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    54
    However, some operations require explicit conversion to a device font
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    55
    before being allowed. For example, a query for a fonts height (in device
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    56
    units) can only be done if the font being asked is associated to
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    57
    a device (which should be clear, since a 'courier-roman-12' font may
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    58
    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
    59
    a totally different number of device units on a 600dpi laser printer.
81
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    60
    Thus, to query a font for its height (or ascent, or descent, or width),
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    61
    use something like:
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    62
564
3ddccbec4ee7 commentary
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
    63
        myFont := Font family:'courier' ... size:12.
3ddccbec4ee7 commentary
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
    64
            ...
81
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    65
        
564
3ddccbec4ee7 commentary
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
    66
        'want to know its height on the Display'
81
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    67
        
564
3ddccbec4ee7 commentary
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
    68
        h := (myFont on:Display) height.
81
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    69
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    70
        
564
3ddccbec4ee7 commentary
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
    71
        'want to know its height on a printer'
81
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    72
        
564
3ddccbec4ee7 commentary
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
    73
        h := (myFont on:aPrinter) height.
81
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    74
        
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    75
    Keep in mind, that each device is free to think in whatever units it
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    76
    likes - a display may return units of pixels, a postscript printer may
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    77
    think in (fractions of) inches, a dot matrix printer may think in dots.
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    78
    Also, notice that currently only graphic displays are really supported;
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    79
    printer devices are being developped and may or may not be in the current
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    80
    system.
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    81
564
3ddccbec4ee7 commentary
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
    82
    If a font cannot be represented on a device, a replacement
46
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    83
    font is chosen and kept in the replacementFont instance variable. 
564
3ddccbec4ee7 commentary
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
    84
    This is done to preserve the original font information, in case the image
3ddccbec4ee7 commentary
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
    85
    is restarted later on another display which has that font available.
3ddccbec4ee7 commentary
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
    86
3ddccbec4ee7 commentary
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
    87
3ddccbec4ee7 commentary
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
    88
    All device fonts are registered in a Lobby object (a registry) and
3ddccbec4ee7 commentary
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
    89
    the underlying device resources are freed, when the ST font object is
3ddccbec4ee7 commentary
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
    90
    garbage collected.
3ddccbec4ee7 commentary
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
    91
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    92
601
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
    93
    [Instance variables:]
46
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    94
109
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
    95
      family          <String>        the fonts family ('courier', 'helvetica' etc)
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
    96
      face            <String>        the fonts face ('bold', 'medium' etc)
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
    97
      style           <String>        the fonts style ('roman', 'italic', 'oblique')
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
    98
      size            <String>        the fonts size (not in pixels) 
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
    99
      encoding        <Symbol>        the fonts encoding (usually #iso8859)
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   100
109
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   101
      device          <Object>        the device the font is associated to, or nil
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   102
      fontId          <Object>        the id of the font on that device, or nil
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   103
      replacement     <Font>          the replacement font or nil
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   104
109
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   105
      ascent          <Integer>       the fonts ascent in device units on device
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   106
      descent         <Integer>       the fonts descent in device units on device
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   107
      width           <Integer>       the character width in device units on device
564
3ddccbec4ee7 commentary
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
   108
                                      (for variable fonts, its the width of a space)
109
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   109
      isFixedWidth    <Boolean>       true if font is a fixed width font
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   110
      minWidth        <Integer>       width of the smallest-width character in
564
3ddccbec4ee7 commentary
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
   111
                                      in device units on device
109
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   112
      maxWidth        <Integer>       width of the largest-width character in
564
3ddccbec4ee7 commentary
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
   113
                                      in device units on device
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   114
601
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
   115
    [class variables:]
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   116
109
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   117
      Lobby           <Registry>      keeps track of all known fonts
46
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
   118
109
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   119
      Replacements    <Dictionary>    replacement fonts
601
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
   120
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
   121
    [see also:]
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
   122
        DeviceWorkstation 
628
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   123
        DeviceDrawable GraphicsContext
601
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
   124
        Cursor Color
628
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   125
        ( introduction to view programming :html: programming/viewintro.html#FONTS )
611
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 601
diff changeset
   126
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 601
diff changeset
   127
    [author:]
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 601
diff changeset
   128
        Claus Gittinger
46
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
   129
"
628
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   130
!
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   131
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   132
examples
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   133
"
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   134
    standard fonts:
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   135
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   136
        aFont := Font family:'courier' size:12
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   137
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   138
        aFont := Font 
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   139
                     family:'helvetica' 
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   140
                     face:'roman' 
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   141
                     style:'bold' 
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   142
                     size:16
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
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   145
    special (non-portable displayType specific) fonts:
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   146
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   147
        aFont := Font name:'6x10'
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   148
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   149
        aFont := Font name:'k14'
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   150
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   151
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   152
    setting the font of a button:
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   153
                                                                        [exBegin]
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   154
        |b|
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   155
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   156
        b := Button new.
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   157
        b label:'hello'.
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   158
        b font:(Font family:'helvetica' 
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   159
                     face:'medium' 
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   160
                     style:'roman' 
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   161
                     size:16).
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   162
        b open
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   163
                                                                        [exEnd]
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   164
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   165
    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
   166
    if it was used on some device:
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   167
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   168
        aFont widthOf:'hello' on:Display
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   169
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   170
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   171
    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
   172
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   173
        aFont ascentOn:Display
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
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   176
    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
   177
    a bit faster:
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   178
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   179
        |aFont|
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
        ...
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 := aFont on:aDevice.
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
        aFont widthOf:'hello'
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   186
        ...
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   187
        aFont ascent
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
"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   190
! !
48194c26a46c Initial revision
claus
parents:
diff changeset
   191
48194c26a46c Initial revision
claus
parents:
diff changeset
   192
!Font class methodsFor:'initialization'!
48194c26a46c Initial revision
claus
parents:
diff changeset
   193
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   194
flushDeviceFontsFor:aDevice
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   195
    "unassign all fonts from their device if they are assigned
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   196
     to aDevice"
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   197
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   198
    Lobby do:[:aFont |
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   199
	(aDevice isNil or:[aFont device == aDevice]) ifTrue:[
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   200
	    aFont restored.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   201
	    Lobby registerChange:aFont
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   202
	]
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   203
    ]
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   204
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   205
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   206
initialize
48194c26a46c Initial revision
claus
parents:
diff changeset
   207
    "initialize the font tracking array"
48194c26a46c Initial revision
claus
parents:
diff changeset
   208
23
4a7e02de7b72 *** empty log message ***
claus
parents: 12
diff changeset
   209
    Lobby isNil ifTrue:[
71
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   210
	Lobby := Registry new.
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   211
71
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   212
	"
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   213
	 want to be informed when returning from snapshot
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   214
	"
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   215
	ObjectMemory addDependent:self.
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   216
71
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   217
	"
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   218
	 replacement handling is not yet finished
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   219
	"
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   220
	Replacements := Dictionary new.
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   221
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   222
	Replacements at:'clean'                  put:'courier'.
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   223
	Replacements at:'fixed'                  put:'courier'.
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   224
	Replacements at:'new century schoolbook' put:'times'.
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   225
	Replacements at:'lucida'                 put:'helvetica'.
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   226
	Replacements at:'lucidabright'           put:'helvetica'.
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   227
	Replacements at:'lucidatypewriter'       put:'courier'.
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   228
	Replacements at:'charter'                put:'times'.
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   229
	Replacements at:'terminal'               put:'courier'.
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   230
    ]
48194c26a46c Initial revision
claus
parents:
diff changeset
   231
!
48194c26a46c Initial revision
claus
parents:
diff changeset
   232
48194c26a46c Initial revision
claus
parents:
diff changeset
   233
update:something
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   234
    "sent early during restart - flush any leftover device handles"
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   235
414
bf996c417cc8 flush device fonts early; allow selective flushing; catch errors during reinitialize of views
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   236
    (something == #earlyRestart) ifTrue:[
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   237
        "
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   238
         this is sent by ObjectMemory when restarting from
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   239
         an image. All device specific information (especially device
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   240
         handles) are now invalid and have to be flushed
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   241
        "
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   242
        self flushDeviceFontsFor:nil
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   243
    ]
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   244
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   245
    "Modified: 20.4.1996 / 23:22:23 / cg"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   246
! !
48194c26a46c Initial revision
claus
parents:
diff changeset
   247
48194c26a46c Initial revision
claus
parents:
diff changeset
   248
!Font class methodsFor:'instance creation'!
48194c26a46c Initial revision
claus
parents:
diff changeset
   249
48194c26a46c Initial revision
claus
parents:
diff changeset
   250
family:familyString face:faceString style:styleString size:sizeNum encoding:encodingSym
48194c26a46c Initial revision
claus
parents:
diff changeset
   251
    "returns a font for given family, face, style, size and encoding. 
71
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   252
     The returned font is not associated to a specific device"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   253
54
29a6b2f8e042 *** empty log message ***
claus
parents: 46
diff changeset
   254
    |family newFont|
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   255
48194c26a46c Initial revision
claus
parents:
diff changeset
   256
    (familyString at:1) isUppercase ifTrue:[
71
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   257
	family := familyString asLowercase
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   258
    ] ifFalse:[
71
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   259
	family := familyString
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   260
    ].
48194c26a46c Initial revision
claus
parents:
diff changeset
   261
48194c26a46c Initial revision
claus
parents:
diff changeset
   262
    "look if this font is already known"
48194c26a46c Initial revision
claus
parents:
diff changeset
   263
115
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
   264
    Lobby do:[:aFont |
71
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   265
	(aFont family = family) ifTrue:[
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   266
	    (aFont face = faceString) ifTrue:[
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   267
		(aFont style = styleString) ifTrue:[
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   268
		     (aFont size == sizeNum) ifTrue:[
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   269
			(encodingSym isNil or:[aFont encoding == encodingSym]) ifTrue:[
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   270
			    ^ aFont
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   271
			]
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   272
		    ]
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   273
		]
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   274
	    ]
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   275
	]
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   276
    ].
12
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   277
    newFont := self basicNew setFamily:familyString
71
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   278
				  face:faceString
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   279
				 style:styleString
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   280
				  size:sizeNum
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   281
			      encoding:encodingSym
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   282
				device:nil.
23
4a7e02de7b72 *** empty log message ***
claus
parents: 12
diff changeset
   283
    Lobby register:newFont.
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   284
    ^ newFont
48194c26a46c Initial revision
claus
parents:
diff changeset
   285
! !
48194c26a46c Initial revision
claus
parents:
diff changeset
   286
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   287
!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
   288
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   289
device
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   290
    "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
   291
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   292
    ^ device
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
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   295
fontId
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   296
    "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
   297
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   298
    ^ fontId
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   299
! !
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   300
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   301
!Font methodsFor:'binary storage'!
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   302
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   303
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
   304
    "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
   305
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   306
    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
   307
    self restored
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   308
! !
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   309
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   310
!Font methodsFor:'displaying'!
71
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   311
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   312
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
   313
    "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
   314
     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
   315
     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
   316
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   317
    |prevFont|
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   318
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:[
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   320
        'FONT: oops - no replacementFont. should not happen' errorPrintNL.
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   321
        ^ self
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   322
    ].
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   323
    prevFont := aGC font.
442
eb4ee58f5f0a use #basicFont:
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   324
    aGC basicFont:replacementFont.
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   325
    aGC displayOpaqueString:aString from:index1 to:index2 x:x y:y.
442
eb4ee58f5f0a use #basicFont:
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   326
    aGC basicFont:prevFont
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   327
442
eb4ee58f5f0a use #basicFont:
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   328
    "Modified: 23.2.1996 / 17:16:24 / cg"
71
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   329
!
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   330
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   331
displayOpaqueString:aString 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
   332
    "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
   333
     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
   334
     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
   335
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   336
    |prevFont|
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   337
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   338
    replacementFont isNil ifTrue:[
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   339
        'FONT: oops - no replacementFont. should not happen' errorPrintNL.
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   340
        ^ self
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   341
    ].
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   342
    prevFont := aGC font.
442
eb4ee58f5f0a use #basicFont:
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   343
    aGC basicFont:replacementFont.
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   344
    aGC displayOpaqueString:aString x:x y:y.
442
eb4ee58f5f0a use #basicFont:
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   345
    aGC basicFont:prevFont.
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   346
442
eb4ee58f5f0a use #basicFont:
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   347
    "Modified: 23.2.1996 / 17:16:29 / cg"
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   348
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   349
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   350
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
   351
    "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
   352
     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
   353
     for non-replacement fonts."
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   354
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   355
    |prevFont|
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   356
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   357
    replacementFont isNil ifTrue:[
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   358
        'FONT: oops - no replacementFont. should not happen' errorPrintNL.
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   359
        ^ self
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   360
    ].
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   361
    prevFont := aGC font.
442
eb4ee58f5f0a use #basicFont:
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   362
    aGC basicFont:replacementFont.
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   363
    aGC displayString:aString from:index1 to:index2 x:x y:y.
442
eb4ee58f5f0a use #basicFont:
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   364
    aGC basicFont:prevFont.
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   365
442
eb4ee58f5f0a use #basicFont:
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   366
    "Modified: 23.2.1996 / 17:16:33 / cg"
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   367
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   368
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   369
displayString:aString 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
   370
    "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
   371
     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
   372
     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
   373
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   374
    |prevFont|
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   375
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   376
    replacementFont isNil ifTrue:[
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   377
        'FONT: oops - no replacementFont. should not happen' errorPrintNL.
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   378
        ^ self
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   379
    ].
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   380
    prevFont := aGC font.
442
eb4ee58f5f0a use #basicFont:
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   381
    aGC basicFont:replacementFont.
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   382
    aGC displayString:aString x:x y:y.
442
eb4ee58f5f0a use #basicFont:
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   383
    aGC basicFont:prevFont.
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   384
442
eb4ee58f5f0a use #basicFont:
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   385
    "Modified: 23.2.1996 / 17:16:37 / cg"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   386
! !
48194c26a46c Initial revision
claus
parents:
diff changeset
   387
48194c26a46c Initial revision
claus
parents:
diff changeset
   388
!Font methodsFor:'getting a device font'!
48194c26a46c Initial revision
claus
parents:
diff changeset
   389
48194c26a46c Initial revision
claus
parents:
diff changeset
   390
on:aDevice
48194c26a46c Initial revision
claus
parents:
diff changeset
   391
    "create a new Font representing the same font as
48194c26a46c Initial revision
claus
parents:
diff changeset
   392
     myself on aDevice; if one already exists, return the one."
48194c26a46c Initial revision
claus
parents:
diff changeset
   393
336
fa55b8596c8c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   394
    |newFont rep|
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   395
48194c26a46c Initial revision
claus
parents:
diff changeset
   396
    "if I am already assigned to that device ..."
48194c26a46c Initial revision
claus
parents:
diff changeset
   397
    (device == aDevice) ifTrue:[^ self].
48194c26a46c Initial revision
claus
parents:
diff changeset
   398
48194c26a46c Initial revision
claus
parents:
diff changeset
   399
    "first look if not already there"
115
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
   400
    Lobby do:[:aFont |
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   401
        (aDevice == aFont device) ifTrue:[
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   402
            (size == aFont size) ifTrue:[
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   403
                (family = aFont family) ifTrue:[
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   404
                    (face = aFont face) ifTrue:[
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   405
                        (style = aFont style) ifTrue:[
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   406
                            (encoding isNil or:[encoding == aFont encoding]) ifTrue:[
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   407
                                ^ aFont
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   408
                            ]
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   409
                        ]
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   410
                    ]
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   411
                ]
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   412
            ]
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   413
        ]
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   414
    ].
48194c26a46c Initial revision
claus
parents:
diff changeset
   415
157
claus
parents: 151
diff changeset
   416
    newFont := self on:aDevice ifAbsent:nil.
claus
parents: 151
diff changeset
   417
    newFont isNil ifTrue:[
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   418
        "oops did not work - (device has no such font)"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   419
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   420
        rep := self replacementFontOn:aDevice.
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   421
        device isNil ifTrue:[
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   422
            device := aDevice.
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   423
            replacementFont := rep.
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   424
            Lobby registerChange:self.
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   425
            ^ self
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   426
        ].
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   427
        newFont := (self class basicNew)
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   428
                     setFamily:family face:face style:style size:size encoding:encoding device:aDevice.
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   429
        newFont setReplacementFont:rep.
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   430
        Lobby register:newFont.
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   431
        ^ newFont
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   432
    ].
48194c26a46c Initial revision
claus
parents:
diff changeset
   433
48194c26a46c Initial revision
claus
parents:
diff changeset
   434
    ^ newFont
441
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
     Font family:'foo' size:17
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   438
    "
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   439
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   440
    "Modified: 23.2.1996 / 16:30:06 / cg"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   441
!
48194c26a46c Initial revision
claus
parents:
diff changeset
   442
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   443
on:aDevice ifAbsent:exceptionBlock 
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   444
    "create a new Font representing the same font as
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   445
     myself on aDevice. This does NOT try to look for existing
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   446
     or replacement fonts (i.e. can be used to get physical fonts)."
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   447
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   448
    |newFont id|
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   449
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   450
    "ask that device for the font"
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   451
    id := aDevice getFontWithFamily:family face:face style:style size:size encoding:encoding.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   452
    id isNil ifTrue:[
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   453
	"oops did not work - (device has no such font)"
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   454
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   455
	^ exceptionBlock value
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   456
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   457
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   458
    "receiver was not associated - do it now"
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   459
    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
   460
	device := aDevice.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   461
	fontId := id.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   462
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   463
	self getFontInfos.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   464
	Lobby registerChange:self.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   465
	^ self
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   466
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   467
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   468
    "receiver was already associated to another device - need a new font"
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   469
    newFont := (self class basicNew) setFamily:family 
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   470
					  face:face
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   471
					 style:style
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   472
					  size:size
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   473
				      encoding:encoding
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   474
					device:aDevice.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   475
    newFont setFontId:id.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   476
    newFont getFontInfos.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   477
    Lobby register:newFont.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   478
    ^ newFont
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   479
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   480
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   481
replacementFontOn:aDevice
12
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   482
    "return a replacement font for the receiver - this is needed, if
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   483
     an image is restored on another type of display, or one which has
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   484
     a different set of fonts."
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   485
48194c26a46c Initial revision
claus
parents:
diff changeset
   486
    |id f alternative|
48194c26a46c Initial revision
claus
parents:
diff changeset
   487
144
claus
parents: 127
diff changeset
   488
    alternative := Replacements at:family ifAbsent:nil.
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   489
    alternative notNil ifTrue:[
454
b31d0a7e5530 nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   490
        id := aDevice getFontWithFamily:alternative
b31d0a7e5530 nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   491
                                   face:face
b31d0a7e5530 nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   492
                                  style:style 
b31d0a7e5530 nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   493
                                   size:size
b31d0a7e5530 nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   494
                               encoding:encoding.
144
claus
parents: 127
diff changeset
   495
    ].
claus
parents: 127
diff changeset
   496
    id notNil ifTrue:[
454
b31d0a7e5530 nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   497
        ('FONT: use alternative for ' , (self userFriendlyName)) infoPrintNL.
144
claus
parents: 127
diff changeset
   498
    ] ifFalse:[
454
b31d0a7e5530 nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   499
        id := aDevice getDefaultFont.
b31d0a7e5530 nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   500
        ('FONT: use default for ' , (self userFriendlyName)) infoPrintNL.
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   501
    ].
48194c26a46c Initial revision
claus
parents:
diff changeset
   502
    id isNil ifTrue:[
454
b31d0a7e5530 nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   503
        "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
   504
        self error:'cannot get default font'.
b31d0a7e5530 nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   505
        ^ nil
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   506
    ].
48194c26a46c Initial revision
claus
parents:
diff changeset
   507
    f := self class basicNew.
48194c26a46c Initial revision
claus
parents:
diff changeset
   508
    f setDevice:aDevice fontId:id.
48194c26a46c Initial revision
claus
parents:
diff changeset
   509
    f getFontInfos.
23
4a7e02de7b72 *** empty log message ***
claus
parents: 12
diff changeset
   510
    Lobby register:f.
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   511
    ^ f
454
b31d0a7e5530 nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   512
b31d0a7e5530 nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   513
    "Modified: 24.2.1996 / 19:56:11 / cg"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   514
! !
48194c26a46c Initial revision
claus
parents:
diff changeset
   515
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   516
!Font methodsFor:'instance release'!
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   517
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   518
disposed
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   519
    "some Font has been collected - tell it to the x-server"
157
claus
parents: 151
diff changeset
   520
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   521
    fontId notNil ifTrue:[
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   522
	device releaseFont:fontId.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   523
	fontId := nil
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   524
    ]
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   525
!
48194c26a46c Initial revision
claus
parents:
diff changeset
   526
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   527
shallowCopyForFinalization
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   528
    "redefined to return a lightweight copy 
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   529
     - all we need is the device handle"
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   530
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   531
    |aCopy|
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   532
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   533
    aCopy := self class basicNew.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   534
    aCopy setDevice:device fontId:fontId.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   535
   ^ aCopy
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   536
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   537
    "Modified: 20.4.1996 / 23:23:04 / cg"
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   538
! !
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   539
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   540
!Font methodsFor:'printing & storing'!
48194c26a46c Initial revision
claus
parents:
diff changeset
   541
109
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   542
printOn:aStream
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   543
    "append a printed representation of the receiver to aStream.
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   544
     Redefined to print more about the fonts name"
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   545
46
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
   546
    face isNil ifTrue:[
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   547
        family isNil ifTrue:[
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   548
            aStream nextPutAll:('a replacement-Font').
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   549
            ^ self
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   550
        ].
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   551
        aStream nextPutAll:('a ' , family , '-Font').
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   552
        ^ self.
46
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
   553
    ].
109
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   554
    aStream nextPutAll:('a ' , family , '-' , 
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   555
                               face , '-' , 
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   556
                               style , '-' , 
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   557
                               size printString , '-Font')
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   558
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   559
    "Modified: 20.4.1996 / 23:25:11 / cg"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   560
!
48194c26a46c Initial revision
claus
parents:
diff changeset
   561
109
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   562
storeOn:aStream
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   563
    "append a character sequence to the argument, aStream from which the
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   564
     receiver can be reconstructed using readFrom:."
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   565
109
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   566
    aStream nextPutAll:'(Font family:'. family storeOn:aStream.
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   567
    aStream nextPutAll:' face:'.        face storeOn:aStream.
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   568
    aStream nextPutAll:' style:'.       style storeOn:aStream.
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   569
    aStream nextPutAll:' size:'.        size storeOn:aStream.
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   570
    aStream nextPutAll:' encoding:'.    encoding storeOn:aStream.
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   571
    aStream nextPut:$)
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   572
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   573
    "
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   574
     (Font family:'helvetica' size:10) storeString
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   575
    "
453
a1541566a972 added #userFriendlyName
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   576
!
a1541566a972 added #userFriendlyName
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   577
a1541566a972 added #userFriendlyName
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   578
userFriendlyName
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   579
    "return a user-friendly printed representation of the receiver"
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   580
453
a1541566a972 added #userFriendlyName
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   581
    |nm|
a1541566a972 added #userFriendlyName
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   582
a1541566a972 added #userFriendlyName
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   583
    nm := family.
a1541566a972 added #userFriendlyName
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   584
    face notNil ifTrue:[
a1541566a972 added #userFriendlyName
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   585
        nm := nm , '-', face.
a1541566a972 added #userFriendlyName
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   586
    ].
a1541566a972 added #userFriendlyName
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   587
    style notNil ifTrue:[
a1541566a972 added #userFriendlyName
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   588
        nm := nm , '-', style.
a1541566a972 added #userFriendlyName
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   589
    ].
a1541566a972 added #userFriendlyName
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   590
    size notNil ifTrue:[
a1541566a972 added #userFriendlyName
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   591
        nm := nm , '-', size printString.
a1541566a972 added #userFriendlyName
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   592
    ].
456
3ab60f26b5a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 454
diff changeset
   593
    encoding notNil ifTrue:[
3ab60f26b5a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 454
diff changeset
   594
        nm := nm , '-', encoding .
3ab60f26b5a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 454
diff changeset
   595
    ].
453
a1541566a972 added #userFriendlyName
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   596
    ^ nm
a1541566a972 added #userFriendlyName
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   597
a1541566a972 added #userFriendlyName
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   598
    "
a1541566a972 added #userFriendlyName
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   599
     View defaultFont userFriendlyName
a1541566a972 added #userFriendlyName
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   600
     Button defaultFont userFriendlyName
a1541566a972 added #userFriendlyName
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   601
    "
456
3ab60f26b5a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 454
diff changeset
   602
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   603
    "Modified: 20.4.1996 / 23:25:36 / cg"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   604
! !
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
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
!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
   607
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   608
getFontInfos
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   609
    "ask the device about all of my actual attributes"
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   610
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   611
    replacementFont isNil ifTrue:[
438
03e433e2be99 return encoding & fullNames
Claus Gittinger <cg@exept.de>
parents: 435
diff changeset
   612
        encoding := device encodingOf:fontId.
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   613
        ascent := device ascentOf:fontId.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   614
        descent := device descentOf:fontId.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   615
        maxAscent := device maxAscentOf:fontId.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   616
        maxDescent := device maxDescentOf:fontId.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   617
        minWidth := device minWidthOfFont:fontId.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   618
        maxWidth := device maxWidthOfFont:fontId.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   619
        width := device widthOf:' ' inFont:fontId.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   620
        width < minWidth ifTrue:[
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   621
            width := minWidth
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
    ] ifFalse:[
438
03e433e2be99 return encoding & fullNames
Claus Gittinger <cg@exept.de>
parents: 435
diff changeset
   624
        encoding := replacementFont encoding.
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   625
        ascent := replacementFont ascent.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   626
        descent := replacementFont descent.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   627
        maxAscent := replacementFont maxAscent.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   628
        maxDescent := replacementFont maxDescent.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   629
        width := replacementFont width.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   630
        minWidth := replacementFont minWidth.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   631
        maxWidth := replacementFont maxWidth.
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
    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
   634
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   635
    "Modified: 20.4.1996 / 23:26:13 / cg"
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   636
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   637
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   638
restored
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   639
    "flush device handles when restored"
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   640
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   641
    device := nil.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   642
    fontId := nil.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   643
    replacementFont := nil
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   644
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   645
    "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
   646
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   647
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   648
setDevice:aDevice
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   649
    "set the device handle"
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   650
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   651
    device := aDevice
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   652
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   653
    "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
   654
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   655
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   656
setDevice:aDevice fontId:aFontId
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   657
    "set the device and font handles"
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   658
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   659
    device := aDevice.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   660
    fontId := aFontId
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   661
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   662
    "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
   663
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   664
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   665
setFamily:familyString face:faceString style:styleString size:sizeNum encoding:encodingSym device:aDevice
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   666
    "set my instance attributes"
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   667
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   668
    family := familyString.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   669
    face := faceString.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   670
    style := styleString.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   671
    size := sizeNum.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   672
    encoding := encodingSym.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   673
    device := aDevice
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   674
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   675
    "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
   676
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   677
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   678
setFontId:aFontId
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   679
    "set my font handle"
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   680
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   681
    fontId := aFontId
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   682
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   683
    "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
   684
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   685
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   686
setReplacementFont:aFont
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   687
    "set my replacement font"
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   688
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   689
    replacementFont := aFont
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   690
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   691
    "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
   692
! !
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   693
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   694
!Font methodsFor:'queries'!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   695
628
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   696
ascentOn:aDevice
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   697
    "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
   698
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   699
    device == aDevice ifTrue:[
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   700
        ^ ascent
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   701
    ].
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   702
    ^ (self on:aDevice) ascent
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   703
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   704
    "Created: 30.4.1996 / 16:41:32 / cg"
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   705
    "Modified: 30.4.1996 / 16:44:49 / cg"
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   706
!
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   707
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   708
descentOn:aDevice
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   709
    "return the fonts descent (average), if used on aDevice."
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   710
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   711
    device == aDevice ifTrue:[
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   712
        ^ descent
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   713
    ].
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   714
    ^ (self on:aDevice) descent
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   715
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   716
    "Created: 30.4.1996 / 16:41:43 / cg"
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   717
    "Modified: 30.4.1996 / 16:45:02 / cg"
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   718
!
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   719
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   720
existsOn:aDevice
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   721
    "return true, if the recevier is available on aDevice;
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   722
     false otherwise. This is a kludge method; its better to
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   723
     ask a device for its available fonts and use this info ...
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   724
     Notice, that if you simply use a font by name, the system
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   725
     will automatically take a replacement font."
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   726
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   727
    ^ (self on:aDevice ifAbsent:nil) notNil
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   728
!
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   729
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   730
heightOn:aDevice
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   731
    "return the fonts height (average), if used on aDevice."
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   732
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   733
    device == aDevice ifTrue:[
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   734
        ^ descent + ascent
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   735
    ].
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   736
    ^ (self on:aDevice) height
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   737
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   738
    "Created: 30.4.1996 / 16:41:59 / cg"
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   739
    "Modified: 30.4.1996 / 16:44:39 / cg"
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   740
!
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   741
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   742
widthOf:aString from:startIndex to:endIndex on:aDevice
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   743
    "return the width of substring, if displayed on aDevice.
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   744
     The argument may be a Character, String or some Text;
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   745
     in the last case the width of the longest line in the text is returned."
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   746
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   747
    device == aDevice ifTrue:[
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   748
        ^ self widthOf:aString from:startIndex to:endIndex
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   749
    ].
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   750
    ^ (self on:aDevice) widthOf:aString from:startIndex to:endIndex
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   751
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   752
    "Modified: 30.4.1996 / 17:14:50 / cg"
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   753
    "Created: 30.4.1996 / 17:15:20 / cg"
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   754
!
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   755
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   756
widthOf:aString on:aDevice
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   757
    "return the width of aString, if displayed on aDevice.
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   758
     The argument may be a Character, String or some Text;
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   759
     in the last case the width of the longest line in the text is returned."
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   760
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   761
    device == aDevice ifTrue:[
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   762
        ^ self widthOf:aString
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   763
    ].
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   764
    ^ (self on:aDevice) widthOf:aString
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   765
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   766
    "Created: 30.4.1996 / 17:14:18 / cg"
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   767
    "Modified: 30.4.1996 / 17:14:50 / cg"
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   768
!
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   769
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   770
widthOn:aDevice
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   771
    "return the fonts width, if used on aDevice.
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   772
     For variable pitch fonts, the width of the space character is returned.
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   773
     For fixed fonts, this is the same as minWidth or maxWidth (or any character)."
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   774
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   775
    device == aDevice ifTrue:[
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   776
        ^ descent + ascent
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   777
    ].
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   778
    ^ (self on:aDevice) width
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   779
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   780
    "Created: 30.4.1996 / 16:42:28 / cg"
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   781
    "Modified: 30.4.1996 / 16:43:50 / cg"
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   782
! !
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   783
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   784
!Font methodsFor:'queries-deviceFonts'!
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   785
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   786
ascent
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   787
    "return the font-ascent (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
   788
     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
   789
     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
   790
     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
   791
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   792
    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
   793
	self errorNoDevice
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   794
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   795
    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
   796
	^ replacementFont ascent
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   797
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   798
    ^ ascent
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   799
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   800
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   801
descent
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   802
    "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
   803
     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
   804
     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
   805
     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
   806
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   807
    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
   808
	self errorNoDevice
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   809
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   810
    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
   811
	^ replacementFont descent
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   812
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   813
    ^ descent
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   814
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   815
628
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   816
fullName
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   817
    "return the full (device specific) name of the receiver.
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   818
     This is query only valid if the receiver is associated to a device"
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   819
438
03e433e2be99 return encoding & fullNames
Claus Gittinger <cg@exept.de>
parents: 435
diff changeset
   820
    device isNil ifTrue:[
03e433e2be99 return encoding & fullNames
Claus Gittinger <cg@exept.de>
parents: 435
diff changeset
   821
        ^ nil
03e433e2be99 return encoding & fullNames
Claus Gittinger <cg@exept.de>
parents: 435
diff changeset
   822
    ].
03e433e2be99 return encoding & fullNames
Claus Gittinger <cg@exept.de>
parents: 435
diff changeset
   823
    ^ device fullNameOf:fontId.
03e433e2be99 return encoding & fullNames
Claus Gittinger <cg@exept.de>
parents: 435
diff changeset
   824
628
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   825
    "
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   826
     ((Font name:'6x10') on:Display) fullName  
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   827
    "
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   828
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   829
    "Modified: 30.4.1996 / 17:30:10 / cg"
438
03e433e2be99 return encoding & fullNames
Claus Gittinger <cg@exept.de>
parents: 435
diff changeset
   830
!
03e433e2be99 return encoding & fullNames
Claus Gittinger <cg@exept.de>
parents: 435
diff changeset
   831
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   832
height
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   833
    "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
   834
     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
   835
     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
   836
     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
   837
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   838
    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
   839
	self errorNoDevice.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   840
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   841
    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
   842
	^ replacementFont height
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   843
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   844
    ^ descent + ascent.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   845
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   846
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   847
isFixedWidth
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   848
    "return true, if all characters have same width (as in courier).
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   849
     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
   850
     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
   851
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   852
    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
   853
	self errorNoDevice.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   854
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   855
    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
   856
	^ replacementFont isFixedWidth
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   857
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   858
    ^ isFixedWidth
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
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   861
maxAscent
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   862
    "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
   863
     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
   864
     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
   865
     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
   866
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   867
    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
   868
	self errorNoDevice
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   869
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   870
    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
   871
	^ replacementFont maxAscent
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   872
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   873
    ^ maxAscent
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
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   876
maxDescent
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   877
    "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
   878
     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
   879
     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
   880
     for this query to be legal."
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   881
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   882
    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
   883
	self errorNoDevice
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   884
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   885
    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
   886
	^ replacementFont maxDescent
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   887
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   888
    ^ maxDescent
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
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   891
maxHeight
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   892
    "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
   893
     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
   894
     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
   895
     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
   896
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   897
    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
   898
	self errorNoDevice.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   899
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   900
    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
   901
	^ replacementFont maxHeight
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
    ^ maxDescent + maxAscent.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   904
!
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
maxWidth
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   907
    "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
   908
     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
   909
     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
   910
     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
   911
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   912
    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
   913
	self errorNoDevice
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   914
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   915
    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
   916
	^ replacementFont maxWidth
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   917
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   918
    ^ maxWidth
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   919
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   920
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   921
minWidth
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   922
    "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
   923
     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
   924
     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
   925
     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
   926
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   927
    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
   928
	self errorNoDevice
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
    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
   931
	^ replacementFont minWidth
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   932
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   933
    ^ minWidth
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   934
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   935
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   936
width
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   937
    "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
   938
     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
   939
     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
   940
     For fixed fonts, this is the same as minWidth or maxWidth (or any character).
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   941
     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
   942
     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
   943
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   944
    device isNil ifTrue:[
628
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   945
        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
   946
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   947
    replacementFont notNil ifTrue:[
628
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   948
        ^ 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
   949
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   950
    ^ width
628
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   951
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   952
    "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
   953
!
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
widthOf:textOrString
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   956
    "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
   957
     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
   958
     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
   959
     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
   960
     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
   961
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   962
    |this max|
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   963
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   964
    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
   965
        self errorNoDevice.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   966
        ^ 0
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   967
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   968
    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
   969
        ^ 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
   970
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   971
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   972
    (textOrString isString) ifTrue:[
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   973
        isFixedWidth ifFalse:[
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   974
            ^ device widthOf:textOrString inFont:fontId
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   975
        ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   976
        ^ width * textOrString size
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   977
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   978
    (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
   979
        isFixedWidth ifFalse:[
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   980
            ^ 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
   981
        ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   982
        ^ width
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   983
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   984
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   985
    max := 0.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   986
    isFixedWidth ifFalse:[
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   987
        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
   988
            line notNil ifTrue:[
435
5288c637512e care for nonStrings when asked for the size
Claus Gittinger <cg@exept.de>
parents: 434
diff changeset
   989
                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
   990
                (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
   991
            ]
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   992
        ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   993
        ^ max
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   994
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   995
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   996
    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
   997
        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
   998
        (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
   999
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1000
    ^ max * width
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1001
435
5288c637512e care for nonStrings when asked for the size
Claus Gittinger <cg@exept.de>
parents: 434
diff changeset
  1002
    "Modified: 22.2.1996 / 21:53:52 / cg"
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1003
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1004
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1005
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
  1006
    "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
  1007
     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
  1008
     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
  1009
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1010
    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
  1011
	self errorNoDevice.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1012
	^ 0
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1013
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1014
    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
  1015
	^ 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
  1016
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1017
    (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
  1018
    isFixedWidth ifFalse:[
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1019
	^ 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
  1020
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1021
    ^ (stop - start + 1) * width
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
  1022
! !
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1023
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1024
!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
  1025
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1026
fixedWidth
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1027
    "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
  1028
     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
  1029
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1030
    ^ self isFixedWidth
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1031
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1032
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1033
pixelSize
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1034
    "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
  1035
     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
  1036
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1037
    ^ self height
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1038
! !
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1039
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1040
!Font class methodsFor:'documentation'!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1041
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1042
version
628
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
  1043
    ^ '$Header: /cvs/stx/stx/libview/Font.st,v 1.41 1996-04-30 15:31:16 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
  1044
! !
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1045
Font initialize!