murarinayak / alivepdf

Automatically exported from code.google.com/p/alivepdf
0 stars 0 forks source link

AlivePDF embedded font line height isn't treated the same for all embedded fonts #330

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Use the funtion myPDF.writeText(lineHeight, theText); with an embedded font.
2. Tried font size a line height and also tried to calculate line height 
constant to match a given font e.g for Arial var lineHeight = theSize * 4.305 
seems to work
3. Same calculation does not work for different fonts so spacing appears 
differently on different fonts when outputted on pdf than it was in Flash.

What is the expected output? What do you see instead?
Expect identical spacing for identical font size also tried calculating a 
constant

What version of the product are you using? On what operating system?
0.1.5 RC, OSX apache

Please provide any additional information below.

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);

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 

Original issue reported on code.google.com by joe.prit...@gmail.com on 27 Aug 2011 at 3:29