To do this manually requires knowledge of the absolute position of the box and the use of font metrics.
To get the process that works for you, I suggest you get some graph paper and play around using the information below.
You need to know the absolute height of the font for a given "font size". For example, a font presented at 72 points is NOT necessarily 1" in height. The metrics for the font are complicated and I am no expert. I use a fixed pitch font to make my life easier. Both the height and width are easily measured. Print out capital letters and a few lower case with descenders (g,q,p,...) and see what works as far as scalings and line-to-line spacing.
Use the libHaru call
width = HPDF_Page_TextWidth (page,p); // in default measurement units (points)
Once you have this, you can "estimate" where the text break should be, then go backward or forward in your original string and use the width returned value to "fit" the text in. Then, break the string, go to the next line in the box and repeat.
If you have a fixed size box, then you might have to change the font size to get it all to fix.
The easiest problem would be one where the text can be folded again and again without a limit (i.e. an open-bottomed box). Once the entire row of text segments can be placed, then draw the boxes accordingly and fit the text in. If it won't fit on the page, then you'd generate a new page (in the simplest of cases) and place the boxes and text there.
I've never used foreign multi-byte fonts (i.e. Chinese, Korean,...), so I am of no help there
I only place text in absolute terms (to produce plots and graphs), or to display consecutive lines of text on a page. I don't use TextRect