Font.st
author Stefan Vogel <sv@exept.de>
Fri, 22 Nov 2013 12:02:32 +0100
changeset 6158 17d06f1e4ca6
parent 6109 e35961f7892a
child 6163 f5e0de280f35
permissions -rw-r--r--
class: Font changed: #onDevice:ifAbsent: do not crash when encoding is nil (encoding '*' in FontPanel is selected)
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
"
3213
78add46c0f4b only init once
Claus Gittinger <cg@exept.de>
parents: 3060
diff changeset
    12
"{ Package: 'stx:libview' }"
78add46c0f4b only init once
Claus Gittinger <cg@exept.de>
parents: 3060
diff changeset
    13
109
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
    14
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
    15
	instanceVariableNames:'device fontId replacementFont ascent descent width isFixedWidth
4023
b60e9d3335d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4007
diff changeset
    16
		minWidth maxWidth maxAscent maxDescent minCode maxCode direction'
1372
2b55617a712f keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
    17
	classVariableNames:'Replacements'
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
    18
	poolDictionaries:''
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
    19
	category:'Graphics-Support'
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    20
!
48194c26a46c Initial revision
claus
parents:
diff changeset
    21
2433
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
    22
Object subclass:#DeviceFontHandle
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
    23
	instanceVariableNames:'device fontId'
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
    24
	classVariableNames:''
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
    25
	poolDictionaries:''
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
    26
	privateIn:Font
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
    27
!
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
    28
1087
1e5a93e03d7f handle text-argument in withOf:
Claus Gittinger <cg@exept.de>
parents: 1067
diff changeset
    29
!Font class methodsFor:'documentation'!
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    30
46
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    31
copyright
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    32
"
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    33
 COPYRIGHT (c) 1992 by Claus Gittinger
71
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
    34
	      All Rights Reserved
46
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    35
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    36
 This software is furnished under a license and may be used
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    37
 only in accordance with the terms of that license and with the
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    38
 inclusion of the above copyright notice.   This software may not
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    39
 be provided or otherwise made available to, or used by, any
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    40
 other person.  No title to or ownership of the software is
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    41
 hereby transferred.
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    42
"
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    43
!
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    44
46
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    45
documentation
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    46
"
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    47
    Font represents fonts in a device independent manner; after being
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    48
    created using 'Font family:family face:face style:style size:size',
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    49
    the returned font is not associated to a specific device.
157
claus
parents: 151
diff changeset
    50
    (therefore, those fonts can be used to draw on any GC)
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    51
46
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    52
    To get a device font, any font can be sent the message
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    53
    'aFont on:aDevice' which returns an instance of Font which is
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    54
    associated to a device (it returns the receiver, if that is already
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    55
    associated to that device).
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    56
46
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    57
    For proper operation, each graphics operation working with fonts
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    58
    must get a device font before doing the draw.
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    59
    Most draw methods in DeviceDrawable do that automatically for you, 
157
claus
parents: 151
diff changeset
    60
    before doing the draw; so you do not have to care.
