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