Font.st
author Claus Gittinger <cg@exept.de>
Thu, 25 Apr 1996 18:26:07 +0200
changeset 611 e0442439a3c6
parent 601 2c4c1e797909
child 628 4ac28f9d9c7b
permissions -rw-r--r--
documentation
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 
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
   123
        DeviceDrawable
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
   124
        Cursor Color
611
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 601
diff changeset
   125
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 601
diff changeset
   126
    [author:]
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 601
diff changeset
   127
        Claus Gittinger
46
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
   128
"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   129
! !
48194c26a46c Initial revision
claus
parents:
diff changeset
   130
48194c26a46c Initial revision
claus
parents:
diff changeset
   131
!Font class methodsFor:'initialization'!
48194c26a46c Initial revision
claus
parents:
diff changeset
   132
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   133
flushDeviceFontsFor:aDevice
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   134
    "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
   135
     to aDevice"
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   136
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   137
    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
   138
	(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
   139
	    aFont restored.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   140
	    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
   141
	]
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   142
    ]
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   143
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   144
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   145
initialize
48194c26a46c Initial revision
claus
parents:
diff changeset
   146
    "initialize the font tracking array"
48194c26a46c Initial revision
claus
parents:
diff changeset
   147
23
4a7e02de7b72 *** empty log message ***
claus
parents: 12
diff changeset
   148
    Lobby isNil ifTrue:[
71
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   149
	Lobby := Registry new.
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   150
71
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   151
	"
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   152
	 want to be informed when returning from snapshot
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   153
	"
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   154
	ObjectMemory addDependent:self.
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   155
71
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   156
	"
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   157
	 replacement handling is not yet finished
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   158
	"
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   159
	Replacements := Dictionary new.
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   160
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   161
	Replacements at:'clean'                  put:'courier'.
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   162
	Replacements at:'fixed'                  put:'courier'.
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   163
	Replacements at:'new century schoolbook' put:'times'.
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   164
	Replacements at:'lucida'                 put:'helvetica'.
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   165
	Replacements at:'lucidabright'           put:'helvetica'.
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   166
	Replacements at:'lucidatypewriter'       put:'courier'.
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   167
	Replacements at:'charter'                put:'times'.
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   168
	Replacements at:'terminal'               put:'courier'.
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   169
    ]
48194c26a46c Initial revision
claus
parents:
diff changeset
   170
!
48194c26a46c Initial revision
claus
parents:
diff changeset
   171
48194c26a46c Initial revision
claus
parents:
diff changeset
   172
update:something
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   173
    "sent early during restart - flush any leftover device handles"
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   174
414
bf996c417cc8 flush device fonts early; allow selective flushing; catch errors during reinitialize of views
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   175
    (something == #earlyRestart) ifTrue:[
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   176
        "
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   177
         this is sent by ObjectMemory when restarting from
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   178
         an image. All device specific information (especially device
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   179
         handles) are now invalid and have to be flushed
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   180
        "
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   181
        self flushDeviceFontsFor:nil
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   182
    ]
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   183
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   184
    "Modified: 20.4.1996 / 23:22:23 / cg"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   185
! !
48194c26a46c Initial revision
claus
parents:
diff changeset
   186
48194c26a46c Initial revision
claus
parents:
diff changeset
   187
!Font class methodsFor:'instance creation'!
48194c26a46c Initial revision
claus
parents:
diff changeset
   188
48194c26a46c Initial revision
claus
parents:
diff changeset
   189
family:familyString face:faceString style:styleString size:sizeNum encoding:encodingSym
48194c26a46c Initial revision
claus
parents:
diff changeset
   190
    "returns a font for given family, face, style, size and encoding. 
71
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   191
     The returned font is not associated to a specific device"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   192
54
29a6b2f8e042 *** empty log message ***
claus
parents: 46
diff changeset
   193
    |family newFont|
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   194
48194c26a46c Initial revision
claus
parents:
diff changeset
   195
    (familyString at:1) isUppercase ifTrue:[
71
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   196
	family := familyString asLowercase
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   197
    ] ifFalse:[
71
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   198
	family := familyString
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   199
    ].
