المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : How do I get the correct font height in Hindi fonts?



C# Programming
07-29-2009, 12:10 PM
Hi, I want to draw a Hindi text with a bounding box around. Sample text "??? ?????? ???? ??? ???? ????".
The problem is the last character with dependent vowel sign, the method misses the bottom part of the text.
0x0939, 0x0942, 0x0901 (devanagari letter ha, vowel sign uu, sign candrabindu)

C# code sample

string text = "??? ?????? ???? ??? ???? ????";
Font font = new Font("Tahoma", 20.0f, FontStyle.Regular);
SizeF layoutArea = new SizeF(1000, 1000);
StringFormat stringFormat = new StringFormat();
SizeF measure = g.MeasureString(text, font, layoutArea, stringFormat);
g.DrawRectangle(Pens.Red, new Rectangle(50, 50, (int)measure.Width, (int)measure.Height));
g.DrawString(text, font, Brushes.Black, 50, 50);

I have also tried C++ functions GetTextExtentPoint32(), GetTextMetrics() and GetOutlineTextMetrics() to get the correct height but failed.

Any suggestions?
Thanks in advance,
Gywox