HersheyFont.st
author Claus Gittinger <cg@exept.de>
Sat, 12 May 2018 14:23:45 +0200
changeset 4088 bbf9b58f99c8
parent 3746 57a7dc5fde0c
permissions -rw-r--r--
#FEATURE by cg class: MIMETypes class changed: #initializeFileInfoMappings class: MIMETypes::MIMEType added: #asMimeType #isCHeaderType #isCPPSourceType #isCSourceType
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
     1
"
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
     2
 COPYRIGHT (c) 1989 by Claus Gittinger
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
     3
              All Rights Reserved
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
     4
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
     5
 This software is furnished under a license and may be used
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
     6
 only in accordance with the terms of that license and with the
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
     8
 be provided or otherwise made available to, or used by, any
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
     9
 other person.  No title to or ownership of the software is
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
    10
 hereby transferred.
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
    11
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
    12
 This is a demo example:
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
    13
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
    14
 THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTOR ``AS IS'' AND
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
    15
 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
    16
 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
    17
 ARE DISCLAIMED.  IN NO EVENT SHALL THE CONTRIBUTOR BE LIABLE
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
    18
 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
    19
 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
    20
 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
    21
 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
    22
 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
    23
 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
    24
 SUCH DAMAGE.
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
    25
"
3500
256dfb6ac4df #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
    26
"{ Package: 'stx:libview2' }"
0
3f9277473954 Initial revision
claus
parents:
diff changeset
    27
3500
256dfb6ac4df #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
    28
"{ NameSpace: Smalltalk }"
1580
84e53294af20 on -> onDevice
Michael Beyl <mb@exept.de>
parents: 370
diff changeset
    29
0
3f9277473954 Initial revision
claus
parents:
diff changeset
    30
Font subclass:#HersheyFont
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
    31
	instanceVariableNames:'glyphs scale'
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
    32
	classVariableNames:'GlyphData'
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
    33
	poolDictionaries:''
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
    34
	category:'Graphics-Support'
0
3f9277473954 Initial revision
claus
parents:
diff changeset
    35
!
3f9277473954 Initial revision
claus
parents:
diff changeset
    36
86
claus
parents: 0
diff changeset
    37
HersheyFont comment:'
claus
parents: 0
diff changeset
    38
Support for hershey fonts is based on a freeware cd-rom distribution 
0
3f9277473954 Initial revision
claus
parents:
diff changeset
    39
by DEC. This disk contains the hershey outlines and glyph maps of
3f9277473954 Initial revision
claus
parents:
diff changeset
    40
the following fonts:
3f9277473954 Initial revision
claus
parents:
diff changeset
    41
3f9277473954 Initial revision
claus
parents:
diff changeset
    42
Fonts:
86
claus
parents: 0
diff changeset
    43
	Roman:  Plain, Simplex, Duplex, Complex Small, Complex, Triplex
0
3f9277473954 Initial revision
claus
parents:
diff changeset
    44
       Italic:  Complex Small, Complex, Triplex
3f9277473954 Initial revision
claus
parents:
diff changeset
    45
       Script:  Simplex, Complex
3f9277473954 Initial revision
claus
parents:
diff changeset
    46
       Gothic:  German, English, Italian
86
claus
parents: 0
diff changeset
    47
	Greek:  Plain, Simplex, Complex Small, Complex
0
3f9277473954 Initial revision
claus
parents:
diff changeset
    48
     Cyrillic:  Complex
3f9277473954 Initial revision
claus
parents:
diff changeset
    49
3f9277473954 Initial revision
claus
parents:
diff changeset
    50
Symbols:
86
claus
parents: 0
diff changeset
    51
	Mathematical 
claus
parents: 0
diff changeset
    52
	Daggers 
claus
parents: 0
diff changeset
    53
	Astronomical 
claus
parents: 0
diff changeset
    54
	Astrological 
claus
parents: 0
diff changeset
    55
	Musical 
claus
parents: 0
diff changeset
    56
	Typesetting (ffl,fl,fi sorts of things) 
claus
parents: 0
diff changeset
    57
	Miscellaneous:
claus
parents: 0
diff changeset
    58
		- Playing card suits
claus
parents: 0
diff changeset
    59
		- Meteorology
claus
parents: 0
diff changeset
    60
		- Graphics (lines, curves)
claus
parents: 0
diff changeset
    61
		- Electrical
claus
parents: 0
diff changeset
    62
		- Geometric (shapes)
claus
parents: 0
diff changeset
    63
		- Cartographic
claus
parents: 0
diff changeset
    64
		- Naval
claus
parents: 0
diff changeset
    65
		- Agricultural
claus
parents: 0
diff changeset
    66
		- Highways
claus
parents: 0
diff changeset
    67
		- Etc...
0
3f9277473954 Initial revision
claus
parents:
diff changeset
    68
3f9277473954 Initial revision
claus
parents:
diff changeset
    69
Legal notice:
86
claus
parents: 0
diff changeset
    70
	This distribution of the Hershey Fonts may be used by anyone for
claus
parents: 0
diff changeset
    71
	any purpose, commercial or otherwise, providing that:
claus
parents: 0
diff changeset
    72
claus
parents: 0
diff changeset
    73
	1. The following acknowledgements must be distributed with
claus
parents: 0
diff changeset
    74
	the font data:
claus
parents: 0
diff changeset
    75
	    - The Hershey Fonts were originally created by Dr.
claus
parents: 0
diff changeset
    76
		    A. V. Hershey while working at the U. S.
claus
parents: 0
diff changeset
    77
		    National Bureau of Standards.