46
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    61
81
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    62
    However, some operations require explicit conversion to a device font
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    63
    before being allowed. For example, a query for a fonts height (in device
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    64
    units) can only be done if the font being asked is associated to
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    65
    a device (which should be clear, since a 'courier-roman-12' font may
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    66
    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
    67
    a totally different number of device units on a 600dpi laser printer.
81
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    68
    Thus, to query a font for its height (or ascent, or descent, or width),
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    69
    use something like:
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    70
564
3ddccbec4ee7 commentary
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
    71
        myFont := Font family:'courier' ... size:12.
3ddccbec4ee7 commentary
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
    72
            ...
81
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    73
        
564
3ddccbec4ee7 commentary
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
    74
        'want to know its height on the Display'
81
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    75
        
564
3ddccbec4ee7 commentary
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
    76
        h := (myFont on:Display) height.
81
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    77
        
564
3ddccbec4ee7 commentary
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
    78
        'want to know its height on a printer'
81
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    79
        
564
3ddccbec4ee7 commentary
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
    80
        h := (myFont on:aPrinter) height.
2545
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
    81
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
    82
    there are alternative shortcuts for these operations:
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
    83
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
    84
        h := myFont heightOn:Display.
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
    85
        h := myFont heightOn:Printer.
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
    86
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
    87
        or:
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
    88
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
    89
        a := myFont ascentOn:Display.
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
    90
81
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    91
    Keep in mind, that each device is free to think in whatever units it
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    92
    likes - a display may return units of pixels, a postscript printer may
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    93
    think in (fractions of) inches, a dot matrix printer may think in dots.
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    94
    Also, notice that currently only graphic displays are really supported;
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    95
    printer devices are being developped and may or may not be in the current
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    96
    system.
4ba554473294 *** empty log message ***
claus
parents: 71
diff changeset
    97
564
3ddccbec4ee7 commentary
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
    98
    If a font cannot be represented on a device, a replacement
46
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
    99
    font is chosen and kept in the replacementFont instance variable. 
564
3ddccbec4ee7 commentary
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
   100
    This is done to preserve the original font information, in case the image
3ddccbec4ee7 commentary
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
   101
    is restarted later on another display which has that font available.
3ddccbec4ee7 commentary
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
   102
3ddccbec4ee7 commentary
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
   103
601
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
   104
    [Instance variables:]
46
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
   105
109
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   106
      family          <String>        the fonts family ('courier', 'helvetica' etc)
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   107
      face            <String>        the fonts face ('bold', 'medium' etc)
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   108
      style           <String>        the fonts style ('roman', 'italic', 'oblique')
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   109
      size            <String>        the fonts size (not in pixels) 
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   110
      encoding        <Symbol>        the fonts encoding (usually #iso8859)
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   111
109
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   112
      device          <Object>        the device the font is associated to, or nil
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   113
      fontId          <Object>        the id of the font on that device, or nil
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   114
      replacement     <Font>          the replacement font or nil
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   115
109
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   116
      ascent          <Integer>       the fonts ascent in device units on device
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   117
      descent         <Integer>       the fonts descent in device units on device
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   118
      width           <Integer>       the character width in device units on device
564
3ddccbec4ee7 commentary
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
   119
                                      (for variable fonts, its the width of a space)
109
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   120
      isFixedWidth    <Boolean>       true if font is a fixed width font
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   121
      minWidth        <Integer>       width of the smallest-width character in
564
3ddccbec4ee7 commentary
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
   122
                                      in device units on device
109
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   123
      maxWidth        <Integer>       width of the largest-width character in
564
3ddccbec4ee7 commentary
Claus Gittinger <cg@exept.de>
parents: 456
diff changeset
   124
                                      in device units on device
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   125
601
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
   126
    [class variables:]
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   127
109
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   128
      Replacements    <Dictionary>    replacement fonts
601
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
   129
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
   130
    [see also:]
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
   131
        DeviceWorkstation 
628
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   132
        DeviceDrawable GraphicsContext
601
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
   133
        Cursor Color
628
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   134
        ( introduction to view programming :html: programming/viewintro.html#FONTS )
611
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 601
diff changeset
   135
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 601
diff changeset
   136
    [author:]
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 601
diff changeset
   137
        Claus Gittinger
46
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
   138
"
628
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   139
!
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   140
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   141
examples
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   142
"
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   143
    standard fonts:
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   144
5170
4646aa850bf2 pixelSized font preps
Claus Gittinger <cg@exept.de>
parents: 5167
diff changeset
   145
        Font family:'courier' size:12
628
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   146
5170
4646aa850bf2 pixelSized font preps
Claus Gittinger <cg@exept.de>
parents: 5167
diff changeset
   147
        Font 
4646aa850bf2 pixelSized font preps
Claus Gittinger <cg@exept.de>
parents: 5167
diff changeset
   148
             family:'helvetica' 
4646aa850bf2 pixelSized font preps
Claus Gittinger <cg@exept.de>
parents: 5167
diff changeset
   149
             face:'roman' 
4646aa850bf2 pixelSized font preps
Claus Gittinger <cg@exept.de>
parents: 5167
diff changeset
   150
             style:'bold' 
4646aa850bf2 pixelSized font preps
Claus Gittinger <cg@exept.de>
parents: 5167
diff changeset
   151
             size:16
4646aa850bf2 pixelSized font preps
Claus Gittinger <cg@exept.de>
parents: 5167
diff changeset
   152
4646aa850bf2 pixelSized font preps
Claus Gittinger <cg@exept.de>
parents: 5167
diff changeset
   153
        Font 
4646aa850bf2 pixelSized font preps
Claus Gittinger <cg@exept.de>
parents: 5167
diff changeset
   154
             family:'helvetica' 
4646aa850bf2 pixelSized font preps
Claus Gittinger <cg@exept.de>
parents: 5167
diff changeset
   155
             pixelSize:20
628
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   156
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   157
5170
4646aa850bf2 pixelSized font preps
Claus Gittinger <cg@exept.de>
parents: 5167
diff changeset
   158
    special (non-portable displayType specific) fonts (typically: old X11 fonts):
628
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   159
5170
4646aa850bf2 pixelSized font preps
Claus Gittinger <cg@exept.de>
parents: 5167
diff changeset
   160
        Font name:'6x10'
628
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   161
5170
4646aa850bf2 pixelSized font preps
Claus Gittinger <cg@exept.de>
parents: 5167
diff changeset
   162
        Font name:'k14'
628
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   163
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   164
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   165
    setting the font of a button:
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   166
                                                                        [exBegin]
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   167
        |b|
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   168
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   169
        b := Button new.
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   170
        b label:'hello'.
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   171
        b font:(Font family:'helvetica' 
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   172
                     face:'medium' 
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   173
                     style:'roman' 
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   174
                     size:16).
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   175
        b open
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   176
                                                                        [exEnd]
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   177
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   178
    asking a font about a strings size in pixels, 
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   179
    if it was used on some device:
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   180
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   181
        aFont widthOf:'hello' on:Display
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   182
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   183
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   184
    asking about the ascent, if used on some device:
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   185
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   186
        aFont ascentOn:Display
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   187
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   188
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   189
    if the font has been associated to a device, the following are 
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   190
    a bit faster:
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   191
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   192
        |aFont|
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   193
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   194
        ...
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   195
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   196
        aFont := aFont on:aDevice.
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   197
        ...
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   198
        aFont widthOf:'hello'
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   199
        ...
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   200
        aFont ascent
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   201
        ...
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   202
"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   203
! !
48194c26a46c Initial revision
claus
parents:
diff changeset
   204
1087
1e5a93e03d7f handle text-argument in withOf:
Claus Gittinger <cg@exept.de>
parents: 1067
diff changeset
   205
!Font class methodsFor:'initialization'!
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   206
48194c26a46c Initial revision
claus
parents:
diff changeset
   207
initialize
48194c26a46c Initial revision
claus
parents:
diff changeset
   208
    "initialize the font tracking array"
48194c26a46c Initial revision
claus
parents:
diff changeset
   209
3213
78add46c0f4b only init once
Claus Gittinger <cg@exept.de>
parents: 3060
diff changeset
   210
    Replacements isNil ifTrue:[
78add46c0f4b only init once
Claus Gittinger <cg@exept.de>
parents: 3060
diff changeset
   211
        Replacements := Dictionary new.
71
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   212
5512
e4ede40d58ee Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents: 5493
diff changeset
   213
        Replacements 
e4ede40d58ee Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents: 5493
diff changeset
   214
            at:'serif'                  put:#('times' 'times new roman' 'palatino' 'bookman');
e4ede40d58ee Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents: 5493
diff changeset
   215
            at:'sans-serif'             put:#('arial' 'lucida' 'helvetica');
e4ede40d58ee Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents: 5493
diff changeset
   216
            at:'monospace'              put:#('courier new' 'courier' 'andale mono' 'lucidatypewriter' 'fixed').
5145
bad0795c0e71 *** empty log message ***
sr
parents: 5041
diff changeset
   217
5512
e4ede40d58ee Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents: 5493
diff changeset
   218
        Replacements 
6109
e35961f7892a class: Font
Stefan Vogel <sv@exept.de>
parents: 6104
diff changeset
   219
            at:'clean'                  put:#('courier new' 'courier');
e35961f7892a class: Font
Stefan Vogel <sv@exept.de>
parents: 6104
diff changeset
   220
            at:'fixed'                  put:#('courier new' 'courier');
e35961f7892a class: Font
Stefan Vogel <sv@exept.de>
parents: 6104
diff changeset
   221
            at:'new century schoolbook' put:#('times' 'times new roman');
5512
e4ede40d58ee Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents: 5493
diff changeset
   222
            at:'arial'                  put:#('helvetica' 'lucida');
e4ede40d58ee Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents: 5493
diff changeset
   223
            at:'lucida'                 put:#('arial' 'helvetica');
e4ede40d58ee Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents: 5493
diff changeset
   224
            at:'lucidabright'           put:#('arial' 'helvetica');
e4ede40d58ee Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents: 5493
diff changeset
   225
            at:'lucidatypewriter'       put:#('courier' 'courier new');
e4ede40d58ee Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents: 5493
diff changeset
   226
            at:'courier'                put:#('courier new');
6109
e35961f7892a class: Font
Stefan Vogel <sv@exept.de>
parents: 6104
diff changeset
   227
            at:'courier new'            put:#('courier');
5512
e4ede40d58ee Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents: 5493
diff changeset
   228
            at:'charter'                put:#('times' 'times new roman');
e4ede40d58ee Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents: 5493
diff changeset
   229
            at:'times new roman'        put:#('times');
6109
e35961f7892a class: Font
Stefan Vogel <sv@exept.de>
parents: 6104
diff changeset
   230
            at:'times'                  put:#('times new roman');
5512
e4ede40d58ee Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents: 5493
diff changeset
   231
            at:'terminal'               put:#('courier' 'courier new');
e4ede40d58ee Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents: 5493
diff changeset
   232
            at:'helvetica'              put:#('arial' 'lucida').
6109
e35961f7892a class: Font
Stefan Vogel <sv@exept.de>
parents: 6104
diff changeset
   233
    ].
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   234
! !
48194c26a46c Initial revision
claus
parents:
diff changeset
   235
1087
1e5a93e03d7f handle text-argument in withOf:
Claus Gittinger <cg@exept.de>
parents: 1067
diff changeset
   236
!Font class methodsFor:'instance creation'!
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   237
5186
adffd6f387e7 pixelSize stuff
Claus Gittinger <cg@exept.de>
parents: 5174
diff changeset
   238
family:familyString face:faceString style:styleString size:sizeArgOrNil sizeUnit:sizeUnitArg encoding:encodingSym
5167
39ac1126dc6b preps for pixelSized fonts
Claus Gittinger <cg@exept.de>
parents: 5146
diff changeset
   239
    "returns a font for given family, face, style, size and encoding. 
5225
d5786752d508 fixes for pixel-sized fonts
Stefan Vogel <sv@exept.de>
parents: 5222
diff changeset
   240
     The returned font is not associated to a specific device."
5167
39ac1126dc6b preps for pixelSized fonts
Claus Gittinger <cg@exept.de>
parents: 5146
diff changeset
   241
54
29a6b2f8e042 *** empty log message ***
claus
parents: 46
diff changeset
   242
    |family newFont|
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   243
48194c26a46c Initial revision
claus
parents:
diff changeset
   244
    (familyString at:1) isUppercase ifTrue:[
2925
fadcf27b8f99 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   245
        family := familyString asLowercase
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   246
    ] ifFalse:[
2925
fadcf27b8f99 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   247
        family := familyString
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   248
    ].
48194c26a46c Initial revision
claus
parents:
diff changeset
   249
1372
2b55617a712f keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   250
    newFont := self basicNew 
2925
fadcf27b8f99 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   251
                    setFamily:familyString
fadcf27b8f99 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   252
                    face:faceString
fadcf27b8f99 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   253
                    style:styleString
5167
39ac1126dc6b preps for pixelSized fonts
Claus Gittinger <cg@exept.de>
parents: 5146
diff changeset
   254
                    size:sizeArgOrNil
5186
adffd6f387e7 pixelSize stuff
Claus Gittinger <cg@exept.de>
parents: 5174
diff changeset
   255
                    sizeUnit:sizeUnitArg
2925
fadcf27b8f99 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   256
                    encoding:encodingSym
fadcf27b8f99 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   257
                    device:nil.
1372
2b55617a712f keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   258
5167
39ac1126dc6b preps for pixelSized fonts
Claus Gittinger <cg@exept.de>
parents: 5146
diff changeset
   259
    "look if this font is already known on the default device (the most common case)"
39ac1126dc6b preps for pixelSized fonts
Claus Gittinger <cg@exept.de>
parents: 5146
diff changeset
   260
39ac1126dc6b preps for pixelSized fonts
Claus Gittinger <cg@exept.de>
parents: 5146
diff changeset
   261
    Display notNil ifTrue:[
39ac1126dc6b preps for pixelSized fonts
Claus Gittinger <cg@exept.de>
parents: 5146
diff changeset
   262
        Display deviceFonts do:[:aFont |
39ac1126dc6b preps for pixelSized fonts
Claus Gittinger <cg@exept.de>
parents: 5146
diff changeset
   263
            (newFont sameDeviceFontAs:aFont) ifTrue:[
5442
218a6ae3e112 changed: #family:face:style:size:sizeUnit:encoding:
Claus Gittinger <cg@exept.de>
parents: 5253
diff changeset
   264
                "/ self assert:(aFont encoding = newFont encoding).
5167
39ac1126dc6b preps for pixelSized fonts
Claus Gittinger <cg@exept.de>
parents: 5146
diff changeset
   265
                ^ aFont
39ac1126dc6b preps for pixelSized fonts
Claus Gittinger <cg@exept.de>
parents: 5146
diff changeset
   266
            ]
39ac1126dc6b preps for pixelSized fonts
Claus Gittinger <cg@exept.de>
parents: 5146
diff changeset
   267
        ]
39ac1126dc6b preps for pixelSized fonts
Claus Gittinger <cg@exept.de>
parents: 5146
diff changeset
   268
    ].
39ac1126dc6b preps for pixelSized fonts
Claus Gittinger <cg@exept.de>
parents: 5146
diff changeset
   269
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   270
    ^ newFont
2925
fadcf27b8f99 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   271
fadcf27b8f99 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   272
    "Modified: / 26.9.1999 / 13:49:45 / cg"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   273
! !
48194c26a46c Initial revision
claus
parents:
diff changeset
   274
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   275
!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
   276
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   277
device
4146
4c46ae30bd64 Use #graphicsDevice
Stefan Vogel <sv@exept.de>
parents: 4116
diff changeset
   278
    "return the device I am on.
4c46ae30bd64 Use #graphicsDevice
Stefan Vogel <sv@exept.de>
parents: 4116
diff changeset
   279
     Obsolete - use #graphicsDevice"
4c46ae30bd64 Use #graphicsDevice
Stefan Vogel <sv@exept.de>
parents: 4116
diff changeset
   280
4c46ae30bd64 Use #graphicsDevice
Stefan Vogel <sv@exept.de>
parents: 4116
diff changeset
   281
    <resource:#obsolete>
6109
e35961f7892a class: Font
Stefan Vogel <sv@exept.de>
parents: 6104
diff changeset
   282
    self obsoleteMethodWarning:'2013-07-25'.
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   283
    ^ device
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   284
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   285
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   286
fontId
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   287
    "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
   288
6109
e35961f7892a class: Font
Stefan Vogel <sv@exept.de>
parents: 6104
diff changeset
   289
    replacementFont notNil ifTrue:[
e35961f7892a class: Font
Stefan Vogel <sv@exept.de>
parents: 6104
diff changeset
   290
        ^ replacementFont fontId
e35961f7892a class: Font
Stefan Vogel <sv@exept.de>
parents: 6104
diff changeset
   291
    ].
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   292
    ^ fontId
731
8cac3347e13a added #graphicsDevice
Claus Gittinger <cg@exept.de>
parents: 710
diff changeset
   293
!
8cac3347e13a added #graphicsDevice
Claus Gittinger <cg@exept.de>
parents: 710
diff changeset
   294
8cac3347e13a added #graphicsDevice
Claus Gittinger <cg@exept.de>
parents: 710
diff changeset
   295
graphicsDevice
8cac3347e13a added #graphicsDevice
Claus Gittinger <cg@exept.de>
parents: 710
diff changeset
   296
    "same as #device, for ST-80 compatibility naming.
8cac3347e13a added #graphicsDevice
Claus Gittinger <cg@exept.de>
parents: 710
diff changeset
   297
     Return the device I am associated with."
8cac3347e13a added #graphicsDevice
Claus Gittinger <cg@exept.de>
parents: 710
diff changeset
   298
8cac3347e13a added #graphicsDevice
Claus Gittinger <cg@exept.de>
parents: 710
diff changeset
   299
    ^ device
8cac3347e13a added #graphicsDevice
Claus Gittinger <cg@exept.de>
parents: 710
diff changeset
   300
8cac3347e13a added #graphicsDevice
Claus Gittinger <cg@exept.de>
parents: 710
diff changeset
   301
    "Created: 28.5.1996 / 18:39:53 / cg"
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   302
! !
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   303
5145
bad0795c0e71 *** empty log message ***
sr
parents: 5041
diff changeset
   304
5559
7fb05191247a added: #asFontDescription
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   305
!Font methodsFor:'converting'!
7fb05191247a added: #asFontDescription
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   306
7fb05191247a added: #asFontDescription
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   307
asFontDescription
7fb05191247a added: #asFontDescription
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   308
    ^ FontDescription 
7fb05191247a added: #asFontDescription
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   309
        family:family
7fb05191247a added: #asFontDescription
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   310
        face:face
7fb05191247a added: #asFontDescription
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   311
        style:style
7fb05191247a added: #asFontDescription
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   312
        size:size
7fb05191247a added: #asFontDescription
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   313
        sizeUnit:(sizeUnit ? #pt)
7fb05191247a added: #asFontDescription
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   314
        encoding:encoding
7fb05191247a added: #asFontDescription
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   315
! !
7fb05191247a added: #asFontDescription
Claus Gittinger <cg@exept.de>
parents: 5526
diff changeset
   316
3027
efb7b0c760f5 blocked deepCopying of fonts
Claus Gittinger <cg@exept.de>
parents: 2980
diff changeset
   317
!Font methodsFor:'copying'!
efb7b0c760f5 blocked deepCopying of fonts
Claus Gittinger <cg@exept.de>
parents: 2980
diff changeset
   318
4934
d715eb782001 deepCopy change
ab
parents: 4852
diff changeset
   319
deepCopyUsing:aDictionary postCopySelector:postCopySelector
3027
efb7b0c760f5 blocked deepCopying of fonts
Claus Gittinger <cg@exept.de>
parents: 2980
diff changeset
   320
    ^ self
efb7b0c760f5 blocked deepCopying of fonts
Claus Gittinger <cg@exept.de>
parents: 2980
diff changeset
   321
! !
efb7b0c760f5 blocked deepCopying of fonts
Claus Gittinger <cg@exept.de>
parents: 2980
diff changeset
   322
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   323
!Font methodsFor:'displaying'!
71
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   324
3663
d40999d6cd1e refactored
Michael Beyl <mb@exept.de>
parents: 3658
diff changeset
   325
displayString:aString from:index1 to:index2 x:x y:y in:aGC opaque:opaque
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   326
    "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
   327
     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
   328
     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
   329
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   330
    |prevFont|
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   331
2545
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   332
    prevFont := aGC font.
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   333
    replacementFont isNil ifTrue:[
2545
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   334
        fontId notNil ifTrue:[
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   335
            aGC basicFont:self.
3663
d40999d6cd1e refactored
Michael Beyl <mb@exept.de>
parents: 3658
diff changeset
   336
            aGC displayString:aString from:index1 to:index2 x:x y:y opaque:opaque.
2545
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   337
        ] ifFalse:[
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   338
            'Font: [warning]: no replacementFont. should not happen' errorPrintCR.
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   339
        ].
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   340
    ] ifFalse:[
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   341
        aGC basicFont:replacementFont.
3663
d40999d6cd1e refactored
Michael Beyl <mb@exept.de>
parents: 3658
diff changeset
   342
        aGC displayString:aString from:index1 to:index2 x:x y:y opaque:opaque.
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   343
    ].
442
eb4ee58f5f0a use #basicFont:
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
   344
    aGC basicFont:prevFont.
441
91c3ba82098f replacementFont fixes
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   345
1176
e0e2c8cbb3c8 newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 1166
diff changeset
   346
    "Modified: 10.1.1997 / 17:51:17 / cg"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   347
! !
48194c26a46c Initial revision
claus
parents:
diff changeset
   348
48194c26a46c Initial revision
claus
parents:
diff changeset
   349
!Font methodsFor:'getting a device font'!
48194c26a46c Initial revision
claus
parents:
diff changeset
   350
3628
ddeeaa203e86 Fix obsolete methods
Stefan Vogel <sv@exept.de>
parents: 3623
diff changeset
   351
onDevice:aDevice
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   352
    "create a new Font representing the same font as
48194c26a46c Initial revision
claus
parents:
diff changeset
   353
     myself on aDevice; if one already exists, return the one."
48194c26a46c Initial revision
claus
parents:
diff changeset
   354
5167
39ac1126dc6b preps for pixelSized fonts
Claus Gittinger <cg@exept.de>
parents: 5146
diff changeset
   355
    |newFont rep|
3628
ddeeaa203e86 Fix obsolete methods
Stefan Vogel <sv@exept.de>
parents: 3623
diff changeset
   356
ddeeaa203e86 Fix obsolete methods
Stefan Vogel <sv@exept.de>
parents: 3623
diff changeset
   357
    "if I am already assigned to that device ..."
ddeeaa203e86 Fix obsolete methods
Stefan Vogel <sv@exept.de>
parents: 3623
diff changeset
   358
    (device == aDevice) ifTrue:[^ self].
ddeeaa203e86 Fix obsolete methods
Stefan Vogel <sv@exept.de>
parents: 3623
diff changeset
   359
5222
09fb6ebff525 changed #onDevice: - formatting
Stefan Vogel <sv@exept.de>
parents: 5197
diff changeset
   360
    (aDevice isNil and:[device notNil]) ifTrue:[
09fb6ebff525 changed #onDevice: - formatting
Stefan Vogel <sv@exept.de>
parents: 5197
diff changeset
   361
        ^ self
5174
1bc656582c8b pixel size support
Claus Gittinger <cg@exept.de>
parents: 5170
diff changeset
   362
    ].
4163
27ad8e90c647 When a font with a given size does not exist, try smaller fonts as replacement.
Stefan Vogel <sv@exept.de>
parents: 4146
diff changeset
   363
3628
ddeeaa203e86 Fix obsolete methods
Stefan Vogel <sv@exept.de>
parents: 3623
diff changeset
   364
    aDevice deviceFonts do:[:aFont |
5167
39ac1126dc6b preps for pixelSized fonts
Claus Gittinger <cg@exept.de>
parents: 5146
diff changeset
   365
        (self sameDeviceFontAs:aFont) ifTrue:[
39ac1126dc6b preps for pixelSized fonts
Claus Gittinger <cg@exept.de>
parents: 5146
diff changeset
   366
            ^ aFont
39ac1126dc6b preps for pixelSized fonts
Claus Gittinger <cg@exept.de>
parents: 5146
diff changeset
   367
        ].
3628
ddeeaa203e86 Fix obsolete methods
Stefan Vogel <sv@exept.de>
parents: 3623
diff changeset
   368
    ].
ddeeaa203e86 Fix obsolete methods
Stefan Vogel <sv@exept.de>
parents: 3623
diff changeset
   369
ddeeaa203e86 Fix obsolete methods
Stefan Vogel <sv@exept.de>
parents: 3623
diff changeset
   370
    newFont := self onDevice:aDevice ifAbsent:nil.
ddeeaa203e86 Fix obsolete methods
Stefan Vogel <sv@exept.de>
parents: 3623
diff changeset
   371
    newFont isNil ifTrue:[
ddeeaa203e86 Fix obsolete methods
Stefan Vogel <sv@exept.de>
parents: 3623
diff changeset
   372
        "oops did not work - (device has no such font)"
ddeeaa203e86 Fix obsolete methods
Stefan Vogel <sv@exept.de>
parents: 3623
diff changeset
   373
        aDevice isOpen ifFalse:[
ddeeaa203e86 Fix obsolete methods
Stefan Vogel <sv@exept.de>
parents: 3623
diff changeset
   374
            "/ the display device is not connected
ddeeaa203e86 Fix obsolete methods
Stefan Vogel <sv@exept.de>
parents: 3623
diff changeset
   375
            "/ (or has a broken connection).
3739
909fefa92b5a Raise #drawingOnClosedDeviceSignal instead of #error
Stefan Vogel <sv@exept.de>
parents: 3663
diff changeset
   376
            aDevice class drawingOnClosedDeviceSignal raiseRequestWith:aDevice.
3628
ddeeaa203e86 Fix obsolete methods
Stefan Vogel <sv@exept.de>
parents: 3623
diff changeset
   377
            ^ self.
ddeeaa203e86 Fix obsolete methods
Stefan Vogel <sv@exept.de>
parents: 3623
diff changeset
   378
        ].
6109
e35961f7892a class: Font
Stefan Vogel <sv@exept.de>
parents: 6104
diff changeset
   379
5040
b28c261dd543 replacement font handling did not remember font in the registry,
Claus Gittinger <cg@exept.de>
parents: 4934
diff changeset
   380
        "/ look for a replacement font
3628
ddeeaa203e86 Fix obsolete methods
Stefan Vogel <sv@exept.de>
parents: 3623
diff changeset
   381
        rep := self replacementFontOnDevice:aDevice.
ddeeaa203e86 Fix obsolete methods
Stefan Vogel <sv@exept.de>
parents: 3623
diff changeset
   382
        device isNil ifTrue:[
ddeeaa203e86 Fix obsolete methods
Stefan Vogel <sv@exept.de>
parents: 3623
diff changeset
   383
            device := aDevice.
ddeeaa203e86 Fix obsolete methods
Stefan Vogel <sv@exept.de>
parents: 3623
diff changeset
   384
            replacementFont := rep.
6109
e35961f7892a class: Font
Stefan Vogel <sv@exept.de>
parents: 6104
diff changeset
   385
            newFont := self.
e35961f7892a class: Font
Stefan Vogel <sv@exept.de>
parents: 6104
diff changeset
   386
        ] ifFalse:[
e35961f7892a class: Font
Stefan Vogel <sv@exept.de>
parents: 6104
diff changeset
   387
            newFont := self class basicNew.
e35961f7892a class: Font
Stefan Vogel <sv@exept.de>
parents: 6104
diff changeset
   388
            newFont
e35961f7892a class: Font
Stefan Vogel <sv@exept.de>
parents: 6104
diff changeset
   389
                setFamily:family 
e35961f7892a class: Font
Stefan Vogel <sv@exept.de>
parents: 6104
diff changeset
   390
                face:face 
e35961f7892a class: Font
Stefan Vogel <sv@exept.de>
parents: 6104
diff changeset
   391
                style:style 
e35961f7892a class: Font
Stefan Vogel <sv@exept.de>
parents: 6104
diff changeset
   392
                size:(sizeUnit == #px ifTrue:[pixelSize] ifFalse:[size]) 
e35961f7892a class: Font
Stefan Vogel <sv@exept.de>
parents: 6104
diff changeset
   393
                sizeUnit:sizeUnit 
e35961f7892a class: Font
Stefan Vogel <sv@exept.de>
parents: 6104
diff changeset
   394
                encoding:encoding 
e35961f7892a class: Font
Stefan Vogel <sv@exept.de>
parents: 6104
diff changeset
   395
                device:aDevice;
e35961f7892a class: Font
Stefan Vogel <sv@exept.de>
parents: 6104
diff changeset
   396
                isGenericFont:self isGenericFont;
e35961f7892a class: Font
Stefan Vogel <sv@exept.de>
parents: 6104
diff changeset
   397
                setReplacementFont:rep.
3628
ddeeaa203e86 Fix obsolete methods
Stefan Vogel <sv@exept.de>
parents: 3623
diff changeset
   398
        ].
ddeeaa203e86 Fix obsolete methods
Stefan Vogel <sv@exept.de>
parents: 3623
diff changeset
   399
        aDevice registerFont:newFont.
ddeeaa203e86 Fix obsolete methods
Stefan Vogel <sv@exept.de>
parents: 3623
diff changeset
   400
    ].
ddeeaa203e86 Fix obsolete methods
Stefan Vogel <sv@exept.de>
parents: 3623
diff changeset
   401
ddeeaa203e86 Fix obsolete methods
Stefan Vogel <sv@exept.de>
parents: 3623
diff changeset
   402
    ^ newFont
ddeeaa203e86 Fix obsolete methods
Stefan Vogel <sv@exept.de>
parents: 3623
diff changeset
   403
ddeeaa203e86 Fix obsolete methods
Stefan Vogel <sv@exept.de>
parents: 3623
diff changeset
   404
    "
6109
e35961f7892a class: Font
Stefan Vogel <sv@exept.de>
parents: 6104
diff changeset
   405
     (Font family:'fooXXXXXX' size:17) onDevice:Screen current
3628
ddeeaa203e86 Fix obsolete methods
Stefan Vogel <sv@exept.de>
parents: 3623
diff changeset
   406
    "
ddeeaa203e86 Fix obsolete methods
Stefan Vogel <sv@exept.de>
parents: 3623
diff changeset
   407
ddeeaa203e86 Fix obsolete methods
Stefan Vogel <sv@exept.de>
parents: 3623
diff changeset
   408
    "Modified: 14.4.1997 / 18:22:31 / cg"
2848
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   409
!
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   410
3628
ddeeaa203e86 Fix obsolete methods
Stefan Vogel <sv@exept.de>
parents: 3623
diff changeset
   411
onDevice:aDevice ifAbsent:exceptionBlock 
2848
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   412
    "create a new Font representing the same font as
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   413
     myself on aDevice. This does NOT try to look for existing
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   414
     or replacement fonts (i.e. can be used to get physical fonts)."
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   415
4163
27ad8e90c647 When a font with a given size does not exist, try smaller fonts as replacement.
Stefan Vogel <sv@exept.de>
parents: 4146
diff changeset
   416
    |id|
2848
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   417
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   418
    "receiver was not associated - do it now"
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   419
    device isNil ifTrue:[
3785
045a05c6abbe onDevice:ifAbsent:
Claus Gittinger <cg@exept.de>
parents: 3739
diff changeset
   420
        "ask that device for the font"
5167
39ac1126dc6b preps for pixelSized fonts
Claus Gittinger <cg@exept.de>
parents: 5146
diff changeset
   421
        id := aDevice 
39ac1126dc6b preps for pixelSized fonts
Claus Gittinger <cg@exept.de>
parents: 5146
diff changeset
   422
                getFontWithFamily:family 
39ac1126dc6b preps for pixelSized fonts
Claus Gittinger <cg@exept.de>
parents: 5146
diff changeset
   423
                face:face 
39ac1126dc6b preps for pixelSized fonts
Claus Gittinger <cg@exept.de>
parents: 5146
diff changeset
   424
                style:style 
5186
adffd6f387e7 pixelSize stuff
Claus Gittinger <cg@exept.de>
parents: 5174
diff changeset
   425
                size:(sizeUnit == #px ifTrue:[pixelSize] ifFalse:[size])  
adffd6f387e7 pixelSize stuff
Claus Gittinger <cg@exept.de>
parents: 5174
diff changeset
   426
                sizeUnit:sizeUnit  
6158
17d06f1e4ca6 class: Font
Stefan Vogel <sv@exept.de>
parents: 6109
diff changeset
   427
                encoding:encoding ? '*'.
3785
045a05c6abbe onDevice:ifAbsent:
Claus Gittinger <cg@exept.de>
parents: 3739
diff changeset
   428
        id isNil ifTrue:[
045a05c6abbe onDevice:ifAbsent:
Claus Gittinger <cg@exept.de>
parents: 3739
diff changeset
   429
            "oops did not work - (device has no such font)"
045a05c6abbe onDevice:ifAbsent:
Claus Gittinger <cg@exept.de>
parents: 3739
diff changeset
   430
045a05c6abbe onDevice:ifAbsent:
Claus Gittinger <cg@exept.de>
parents: 3739
diff changeset
   431
            ^ exceptionBlock value
045a05c6abbe onDevice:ifAbsent:
Claus Gittinger <cg@exept.de>
parents: 3739
diff changeset
   432
        ].
045a05c6abbe onDevice:ifAbsent:
Claus Gittinger <cg@exept.de>
parents: 3739
diff changeset
   433
2848
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   434
        device := aDevice.
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   435
        fontId := id.
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   436
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   437
        self getFontInfos.
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   438
        aDevice registerFont:self.
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   439
        ^ self
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   440
    ].
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   441
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   442
    "receiver was already associated to another device - need a new font"
3785
045a05c6abbe onDevice:ifAbsent:
Claus Gittinger <cg@exept.de>
parents: 3739
diff changeset
   443
    ^ super onDevice:aDevice ifAbsent:exceptionBlock
2848
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   444
!
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   445
3628
ddeeaa203e86 Fix obsolete methods
Stefan Vogel <sv@exept.de>
parents: 3623
diff changeset
   446
replacementFontOnDevice:aDevice
12
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   447
    "return a replacement font for the receiver - this is needed, if
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   448
     an image is restored on another type of display, or one which has
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   449
     a different set of fonts."
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   450
5512
e4ede40d58ee Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents: 5493
diff changeset
   451
    |id f trySize alternatives alternateFamilyName|
4163
27ad8e90c647 When a font with a given size does not exist, try smaller fonts as replacement.
Stefan Vogel <sv@exept.de>
parents: 4146
diff changeset
   452
5512
e4ede40d58ee Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents: 5493
diff changeset
   453
    "try font with smaller size - 
e4ede40d58ee Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents: 5493
diff changeset
   454
     but do not try this on scaled fonts (they have size == 0)"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   455
5512
e4ede40d58ee Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents: 5493
diff changeset
   456
    alternateFamilyName := family.
e4ede40d58ee Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents: 5493
diff changeset
   457
    self isGenericFont ifFalse:[
6109
e35961f7892a class: Font
Stefan Vogel <sv@exept.de>
parents: 6104
diff changeset
   458
        trySize := (sizeUnit == #px ifTrue:[pixelSize] ifFalse:[size]) ? 0.
5512
e4ede40d58ee Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents: 5493
diff changeset
   459
        [id isNil and:[trySize := trySize - 1. trySize > 4]] whileTrue:[
e4ede40d58ee Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents: 5493
diff changeset
   460
            id := aDevice 
e4ede40d58ee Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents: 5493
diff changeset
   461
                    getFontWithFamily:family
e4ede40d58ee Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents: 5493
diff changeset
   462
                    face:face
e4ede40d58ee Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents: 5493
diff changeset
   463
                    style:style 
6109
e35961f7892a class: Font
Stefan Vogel <sv@exept.de>
parents: 6104
diff changeset
   464
                    size:trySize  
5512
e4ede40d58ee Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents: 5493
diff changeset
   465
                    sizeUnit:sizeUnit  
e4ede40d58ee Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents: 5493
diff changeset
   466
                    encoding:encoding.
e4ede40d58ee Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents: 5493
diff changeset
   467
        ].
e4ede40d58ee Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents: 5493
diff changeset
   468
    ].
4163
27ad8e90c647 When a font with a given size does not exist, try smaller fonts as replacement.
Stefan Vogel <sv@exept.de>
parents: 4146
diff changeset
   469
144
claus
parents: 127
diff changeset
   470
    id notNil ifTrue:[
4163
27ad8e90c647 When a font with a given size does not exist, try smaller fonts as replacement.
Stefan Vogel <sv@exept.de>
parents: 4146
diff changeset
   471
        ('Font [info]: use alternative size ', trySize printString, ' for ' , (self userFriendlyName)) infoPrintCR.
144
claus
parents: 127
diff changeset
   472
    ] ifFalse:[
5512
e4ede40d58ee Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents: 5493
diff changeset
   473
        alternatives := Replacements at:family asLowercase ifAbsent:nil.
e4ede40d58ee Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents: 5493
diff changeset
   474
        alternatives notNil ifTrue:[
e4ede40d58ee Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents: 5493
diff changeset
   475
            alternatives detect:[:eachAlternateFamilyName|
6109
e35961f7892a class: Font
Stefan Vogel <sv@exept.de>
parents: 6104
diff changeset
   476
                trySize := (sizeUnit == #px ifTrue:[pixelSize] ifFalse:[size]) ? 0.
5512
e4ede40d58ee Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents: 5493
diff changeset
   477
                [
e4ede40d58ee Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents: 5493
diff changeset
   478
                    id := aDevice 
e4ede40d58ee Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents: 5493
diff changeset
   479
                            getFontWithFamily:eachAlternateFamilyName
e4ede40d58ee Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents: 5493
diff changeset
   480
                            face:face
e4ede40d58ee Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents: 5493
diff changeset
   481
                            style:style 
6109
e35961f7892a class: Font
Stefan Vogel <sv@exept.de>
parents: 6104
diff changeset
   482
                            size:trySize  
5512
e4ede40d58ee Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents: 5493
diff changeset
   483
                            sizeUnit:sizeUnit  
e4ede40d58ee Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents: 5493
diff changeset
   484
                            encoding:encoding.
5990
13498d2ba36b class: Font
Claus Gittinger <cg@exept.de>
parents: 5981
diff changeset
   485
                ] doWhile:[id isNil and:[trySize := trySize - 1. trySize > 4. false]].
5512
e4ede40d58ee Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents: 5493
diff changeset
   486
                alternateFamilyName := eachAlternateFamilyName.
e4ede40d58ee Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents: 5493
diff changeset
   487
                id notNil.
5526
2eb1df09a195 changed: #replacementFontOnDevice:
Stefan Vogel <sv@exept.de>
parents: 5512
diff changeset
   488
            ] ifNone:[].
4163
27ad8e90c647 When a font with a given size does not exist, try smaller fonts as replacement.
Stefan Vogel <sv@exept.de>
parents: 4146
diff changeset
   489
        ].
27ad8e90c647 When a font with a given size does not exist, try smaller fonts as replacement.
Stefan Vogel <sv@exept.de>
parents: 4146
diff changeset
   490
        id notNil ifTrue:[
5512
e4ede40d58ee Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents: 5493
diff changeset
   491
            ('Font [info]: use alternative: ', alternateFamilyName , ' for: ' , (self userFriendlyName)) infoPrintCR.
4163
27ad8e90c647 When a font with a given size does not exist, try smaller fonts as replacement.
Stefan Vogel <sv@exept.de>
parents: 4146
diff changeset
   492
        ] ifFalse:[
5990
13498d2ba36b class: Font
Claus Gittinger <cg@exept.de>
parents: 5981
diff changeset
   493
            encoding = #'iso10646-1' ifTrue:[
13498d2ba36b class: Font
Claus Gittinger <cg@exept.de>
parents: 5981
diff changeset
   494
                "/ try latin1 (for osx-X11)
13498d2ba36b class: Font
Claus Gittinger <cg@exept.de>
parents: 5981
diff changeset
   495
                id := aDevice 
13498d2ba36b class: Font
Claus Gittinger <cg@exept.de>
parents: 5981
diff changeset
   496
                        getFontWithFamily:family
13498d2ba36b class: Font
Claus Gittinger <cg@exept.de>
parents: 5981
diff changeset
   497
                        face:face
13498d2ba36b class: Font
Claus Gittinger <cg@exept.de>
parents: 5981
diff changeset
   498
                        style:style 
13498d2ba36b class: Font
Claus Gittinger <cg@exept.de>
parents: 5981
diff changeset
   499
                        size:(sizeUnit == #px ifTrue:[pixelSize] ifFalse:[size ? 0])  
13498d2ba36b class: Font
Claus Gittinger <cg@exept.de>
parents: 5981
diff changeset
   500
                        sizeUnit:sizeUnit  
13498d2ba36b class: Font
Claus Gittinger <cg@exept.de>
parents: 5981
diff changeset
   501
                        encoding:#'iso8859-1'.
13498d2ba36b class: Font
Claus Gittinger <cg@exept.de>
parents: 5981
diff changeset
   502
                id notNil ifTrue:[
13498d2ba36b class: Font
Claus Gittinger <cg@exept.de>
parents: 5981
diff changeset
   503
                    ('Font [info]: use latin1 encoding for: ' , (self userFriendlyName)) infoPrintCR.
13498d2ba36b class: Font
Claus Gittinger <cg@exept.de>
parents: 5981
diff changeset
   504
                ].
13498d2ba36b class: Font
Claus Gittinger <cg@exept.de>
parents: 5981
diff changeset
   505
            ].
13498d2ba36b class: Font
Claus Gittinger <cg@exept.de>
parents: 5981
diff changeset
   506
            id isNil ifTrue:[
13498d2ba36b class: Font
Claus Gittinger <cg@exept.de>
parents: 5981
diff changeset
   507
                id := aDevice getDefaultFontWithEncoding:encoding.
13498d2ba36b class: Font
Claus Gittinger <cg@exept.de>
parents: 5981
diff changeset
   508
                ('Font [info]: use default for ' , (self userFriendlyName)) infoPrintCR.
13498d2ba36b class: Font
Claus Gittinger <cg@exept.de>
parents: 5981
diff changeset
   509
            ].
4163
27ad8e90c647 When a font with a given size does not exist, try smaller fonts as replacement.
Stefan Vogel <sv@exept.de>
parents: 4146
diff changeset
   510
        ].
27ad8e90c647 When a font with a given size does not exist, try smaller fonts as replacement.
Stefan Vogel <sv@exept.de>
parents: 4146
diff changeset
   511
        id isNil ifTrue:[
27ad8e90c647 When a font with a given size does not exist, try smaller fonts as replacement.
Stefan Vogel <sv@exept.de>
parents: 4146
diff changeset
   512
            "oops did not work - this is a serious an error"
27ad8e90c647 When a font with a given size does not exist, try smaller fonts as replacement.
Stefan Vogel <sv@exept.de>
parents: 4146
diff changeset
   513
            self error:'cannot get default font' mayProceed:true.
27ad8e90c647 When a font with a given size does not exist, try smaller fonts as replacement.
Stefan Vogel <sv@exept.de>
parents: 4146
diff changeset
   514
            ^ nil
27ad8e90c647 When a font with a given size does not exist, try smaller fonts as replacement.
Stefan Vogel <sv@exept.de>
parents: 4146
diff changeset
   515
        ].
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   516
    ].
4163
27ad8e90c647 When a font with a given size does not exist, try smaller fonts as replacement.
Stefan Vogel <sv@exept.de>
parents: 4146
diff changeset
   517
5040
b28c261dd543 replacement font handling did not remember font in the registry,
Claus Gittinger <cg@exept.de>
parents: 4934
diff changeset
   518
    "/ if there already is a device font for that replacement, return that one
b28c261dd543 replacement font handling did not remember font in the registry,
Claus Gittinger <cg@exept.de>
parents: 4934
diff changeset
   519
    "/ to avoid allocating multiple replacements for the same font
5512
e4ede40d58ee Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents: 5493
diff changeset
   520
    aDevice deviceFonts do:[:eachDeviceFont |
e4ede40d58ee Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents: 5493
diff changeset
   521
        (self sameDeviceFontAs:eachDeviceFont) ifTrue:[
e4ede40d58ee Support a list of replacement fonts and try each in order
Stefan Vogel <sv@exept.de>
parents: 5493
diff changeset
   522
            ^ eachDeviceFont
5040
b28c261dd543 replacement font handling did not remember font in the registry,
Claus Gittinger <cg@exept.de>
parents: 4934
diff changeset
   523
        ]
b28c261dd543 replacement font handling did not remember font in the registry,
Claus Gittinger <cg@exept.de>
parents: 4934
diff changeset
   524
    ].
b28c261dd543 replacement font handling did not remember font in the registry,
Claus Gittinger <cg@exept.de>
parents: 4934
diff changeset
   525
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   526
    f := self class basicNew.
6109
e35961f7892a class: Font
Stefan Vogel <sv@exept.de>
parents: 6104
diff changeset
   527
    f 
e35961f7892a class: Font
Stefan Vogel <sv@exept.de>
parents: 6104
diff changeset
   528
        setFamily:alternateFamilyName face:face style:style size:trySize sizeUnit:sizeUnit encoding:encoding device:aDevice;
e35961f7892a class: Font
Stefan Vogel <sv@exept.de>
parents: 6104
diff changeset
   529
        setDevice:aDevice fontId:id;
e35961f7892a class: Font
Stefan Vogel <sv@exept.de>
parents: 6104
diff changeset
   530
        getFontInfos.
5040
b28c261dd543 replacement font handling did not remember font in the registry,
Claus Gittinger <cg@exept.de>
parents: 4934
diff changeset
   531
1372
2b55617a712f keep deviceFonts in display device.
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   532
    aDevice registerFont:f.
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   533
    ^ f
454
b31d0a7e5530 nicer infoMessage when replacementFont is used
Claus Gittinger <cg@exept.de>
parents: 453
diff changeset
   534
1166
a3bd26b25dc3 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   535
    "Modified: 10.1.1997 / 15:40:21 / cg"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   536
! !
48194c26a46c Initial revision
claus
parents:
diff changeset
   537
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   538
!Font methodsFor:'instance release'!
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   539
2848
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   540
executor
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   541
    "redefined to return a lightweight copy 
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   542
     - all we need is the device handle"
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   543
2848
93cb416c82b2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   544
    ^ DeviceFontHandle basicNew setDevice:device fontId:fontId.
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   545
2433
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
   546
    "Modified: / 20.4.1996 / 23:23:04 / cg"
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
   547
    "Modified: / 3.2.1999 / 16:13:10 / stefan"
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   548
! !
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   549
4852
60af6ad07a3c category change
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
   550
!Font methodsFor:'object persistency'!
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   551
4207
9e70f7998f66 elementDescriptorFor: instead of encodingVectorFor:
penk
parents: 4205
diff changeset
   552
elementDescriptorFor:aspect
4852
60af6ad07a3c category change
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
   553
    "support for persistency:
60af6ad07a3c category change
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
   554
     answer the elements to be made persistent with an ObjectCoder"
60af6ad07a3c category change
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
   555
4006
8af191725687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3934
diff changeset
   556
    "binary storage encoding vector"
8af191725687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3934
diff changeset
   557
8af191725687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3934
diff changeset
   558
    ^ Array 
8af191725687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3934
diff changeset
   559
        with:(#family->self family) 
8af191725687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3934
diff changeset
   560
        with:(#face->self face) 
8af191725687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3934
diff changeset
   561
        with:(#style->self style) 
8af191725687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3934
diff changeset
   562
        with:(#size->self size)
8af191725687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3934
diff changeset
   563
        with:(#encoding->self encoding)
4852
60af6ad07a3c category change
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
   564
! !
60af6ad07a3c category change
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
   565
60af6ad07a3c category change
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
   566
!Font methodsFor:'printing & storing'!
3934
9226f49c99d5 encodingVectorFor:aspect (XMLStandardCoder)
tm
parents: 3785
diff changeset
   567
109
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   568
printOn:aStream
2805
2efe543c9788 comment
Claus Gittinger <cg@exept.de>
parents: 2767
diff changeset
   569
    "append a user printed representation of the receiver to aStream.
2efe543c9788 comment
Claus Gittinger <cg@exept.de>
parents: 2767
diff changeset
   570
     The format is suitable for a human - not meant to be read back.
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   571
     Redefined to print more about the fonts name"
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   572
46
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
   573
    face isNil ifTrue:[
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   574
        family isNil ifTrue:[
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   575
            aStream nextPutAll:('a replacement-Font').
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   576
            ^ self
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   577
        ].
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   578
        aStream nextPutAll:('a ' , family , '-Font').
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   579
        ^ self.
46
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
   580
    ].
109
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   581
    aStream nextPutAll:('a ' , family , '-' , 
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   582
                               face , '-' , 
4803
71f3f3c09cf7 changed #printOn:
sr
parents: 4751
diff changeset
   583
                               style printString , '-' , 
4007
f6f734115906 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4006
diff changeset
   584
                               size printString , 
f6f734115906 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4006
diff changeset
   585
                               ' (' , encoding printString , ')' ,
f6f734115906 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4006
diff changeset
   586
                               '-Font')
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   587
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   588
    "Modified: 20.4.1996 / 23:25:11 / cg"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   589
!
48194c26a46c Initial revision
claus
parents:
diff changeset
   590
109
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   591
storeOn:aStream
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   592
    "append a character sequence to the argument, aStream from which the
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   593
     receiver can be reconstructed using readFrom:."
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   594
109
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   595
    aStream nextPutAll:'(Font family:'. family storeOn:aStream.
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   596
    aStream nextPutAll:' face:'.        face storeOn:aStream.
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   597
    aStream nextPutAll:' style:'.       style storeOn:aStream.
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   598
    aStream nextPutAll:' size:'.        size storeOn:aStream.
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   599
    aStream nextPutAll:' encoding:'.    encoding storeOn:aStream.
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   600
    aStream nextPut:$)
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   601
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   602
    "
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   603
     (Font family:'helvetica' size:10) storeString
ba47d9d6bda8 *** empty log message ***
claus
parents: 99
diff changeset
   604
    "
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   605
! !
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
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
!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
   608
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   609
getFontInfos
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   610
    "ask the device about all of my actual attributes"
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   611
5578
8b4715d3c62d getFontInfos: do NOT overwrite my current encosing,
ca
parents: 5559
diff changeset
   612
    |info fetchedEncoding|
991
b3a0b903bd7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   613
3479
e647bc300eba fontMetric stuff changed
Claus Gittinger <cg@exept.de>
parents: 3415
diff changeset
   614
    replacementFont notNil ifTrue:[
e647bc300eba fontMetric stuff changed
Claus Gittinger <cg@exept.de>
parents: 3415
diff changeset
   615
        replacementFont getFontInfos.
e647bc300eba fontMetric stuff changed
Claus Gittinger <cg@exept.de>
parents: 3415
diff changeset
   616
        ^ self
e647bc300eba fontMetric stuff changed
Claus Gittinger <cg@exept.de>
parents: 3415
diff changeset
   617
    ].
991
b3a0b903bd7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   618
4023
b60e9d3335d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4007
diff changeset
   619
    info := self getFontMetrics.
b60e9d3335d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4007
diff changeset
   620
b60e9d3335d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4007
diff changeset
   621
    minCode := info minCode.
b60e9d3335d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4007
diff changeset
   622
    maxCode := info maxCode.
b60e9d3335d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4007
diff changeset
   623
    direction := info direction.
b60e9d3335d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4007
diff changeset
   624
5578
8b4715d3c62d getFontInfos: do NOT overwrite my current encosing,
ca
parents: 5559
diff changeset
   625
    fetchedEncoding := info encoding.
8b4715d3c62d getFontInfos: do NOT overwrite my current encosing,
ca
parents: 5559
diff changeset
   626
    fetchedEncoding isNil ifTrue:[
8b4715d3c62d getFontInfos: do NOT overwrite my current encosing,
ca
parents: 5559
diff changeset
   627
        fetchedEncoding := device encodingOf:fontId.
8b4715d3c62d getFontInfos: do NOT overwrite my current encosing,
ca
parents: 5559
diff changeset
   628
    ].
6078
929a4443cb7c class: Font
Claus Gittinger <cg@exept.de>
parents: 6076
diff changeset
   629
5578
8b4715d3c62d getFontInfos: do NOT overwrite my current encosing,
ca
parents: 5559
diff changeset
   630
    encoding notNil ifTrue:[
6078
929a4443cb7c class: Font
Claus Gittinger <cg@exept.de>
parents: 6076
diff changeset
   631
        (encoding ~= fetchedEncoding) ifTrue:[
929a4443cb7c class: Font
Claus Gittinger <cg@exept.de>
parents: 6076
diff changeset
   632
            (( #( #'iso10646-1' #'ms-default' #'ms-ansi' #'ms-oem' ) includes:encoding)
929a4443cb7c class: Font
Claus Gittinger <cg@exept.de>
parents: 6076
diff changeset
   633
            and:[ ( #( #'iso10646-1' #'ms-default' #'ms-ansi' #'ms-oem' ) includes:fetchedEncoding)]) ifFalse:[
929a4443cb7c class: Font
Claus Gittinger <cg@exept.de>
parents: 6076
diff changeset
   634
                encoding ~= #* ifTrue:[
929a4443cb7c class: Font
Claus Gittinger <cg@exept.de>
parents: 6076
diff changeset
   635
                    ('Font [warning]: encoding for "%1" should be %2; is %3 '
929a4443cb7c class: Font
Claus Gittinger <cg@exept.de>
parents: 6076
diff changeset
   636
                        bindWith:self with: encoding with: fetchedEncoding) infoPrintCR.
929a4443cb7c class: Font
Claus Gittinger <cg@exept.de>
parents: 6076
diff changeset
   637
                ].
929a4443cb7c class: Font
Claus Gittinger <cg@exept.de>
parents: 6076
diff changeset
   638
            ].
5582
c9401d8e2207 changed: #getFontInfos
Stefan Vogel <sv@exept.de>
parents: 5579
diff changeset
   639
        ].
5578
8b4715d3c62d getFontInfos: do NOT overwrite my current encosing,
ca
parents: 5559
diff changeset
   640
    ] ifFalse:[
8b4715d3c62d getFontInfos: do NOT overwrite my current encosing,
ca
parents: 5559
diff changeset
   641
        encoding := fetchedEncoding.
3527
cac44b80270e ps font fixes
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
   642
    ].
3479
e647bc300eba fontMetric stuff changed
Claus Gittinger <cg@exept.de>
parents: 3415
diff changeset
   643
    ascent := info ascent.
e647bc300eba fontMetric stuff changed
Claus Gittinger <cg@exept.de>
parents: 3415
diff changeset
   644
    descent := info descent.
e647bc300eba fontMetric stuff changed
Claus Gittinger <cg@exept.de>
parents: 3415
diff changeset
   645
    maxAscent := info maxAscent.
e647bc300eba fontMetric stuff changed
Claus Gittinger <cg@exept.de>
parents: 3415
diff changeset
   646
    maxDescent := info maxDescent.
e647bc300eba fontMetric stuff changed
Claus Gittinger <cg@exept.de>
parents: 3415
diff changeset
   647
    minWidth := info minWidth.
e647bc300eba fontMetric stuff changed
Claus Gittinger <cg@exept.de>
parents: 3415
diff changeset
   648
    maxWidth := info maxWidth.
e647bc300eba fontMetric stuff changed
Claus Gittinger <cg@exept.de>
parents: 3415
diff changeset
   649
    width := info averageWidth.
991
b3a0b903bd7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   650
b3a0b903bd7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   651
    width < minWidth ifTrue:[
b3a0b903bd7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   652
        "/ some systems/fonts return a wrong value (0) as width of a space
b3a0b903bd7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   653
        "/ - at least with X11 ...
b3a0b903bd7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   654
        width := minWidth
994
7e720b29c838 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 991
diff changeset
   655
    ].
5647
137a4b4eb652 changed: #getFontInfos
Claus Gittinger <cg@exept.de>
parents: 5585
diff changeset
   656
    isFixedWidth := minWidth == maxWidth.
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   657
5647
137a4b4eb652 changed: #getFontInfos
Claus Gittinger <cg@exept.de>
parents: 5585
diff changeset
   658
    "/ a temporary hack for the vista-cleartype font redraw problem
5668
7c7c6df62b22 changed: #getFontInfos
Claus Gittinger <cg@exept.de>
parents: 5647
diff changeset
   659
    false "isFixedWidth" ifFalse:[
5647
137a4b4eb652 changed: #getFontInfos
Claus Gittinger <cg@exept.de>
parents: 5585
diff changeset
   660
        UserPreferences current workAroundRenderingBugOnVista ifTrue:[
137a4b4eb652 changed: #getFontInfos
Claus Gittinger <cg@exept.de>
parents: 5585
diff changeset
   661
            self hasOverlappingCharacters:true.
137a4b4eb652 changed: #getFontInfos
Claus Gittinger <cg@exept.de>
parents: 5585
diff changeset
   662
        ]
137a4b4eb652 changed: #getFontInfos
Claus Gittinger <cg@exept.de>
parents: 5585
diff changeset
   663
    ].
137a4b4eb652 changed: #getFontInfos
Claus Gittinger <cg@exept.de>
parents: 5585
diff changeset
   664
    "Modified: / 09-11-2010 / 12:58: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
   665
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   666
3658
8932bb6311ef #getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents: 3628
diff changeset
   667
getFontMetrics
8932bb6311ef #getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents: 3628
diff changeset
   668
    "ask the device about all of my actual attributes"
8932bb6311ef #getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents: 3628
diff changeset
   669
8932bb6311ef #getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents: 3628
diff changeset
   670
    replacementFont notNil ifTrue:[
4023
b60e9d3335d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4007
diff changeset
   671
        ^ replacementFont getFontMetrics
3658
8932bb6311ef #getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents: 3628
diff changeset
   672
    ].
8932bb6311ef #getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents: 3628
diff changeset
   673
4023
b60e9d3335d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4007
diff changeset
   674
    ^ device fontMetricsOf:fontId.
3658
8932bb6311ef #getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents: 3628
diff changeset
   675
!
8932bb6311ef #getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents: 3628
diff changeset
   676
8932bb6311ef #getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents: 3628
diff changeset
   677
getFontResolution
8932bb6311ef #getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents: 3628
diff changeset
   678
    "ask the device about all of my actual attributes"
8932bb6311ef #getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents: 3628
diff changeset
   679
8932bb6311ef #getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents: 3628
diff changeset
   680
    |f|
8932bb6311ef #getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents: 3628
diff changeset
   681
8932bb6311ef #getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents: 3628
diff changeset
   682
    f := fontId.
8932bb6311ef #getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents: 3628
diff changeset
   683
    replacementFont notNil ifTrue:[
8932bb6311ef #getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents: 3628
diff changeset
   684
        f := replacementFont fontId.
8932bb6311ef #getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents: 3628
diff changeset
   685
    ].
8932bb6311ef #getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents: 3628
diff changeset
   686
8932bb6311ef #getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents: 3628
diff changeset
   687
    ^ device fontResolutionOf:f.
8932bb6311ef #getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents: 3628
diff changeset
   688
!
8932bb6311ef #getFontMetrics and #getFontResolution
Stefan Vogel <sv@exept.de>
parents: 3628
diff changeset
   689
2846
05c5fdd17641 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2833
diff changeset
   690
releaseFromDevice
05c5fdd17641 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2833
diff changeset
   691
    "I am no longer available on the device"
05c5fdd17641 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2833
diff changeset
   692
05c5fdd17641 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2833
diff changeset
   693
    device := nil.
05c5fdd17641 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2833
diff changeset
   694
    fontId := nil.
05c5fdd17641 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2833
diff changeset
   695
    replacementFont := nil
05c5fdd17641 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2833
diff changeset
   696
05c5fdd17641 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2833
diff changeset
   697
    "Modified: 20.4.1996 / 23:26:26 / cg"
05c5fdd17641 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2833
diff changeset
   698
!
05c5fdd17641 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2833
diff changeset
   699
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   700
restored
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   701
    "flush device handles when restored"
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   702
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   703
    device := nil.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   704
    fontId := nil.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   705
    replacementFont := nil
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   706
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   707
    "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
   708
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   709
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   710
setDevice:aDevice
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   711
    "set the device handle"
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   712
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   713
    device := aDevice
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   714
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   715
    "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
   716
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   717
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   718
setDevice:aDevice fontId:aFontId
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   719
    "set the device and font handles"
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   720
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   721
    device := aDevice.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   722
    fontId := aFontId
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   723
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   724
    "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
   725
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   726
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   727
setFamily:familyString face:faceString style:styleString size:sizeNum encoding:encodingSym device:aDevice
5186
adffd6f387e7 pixelSize stuff
Claus Gittinger <cg@exept.de>
parents: 5174
diff changeset
   728
    <resource: #obsolete>
6109
e35961f7892a class: Font
Stefan Vogel <sv@exept.de>
parents: 6104
diff changeset
   729
    self obsoleteMethodWarning:'2013-07-25'.
5186
adffd6f387e7 pixelSize stuff
Claus Gittinger <cg@exept.de>
parents: 5174
diff changeset
   730
adffd6f387e7 pixelSize stuff
Claus Gittinger <cg@exept.de>
parents: 5174
diff changeset
   731
    self 
adffd6f387e7 pixelSize stuff
Claus Gittinger <cg@exept.de>
parents: 5174
diff changeset
   732
        setFamily:familyString 
adffd6f387e7 pixelSize stuff
Claus Gittinger <cg@exept.de>
parents: 5174
diff changeset
   733
        face:faceString 
adffd6f387e7 pixelSize stuff
Claus Gittinger <cg@exept.de>
parents: 5174
diff changeset
   734
        style:styleString 
adffd6f387e7 pixelSize stuff
Claus Gittinger <cg@exept.de>
parents: 5174
diff changeset
   735
        size:sizeNum 
adffd6f387e7 pixelSize stuff
Claus Gittinger <cg@exept.de>
parents: 5174
diff changeset
   736
        sizeUnit:#pt
adffd6f387e7 pixelSize stuff
Claus Gittinger <cg@exept.de>
parents: 5174
diff changeset
   737
        encoding:encodingSym 
adffd6f387e7 pixelSize stuff
Claus Gittinger <cg@exept.de>
parents: 5174
diff changeset
   738
        device:aDevice
adffd6f387e7 pixelSize stuff
Claus Gittinger <cg@exept.de>
parents: 5174
diff changeset
   739
!
adffd6f387e7 pixelSize stuff
Claus Gittinger <cg@exept.de>
parents: 5174
diff changeset
   740
adffd6f387e7 pixelSize stuff
Claus Gittinger <cg@exept.de>
parents: 5174
diff changeset
   741
setFamily:familyString face:faceString style:styleString size:sizeArg sizeUnit:sizeUnitArg encoding:encodingSym device:aDevice
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   742
    "set my instance attributes"
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   743
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   744
    family := familyString.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   745
    face := faceString.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   746
    style := styleString.
5253
da138ae76b05 care for nil sizeUnit
Claus Gittinger <cg@exept.de>
parents: 5225
diff changeset
   747
    sizeUnit := (sizeUnitArg ? #pt).
da138ae76b05 care for nil sizeUnit
Claus Gittinger <cg@exept.de>
parents: 5225
diff changeset
   748
    sizeUnit == #pt ifTrue:[ 
da138ae76b05 care for nil sizeUnit
Claus Gittinger <cg@exept.de>
parents: 5225
diff changeset
   749
        size := sizeArg 
da138ae76b05 care for nil sizeUnit
Claus Gittinger <cg@exept.de>
parents: 5225
diff changeset
   750
    ] ifFalse:[
da138ae76b05 care for nil sizeUnit
Claus Gittinger <cg@exept.de>
parents: 5225
diff changeset
   751
        sizeUnit == #px ifTrue:[ 
da138ae76b05 care for nil sizeUnit
Claus Gittinger <cg@exept.de>
parents: 5225
diff changeset
   752
            pixelSize := sizeArg 
da138ae76b05 care for nil sizeUnit
Claus Gittinger <cg@exept.de>
parents: 5225
diff changeset
   753
        ] ifFalse:[
da138ae76b05 care for nil sizeUnit
Claus Gittinger <cg@exept.de>
parents: 5225
diff changeset
   754
            self error:'invalid sizeUnit' mayProceed:true.
da138ae76b05 care for nil sizeUnit
Claus Gittinger <cg@exept.de>
parents: 5225
diff changeset
   755
            size := 12.
da138ae76b05 care for nil sizeUnit
Claus Gittinger <cg@exept.de>
parents: 5225
diff changeset
   756
            sizeUnit := #pt
da138ae76b05 care for nil sizeUnit
Claus Gittinger <cg@exept.de>
parents: 5225
diff changeset
   757
        ].
da138ae76b05 care for nil sizeUnit
Claus Gittinger <cg@exept.de>
parents: 5225
diff changeset
   758
    ].
5167
39ac1126dc6b preps for pixelSized fonts
Claus Gittinger <cg@exept.de>
parents: 5146
diff changeset
   759
    encoding := encodingSym.
39ac1126dc6b preps for pixelSized fonts
Claus Gittinger <cg@exept.de>
parents: 5146
diff changeset
   760
    device := aDevice
39ac1126dc6b preps for pixelSized fonts
Claus Gittinger <cg@exept.de>
parents: 5146
diff changeset
   761
39ac1126dc6b preps for pixelSized fonts
Claus Gittinger <cg@exept.de>
parents: 5146
diff changeset
   762
    "Modified: 20.4.1996 / 23:26:56 / cg"
39ac1126dc6b preps for pixelSized fonts
Claus Gittinger <cg@exept.de>
parents: 5146
diff changeset
   763
!
39ac1126dc6b preps for pixelSized fonts
Claus Gittinger <cg@exept.de>
parents: 5146
diff changeset
   764
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   765
setFontId:aFontId
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   766
    "set my font handle"
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   767
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   768
    fontId := aFontId
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   769
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   770
    "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
   771
!
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
setReplacementFont:aFont
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   774
    "set my replacement font"
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   775
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   776
    replacementFont := aFont
578
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   777
69373a884165 commentary
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   778
    "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
   779
! !
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   780
2545
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   781
!Font methodsFor:'queries-deviceFonts'!
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   782
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   783
fullName
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   784
    "return the full (device specific) name of the receiver.
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   785
     This is query only valid if the receiver is associated to a device"
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   786
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   787
    device isNil ifTrue:[
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   788
        ^ nil
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   789
    ].
3415
5318d7f58d35 Rename #fullNameOf: to #fullFontNameOf:
Stefan Vogel <sv@exept.de>
parents: 3213
diff changeset
   790
    ^ device fullFontNameOf:fontId.
2545
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   791
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   792
    "
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   793
     ((Font name:'6x10') on:Display) fullName  
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   794
    "
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   795
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   796
    "Modified: 30.4.1996 / 17:30:10 / cg"
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   797
!
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   798
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   799
isFixedWidth
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   800
    "return true, if all characters have same width (as in courier).
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   801
     The receiver must be associated to a device,
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   802
     for this query to be legal."
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   803
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   804
    device isNil ifTrue:[
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   805
	self errorNoDevice.
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   806
    ].
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   807
    replacementFont notNil ifTrue:[
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   808
	^ replacementFont isFixedWidth
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   809
    ].
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   810
    ^ isFixedWidth
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   811
! !
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   812
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   813
!Font methodsFor:'queries-dimensions'!
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   814
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   815
ascent
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   816
    "return the font-ascent (i.e. the normal average of all characters);
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   817
     That is the number of units (usually pixels) above the baseline.
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   818
     The receiver must be associated to a device,
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   819
     for this query to be legal."
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   820
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   821
    device isNil ifTrue:[
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   822
	self errorNoDevice
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   823
    ].
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   824
    replacementFont notNil ifTrue:[
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   825
	^ replacementFont ascent
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   826
    ].
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   827
    ^ ascent
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   828
!
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   829
628
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   830
ascentOn:aDevice
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   831
    "return the fonts ascent (average), if used on aDevice."
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   832
2321
75a179c343cf try replacement forn first if nonnil in queries
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
   833
    replacementFont notNil ifTrue:[
75a179c343cf try replacement forn first if nonnil in queries
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
   834
        ^ replacementFont ascentOn:aDevice
75a179c343cf try replacement forn first if nonnil in queries
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
   835
    ].
628
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   836
    device == aDevice ifTrue:[
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   837
        ^ ascent
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   838
    ].
2833
90f9a9f6a05d #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2805
diff changeset
   839
    ^ (self onDevice:aDevice) ascent
628
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   840
2321
75a179c343cf try replacement forn first if nonnil in queries
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
   841
    "Created: / 30.4.1996 / 16:41:32 / cg"
75a179c343cf try replacement forn first if nonnil in queries
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
   842
    "Modified: / 10.9.1998 / 12:09:06 / cg"
628
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   843
!
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   844
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   845
descent
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   846
    "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
   847
     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
   848
     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
   849
     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
   850
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   851
    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
   852
	self errorNoDevice
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   853
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   854
    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
   855
	^ replacementFont descent
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   856
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   857
    ^ descent
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   858
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   859
2545
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   860
descentOn:aDevice
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   861
    "return the fonts descent (average), if used on aDevice."
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   862
2545
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   863
    replacementFont notNil ifTrue:[
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   864
        ^ replacementFont descentOn:aDevice
438
03e433e2be99 return encoding & fullNames
Claus Gittinger <cg@exept.de>
parents: 435
diff changeset
   865
    ].
2545
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   866
    device == aDevice ifTrue:[
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   867
        ^ descent
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   868
    ].
2833
90f9a9f6a05d #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2805
diff changeset
   869
    ^ (self onDevice:aDevice) descent
438
03e433e2be99 return encoding & fullNames
Claus Gittinger <cg@exept.de>
parents: 435
diff changeset
   870
2545
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   871
    "Created: / 30.4.1996 / 16:41:43 / cg"
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   872
    "Modified: / 10.9.1998 / 12:09:30 / cg"
438
03e433e2be99 return encoding & fullNames
Claus Gittinger <cg@exept.de>
parents: 435
diff changeset
   873
!
03e433e2be99 return encoding & fullNames
Claus Gittinger <cg@exept.de>
parents: 435
diff changeset
   874
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   875
height
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   876
    "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
   877
     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
   878
     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
   879
     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
   880
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   881
    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
   882
	self errorNoDevice.
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
    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
   885
	^ replacementFont height
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   886
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   887
    ^ descent + ascent.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   888
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   889
667
091cc1707848 height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   890
heightOf:textOrString
091cc1707848 height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   891
    "return the height (device specific) of the argument;
091cc1707848 height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   892
     the argument must be a String.
091cc1707848 height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   893
     CAVEAT:
091cc1707848 height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   894
        currently only constant height fonts are supported."
091cc1707848 height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   895
5981
100d92bb2b39 class: Font
Stefan Vogel <sv@exept.de>
parents: 5907
diff changeset
   896
    |sum|
100d92bb2b39 class: Font
Stefan Vogel <sv@exept.de>
parents: 5907
diff changeset
   897
667
091cc1707848 height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   898
    device isNil ifTrue:[
091cc1707848 height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   899
        self errorNoDevice.
091cc1707848 height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   900
        ^ 0
091cc1707848 height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   901
    ].
091cc1707848 height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   902
    replacementFont notNil ifTrue:[
091cc1707848 height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   903
        ^ replacementFont heightOf:textOrString
091cc1707848 height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   904
    ].
5981
100d92bb2b39 class: Font
Stefan Vogel <sv@exept.de>
parents: 5907
diff changeset
   905
    device supportsVariableHeightFonts ifFalse:[
100d92bb2b39 class: Font
Stefan Vogel <sv@exept.de>
parents: 5907
diff changeset
   906
        ^ descent + ascent
100d92bb2b39 class: Font
Stefan Vogel <sv@exept.de>
parents: 5907
diff changeset
   907
    ].
667
091cc1707848 height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   908
5981
100d92bb2b39 class: Font
Stefan Vogel <sv@exept.de>
parents: 5907
diff changeset
   909
    (textOrString isString) ifTrue:[
100d92bb2b39 class: Font
Stefan Vogel <sv@exept.de>
parents: 5907
diff changeset
   910
        ^ device heightOf:textOrString string inFont:fontId
100d92bb2b39 class: Font
Stefan Vogel <sv@exept.de>
parents: 5907
diff changeset
   911
    ].
100d92bb2b39 class: Font
Stefan Vogel <sv@exept.de>
parents: 5907
diff changeset
   912
    (textOrString isCharacter) ifTrue:[
100d92bb2b39 class: Font
Stefan Vogel <sv@exept.de>
parents: 5907
diff changeset
   913
        ^ device heightOf:textOrString asString inFont:fontId
100d92bb2b39 class: Font
Stefan Vogel <sv@exept.de>
parents: 5907
diff changeset
   914
    ].
100d92bb2b39 class: Font
Stefan Vogel <sv@exept.de>
parents: 5907
diff changeset
   915
100d92bb2b39 class: Font
Stefan Vogel <sv@exept.de>
parents: 5907
diff changeset
   916
    sum := 0.
100d92bb2b39 class: Font
Stefan Vogel <sv@exept.de>
parents: 5907
diff changeset
   917
    textOrString do:[:lineString |
100d92bb2b39 class: Font
Stefan Vogel <sv@exept.de>
parents: 5907
diff changeset
   918
        lineString isString ifTrue:[
100d92bb2b39 class: Font
Stefan Vogel <sv@exept.de>
parents: 5907
diff changeset
   919
            sum := sum + (device heightOf:lineString asString inFont:fontId).
100d92bb2b39 class: Font
Stefan Vogel <sv@exept.de>
parents: 5907
diff changeset
   920
        ]
100d92bb2b39 class: Font
Stefan Vogel <sv@exept.de>
parents: 5907
diff changeset
   921
    ].
100d92bb2b39 class: Font
Stefan Vogel <sv@exept.de>
parents: 5907
diff changeset
   922
    ^ sum
667
091cc1707848 height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   923
091cc1707848 height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   924
    "Created: 12.5.1996 / 11:05:00 / cg"
091cc1707848 height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   925
!
091cc1707848 height queries (prepare for non-constant heights)
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   926
2545
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   927
heightOf:aString on:aDevice
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   928
    "return the height of aString, if displayed on aDevice.
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   929
     The argument must be a string-like object."
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   930
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   931
    replacementFont notNil ifTrue:[
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   932
        ^ replacementFont heightOf:aString on:aDevice
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   933
    ].
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   934
    device == aDevice ifTrue:[
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   935
        ^ self heightOf:aString
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   936
    ].
2833
90f9a9f6a05d #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2805
diff changeset
   937
    ^ (self onDevice:aDevice) heightOf:aString
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   938
2545
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   939
    "Created: / 30.4.1996 / 17:14:18 / cg"
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   940
    "Modified: / 10.9.1998 / 12:09:47 / cg"
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   941
!
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   942
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   943
heightOn:aDevice
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   944
    "return the fonts height (average), if used on aDevice."
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   945
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   946
    replacementFont notNil ifTrue:[
2545
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   947
        ^ replacementFont heightOn:aDevice
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   948
    ].
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   949
    device == aDevice ifTrue:[
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   950
        ^ descent + ascent
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   951
    ].
2833
90f9a9f6a05d #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2805
diff changeset
   952
    ^ (self onDevice:aDevice) height
2545
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   953
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   954
    "Created: / 30.4.1996 / 16:41:59 / cg"
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
   955
    "Modified: / 10.9.1998 / 12:08:18 / cg"
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   956
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   957
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   958
maxAscent
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   959
    "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
   960
     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
   961
     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
   962
     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
   963
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   964
    device isNil ifTrue:[
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   965
	self errorNoDevice
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   966
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   967
    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
   968
	^ replacementFont maxAscent
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   969
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   970
    ^ maxAscent
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   971
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   972
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   973
maxDescent
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   974
    "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
   975
     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
   976
     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
   977
     for this query to be legal."
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   978
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   979
    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
   980
	self errorNoDevice
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   981
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   982
    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
   983
	^ replacementFont maxDescent
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   984
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   985
    ^ maxDescent
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   986
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   987
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   988
maxHeight
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   989
    "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
   990
     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
   991
     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
   992
     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
   993
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   994
    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
   995
	self errorNoDevice.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   996
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   997
    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
   998
	^ replacementFont maxHeight
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   999
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1000
    ^ maxDescent + maxAscent.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1001
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1002
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1003
maxWidth
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1004
    "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
  1005
     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
  1006
     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
  1007
     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
  1008
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1009
    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
  1010
	self errorNoDevice
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1011
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1012
    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
  1013
	^ replacementFont maxWidth
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1014
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1015
    ^ maxWidth
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1016
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1017
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1018
minWidth
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1019
    "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
  1020
     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
  1021
     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
  1022
     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
  1023
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1024
    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
  1025
	self errorNoDevice
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1026
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1027
    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
  1028
	^ replacementFont minWidth
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1029
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1030
    ^ minWidth
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1031
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1032
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1033
width
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1034
    "return the 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
  1035
     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
  1036
     For variable pitch fonts, the width of the space character is returned.
628
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
  1037
     For fixed fonts, this is the same as minWidth or maxWidth (or any character).
2545
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1038
     The receiver must be associated to a device, for this query to be legal."
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1039
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1040
    device isNil ifTrue:[
628
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
  1041
        self errorNoDevice.
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1042
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1043
    replacementFont notNil ifTrue:[
628
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
  1044
        ^ replacementFont width
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1045
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1046
    ^ width
628
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
  1047
4ac28f9d9c7b added queries a-la #widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
  1048
    "Modified: 30.4.1996 / 16:43:45 / cg"
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1049
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1050
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1051
widthOf:textOrString
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1052
    "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
  1053
     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
  1054
     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
  1055
     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
  1056
     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
  1057
3483
b5f133131653 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3479
diff changeset
  1058
    |this max string|
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
  1059
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1060
    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
  1061
        self errorNoDevice.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1062
        ^ 0
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1063
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1064
    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
  1065
        ^ 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
  1066
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1067
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1068
    (textOrString isString) ifTrue:[
3483
b5f133131653 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3479
diff changeset
  1069
        string := textOrString string.
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1070
        isFixedWidth ifFalse:[
3483
b5f133131653 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3479
diff changeset
  1071
            ^ device widthOf:string inFont:fontId
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1072
        ].
3483
b5f133131653 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3479
diff changeset
  1073
        ^ width * string size
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1074
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1075
    (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
  1076
        isFixedWidth ifFalse:[
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1077
            ^ 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
  1078
        ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1079
        ^ width
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1080
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1081
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1082
    max := 0.
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1083
    isFixedWidth ifFalse:[
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1084
        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
  1085
            line notNil ifTrue:[
435
5288c637512e care for nonStrings when asked for the size
Claus Gittinger <cg@exept.de>
parents: 434
diff changeset
  1086
                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
  1087
                (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
  1088
            ]
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1089
        ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1090
        ^ max
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1091
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1092
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1093
    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
  1094
        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
  1095
        (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
  1096
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1097
    ^ max * width
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1098
1087
1e5a93e03d7f handle text-argument in withOf:
Claus Gittinger <cg@exept.de>
parents: 1067
diff changeset
  1099
    "Modified: 22.10.1996 / 17:11:14 / cg"
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1100
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1101
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1102
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
  1103
    "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
  1104
     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
  1105
     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
  1106
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1107
    device isNil ifTrue:[
4513
29b4151e98cf average size bail out out for very long lines when asking for a strings width.
Claus Gittinger <cg@exept.de>
parents: 4207
diff changeset
  1108
        self errorNoDevice.
29b4151e98cf average size bail out out for very long lines when asking for a strings width.
Claus Gittinger <cg@exept.de>
parents: 4207
diff changeset
  1109
        ^ 0
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1110
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1111
    replacementFont notNil ifTrue:[
4513
29b4151e98cf average size bail out out for very long lines when asking for a strings width.
Claus Gittinger <cg@exept.de>
parents: 4207
diff changeset
  1112
        ^ replacementFont widthOf:aString from:start to:stop
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1113
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1114
    (stop < start) ifTrue:[^ 0].
4513
29b4151e98cf average size bail out out for very long lines when asking for a strings width.
Claus Gittinger <cg@exept.de>
parents: 4207
diff changeset
  1115
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1116
    isFixedWidth ifFalse:[
4513
29b4151e98cf average size bail out out for very long lines when asking for a strings width.
Claus Gittinger <cg@exept.de>
parents: 4207
diff changeset
  1117
        stop-start > 10000 ifTrue:[
29b4151e98cf average size bail out out for very long lines when asking for a strings width.
Claus Gittinger <cg@exept.de>
parents: 4207
diff changeset
  1118
            ^ (stop - start + 1) * width
29b4151e98cf average size bail out out for very long lines when asking for a strings width.
Claus Gittinger <cg@exept.de>
parents: 4207
diff changeset
  1119
        ].
29b4151e98cf average size bail out out for very long lines when asking for a strings width.
Claus Gittinger <cg@exept.de>
parents: 4207
diff changeset
  1120
        ^ device widthOf:aString from:start to:stop 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
  1121
    ].
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1122
    ^ (stop - start + 1) * width
2545
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1123
!
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1124
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1125
widthOf:aString from:startIndex to:endIndex on:aDevice
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1126
    "return the width of substring, if displayed on aDevice.
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1127
     The argument may be a Character, String or some Text;
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1128
     in the last case the width of the longest line in the text is returned."
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1129
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1130
    replacementFont notNil ifTrue:[
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1131
        ^ replacementFont widthOf:aString from:startIndex to:endIndex on:aDevice
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1132
    ].
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1133
    device == aDevice ifTrue:[
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1134
        ^ self widthOf:aString from:startIndex to:endIndex
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1135
    ].
2833
90f9a9f6a05d #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2805
diff changeset
  1136
    ^ (self onDevice:aDevice) widthOf:aString from:startIndex to:endIndex
2545
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1137
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1138
    "Created: / 30.4.1996 / 17:15:20 / cg"
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1139
    "Modified: / 10.9.1998 / 12:10:11 / cg"
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1140
!
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1141
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1142
widthOf:aString on:aDevice
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1143
    "return the width of aString, if displayed on aDevice.
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1144
     The argument may be a Character, String or some Text;
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1145
     in the last case the width of the longest line in the text is returned."
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1146
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1147
    replacementFont notNil ifTrue:[
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1148
        ^ replacementFont widthOf:aString on:aDevice
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1149
    ].
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1150
    device == aDevice ifTrue:[
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1151
        ^ self widthOf:aString
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1152
    ].
2833
90f9a9f6a05d #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2805
diff changeset
  1153
    ^ (self onDevice:aDevice) widthOf:aString
2545
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1154
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1155
    "Created: / 30.4.1996 / 17:14:18 / cg"
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1156
    "Modified: / 10.9.1998 / 12:10:26 / cg"
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1157
!
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1158
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1159
widthOn:aDevice
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1160
    "return the fonts width, if used on aDevice.
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1161
     For variable pitch fonts, the width of the space character is returned.
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1162
     For fixed fonts, this is the same as minWidth or maxWidth (or any character)."
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1163
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1164
    replacementFont notNil ifTrue:[
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1165
        ^ replacementFont widthOn:aDevice
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1166
    ].
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1167
    device == aDevice ifTrue:[
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1168
        ^ self width
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1169
    ].
2833
90f9a9f6a05d #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2805
diff changeset
  1170
    ^ (self onDevice:aDevice) width
2545
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1171
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1172
    "Created: / 30.4.1996 / 16:42:28 / cg"
829790f194cc code refactoring & cleanup
Claus Gittinger <cg@exept.de>
parents: 2433
diff changeset
  1173
    "Modified: / 10.9.1998 / 12:11:33 / cg"
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
  1174
! !
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1175
4023
b60e9d3335d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4007
diff changeset
  1176
!Font methodsFor:'queries-misc'!
b60e9d3335d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4007
diff changeset
  1177
b60e9d3335d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4007
diff changeset
  1178
direction
b60e9d3335d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4007
diff changeset
  1179
    device isNil ifTrue:[
b60e9d3335d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4007
diff changeset
  1180
        self errorNoDevice
b60e9d3335d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4007
diff changeset
  1181
    ].
b60e9d3335d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4007
diff changeset
  1182
    replacementFont notNil ifTrue:[
b60e9d3335d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4007
diff changeset
  1183
        ^ replacementFont direction
b60e9d3335d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4007
diff changeset
  1184
    ].
b60e9d3335d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4007
diff changeset
  1185
    ^ direction
b60e9d3335d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4007
diff changeset
  1186
!
b60e9d3335d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4007
diff changeset
  1187
4205
e22cf28fc87a squeak stuff
Claus Gittinger <cg@exept.de>
parents: 4163
diff changeset
  1188
maxAscii
e22cf28fc87a squeak stuff
Claus Gittinger <cg@exept.de>
parents: 4163
diff changeset
  1189
    "squeak compatibility"
e22cf28fc87a squeak stuff
Claus Gittinger <cg@exept.de>
parents: 4163
diff changeset
  1190
e22cf28fc87a squeak stuff
Claus Gittinger <cg@exept.de>
parents: 4163
diff changeset
  1191
    ^ self maxCode
e22cf28fc87a squeak stuff
Claus Gittinger <cg@exept.de>
parents: 4163
diff changeset
  1192
!
e22cf28fc87a squeak stuff
Claus Gittinger <cg@exept.de>
parents: 4163
diff changeset
  1193
4023
b60e9d3335d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4007
diff changeset
  1194
maxCode
b60e9d3335d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4007
diff changeset
  1195
    device isNil ifTrue:[
b60e9d3335d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4007
diff changeset
  1196
        self errorNoDevice
b60e9d3335d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4007
diff changeset
  1197
    ].
b60e9d3335d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4007
diff changeset
  1198
    replacementFont notNil ifTrue:[
b60e9d3335d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4007
diff changeset
  1199
        ^ replacementFont maxCode
b60e9d3335d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4007
diff changeset
  1200
    ].
b60e9d3335d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4007
diff changeset
  1201
    ^ maxCode
b60e9d3335d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4007
diff changeset
  1202
!
b60e9d3335d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4007
diff changeset
  1203
4205
e22cf28fc87a squeak stuff
Claus Gittinger <cg@exept.de>
parents: 4163
diff changeset
  1204
minAscii
e22cf28fc87a squeak stuff
Claus Gittinger <cg@exept.de>
parents: 4163
diff changeset
  1205
    "squeak compatibility"
e22cf28fc87a squeak stuff
Claus Gittinger <cg@exept.de>
parents: 4163
diff changeset
  1206
e22cf28fc87a squeak stuff
Claus Gittinger <cg@exept.de>
parents: 4163
diff changeset
  1207
    ^ self minCode
e22cf28fc87a squeak stuff
Claus Gittinger <cg@exept.de>
parents: 4163
diff changeset
  1208
!
e22cf28fc87a squeak stuff
Claus Gittinger <cg@exept.de>
parents: 4163
diff changeset
  1209
4023
b60e9d3335d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4007
diff changeset
  1210
minCode 
b60e9d3335d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4007
diff changeset
  1211
    device isNil ifTrue:[
b60e9d3335d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4007
diff changeset
  1212
        self errorNoDevice
b60e9d3335d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4007
diff changeset
  1213
    ].
b60e9d3335d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4007
diff changeset
  1214
    replacementFont notNil ifTrue:[
b60e9d3335d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4007
diff changeset
  1215
        ^ replacementFont minCode
b60e9d3335d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4007
diff changeset
  1216
    ].
b60e9d3335d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4007
diff changeset
  1217
    ^ minCode
b60e9d3335d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4007
diff changeset
  1218
! !
b60e9d3335d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4007
diff changeset
  1219
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1220
!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
  1221
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1222
fixedWidth
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1223
    "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
  1224
     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
  1225
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1226
    ^ self isFixedWidth
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1227
!
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1228
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1229
pixelSize
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1230
    "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
  1231
     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
  1232
5197
326a73815dbc changed #pixelSize
Claus Gittinger <cg@exept.de>
parents: 5186
diff changeset
  1233
    ^ pixelSize ? self height
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1234
! !
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1235
6104
2afb79acfffd class: Font
Stefan Vogel <sv@exept.de>
parents: 6078
diff changeset
  1236
!Font methodsFor:'testing'!
2afb79acfffd class: Font
Stefan Vogel <sv@exept.de>
parents: 6078
diff changeset
  1237
2afb79acfffd class: Font
Stefan Vogel <sv@exept.de>
parents: 6078
diff changeset
  1238
isAlienFont
2afb79acfffd class: Font
Stefan Vogel <sv@exept.de>
parents: 6078
diff changeset
  1239
    "answer true, if this is an alien font which does not have a device representation"
2afb79acfffd class: Font
Stefan Vogel <sv@exept.de>
parents: 6078
diff changeset
  1240
2afb79acfffd class: Font
Stefan Vogel <sv@exept.de>
parents: 6078
diff changeset
  1241
    ^ false
2afb79acfffd class: Font
Stefan Vogel <sv@exept.de>
parents: 6078
diff changeset
  1242
! !
2afb79acfffd class: Font
Stefan Vogel <sv@exept.de>
parents: 6078
diff changeset
  1243
2433
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1244
!Font::DeviceFontHandle class methodsFor:'documentation'!
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1245
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1246
documentation
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1247
"
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1248
    This is used as a finalization handle for fonts.
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1249
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1250
    [author:]
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1251
        Stefan Vogel (stefan@nilpferd)
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1252
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1253
    [see also:]
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1254
        Font
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1255
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1256
    [instance variables:]
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1257
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1258
    [class variables:]
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1259
"
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1260
! !
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1261
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1262
!Font::DeviceFontHandle methodsFor:'accessing'!
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1263
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1264
setDevice:aDevice fontId:anId
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1265
    "set the handles contents"
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1266
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1267
    device := aDevice.
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1268
    fontId := anId.
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1269
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1270
    "Created: / 3.2.1999 / 16:08:31 / stefan"
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1271
! !
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1272
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1273
!Font::DeviceFontHandle methodsFor:'finalization'!
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1274
3611
8b4384c9e660 Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents: 3527
diff changeset
  1275
finalize
2433
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1276
    "some Font has been collected - tell it to the x-server"
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1277
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1278
    |id|
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1279
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1280
    (id := fontId) notNil ifTrue:[
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1281
        fontId := nil.
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1282
        device releaseFont:id.
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1283
    ]
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1284
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1285
    "Created: / 3.2.1999 / 16:09:25 / stefan"
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1286
! !
b2d7a24db748 New private class DeviceFontHandle for finalization.
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  1287
1087
1e5a93e03d7f handle text-argument in withOf:
Claus Gittinger <cg@exept.de>
parents: 1067
diff changeset
  1288
!Font class methodsFor:'documentation'!
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1289
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1290
version
6158
17d06f1e4ca6 class: Font
Stefan Vogel <sv@exept.de>
parents: 6109
diff changeset
  1291
    ^ '$Header: /cvs/stx/stx/libview/Font.st,v 1.134 2013-11-22 11:02:32 stefan Exp $'
5442
218a6ae3e112 changed: #family:face:style:size:sizeUnit:encoding:
Claus Gittinger <cg@exept.de>
parents: 5253
diff changeset
  1292
!
218a6ae3e112 changed: #family:face:style:size:sizeUnit:encoding:
Claus Gittinger <cg@exept.de>
parents: 5253
diff changeset
  1293
218a6ae3e112 changed: #family:face:style:size:sizeUnit:encoding:
Claus Gittinger <cg@exept.de>
parents: 5253
diff changeset
  1294
version_CVS
6158
17d06f1e4ca6 class: Font
Stefan Vogel <sv@exept.de>
parents: 6109
diff changeset
  1295
    ^ '$Header: /cvs/stx/stx/libview/Font.st,v 1.134 2013-11-22 11:02:32 stefan Exp $'
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1296
! !
3739
909fefa92b5a Raise #drawingOnClosedDeviceSignal instead of #error
Stefan Vogel <sv@exept.de>
parents: 3663
diff changeset
  1297
5981
100d92bb2b39 class: Font
Stefan Vogel <sv@exept.de>
parents: 5907
diff changeset
  1298
434
d1697f2ff1ec care for wrong info returned by server (width < minWidth) and fix this
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
  1299
Font initialize!