AlivePDF embedded font writeText calc. line height to match flash issue

I’m using alivepdf’s function writeText with embedded fonts but I’m having real trouble trying to get it to match the line height (or spacing between lines) proportionately from the view port in flash to the final pdf.

So when I use

myPDF.writeText(lineHeight, theText);

I’m not sure how to calculate lineHeight based on the size of the original font and then the size it will be outputted at. I think the issue might be that there is spacing / leading around the top and bottom of the text that is treated different in each font and is treated differently in Flash to Alive PDF.

The user has an interface they draw a design on and then I translate this viewport to a pdf. I have the original font size in flash and then I am enlarging this font size by the factor that the final pdf is larger the original viewport when I set the font and this works for the font size on a single line for instance:

var newFontSize=enlargeFactor*theSize
myPDF.setFont(myEmbeddedFont, newFontSize);

I tried using the set font size as the lineheight but this is way too small. If I use a line height proportional to the font size I can get it pretty much right for a given font by calculating a constant. I.e for Arial var lineHeight = theSize * 4.305 seems to work. However this is a different constant for each font so I need to try and work out the formula.

Can anyone help with this? Perhaps I can get information from the font somehow or the EmbeddedFont object? To determine this total line height for each font before writing?

Thanks so much,
Joe