48194c26a46c Initial revision
claus
parents:
diff changeset
   200
48194c26a46c Initial revision
claus
parents:
diff changeset
   201
    "look if this font is already known"
48194c26a46c Initial revision
claus
parents:
diff changeset
   202
115
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
   203
    Lobby do:[:aFont |
71
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   204
	(aFont family = family) ifTrue:[
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   205
	    (aFont face = faceString) ifTrue:[
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   206
		(aFont style = styleString) ifTrue:[
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   207
		     (aFont size == sizeNum) ifTrue:[
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   208
			(encodingSym isNil or:[aFont encoding == encodingSym]) ifTrue:[
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   209
			    ^ aFont
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   210
			]
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   211
		    ]
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   212
		]
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   213
	    ]
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   214
	]
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   215
    ].
12
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   216
    newFont := self basicNew setFamily:familyString
71
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   217
				  face:faceString
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   218
				 style:styleString
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   219
				  size:sizeNum
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   220
			      encoding:encodingSym
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   221
				device:nil.
23
4a7e02de7b72 *** empty log message ***
claus
parents: 12
diff changeset
   222
    Lobby register:newFont.
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   223
    ^ newFont
48194c26a46c Initial revision
claus
parents:
diff changeset
   224
! !
48194c26a46c Initial revision
claus
parents:
diff changeset
   225
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   226
!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
   227
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   228
device
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   229
    "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
   230
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   231
    ^ device
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   232
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   233
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   234
fontId
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   235
    "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
   236
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   237
    ^ fontId
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   238
! !
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   239
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   240
!Font methodsFor:'binary storage'!
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   241
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   242
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
   243
    "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
   244
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   245
    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
   246
    self restored
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   247
! !
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   248
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   249
!Font methodsFor:'displaying'!
71
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   250
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   251
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
   252
    "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
   253
     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
   254
     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
   255
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   256
    |prevFont|
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   257
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   258
    replacementFont isNil ifTrue:[
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   259
        'FONT: oops - no replacementFont. should not happen' errorPrintNL.
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   260
        ^ self
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   261
    ].
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   262
    prevFont := aGC font.
442
eb4ee58f5f0a use #basicFont:
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   263
    aGC basicFont:replacementFont.
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   264
    aGC displayOpaqueString:aString from:index1 to:index2 x:x y:y.
442
eb4ee58f5f0a use #basicFont:
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   265
    aGC basicFont:prevFont
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   266
442
eb4ee58f5f0a use #basicFont:
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   267
    "Modified: 23.2.1996 / 17:16:24 / cg"
71
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   268
!
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   269
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   270
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
   271
    "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
   272
     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
   273
     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
   274
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   275
    |prevFont|
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   276
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   277
    replacementFont isNil ifTrue:[
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   278
        'FONT: oops - no replacementFont. should not happen' errorPrintNL.
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   279
        ^ self
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   280
    ].
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   281
    prevFont := aGC font.
442
eb4ee58f5f0a use #basicFont:
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   282
    aGC basicFont:replacementFont.
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   283
    aGC displayOpaqueString:aString x:x y:y.
442
eb4ee58f5f0a use #basicFont:
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   284
    aGC basicFont:prevFont.
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   285
442
eb4ee58f5f0a use #basicFont:
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   286
    "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
   287
!
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
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
   290
    "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
   291
     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
   292
     for non-replacement fonts."
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   293
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   294
    |prevFont|
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   295
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   296
    replacementFont isNil ifTrue:[
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   297
        'FONT: oops - no replacementFont. should not happen' errorPrintNL.
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   298
        ^ self
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   299
    ].
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   300
    prevFont := aGC font.
442
eb4ee58f5f0a use #basicFont:
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   301
    aGC basicFont:replacementFont.
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   302
    aGC displayString:aString from:index1 to:index2 x:x y:y.
