
TextFit:
   add.w #-24,sp
   movem.l  d2-d7/a2-a6,-(sp)
   move.l   a1,a5
   move.l   a0,d5
   move.l   d0,d4
   move.l   a2,a4
   move.l   d1,(48,sp)
   move.l   d2,(44,sp)
   move.l   (52,a5),a0
   clr.l d6
   tst.l d4
   beq   .L3
   clr.l d0
   move.w   (20,a0),d0
   cmp.l d3,d0
   bhi   .L3
   moveq #1,d3
   clr.w (4,a4)
   move.w   (26,a0),d1
   neg.w d1
   move.w   d1,(6,a4)
   clr.w (8,a4)
   move.w   (20,a0),d0
   sub.w (26,a0),d0
   subq.w   #1,d0
   move.w   d0,(10,a4)
   clr.w (a4)
   move.w   (20,a0),(2,a4)
   tst.l a3
   beq   .L4
   cmp.w (6,a3),d1
   blt   .L6
   cmp.w (10,a3),d0
   bgt   .L6
   move.w   (2,a4),d0
   cmp.w (2,a3),d0
   bls   .L4
.L6:
   clr.w d3
.L4:
   tst.w d3
   beq   .L3
   move.l   d4,d0
   subq.l   #1,d4
   tst.l d0
   beq   .L3
   moveq #52,d7
   add.l sp,d7
   clr.l d2
   even
.L10:
   move.l   a5,a1
   move.l   d5,a0
   moveq #1,d0
   move.l   d7,a2
;#APP
    jsr _LVOTextExtent(a6)
;#NO_APP
   add.l (48,sp),d5
   move.w   (a4),d0
   move.w   d0,a1
   add.w (52,sp),a1
   move.w   d0,d1
   add.w (56,sp),d1
   add.w (60,sp),d0
   move.w   (4,a4),d3
   cmp.w d3,d1
   bge   .L11
   move.w   d1,d3
.L11:
   move.w   (8,a4),d1
   cmp.w d1,d0
   ble   .L12
   move.w   d0,d1
.L12:
   move.w   d1,a0
   sub.w d3,a0
   addq.l   #1,a0
   cmp.l (44,sp),a0
   bhi   .L3
   tst.l a3
   beq   .L14
   cmp.w (4,a3),d3
   blt   .L3
   cmp.w (8,a3),d1
   bgt   .L3
   move.w   (a3),d2
   move.w   a1,a0
   cmp.l d2,a0
   bgt   .L3
.L14:
   move.w   a1,(a4)
   move.w   d3,(4,a4)
   move.w   d1,(8,a4)
   addq.l   #1,d6
   move.l   d4,d0
   subq.l   #1,d4
   tst.l d0
   bne   .L10
.L3:
   tst.l d6
   bne   .L19
   clr.w (a4)
   clr.w (2,a4)
   clr.w (4,a4)
   clr.w (6,a4)
   clr.w (8,a4)
   clr.w (10,a4)
.L19:
   move.l   d6,d0
   movem.l  (sp)+,d2-d7/a2-a6
   add.w #24,sp
   rts

