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