claus
parents: 0
diff changeset
    78
	    - The format of the Font data in this distribution
claus
parents: 0
diff changeset
    79
		    was originally created by
claus
parents: 0
diff changeset
    80
			    James Hurt
claus
parents: 0
diff changeset
    81
			    Cognition, Inc.
claus
parents: 0
diff changeset
    82
			    900 Technology Park Drive
claus
parents: 0
diff changeset
    83
			    Billerica, MA 01821
claus
parents: 0
diff changeset
    84
			    (mit-eddie!!ci-dandelion!!hurt)
claus
parents: 0
diff changeset
    85
claus
parents: 0
diff changeset
    86
	2. The font data in this distribution may be converted into
claus
parents: 0
diff changeset
    87
	any other format *EXCEPT* the format distributed by
claus
parents: 0
diff changeset
    88
	the U.S. NTIS (which organization holds the rights
claus
parents: 0
diff changeset
    89
	to the distribution and use of the font data in that
claus
parents: 0
diff changeset
    90
	particular format). Not that anybody would really
claus
parents: 0
diff changeset
    91
	*want* to use their format... each point is described
claus
parents: 0
diff changeset
    92
	in eight bytes as "xxx yyy:", where xxx and yyy are
claus
parents: 0
diff changeset
    93
	the coordinate values as ASCII numbers.
1580
84e53294af20 on -> onDevice
Michael Beyl <mb@exept.de>
parents: 370
diff changeset
    94
'
84e53294af20 on -> onDevice
Michael Beyl <mb@exept.de>
parents: 370
diff changeset
    95
!
0
3f9277473954 Initial revision
claus
parents:
diff changeset
    96
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
    97
!HersheyFont class methodsFor:'documentation'!
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
    98
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
    99
copyright
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   100
"
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   101
 COPYRIGHT (c) 1989 by Claus Gittinger
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   102
              All Rights Reserved
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   103
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   104
 This software is furnished under a license and may be used
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   105
 only in accordance with the terms of that license and with the
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   106
 inclusion of the above copyright notice.   This software may not
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   107
 be provided or otherwise made available to, or used by, any
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   108
 other person.  No title to or ownership of the software is
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   109
 hereby transferred.
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   110
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   111
 This is a demo example:
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   112
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   113
 THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTOR ``AS IS'' AND
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   114
 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   115
 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   116
 ARE DISCLAIMED.  IN NO EVENT SHALL THE CONTRIBUTOR BE LIABLE
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   117
 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   118
 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   119
 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   120
 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   121
 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   122
 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   123
 SUCH DAMAGE.
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   124
"
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   125
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   126
!
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   127
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   128
documentation
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   129
"
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   130
    HersheyFont provides (limited) support to draw characters
3501
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   131
    from the hershey font set.
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   132
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   133
    This is a demo class - not maintained or meant for productive use.
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   134
    Notice: this is a very old demo - it should be rewritten to honor
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   135
    the FontDescription protocol (see BitmapFont as a better example).
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   136
3501
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   137
    Caveat: not completely correct; the ascent and descent data is wrong, which
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   138
    gives textView a little trouble when selecting. (see examples)
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   139
    We leave it as an exercise to the interested user to fix those.
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   140
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   141
    You need the data file 'hersh.oc' and the glyph data files
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   142
        astrol.hmp              astrology
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   143
        scripts.hmp             cursive
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   144
        cyrilc.hmp              cyrillic
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   145
        romans.hmp              futura.l
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   146
        romand.hmp              futura.m
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   147
        gotheng.hmp             gothic.eng
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   148
        gothger.hmp             gothic.ger
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   149
        gothita.hmp             gothic.ita
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   150
        greeks.hmp              greek
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   151
        marker.hmp              markers
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   152
        lowmat.hmp              math.low
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   153
        uppmat.hmp              math.upp
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   154
        meteo.hmp               meteorology
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   155
        music.hmp               music
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   156
        scriptc.hmp             script
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   157
        symbol.hmp              symbolic
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   158
        greekc.hmp              times.g
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   159
        italicc.hmp             times.i
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   160
        italict.hmp             times.ib
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   161
        romanc.hmp              times.r
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   162
        romant.hmp              times.rb
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   163
        japan.hmp               japanese
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   164
3746
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   165
    (these are available via http/ftp and must be acquired from elsewhere due to
3501
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   166
     copyright restrictions - google for 'hersh.oc' or search for hershey in github).
3746
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   167
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   168
    You should install those files in some font folder
3501
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   169
    (see hersheyFontPath for a list of places where they are expected)
3746
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   170
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   171
    [see also:]
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   172
        BitmapFont FontDescription Font
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   173
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   174
3746
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   175
    Support for hershey fonts is based on a freeware cd-rom distribution
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   176
    by DEC. This disk contains the hershey outlines and glyph maps of
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   177
    the following fonts:
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   178
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   179
    Fonts:
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   180
        Roman:  Plain, Simplex, Duplex, Complex Small, Complex, Triplex
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   181
       Italic:  Complex Small, Complex, Triplex
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   182
       Script:  Simplex, Complex
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   183
       Gothic:  German, English, Italian
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   184
        Greek:  Plain, Simplex, Complex Small, Complex
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   185
     Cyrillic:  Complex
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   186
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   187
    Symbols:
3746
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   188
        Mathematical
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   189
        Daggers
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   190
        Astronomical
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   191
        Astrological
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   192
        Musical
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   193
        Typesetting (ffl,fl,fi sorts of things)
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   194
        Miscellaneous:
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   195
                - Playing card suits
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   196
                - Meteorology
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   197
                - Graphics (lines, curves)
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   198
                - Electrical
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   199
                - Geometric (shapes)
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   200
                - Cartographic
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   201
                - Naval
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   202
                - Agricultural
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   203
                - Highways
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   204
                - Etc...
