Nobody knows what you mean by factoring.

Here's a simple example of how you might do it:
Code:
; Setup variables

var %text = THIS IS THE TEXT TO BE DISPLAYED
var %fontname = FONT NAME HERE
var %fontsize = FONT SIZE HERE
var %width = THIS IS THE WIDTH THE TEXT NEEDS TO FIT IN
var %window = THE PICWIN YOU WANT TO DRAW ON
var %color = A $RGB() VALUE OF THE TEXT COLOUR

; End of setup variables

var %lines = $wrap(%text, %fontname, %fontsize, %width, 0)
var %height = $height(%text, %fontname, %fontsize)
var %i = 1
while %i <= %lines {
  drawtext -r %window %color $qt(%fontname) %fontsize 0 $calc(%height * (%i -1)) $wrap(%text, %fontname, %fontsize, %width, %i)
  inc %i
}


Spelling mistakes, grammatical errors, and stupid comments are intentional.