h51336
s 00069/00000/00000
d D 1.1 83/03/30 22:47:06 mjb 1 0
c date and time created 83/03/30 22:47:06 by mjb
e
u
mjb
tes
U
t
T
I 1
subroutine hstclp (font, xyin, string, min, max, start, end, xyout)
SHORTINT string(1)
integer font, start, end
real xyin(2), xyout(2), min(2), max(2)

real xcur, xoff, yoff, ytemp, xlast

integer i, f
integer hshrec, hshclp, hshhgt, hshwid

include(`hshcom')

f = font
if (f < 0) f=0
if (f > nfonts) f = nfonts - 1
if (f != chfont) 
   i = hshrec (font, 0)

start = 1        # initialize start and end to all clip
end = 0

xyout(1) = xyin(1) 
xyout(2) = xyin(2)

# Compute base line with justification
yoff = xyout(2) - (cfbase*vsize*cfscal) - (hshhgt()*vjust)/100.

if (hshclp(yoff, min(2), max(2)) != 0) return       # Clip to base line
ytemp = yoff + hshhgt()
if (hshclp(ytemp, min(2), max(2)) != 0) return      # Clip to cap line

# Compute total length of string
i = 1
xoff = 0.0
while (string(i) != NUL) {
   xoff = xoff + hshwid (string(i))
   i = i + 1
   }

# Determine x start position with justification
xcur = xyout(1) - (hjust*xoff)/100.

if ((hshclp (xcur, min(1), max(1)) == 0) & 
    (hshclp (xcur+xoff,min(1), max(1)) == 0)) {
    xyout(1) = xcur
    xyout(2) = yoff
    end = i - 1
    return
    }

# Clip the string one character at a time
i = 1
while (string(i) != NUL) {
   xoff = hshwid (string(i))
   xlast = xcur
   xcur = xcur + xoff
   if (hshclp(xcur,min(1),max(1)) == 0) {
      if (end < start) {
	 start = i
	 xyout(1) = xlast
	 xyout(2) = yoff
	 }
      end = i
      }
   i = i + 1
   }

return
end
E 1