442
eb4ee58f5f0a use #basicFont:
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   303
    aGC basicFont:prevFont.
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   304
442
eb4ee58f5f0a use #basicFont:
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   305
    "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
   306
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   307
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   308
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
   309
    "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
   310
     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
   311
     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
   312
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   313
    |prevFont|
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   314
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   315
    replacementFont isNil ifTrue:[
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   316
        'FONT: oops - no replacementFont. should not happen' errorPrintNL.
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   317
        ^ self
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   318
    ].
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   319
    prevFont := aGC font.
442
eb4ee58f5f0a use #basicFont:
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   320
    aGC basicFont:replacementFont.
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   321
    aGC displayString:aString x:x y:y.
442
eb4ee58f5f0a use #basicFont:
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   322
    aGC basicFont:prevFont.
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   323
442
eb4ee58f5f0a use #basicFont:
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   324
    "Modified: 23.2.1996 / 17:16:37 / cg"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   325
! !
48194c26a46c Initial revision
claus
parents:
diff changeset
   326
48194c26a46c Initial revision
claus
parents:
diff changeset
   327
!Font methodsFor:'getting a device font'!
48194c26a46c Initial revision
claus
parents:
diff changeset
   328
48194c26a46c Initial revision
claus
parents:
diff changeset
   329
on:aDevice
48194c26a46c Initial revision
claus
parents:
diff changeset
   330
    "create a new Font representing the same font as
48194c26a46c Initial revision
claus
parents:
diff changeset
   331
     myself on aDevice; if one already exists, return the one."
48194c26a46c Initial revision
claus
parents:
diff changeset
   332
336
fa55b8596c8c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   333
    |newFont rep|
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   334
48194c26a46c Initial revision
claus
parents:
diff changeset
   335
    "if I am already assigned to that device ..."
48194c26a46c Initial revision
claus
parents:
diff changeset
   336
    (device == aDevice) ifTrue:[^ self].
48194c26a46c Initial revision
claus
parents:
diff changeset
   337
48194c26a46c Initial revision
claus
parents:
diff changeset
   338
    "first look if not already there"
115
1d93fd8c5371 *** empty log message ***
claus
parents: 109
diff changeset
   339
    Lobby do:[:aFont |
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   340
        (aDevice == aFont device) ifTrue:[
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   341
            (size == aFont size) ifTrue:[
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   342
                (family = aFont family) ifTrue:[
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   343
                    (face = aFont face) ifTrue:[
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   344
                        (style = aFont style) ifTrue:[
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   345
                            (encoding isNil or:[encoding == aFont encoding]) ifTrue:[
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   346
                                ^ aFont
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   347
                            ]
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   348
                        ]
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   349
                    ]
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   350
                ]
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   351
            ]
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   352
        ]
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   353
    ].
48194c26a46c Initial revision
claus
parents:
diff changeset
   354
157
claus
parents: 151
diff changeset
   355
    newFont := self on:aDevice ifAbsent:nil.
claus
parents: 151
diff changeset
   356
    newFont isNil ifTrue:[
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   357
        "oops did not work - (device has no such font)"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   358
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   359
        rep := self replacementFontOn:aDevice.
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   360
        device isNil ifTrue:[
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   361
            device := aDevice.
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   362
            replacementFont := rep.
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   363
            Lobby registerChange:self.
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   364
            ^ self
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   365
        ].
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   366
        newFont := (self class basicNew)
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   367
                     setFamily:family face:face style:style size:size encoding:encoding device:aDevice.
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   368
        newFont setReplacementFont:rep.
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   369
        Lobby register:newFont.
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   370
        ^ newFont
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   371
    ].
48194c26a46c Initial revision
claus
parents:
diff changeset
   372
48194c26a46c Initial revision
claus
parents:
diff changeset
   373
    ^ newFont
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   374
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   375
    "
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   376
     Font family:'foo' size:17
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   377
    "
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   378
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   379
    "Modified: 23.2.1996 / 16:30:06 / cg"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   380
