00001
00002 c
00003 c Copyright (c) 1986,1987,1988,1989,1990,1991,1992,1993,
00004 c by Steve McMillan, Drexel University, Philadelphia, PA.
00005 c
00006 c All rights reserved.
00007 c
00008 c Redistribution and use in source and binary forms are permitted
00009 c provided that the above copyright notice and this paragraph are
00010 c duplicated in all such forms and that any documentation,
00011 c advertising materials, and other materials related to such
00012 c distribution and use acknowledge that the software was developed
00013 c by the author named above.
00014 c
00015 c THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
00016 c IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
00017 c WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00018 c
00019
00020 subroutine sim draw(xlhe,ylhe,chars,letts,bounds)
00021 save
00022 character*(*) chars
00023 integer*2 n,m,num,jl,jr,idic,long
00024 common/sim fc2/n,m,num(288),jl(288),jr(288),idic(288),
00025 + long(15610)
00026 c
00027 c Font storage:
00028 c
00029 c Each of the 288 characters is stored as a series of points (i,j) on
00030 c an integer grid. i=0 is at the (horizontal) center of the character
00031 c (specifically, it is on the axis of symmetry of an "a", "h", etc.).
00032 c j=0 is near the vertical center of a capital letter (3/7 of the way
00033 c up a capital "a", in fact). Capital letters are contained within
00034 c a 25 x 25 grid (i,j ranging from -12 to 12) and have their bases at
00035 c j=-9. In this routine, (xlhe,ylhe) refers to the bottom left-hand
00036 c corner of the string, so an offset of 9 is applied to all j-values.
00037 c For a given character j, jl(j) and jr(j) are the left- and right-
00038 c hand edges of the figure, possibly including some space, and define
00039 c horizontal width actually plotted. Hence, jl is also used as an
00040 c offset below. given the baseline, "height" is set up in "simbol"
00041 c so that a capital "a" is of the size input to that routine. Since
00042 c a capital "a" ranges from j=-9 to j=12, the "height" here is the
00043 c "hite" input to simbol divided by 21 (see implementation below).
00044 c num(j) is twice the number of points required to specify the
00045 c character (2 coordinates per point). Points are stored in long in
00046 c the form i1,j1,i2,j2,i3,j3, etc. idic(j) points to the i
00047 c coordinate of the first point of #j. Note that no coordinate
00048 c lies outside the range (-20,20), so long could be stored as a byte
00049 c array, if desired.
00050 c
00051 c n, m are the lengths of the arrays: 288 and 15610, respectively.
00052 c
00053 integer bounds,backs
00054 integer*4 nch
00055 common/sim ang/sint,cost/sim len/nch,height
00056 real*4 lastinc
00057 common/fontc1/offx,offy,lastinc,xp,yp,xmax,xmin,ymax,ymin
00058 c
00059 c On return, offx and offy are the coordinates, in internal units,
00060 c of the bottom right-hand corner of the string (note: the actual
00061 c plotted angle is irrelevant). lastinc is the width of the last
00062 c character, in the same units. xp and yp are the "real" coordinates
00063 c (i.e. "inches") of the (offx,offy) point, i.e. (xp,yp) is where to
00064 c start if it is desired to continue with simbol. The entire string
00065 c is contained in the box defined by (xmin, xmax, ymin, ymax).
00066 c Note that the box is defined by the figure itself, not by the
00067 c box used in its construction.
00068 c
00069 common/str limits/offxmin,offxmax,offymin,offymax
00070 common/framesize/nxpix,nx0,xfac,nypix,ny0,yfac
00071 common/debug trace/itrace
00072 c
00073 character*80 device
00074 common /plot device/device,aspect,idev
00075 c
00076 if(itrace.eq.1)write(2,*)'sim_draw:',
00077 + xlhe,ylhe,chars,letts,bounds
00078
00079 joff=0
00080 backs=0
00081 talic=0. ! initially, italics are off.
00082 offx=0.
00083 offy=0.
00084 offxmin=1.e10
00085 offxmax=-1.e10
00086 offymin=1.e10
00087 offymax=-1.e10
00088 subs=1.
00089 hc=height*cost
00090 hs=height*sint
00091 c
00092 c ***** loop over characters to be plotted *****
00093 c
00094 do 10 j10=1,nch
00095 kcur=ichar(chars(j10:j10))
00096 if(kcur.eq.64)then
00097 if(joff.eq.192)then
00098 subs=subs*0.6 ! %@ = decrease size
00099 joff=-96
00100 end if
00101 joff=joff+96 ! @ = second font
00102 if(joff-192)10,1,11 ! @@ = backspace
00103 1 backs=1
00104 joff=0
00105 else if (kcur.eq.37) then
00106 if(joff.eq.96)then
00107 subs=subs/0.6 ! @% = increase size
00108 joff=-192
00109 end if
00110 joff=joff+192 ! % = third font
00111 if(joff.gt.192)go to 11 ! %% = end
00112 else if (kcur.eq.94) then
00113 subs=subs*0.6 ! ^ = superscript
00114 offy=offy+21.*subs
00115 else if (kcur.eq.92) then
00116 subs=subs*0.6 ! \ = subscript
00117 offy=offy-12.*subs
00118 else if (kcur.eq.126)then
00119 talic=1.-talic ! ~ = italics off/on
00120 else
00121 j=kcur-31+joff
00122 lefte=jl(j) ! offset of letter within box
00123 if(backs.eq.1.and.nback.eq.0)oldinc=lastinc
00124 lastinc=(jr(j)-jl(j))*subs ! width of (letter+rh edge)
00125 if(backs.eq.1)then
00126 diff=.5*(oldinc-lastinc)
00127 offx=offx-oldinc+diff
00128 lastinc=lastinc+diff
00129 end if
00130 np=num(j)/2 ! # of pen strokes
00131 lastdrawn=0
00132 npp=np
00133 if(np.eq.0)then
00134 npp=1
00135 go to 10005
00136 end if
00137 lastdrawn=1
00138 indx=idic(j) ! where to start
00139 kc=j+31
00140 c
00141 c tal=0.
00142 c if(kc.ge.65.and.kc.le.90)tal=talic ! only italicize letters
00143 c if(kc.ge.97.and.kc.le.122)tal=talic
00144 c
00145 tal=talic ! italicize everything
00146 c
00147 c Force reference point to be at a standard position
00148 c relative to device pixels.
00149 c
00150 c This doesn't seem to work with the versaterm option (?).
00151 c
00152 if(abs(cost).gt..7071)then
00153 xref=xlhe+offx*hc
00154 dxp=nx0+xref*xfac
00155 ixp=dxp
00156 dxp=dxp-ixp
00157 if(dxp.ne.0..and.idev.ne.16)then
00158 if(dxp.le..25)then
00159 do=-dxp
00160 else
00161 do=1.-dxp
00162 end if
00163 offx=offx+do/(xfac*hc)
00164 end if
00165 else
00166 yref=ylhe+offx*hs
00167 dyp=yref*yfac
00168 iyp=dyp
00169 dyp=dyp-iyp
00170 if(dyp.ne.0..and.idev.ne.16)then
00171 if(dyp.le..25)then
00172 do=-dyp
00173 else
00174 do=1.-dyp
00175 end if
00176 offx=offx+do/(yfac*hs)
00177 end if
00178 end if
00179 c
00180 10005 up=1.
00181 c
00182 c ***** loop over pen strokes *****
00183 c
00184 do 5 l=1,npp
00185 if(np.eq.0)then
00186 ix=0
00187 iy=0
00188 subs=0.
00189 go to 10105
00190 end if
00191 ix=long(indx)
00192 iy=long(indx+1)
00193 indx=indx+2
00194 10105 if(ix.eq.31)then
00195 up=1.
00196 go to 5
00197 else ! off is the current offset
00198 xl=offx+subs*(ix-lefte+0.20*tal*(iy+9)) ! relative to the start of the
00199 yl=offy+subs*(iy+9) ! string (i.e. the bottom lh edge
00200 if(bounds.eq.1)then ! of a leading capital letter.)
00201 if(xl.gt.offxmax)offxmax=xl
00202 if(xl.lt.offxmin)offxmin=xl
00203 if(yl.gt.offymax)offymax=yl
00204 if(yl.lt.offymin)offymin=yl
00205 end if
00206 xp=xlhe+height*(xl*cost-yl*sint)
00207 yp=ylhe+height*(yl*cost+xl*sint)
00208 endif
00209 kount bounds=0
00210 if(up.eq.1.)then
00211 if(letts.eq.1)call plot(xp,yp,3)
00212 up=0.
00213 xpo=xp
00214 ypo=yp
00215 else
00216 if(letts.eq.1)call plot(xp,yp,2)
00217 kount bounds=1
00218 end if
00219 if(bounds.eq.1.and.kount bounds.eq.1)then
00220 xmax=max(xmax,xp,xpo)
00221 xmin=min(xmin,xp,xpo)
00222 ymax=max(ymax,yp,ypo)
00223 ymin=min(ymin,yp,ypo)
00224 end if
00225 5 continue
00226 6 joff=0
00227 nback=0
00228 if(backs.eq.1)nback=1
00229 backs=0
00230 subs=1.
00231 offy=0.
00232 offx=offx+lastinc
00233 endif
00234 10 continue
00235 11 continue
00236 xp=xlhe+height*(offx*cost)
00237 yp=ylhe+height*(offx*sint)
00238 if(lastdrawn.eq.0)then
00239 c
00240 c deal with trailing blanks.
00241 c
00242 call plot(xp,yp,3)
00243 if(bounds.eq.1)then
00244 if(xp.gt.xmax)xmax=xp
00245 if(yp.gt.ymax)ymax=yp
00246 if(xp.lt.xmin)xmin=xp
00247 if(yp.lt.ymin)ymin=yp
00248 end if
00249 end if
00250 c
00251 end