**********DrawString is not drawing the text at Point(0,0)**********

  • Thread starter Thread starter Ponnurangam
  • Start date Start date
P

Ponnurangam

Hi,

I am trying to draw text on a bitmap at (0,0)

But Graphics.DrawString("the brown fox",drawFont,drawBrush,drawPoint) is not
writing exactly at (0,0)

drawFont: Font("Arial", 9, Style, GraphicsUnit.Point)


drawPoint: (0,0)

There is space at left and at the Top.

For some fonts the space at the Top is more.

The spacing at the Top is not even for all the fonts.

I don't want the space at the top. If there is space at the top, it should
be even for all the fonts

Any help would be appreciated

Thanks

Ponnurangam
 
The positioning of the font is made according to the height of the EM square
defined by the font. Some fonts have glyphs that sit on different base-lines
and extend upwards to different heights within the EM square. In order to
position letters so that the top of the letter exactly touches a specific
picel would require individual analysis of the font tables and adjustment of
the output position on a character by character basis. This isn't possible
with the standard methods available to GDI+ and certainly not available to
DrawString.

I have written the code that does the font table analysis to extract such
information from a TTF file but it's a whole lot of work and I'm sorry but I
don't give that away for free.

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

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

The GDI+ FAQ RSS feed: http://www.bobpowell.net/faqfeed.xml
Windows Forms Tips and Tricks RSS: http://www.bobpowell.net/tipstricks.xml
Bob's Blog: http://bobpowelldotnet.blogspot.com/atom.xml
 
Hi Bob,

Can you tell me about the font table analysis to extract information from a
TTF file.

Thanks

Ponnurangam
 
Back
Top