!
48194c26a46c Initial revision
claus
parents:
diff changeset
   381
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   382
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
   383
    "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
   384
     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
   385
     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
   386
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   387
    |newFont id|
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   388
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   389
    "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
   390
    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
   391
    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
   392
	"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
   393
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   394
	^ exceptionBlock value
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   395
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   396
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   397
    "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
   398
    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
   399
	device := aDevice.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   400
	fontId := id.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   401
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   402
	self getFontInfos.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   403
	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
   404
	^ self
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   405
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   406
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   407
    "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
   408
    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
   409
					  face:face
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   410
					 style:style
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   411
					  size:size
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   412
				      encoding:encoding
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   413
					device:aDevice.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   414
    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
   415
    newFont getFontInfos.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   416
    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
   417
    ^ newFont
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   418
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   419
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   420
replacementFontOn:aDevice
12
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   421
    "return a replacement font for the receiver - this is needed, if
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   422
     an image is restored on another type of display, or one which has
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   423
     a different set of fonts."
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   424
48194c26a46c Initial revision
claus
parents:
diff changeset
   425
    |id f alternative|
48194c26a46c Initial revision
claus
parents:
diff changeset
   426
144
claus
parents: 127
diff changeset
   427
    alternative := Replacements at:family ifAbsent:nil.
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   428
    alternative notNil ifTrue:[
454
b31d0a7e5530 nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   429
        id := aDevice getFontWithFamily:alternative
b31d0a7e5530 nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   430
                                   face:face
b31d0a7e5530 nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   431
                                  style:style 
b31d0a7e5530 nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   432
                                   size:size
b31d0a7e5530 nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   433
                               encoding:encoding.
144
claus
parents: 127
diff changeset
   434
    ].
claus
parents: 127
diff changeset
   435
    id notNil ifTrue:[
454
b31d0a7e5530 nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   436
        ('FONT: use alternative for ' , (self userFriendlyName)) infoPrintNL.
144
claus
parents: 127
diff changeset
   437
    ] ifFalse:[
454
b31d0a7e5530 nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   438
        id := aDevice getDefaultFont.
b31d0a7e5530 nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   439
        ('FONT: use default for ' , (self userFriendlyName)) infoPrintNL.
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   440
    ].
48194c26a46c Initial revision
claus
parents:
diff changeset
   441
    id isNil ifTrue:[
454
b31d0a7e5530 nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   442
        "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
   443
        self error:'cannot get default font'.
b31d0a7e5530 nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   444
        ^ nil
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   445
    ].
48194c26a46c Initial revision
claus
parents:
diff changeset
   446
    f := self class basicNew.
48194c26a46c Initial revision
claus
parents:
diff changeset
   447
    f setDevice:aDevice fontId:id.
48194c26a46c Initial revision
claus
parents:
diff changeset
   448
    f getFontInfos.
23
4a7e02de7b72 *** empty log message ***
claus
parents: 12
diff changeset
   449
    Lobby register:f.
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   450
    ^ f
454
b31d0a7e5530 nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   451
b31d0a7e5530 nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   452
    "Modified: 24.2.1996 / 19:56:11 / cg"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   453
! !
48194c26a46c Initial revision
claus
parents:
diff changeset
   454
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   455
!Font methodsFor:'instance release'!
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   456
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   457
disposed
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   458
    "some Font has been collected - tell it to the x-server"
157
claus
parents: 151
diff changeset
   459
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   460
    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
   461
	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
   462
	fontId := nil
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   463
    ]
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   464
!
48194c26a46c Initial revision
claus
parents:
diff changeset
   465
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   466
shallowCopyForFinalization
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   467
    "redefined to return a lightweight copy 
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   468
     - all we need is the device handle"
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   469
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   470
    |aCopy|
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   471
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   472
    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
   473
    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
   474
   ^ aCopy
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   475
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   476
    "Modified: 20.4.1996 / 23:23:04 / cg"
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   477
! !
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   478
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   479
!Font methodsFor:'printing & storing'!
48194c26a46c Initial revision
claus
parents:
diff changeset
   480
109
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   481
printOn:aStream
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   482
    "append a printed representation of the receiver to aStream.
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   483
     Redefined to print more about the fonts name"
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   484
46
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
   485
    face isNil ifTrue:[
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   486
        family isNil ifTrue:[
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   487
            aStream nextPutAll:('a replacement-Font').
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   488
            ^ self
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   489
        ].
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   490
        aStream nextPutAll:('a ' , family , '-Font').
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   491
        ^ self.
46
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
   492
    ].
