Line to Line height?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Just as Font.Height property gets the line spacing, in pixels, of the given
font, how to calculate the same when we have an image instead of a text
between two lines.
i.e if we insert an image in any document one after another in consecutive
lines there is some space between two images. How to get that value ?

---------------------------------------- line 1
(^o^)/ my image
---------------------------------------- line 2

please guide
 
Document layout is far more complex. The font height is not really the line
to line height. That should be a function of the paragraph as defined by
your document and is called "leading". Leading is the height between
baselines. Remember also that some fonts have larger ascenders than others.
For an example of this output Times New Roman and Verdana next to one
another. You'll see that the baselines are different so, to correctly
position text, you should start at the baseline position and then go up by
the font's ascent value to obtain the Y position of the font. For your image
positioning you need to calculate the effective baseline of the image taking
into account the image height and the current paragraph leading. The text
that follows will then sit on the next logical baseline.

Unfortunately this isn't something that can be explained with a few code
snippets...

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 
Back
Top