86
claus
parents: 0
diff changeset
   205
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   206
    Legal notice:
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   207
        This distribution of the Hershey Fonts may be used by anyone for
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   208
        any purpose, commercial or otherwise, providing that:
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   209
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   210
        1. The following acknowledgements must be distributed with
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   211
        the font data:
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   212
            - The Hershey Fonts were originally created by Dr.
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   213
                    A. V. Hershey while working at the U. S.
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   214
                    National Bureau of Standards.
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   215
            - The format of the Font data in this distribution
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   216
                    was originally created by
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   217
                            James Hurt
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   218
                            Cognition, Inc.
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   219
                            900 Technology Park Drive
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   220
                            Billerica, MA 01821
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   221
                            (mit-eddie!!ci-dandelion!!hurt)
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   222
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   223
        2. The font data in this distribution may be converted into
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   224
        any other format *EXCEPT* the format distributed by
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   225
        the U.S. NTIS (which organization holds the rights
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   226
        to the distribution and use of the font data in that
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   227
        particular format). Not that anybody would really
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   228
        *want* to use their format... each point is described
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   229
        in eight bytes as 'xxx yyy:', where xxx and yyy are
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   230
        the coordinate values as ASCII numbers.
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   231
"
86
claus
parents: 0
diff changeset
   232
!
claus
parents: 0
diff changeset
   233
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   234
examples
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   235
"
3501
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   236
                                                                [exBegin]
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   237
     |aView|
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   238
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   239
     aView := TextView new extent:400@400.
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   240
     aView openAndWait.
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   241
     aView font:(HersheyFont family:'hershey-gothic-german' face:'bold' style:'roman' size:12).
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   242
     aView contents:'
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   243
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   244
Hello world
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   245
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   246
Is this nice?'.
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   247
                                                                [exEnd]
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   248
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   249
                                                                [exBegin]
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   250
     |aView|
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   251
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   252
     aView := View new extent:500@200.
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   253
     aView openAndWait.
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   254
     aView backingStore:true.
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   255
3746
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   256
     HersheyFont showFont:(HersheyFont family:'hershey-astrology'
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   257
                                         face:'bold'
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   258
                                        style:'roman'
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   259
                                         size:24) in:aView
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   260
3746
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   261
     HersheyFont showFont:(HersheyFont family:'hershey-music'
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   262
                                         face:'bold'
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   263
                                        style:'roman'
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   264
                                         size:24) in:aView
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   265
3746
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   266
     HersheyFont showFont:(HersheyFont family:'hershey-meteorology'
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   267
                                         face:'medium'
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   268
                                        style:'roman'
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   269
                                         size:24) in:aView
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   270
3746
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   271
     HersheyFont showFont:(HersheyFont family:'hershey-cursive'
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   272
                                         face:'medium'
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   273
                                        style:'roman'
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   274
                                         size:10) in:aView
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   275
3746
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   276
     HersheyFont showFont:(HersheyFont family:'hershey-cursive'
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   277
                                         face:'medium'
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   278
                                        style:'roman'
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   279
                                         size:24) in:aView
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   280
3746
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   281
     HersheyFont showFont:(HersheyFont family:'hershey-cursive'
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   282
                                         face:'medium'
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   283
                                        style:'roman'
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   284
                                         size:48) in:aView
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   285
3746
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   286
     HersheyFont showFont:(HersheyFont family:'hershey-script'
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   287
                                         face:'bold'
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   288
                                        style:'roman'
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   289
                                         size:24) in:aView
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   290
3746
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   291
     HersheyFont showFont:(HersheyFont family:'hershey-times'
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   292
                                         face:'medium'
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   293
                                        style:'roman'
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   294
                                         size:12) in:aView
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   295
3746
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   296
     HersheyFont showFont:(HersheyFont family:'hershey-times'
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   297
                                         face:'medium'
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   298
                                        style:'roman'
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   299
                                         size:24) in:aView
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   300
3746
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   301
     HersheyFont showFont:(HersheyFont family:'hershey-times'
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   302
                                         face:'medium'
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   303
                                        style:'roman'
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   304
                                         size:48) in:aView
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   305
3746
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   306
     HersheyFont showFont:(HersheyFont family:'hershey-times'
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   307
                                         face:'bold'
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   308
                                        style:'roman'
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   309
                                         size:24) in:aView
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   310
3746
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   311
     HersheyFont showFont:(HersheyFont family:'hershey-times'
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   312
                                         face:'medium'
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   313
                                        style:'italic'
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   314
                                         size:24) in:aView
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   315
3746
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   316
     HersheyFont showFont:(HersheyFont family:'hershey-times'
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   317
                                         face:'bold'
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   318
                                        style:'italic'
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   319
                                         size:24) in:aView
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   320
3746
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   321
     HersheyFont showFont:(HersheyFont family:'hershey-futura'
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   322
                                         face:'medium'
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   323
                                        style:'roman'
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   324
                                         size:24) in:aView
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   325
3746
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   326
     HersheyFont showFont:(HersheyFont family:'hershey-futura'
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   327
                                         face:'bold'
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   328
                                        style:'roman'
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   329
                                         size:24) in:aView
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   330
3746
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   331
     HersheyFont showFont:(HersheyFont family:'hershey-markers'
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   332
                                         face:'medium'
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   333
                                        style:'roman'
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   334
                                         size:24) in:aView
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   335
3746
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   336
     HersheyFont showFont:(HersheyFont family:'hershey-math1'
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   337
                                         face:'medium'
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   338
                                        style:'roman'
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   339
                                         size:24) in:aView
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   340
3746
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   341
     HersheyFont showFont:(HersheyFont family:'hershey-math2'
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   342
                                         face:'medium'
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   343
                                        style:'roman'
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   344
                                         size:24) in:aView
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   345
3746
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   346
     HersheyFont showFont:(HersheyFont family:'hershey-symbol'
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   347
                                         face:'medium'
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   348
                                        style:'roman'
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   349
                                         size:24) in:aView
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   350
3746
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   351
     HersheyFont showFont:(HersheyFont family:'hershey-gothic-italian'
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   352
                                         face:'bold'
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   353
                                        style:'roman'
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   354
                                         size:24) in:aView
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   355
3746
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   356
     HersheyFont showFont:(HersheyFont family:'hershey-gothic-german'
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   357
                                         face:'bold'
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   358
                                        style:'roman'
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   359
                                         size:24) in:aView
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   360
3746
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   361
     HersheyFont showFont:(HersheyFont family:'hershey-gothic-english'
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   362
                                         face:'bold'
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   363
                                        style:'roman'
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   364
                                         size:24) in:aView
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   365
     ].