109
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   493
    aStream nextPutAll:('a ' , family , '-' , 
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   494
                               face , '-' , 
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   495
                               style , '-' , 
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   496
                               size printString , '-Font')
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   497
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   498
    "Modified: 20.4.1996 / 23:25:11 / cg"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   499
!
48194c26a46c Initial revision
claus
parents:
diff changeset
   500
109
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   501
storeOn:aStream
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   502
    "append a character sequence to the argument, aStream from which the
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   503
     receiver can be reconstructed using readFrom:."
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   504
109
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   505
    aStream nextPutAll:'(Font family:'. family storeOn:aStream.
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   506
    aStream nextPutAll:' face:'.        face storeOn:aStream.
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   507
    aStream nextPutAll:' style:'.       style storeOn:aStream.
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   508
    aStream nextPutAll:' size:'.        size storeOn:aStream.
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   509
    aStream nextPutAll:' encoding:'.    encoding storeOn:aStream.
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   510
    aStream nextPut:$)
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   511
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   512
    "
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   513
     (Font family:'helvetica' size:10) storeString
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   514
    "
453
a1541566a972 added #userFriendlyName
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   515
!
a1541566a972 added #userFriendlyName
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   516
a1541566a972 added #userFriendlyName
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   517
userFriendlyName
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   518
    "return a user-friendly printed representation of the receiver"
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   519
453
a1541566a972 added #userFriendlyName
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   520
    |nm|
a1541566a972 added #userFriendlyName
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   521
a1541566a972 added #userFriendlyName
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   522
    nm := family.
a1541566a972 added #userFriendlyName
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   523
    face notNil ifTrue:[
a1541566a972 added #userFriendlyName
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   524
        nm := nm , '-', face.
a1541566a972 added #userFriendlyName
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   525
    ].
a1541566a972 added #userFriendlyName
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   526
    style notNil ifTrue:[
a1541566a972 added #userFriendlyName
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   527
        nm := nm , '-', style.
a1541566a972 added #userFriendlyName
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   528
    ].
a1541566a972 added #userFriendlyName
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   529
    size notNil ifTrue:[
a1541566a972 added #userFriendlyName
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   530
        nm := nm , '-', size printString.
a1541566a972 added #userFriendlyName
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   531
    ].
456
3ab60f26b5a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 454
diff changeset
   532
    encoding notNil ifTrue:[
3ab60f26b5a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 454
diff changeset
   533
        nm := nm , '-', encoding .
3ab60f26b5a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 454
diff changeset
   534
    ].
453
a1541566a972 added #userFriendlyName
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   535
    ^ nm
a1541566a972 added #userFriendlyName
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   536
a1541566a972 added #userFriendlyName
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   537
    "
a1541566a972 added #userFriendlyName
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   538
     View defaultFont userFriendlyName
a1541566a972 added #userFriendlyName
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   539
     Button defaultFont userFriendlyName
a1541566a972 added #userFriendlyName
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
   540
    "
456
3ab60f26b5a1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 454
diff changeset
   541
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   542
    "Modified: 20.4.1996 / 23:25:36 / cg"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   543
