This post includes a test alias to show there's still a few minor edge cases where $wrap can return extra text. I'm using Consolas 16, and made sure it's not bold, to avoid any issues related to that parm. Using the 1 or 0 on the timer's commandline causes the 'word' parm to be either 1 or 0. This alias repeats the text at 1 seconds interval, and each time it +1 increments the width of the @window, then stops when the @window reaches full width. There are occasional widths where several extra letters are returned, causing a wrap to the next line, then widening the window causes the effect to disappear for a while. It's much less common with word=1, but it's occasionally there. You can only visually see the bug if you see the extra text wrapping to the next line prior to the @window being widened again, so you might need to change the timer's interval to slow it down.

At first, I thought it was related to the issue caused by the red text containing a character which causes nearby numeric text to significantly shrink in size, but it also happens for the green text containing only normal alphanumeric which would not be font-linked. $wrap seems as likely to work/fail just as often for red and green, because whatever function is reporting to $wrap the width of the text is taking account that the text is being shrunk.

The shrinking effect can be more easily seen from these echoed lines:

//clear | var %i 3430 | while (%i isnum 255-3920) { if (%i !isnum 3555-3830) echo -ag 1234567890 $chr(%i) f %i $chr(%i) 1234567890 | inc %i }

Some characters seem more aggressive in shrinking nearby numeric text than others. I'm sure this shrinking text effect can be blamed on Windows itself's font linking, since I can see most of the issue when I paste those echoed lines into Notepad. However, it might be possible that mIRC is exerting a little control over that issue, because there are some lines which appear normal size in a mIRC @window, but Notepad shows them as shrunken. One such codepoint is the 3918, whose line appears normal in the @window text area, but is shrunken in Notepad, and also is shrunken when you paste that line into the mIRC editbox. It's also the purple line in the alias, which seems to consistently return 160% as much text as it 'should'.

/timerwraptest 999 1 wraptest 1
/timerwraptest 999 1 wraptest 0

Code
alias wraptest {
  if (@* !iswm $active) { echo -ag run this alias from a @custom window | return }
  window $active 0 0 $calc(1+$window($active).w) $window($active).h
  echo 6 -a $wrap($window($active).w $str(123 456 $chr(3918) big 789 $chr(3918) ,99) ,$window($active).font,$window($active).fontsize,$window($active).dw,$iif($1 == 1,1,0),1)
  echo 3 -a $wrap($window($active).w $str(123 456 text 789                      ,99) ,$window($active).font,$window($active).fontsize,$window($active).dw,$iif($1 == 1,1,0),1)
  echo 4 -a $wrap($window($active).w $str(123 456 $chr(3902) big 789 $chr(3902) ,99) ,$window($active).font,$window($active).fontsize,$window($active).dw,$iif($1 == 1,1,0),1)
  if ($window($active).w >= $window(-3).w) window $active 0 0 $calc($window($active).w //2) $window($active).h
}