3501
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   366
                                                                [exEnd]
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   367
"
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   368
! !
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   370
!HersheyFont class methodsFor:'instance creation'!
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   371
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   372
family:family face:face style:style size:sz
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   373
    "return a HersheyFont, given an ST/X-style fontName"
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   374
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   375
    |fontNames|
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   376
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   377
    fontNames := #(
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   378
        ('hershey-times'                'bold'          'roman'         'romant')
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   379
        ('hershey-times'                'medium'        'roman'         'romanc')
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   380
        ('hershey-times'                'medium'        'italic'        'italicc')
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   381
        ('hershey-times'                'bold'          'italic'        'italict')
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   382
        ('hershey-times'                'bold'          'greek'         'greekc')
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   383
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   384
        ('hershey-japan'                'bold'          'normal'        'japan')
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   385
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   386
        ('hershey-gothic-german'        'bold'          'roman'         'gothger')
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   387
        ('hershey-gothic-english'       'bold'          'roman'         'gotheng')
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   388
        ('hershey-gothic-italian'       'bold'          'roman'         'gothita')
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   389
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   390
        ('hershey-cursive'              'medium'        'roman'         'scripts')
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   391
        ('hershey-script'               'bold'          'roman'         'scriptc')
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   392
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   393
        ('hershey-futura'               'medium'        'roman'         'romans')
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   394
        ('hershey-futura'               'bold'          'roman'         'romand')
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   395
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   396
        ('hershey-markers'              'medium'        'roman'         'marker')
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   397
        ('hershey-math1'                'medium'        'roman'         'lowmat')
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   398
        ('hershey-math2'                'medium'        'roman'         'uppmat')
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   399
        ('hershey-symbol'               'medium'        'roman'         'symbol')
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   400
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   401
        ('hershey-astrology'            'bold'          'roman'         'astrol')
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   402
        ('hershey-meteorology'          'medium'        'roman'         'meteo')
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   403
        ('hershey-music'                'bold'          'roman'         'music')
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   404
    ).
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   405
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   406
    fontNames do:[:entry |
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   407
        (entry at:1) = family ifTrue:[
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   408
            (entry at:2) = face ifTrue:[
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   409
                (entry at:3) = style ifTrue:[
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   410
                    ^ self name:(entry at:4) family:family face:face style:style size:sz
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   411
                ]
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   412
            ]
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   413
        ]
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   414
    ].
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   415
    ^ nil
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   416
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   417
    "
3501
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   418
     HersheyFont family:'hershey-gothic-german' face:'bold' style:'roman' size:12
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   419
    "
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   420
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   421
    "Modified: 16.1.1997 / 18:19:47 / cg"
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   422
! !
3f9277473954 Initial revision
claus
parents:
diff changeset
   423
3f9277473954 Initial revision
claus
parents:
diff changeset
   424
!HersheyFont class methodsFor:'drawing'!
3f9277473954 Initial revision
claus
parents:
diff changeset
   425
3f9277473954 Initial revision
claus
parents:
diff changeset
   426
drawGlyph:glyphNo in:aGC x:x y:y scale:aScale
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   427
    "draw a single character"
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   428
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   429
    |moves c1 c2 xPos yPos nX nY draw w h savedLW|
3f9277473954 Initial revision
claus
parents:
diff changeset
   430