! !
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   544
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   545
!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
   546
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   547
getFontInfos
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   548
    "ask the device about all of my actual attributes"
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   549
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   550
    replacementFont isNil ifTrue:[
438
03e433e2be99 return encoding & fullNames
Claus Gittinger <cg@exept.de>
parents: 435
diff changeset
   551
        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
   552
        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
   553
        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
   554
        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
   555
        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
   556
        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
   557
        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
   558
        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
   559
        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
   560
            width := minWidth
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   561
        ]
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   562
    ] ifFalse:[
438
03e433e2be99 return encoding & fullNames
Claus Gittinger <cg@exept.de>
parents: 435
diff changeset
   563
        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
   564
        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
   565
        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
   566
        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
   567
        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
   568
        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
   569
        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
   570
        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
   571
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   572
    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
   573
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   574
    "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
   575
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   576
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   577
restored
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   578
    "flush device handles when restored"
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   579
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   580
    device := nil.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   581
    fontId := nil.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   582
    replacementFont := nil
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   583
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   584
    "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
   585
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   586
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   587
setDevice:aDevice
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   588
    "set the device handle"
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   589
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   590
    device := aDevice
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   591
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   592
    "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
   593
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   594
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   595
setDevice:aDevice fontId:aFontId
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   596
    "set the device and font handles"
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   597
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   598
    device := aDevice.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   599
    fontId := aFontId
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   600
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   601
    "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
   602
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   603
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   604
setFamily:familyString face:faceString style:styleString size:sizeNum encoding:encodingSym device:aDevice
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   605
    "set my instance attributes"
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   606
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   607
    family := familyString.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   608
    face := faceString.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   609
    style := styleString.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   610
    size := sizeNum.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   611
    encoding := encodingSym.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   612
    device := aDevice
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   613
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   614
    "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
   615
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   616
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   617
setFontId:aFontId
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   618
    "set my font handle"
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   619
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   620
    fontId := aFontId
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   621
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   622
    "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
   623
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   624
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   625
setReplacementFont:aFont
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   626
    "set my replacement font"
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   627
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   628
    replacementFont := aFont
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   629
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   630
    "Modified: 20.4.1996 / 23: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
   631
! !
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   632
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   633
!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
   634
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   635
ascent
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   636
    "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
   637
     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
   638
     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
   639
     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
   640
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   641
    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
   642
	self errorNoDevice
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   643
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   644
    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
   645
	^ replacementFont ascent
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
    ^ ascent
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   648
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   649
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   650
descent
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   651
    "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
   652
     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
   653
     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
   654
     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
   655
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   656
    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
   657
	self errorNoDevice
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   658
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   659
    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
   660
	^ replacementFont descent
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   661
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   662
    ^ descent
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
existsOn:aDevice
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   666
    "return true, if the recevier is available on aDevice;
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   667
     false otherwise. This is a kludge method; its better to
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   668
     ask a device for its available fonts and use this info ...
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   669
     Notice, that if you simply use a font by name, the system
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   670
     will automatically take a replacement font."
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   671
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   672
    ^ (self on:aDevice ifAbsent:nil) notNil
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   673
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   674
438
03e433e2be99 return encoding & fullNames
Claus Gittinger <cg@exept.de>
parents: 435
diff changeset
   675
fullName
03e433e2be99 return encoding & fullNames
Claus Gittinger <cg@exept.de>
parents: 435
diff changeset
   676
    device isNil ifTrue:[
03e433e2be99 return encoding & fullNames
Claus Gittinger <cg@exept.de>
parents: 435
diff changeset
   677
        ^ nil
03e433e2be99 return encoding & fullNames
Claus Gittinger <cg@exept.de>
parents: 435
diff changeset
   678
    ].
03e433e2be99 return encoding & fullNames
Claus Gittinger <cg@exept.de>
parents: 435
diff changeset
   679
    ^ device fullNameOf:fontId.
03e433e2be99 return encoding & fullNames
Claus Gittinger <cg@exept.de>
parents: 435
diff changeset
   680
03e433e2be99 return encoding & fullNames
Claus Gittinger <cg@exept.de>
parents: 435
diff changeset
   681
    "Created: 23.2.1996 / 00:44:10 / cg"
03e433e2be99 return encoding & fullNames
Claus Gittinger <cg@exept.de>
parents: 435
diff changeset
   682
    "Modified: 23.2.1996 / 00:46:44 / cg"
03e433e2be99 return encoding & fullNames
Claus Gittinger <cg@exept.de>
parents: 435
diff changeset
   683
!
03e433e2be99 return encoding & fullNames
Claus Gittinger <cg@exept.de>
parents: 435
diff changeset
   684
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   685
height
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   686
    "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
   687
     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
   688
     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
   689
     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
   690
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   691
    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
   692
	self errorNoDevice.
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
    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
   695
	^ replacementFont height
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   696
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   697
    ^ descent + ascent.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   698
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   699
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   700
isFixedWidth
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   701
    "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
   702
     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
   703
     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
   704
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   705
    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
   706
	self errorNoDevice.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   707
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   708
    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
   709
	^ replacementFont isFixedWidth
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   710
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   711
    ^ isFixedWidth
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   712
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   713
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   714
maxAscent
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   715
    "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
   716
     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
   717
     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
   718
     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
   719
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   720
    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
   721
	self errorNoDevice
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   722
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   723
    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
   724
	^ replacementFont maxAscent
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   725
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   726
    ^ maxAscent
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   727
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   728
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   729
maxDescent
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   730
    "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
   731
     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
   732
     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
   733
     for this query to be legal."
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   734
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   735
    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
   736
	self errorNoDevice
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   737
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   738
    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
   739
	^ replacementFont maxDescent
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   740
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   741
    ^ maxDescent
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   742
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   743
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   744
maxHeight
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   745
    "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
   746
     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
   747
     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
   748
     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
   749
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   750
    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
   751
	self errorNoDevice.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   752
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   753
    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
   754
	^ replacementFont maxHeight
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   755
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   756
    ^ maxDescent + maxAscent.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   757
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   758
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   759
maxWidth
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   760
    "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
   761
     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
   762
     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
   763
     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
   764
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   765
    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
   766
	self errorNoDevice
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   767
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   768
    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
   769
	^ replacementFont maxWidth
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   770
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   771
    ^ maxWidth
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   772
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   773
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   774
minWidth
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   775
    "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
   776
     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
   777
     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
   778
     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
   779
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   780
    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
   781
	self errorNoDevice
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   782
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   783
    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
   784
	^ replacementFont minWidth
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   785
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   786
    ^ minWidth
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   787
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   788
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   789
width
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   790
    "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
   791
     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
   792
     For variable pitch fonts, the width of the space character is returned.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   793
     For fixed fonts, this is the same as minWidth or maxWidth.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   794
     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
   795
     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
   796
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   797
    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
   798
	self errorNoDevice.
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
    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
   801
	^ replacementFont width
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   802
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   803
    ^ width
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   804
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   805
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   806
widthOf:textOrString
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   807
    "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
   808
     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
   809
     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
   810
     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
   811
     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
   812
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   813
    |this max|
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   814
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   815
    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
   816
        self errorNoDevice.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   817
        ^ 0
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   818
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   819
    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
   820
        ^ 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
   821
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   822
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   823
    (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
   824
        isFixedWidth ifFalse:[
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   825
            ^ 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
   826
        ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   827
        ^ 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
   828
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   829
    (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
   830
        isFixedWidth ifFalse:[
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   831
            ^ 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
   832
        ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   833
        ^ width
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   834
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   835
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   836
    max := 0.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   837
    isFixedWidth ifFalse:[
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   838
        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
   839
            line notNil ifTrue:[
435
5288c637512e care for nonStrings when asked for the size
Claus Gittinger <cg@exept.de>
parents: 434
diff changeset
   840
                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
   841
                (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
   842
            ]
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
        ^ max
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
    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
   848
        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
   849
        (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
   850
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   851
    ^ max * width
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   852
435
5288c637512e care for nonStrings when asked for the size
Claus Gittinger <cg@exept.de>
parents: 434
diff changeset
   853
    "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
   854
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   855
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   856
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
   857
    "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
   858
     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
   859
     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
   860
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   861
    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
   862
	self errorNoDevice.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   863
	^ 0
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   864
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   865
    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
   866
	^ 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
   867
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   868
    (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
   869
    isFixedWidth ifFalse:[
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   870
	^ 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
   871
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   872
    ^ (stop - start + 1) * width
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   873
! !
434
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
!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
   876
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   877
fixedWidth
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   878
    "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
   879
     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
   880
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   881
    ^ self isFixedWidth
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   882
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   883
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   884
pixelSize
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   885
    "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
   886
     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
   887
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   888
    ^ self height
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
!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
   892
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   893
version
611
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 601
diff changeset
   894
    ^ '$Header: /cvs/stx/stx/libview/Font.st,v 1.40 1996-04-25 16:25:34 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
   895
! !
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   896
Font initialize!