How to measure the height of a styledtext ?

hi Group,
in order to print it using a styledtextprinter, how do you calculate the total height of a styledtext ?

the only way I have been able to do it (for gPDF as an example) was to examine each style run checking the the font and textsize of each one, and summing up the max values on each line