86
claus
parents: 0
diff changeset
   431
    moves := GlyphData at:glyphNo.
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   432
    moves isNil ifTrue:[
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   433
        Transcript showCR:('no glyph for ' , glyphNo printString).
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   434
        ^ self
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   435
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
   436
    savedLW := aGC lineWidth.
3f9277473954 Initial revision
claus
parents:
diff changeset
   437
    aGC lineWidth:(aScale * 2) rounded.
3f9277473954 Initial revision
claus
parents:
diff changeset
   438
3f9277473954 Initial revision
claus
parents:
diff changeset
   439
    xPos := 0 "x".
3f9277473954 Initial revision
claus
parents:
diff changeset
   440
    yPos := 0 "y".
3f9277473954 Initial revision
claus
parents:
diff changeset
   441
    draw := false. "start with a skip"
3746
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   442
    w := ((moves at:1) codePoint - $R codePoint)" * aScale".
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   443
    h := ($R codePoint - (moves at:2) codePoint)" negated * aScale".
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   444
    w := w negated * aScale * 2.
3f9277473954 Initial revision
claus
parents:
diff changeset
   445
    h := h negated * aScale * 2.
3f9277473954 Initial revision
claus
parents:
diff changeset
   446
3f9277473954 Initial revision
claus
parents:
diff changeset
   447
    3 to:(moves size) by:2 do:[:index |
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   448
        c1 := moves at:index.
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   449
        c2 := moves at:(index + 1).
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   450
        c1 == Character space ifTrue:[
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   451
            draw := false
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   452
        ] ifFalse:[
3746
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   453
            nX := "xPos +" ((c1 codePoint - $R codePoint) * aScale).
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   454
            nY := "yPos +" (($R codePoint - c2 codePoint) negated * aScale).
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   455
            draw ifTrue:[
3746
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   456
                aGC displayLineFromX:((x + xPos) truncated "rounded")
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   457
                                   y:((y + yPos) truncated "rounded")
3746
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   458
                                 toX:((x + nX) truncated "rounded")
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   459
                                   y:((y + nY) truncated "rounded").
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   460
            ].
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   461
            xPos := nX.
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   462
            yPos := nY.
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   463
            draw := true
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   464
        ]
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   465
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
   466
    aGC lineWidth:savedLW
3f9277473954 Initial revision
claus
parents:
diff changeset
   467
3f9277473954 Initial revision
claus
parents:
diff changeset
   468
    "Smalltalk at:#v put:nil.
3f9277473954 Initial revision
claus
parents:
diff changeset
   469
     Smalltalk at:#f put:nil.
3746
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   470
     v := View new realize.
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   471
3f9277473954 Initial revision
claus
parents:
diff changeset
   472
     v clear.
3f9277473954 Initial revision
claus
parents:
diff changeset
   473
     v font:(f := HersheyFont family:'hershey-times' face:'bold' style:'roman' size:12).
3f9277473954 Initial revision
claus
parents:
diff changeset
   474
     v displayString:'hello' x:50 y:50"
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   475
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   476
    "Modified: 16.1.1997 / 18:22:10 / cg"
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   477
!
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   478
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   479
heightOfGlyph:glyphNo scale:aScale
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   480
    "return the height of a single character"
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   481
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   482
    |moves h|
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   483
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   484
    moves := GlyphData at:glyphNo.
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   485
    moves isNil ifTrue:[
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   486
        Transcript showCR:('no glyph for ' , glyphNo printString).
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   487
        ^ 0
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   488
    ].
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   489
3746
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   490
    h := ($R codePoint - (moves at:2) codePoint)" negated * aScale".
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   491
    h := h negated * aScale * 2.
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   492
    ^ h
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   493
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   494
    "Modified: 16.1.1997 / 18:22:24 / cg"
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   495
!
3f9277473954 Initial revision
claus
parents:
diff changeset
   496
3f9277473954 Initial revision
claus
parents:
diff changeset
   497
widthOfGlyph:glyphNo scale:aScale
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   498
    "return the width of a single character"
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   499
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   500
    |moves w|
3f9277473954 Initial revision
claus
parents:
diff changeset
   501
86
claus
parents: 0
diff changeset
   502
    moves := GlyphData at:glyphNo.
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   503
    moves isNil ifTrue:[
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   504
        Transcript showCR:('no glyph for ' , glyphNo printString).
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   505
        ^ 0
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   506
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
   507
3746
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   508
    w := ((moves at:1) codePoint - $R codePoint).
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   509
    w := w negated * aScale * 2.
3f9277473954 Initial revision
claus
parents:
diff changeset
   510
    ^ w
3f9277473954 Initial revision
claus
parents:
diff changeset
   511
3f9277473954 Initial revision
claus
parents:
diff changeset
   512
    "HersheyFont widthOfGlyph:3401 scale:1"
3f9277473954 Initial revision
claus
parents:
diff changeset
   513
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   514
    "Modified: 16.1.1997 / 18:22:31 / cg"
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   515
! !
3f9277473954 Initial revision
claus
parents:
diff changeset
   516
3f9277473954 Initial revision
claus
parents:
diff changeset
   517
!HersheyFont class methodsFor:'examples'!
3f9277473954 Initial revision
claus
parents:
diff changeset
   518
3f9277473954 Initial revision
claus
parents:
diff changeset
   519
showFont:f in:aView
3f9277473954 Initial revision
claus
parents:
diff changeset
   520
     |x y dy|
3f9277473954 Initial revision
claus
parents:
diff changeset
   521
3f9277473954 Initial revision
claus
parents:
diff changeset
   522
     dy := f heightOn:aView device.
3f9277473954 Initial revision
claus
parents:
diff changeset
   523
     aView clear.
3f9277473954 Initial revision
claus
parents:
diff changeset
   524
     x := 100. y := dy.
3f9277473954 Initial revision
claus
parents:
diff changeset
   525
     32 to:47 do:[:i |
370
587c6dfc87d8 forced checkin / source container change from HersheyFont.st
Claus Gittinger <cg@exept.de>
parents: 369
diff changeset
   526
         f drawCharacter:i in:aView x:x y:y.
587c6dfc87d8 forced checkin / source container change from HersheyFont.st
Claus Gittinger <cg@exept.de>
parents: 369
diff changeset
   527
         x := x + 30
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   528
     ].
3f9277473954 Initial revision
claus
parents:
diff changeset
   529
3f9277473954 Initial revision
claus
parents:
diff changeset
   530
     x := 100. y := y + dy.
3f9277473954 Initial revision
claus
parents:
diff changeset
   531
     48 to:57 do:[:i |
370
587c6dfc87d8 forced checkin / source container change from HersheyFont.st
Claus Gittinger <cg@exept.de>
parents: 369
diff changeset
   532
         f drawCharacter:i in:aView x:x y:y.
587c6dfc87d8 forced checkin / source container change from HersheyFont.st
Claus Gittinger <cg@exept.de>
parents: 369
diff changeset
   533
         x := x + 30
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   534
     ].
3f9277473954 Initial revision
claus
parents:
diff changeset
   535
3f9277473954 Initial revision
claus
parents:
diff changeset
   536
     x := 100. y := y + dy.
3f9277473954 Initial revision
claus
parents:
diff changeset
   537
     58 to:64 do:[:i |
370
587c6dfc87d8 forced checkin / source container change from HersheyFont.st
Claus Gittinger <cg@exept.de>
parents: 369
diff changeset
   538
         f drawCharacter:i in:aView x:x y:y.
587c6dfc87d8 forced checkin / source container change from HersheyFont.st
Claus Gittinger <cg@exept.de>
parents: 369
diff changeset
   539
         x := x + 30
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   540
     ].
3f9277473954 Initial revision
claus
parents:
diff changeset
   541
3f9277473954 Initial revision
claus
parents:
diff changeset
   542
     x := 100. y := y + dy.
3f9277473954 Initial revision
claus
parents:
diff changeset
   543
     65 to:90 do:[:i |
370
587c6dfc87d8 forced checkin / source container change from HersheyFont.st
Claus Gittinger <cg@exept.de>
parents: 369
diff changeset
   544
         f drawCharacter:i in:aView x:x y:y.
587c6dfc87d8 forced checkin / source container change from HersheyFont.st
Claus Gittinger <cg@exept.de>
parents: 369
diff changeset
   545
         x := x + 30
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   546
     ].
3f9277473954 Initial revision
claus
parents:
diff changeset
   547
3f9277473954 Initial revision
claus
parents:
diff changeset
   548
     x := 100. y := y + dy.
3f9277473954 Initial revision
claus
parents:
diff changeset
   549
     91 to:96 do:[:i |
370
587c6dfc87d8 forced checkin / source container change from HersheyFont.st
Claus Gittinger <cg@exept.de>
parents: 369
diff changeset
   550
         f drawCharacter:i in:aView x:x y:y.
587c6dfc87d8 forced checkin / source container change from HersheyFont.st
Claus Gittinger <cg@exept.de>
parents: 369
diff changeset
   551
         x := x + 30
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   552
     ].
3f9277473954 Initial revision
claus
parents:
diff changeset
   553
3f9277473954 Initial revision
claus
parents:
diff changeset
   554
     x := 100. y := y + dy.
3f9277473954 Initial revision
claus
parents:
diff changeset
   555
     97 to:122 do:[:i |
370
587c6dfc87d8 forced checkin / source container change from HersheyFont.st
Claus Gittinger <cg@exept.de>
parents: 369
diff changeset
   556
         f drawCharacter:i in:aView x:x y:y.
587c6dfc87d8 forced checkin / source container change from HersheyFont.st
Claus Gittinger <cg@exept.de>
parents: 369
diff changeset
   557
         x := x + 30
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   558
     ].
3f9277473954 Initial revision
claus
parents:
diff changeset
   559
3f9277473954 Initial revision
claus
parents:
diff changeset
   560
     x := 100. y := y + dy.
3f9277473954 Initial revision
claus
parents:
diff changeset
   561
     123 to:127 do:[:i |
370
587c6dfc87d8 forced checkin / source container change from HersheyFont.st
Claus Gittinger <cg@exept.de>
parents: 369
diff changeset
   562
         f drawCharacter:i in:aView x:x y:y.
587c6dfc87d8 forced checkin / source container change from HersheyFont.st
Claus Gittinger <cg@exept.de>
parents: 369
diff changeset
   563
         x := x + 30
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   564
     ]
370
587c6dfc87d8 forced checkin / source container change from HersheyFont.st
Claus Gittinger <cg@exept.de>
parents: 369
diff changeset
   565
587c6dfc87d8 forced checkin / source container change from HersheyFont.st
Claus Gittinger <cg@exept.de>
parents: 369
diff changeset
   566
    "Modified: 16.1.1997 / 18:27:15 / cg"
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   567
! !
3f9277473954 Initial revision
claus
parents:
diff changeset
   568
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   569
!HersheyFont class methodsFor:'private'!
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   570
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   571
hersheyFontPath
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   572
    "the directory, where the glyph data is found;
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   573
     you may have to modify this a bit ..."
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   574
3501
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   575
    #(
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   576
        '/usr/local/fonts/hershey'
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   577
        '/usr/fonts/hershey'
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   578
        '~/fonts/hershey'
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   579
        '~/Library/fonts/hershey'
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   580
        '~/Fonts/hershey'
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   581
        '/Library/fonts/hershey'
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   582
        '~/Desktop/fonts/hershey'
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   583
        '~/Desktop/hershey'
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   584
        '~/Downloads/fonts/hershey'
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   585
    ) do:[:each |
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   586
        |fn|
3746
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   587
3501
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   588
        fn := each asFilename.
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   589
        (fn / 'data') exists ifTrue:[^ fn pathName].
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   590
    ].
3746
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   591
3501
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   592
    ^ '/usr/local/fonts/hershey'
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   593
3501
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   594
    "
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   595
     self hersheyFontPath
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   596
    "
3746
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   597
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   598
    "Modified: 16.1.1997 / 18:24:35 / cg"
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   599
!
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   600
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   601
name:aFileName family:family face:face style:style size:sz
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   602
    "return a font with glyph-data from aFileName"
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   603
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   604
    |newFont|
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   605
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   606
    newFont := self basicNew readGlyphsFrom:aFileName.
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   607
    newFont family:family face:face style:style size:sz.
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   608
    ^ newFont
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   609
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   610
    "HersheyFont name:'gothger'"
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   611
!
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   612
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   613
readDataFile
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   614
    |inStream b5 b3 chars moves glyphNo nPairs char1 char2 index|
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   615
3501
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   616
    inStream := FileStream readonlyFileNamed:(self hersheyFontPath asFilename / 'data/hersh.oc').
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   617
    inStream isNil ifTrue:[
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   618
        self error:'no glyph data file ''' , self hersheyFontPath , ''' found.'.
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   619
        ^ self
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   620
    ].
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   621
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   622
    GlyphData isNil ifTrue:[
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   623
        Transcript showCR:'reading hershey glyphs ...'.
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   624
3501
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   625
        GlyphData := (OrderedCollection new:4000) grow:4000.
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   626
        b5 := String new:5.
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   627
        b3 := String new:3.
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   628
        [inStream atEnd] whileFalse:[
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   629
            chars := inStream nextBytes:5 into:b5.
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   630
            glyphNo := Number readFromString:b5.
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   631
            chars := inStream nextBytes:3 into:b3.
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   632
            nPairs := Number readFromString:b3.
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   633
            moves := String new:(nPairs * 2).
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   634
            index := 1.
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   635
            1 to:nPairs do:[:i |
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   636
                char1 := inStream next.
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   637
                char1 == Character nl ifTrue:[
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   638
                    char1 := inStream next
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   639
                ].
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   640
                char2 := inStream next.
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   641
                char2 == Character nl ifTrue:[
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   642
                    char2 := inStream next
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   643
                ].
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   644
                moves at:index put:char1.
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   645
                index := index + 1.
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   646
                moves at:index put:char2.
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   647
                index := index + 1
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   648
            ].
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   649
            GlyphData at:glyphNo put:moves.
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   650
            [inStream peek == Character nl] whileTrue:[inStream next]
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   651
        ].
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   652
        inStream close
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   653
    ]
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   654
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   655
    "HersheyFont readDataFile"
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   656
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   657
    "Modified: 16.1.1997 / 18:24:15 / cg"
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   658
! !
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   659
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   660
!HersheyFont methodsFor:'drawing'!
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   661
3501
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   662
displayString:aString from:index1 to:index2 x:x0 y:y in:aGC opaque:opaque
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   663
    |x|
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   664
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   665
    x := x0.
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   666
    index1 to:index2 do:[:index |
3746
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   667
        self drawCharacter:(aString at:index) codePoint in:aGC x:x y:y.
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   668
        x := x + (self widthOfCharacter:(aString at:index) codePoint)
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   669
    ]
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   670
!
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   671
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   672
displayString:aString x:x0 y:y in:aGC
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   673
    |x|
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   674
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   675
    x := x0.
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   676
    aString do:[:character |
3746
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   677
        self drawCharacter:character codePoint in:aGC x:x y:y.
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   678
        x := x + (self widthOfCharacter:character codePoint)
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   679
    ]
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   680
!
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   681
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   682
drawCharacter:ascii in:aGC x:x y:y
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   683
    |glyphNo|
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   684
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   685
    (ascii between:32 and:127) ifFalse:[^ self].
3746
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   686
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   687
    glyphNo := glyphs at:(ascii - 32 + 1).
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   688
    glyphNo isNil ifTrue:[^ self].
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   689
    self class drawGlyph:glyphNo in:aGC x:x y:y scale:scale
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   690
! !
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   691
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   692
!HersheyFont methodsFor:'private'!
3f9277473954 Initial revision
claus
parents:
diff changeset
   693
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   694
family:fam face:fac style:st size:sz
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   695
    family := fam.
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   696
    face := fac.
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   697
    style := st.
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   698
    size := sz.
3746
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   699
    scale := sz / 24
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   700
!
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   701
3501
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   702
onDevice:aDevice
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   703
    ^ self copy setDevice:aDevice
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   704
!
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   705
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   706
readGlyphsFrom:aFileName
3f9277473954 Initial revision
claus
parents:
diff changeset
   707
    "read glyph definitions from aFileName"
3f9277473954 Initial revision
claus
parents:
diff changeset
   708
3f9277473954 Initial revision
claus
parents:
diff changeset
   709
    |inStream ascii index1 index2|
3f9277473954 Initial revision
claus
parents:
diff changeset
   710
3f9277473954 Initial revision
claus
parents:
diff changeset
   711
    self class readDataFile.
3f9277473954 Initial revision
claus
parents:
diff changeset
   712
    glyphs := Array new:(256 - 32).
3501
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   713
    inStream := FileStream readonlyFileNamed:(self class hersheyFontPath asFilename / 'fonts' / (aFileName , '.hmp')).
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   714
    ascii := 32.
3f9277473954 Initial revision
claus
parents:
diff changeset
   715
    [inStream atEnd] whileFalse:[
3501
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   716
        index1 := Number readFrom:inStream.
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   717
        index2 := Number readFrom:inStream.
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   718
        index2 == 0 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   719
            index2 := index1
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   720
        ].
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   721
        index1 to:index2 do:[:pos |
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   722
            glyphs at:(ascii - 32 + 1) put:pos.
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   723
            ascii := ascii + 1
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   724
        ].
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   725
        inStream skipSeparators
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   726
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
   727
    inStream close.
3f9277473954 Initial revision
claus
parents:
diff changeset
   728
    ^ self
3f9277473954 Initial revision
claus
parents:
diff changeset
   729
!
3f9277473954 Initial revision
claus
parents:
diff changeset
   730
3f9277473954 Initial revision
claus
parents:
diff changeset
   731
scale:aScale
3f9277473954 Initial revision
claus
parents:
diff changeset
   732
    scale := aScale
3501
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   733
!
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   734
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   735
setDevice:aDevice
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   736
    super setDevice:aDevice.
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   737
    scale isNil ifTrue:[
3746
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   738
        scale := size / 24
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   739
    ].
3501
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   740
    ascent := maxAscent := self ascentOn:aDevice.
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   741
    descent := maxDescent := self descentOn:aDevice.
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   742
    width := minWidth := maxWidth := self widthOn:aDevice.
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   743
    isFixedWidth := false.
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   744
    minCode := 32.
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   745
    maxCode := 127.
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   746
    encoding := 'ascii'.
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   747
! !
3f9277473954 Initial revision
claus
parents:
diff changeset
   748
3f9277473954 Initial revision
claus
parents:
diff changeset
   749
!HersheyFont methodsFor:'queries'!
3f9277473954 Initial revision
claus
parents:
diff changeset
   750
3f9277473954 Initial revision
claus
parents:
diff changeset
   751
ascentOn:aDevice
3f9277473954 Initial revision
claus
parents:
diff changeset
   752
    ^ 0
3f9277473954 Initial revision
claus
parents:
diff changeset
   753
!
3f9277473954 Initial revision
claus
parents:
diff changeset
   754
3f9277473954 Initial revision
claus
parents:
diff changeset
   755
descentOn:aDevice
3f9277473954 Initial revision
claus
parents:
diff changeset
   756
    ^ self heightOn:aDevice
3f9277473954 Initial revision
claus
parents:
diff changeset
   757
!
3f9277473954 Initial revision
claus
parents:
diff changeset
   758
3f9277473954 Initial revision
claus
parents:
diff changeset
   759
heightOfCharacter:ascii
3f9277473954 Initial revision
claus
parents:
diff changeset
   760
    |glyphNo|
3f9277473954 Initial revision
claus
parents:
diff changeset
   761
3f9277473954 Initial revision
claus
parents:
diff changeset
   762
    (ascii between:32 and:127) ifFalse:[^ 0].
3f9277473954 Initial revision
claus
parents:
diff changeset
   763
    glyphNo := glyphs at:(ascii - 32 + 1).
3f9277473954 Initial revision
claus
parents:
diff changeset
   764
    glyphNo isNil ifTrue:[^ 0].
3f9277473954 Initial revision
claus
parents:
diff changeset
   765
    ^ self class heightOfGlyph:glyphNo scale:scale
3f9277473954 Initial revision
claus
parents:
diff changeset
   766
!
3f9277473954 Initial revision
claus
parents:
diff changeset
   767
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   768
heightOn:aDevice
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   769
    ^ scale * (24 + 12)
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   770
!
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   771
3501
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   772
isAlienFont
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   773
    ^ true
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   774
!
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   775
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   776
widthOf:aString
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   777
    |sumW|
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   778
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   779
    sumW := 0.
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   780
    aString do:[:character |
3746
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   781
        sumW := sumW + (self widthOfCharacter:character codePoint)
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   782
    ].
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   783
    ^ sumW
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   784
!
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   785
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   786
widthOf:aString from:start to:stop
3f9277473954 Initial revision
claus
parents:
diff changeset
   787
    "return the width of a substring"
3f9277473954 Initial revision
claus
parents:
diff changeset
   788
3f9277473954 Initial revision
claus
parents:
diff changeset
   789
    |sumW|
3f9277473954 Initial revision
claus
parents:
diff changeset
   790
3f9277473954 Initial revision
claus
parents:
diff changeset
   791
    (stop < start) ifTrue:[^ 0].
3f9277473954 Initial revision
claus
parents:
diff changeset
   792
    sumW := 0.
3f9277473954 Initial revision
claus
parents:
diff changeset
   793
    start to:stop do:[:index |
3746
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   794
        sumW := sumW + (self widthOfCharacter:(aString at:index) codePoint)
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   795
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
   796
    ^ sumW
3f9277473954 Initial revision
claus
parents:
diff changeset
   797
!
3f9277473954 Initial revision
claus
parents:
diff changeset
   798
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   799
widthOfCharacter:ascii
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   800
    |glyphNo|
3f9277473954 Initial revision
claus
parents:
diff changeset
   801
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   802
    (ascii between:32 and:127) ifFalse:[^ 0].
3746
57a7dc5fde0c #REFACTORING by mawalch
mawalch
parents: 3501
diff changeset
   803
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   804
    glyphNo := glyphs at:(ascii - 32 + 1).
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   805
    glyphNo isNil ifTrue:[^ 0].
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   806
    ^ self class widthOfGlyph:glyphNo scale:scale
3501
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   807
!
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   808
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   809
widthOn:aDevice
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   810
    ^ self widthOfCharacter:($m codePoint)
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   811
! !
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   812
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   813
!HersheyFont class methodsFor:'documentation'!
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   814
369
115d797ebcef defined source container
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   815
version
3500
256dfb6ac4df #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   816
    ^ '$Header$'
3501
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   817
!
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   818
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   819
version_CVS
Claus Gittinger <cg@exept.de>
parents: 3500
diff changeset
   820
    ^ '$Header$'
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   821
! !
3500
256dfb6ac4df #UI_ENHANCEMENT
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   822