Click here to Skip to main content
15,905,915 members
Please Sign up or sign in to vote.
4.00/5 (3 votes)
Hello Experts.

I have a small form based application. which displays unicode chars, this program works fine on windows 7. but fails on windows XP.

for testing i have created a simple program,

this program has a unicode text,

In the On Paint event the text is displayed properly.
(On Win 7 = displayed Properly, On XP = Displayed Properly)

but if the same string displayed on a Button's caption it's characters are displayed as blank rectangles.
(On Win 7 = displayed Properly, On XP = blank rectangles).

in windows 7 there is no problem, but if i run this program under windows XP, then
on button's caption string is displayed as blank rectangles.

am i missing something.

pl. suggest.

-prateek.


here is the code.

C#
public partial class TestForm : Form
   {
       string m_strText;
       public TestForm()
       {
           InitializeComponent();
       }


       private void TestForm_Paint(object sender, PaintEventArgs e)
       {
           Graphics g = e.Graphics;
           g.DrawString ( m_strText, 
                          new Font ( this.Font.FontFamily, 20 ), 
                          new SolidBrush ( Color.Blue), 
                          10, 10 ) ;
       }


       private void TestForm_Load(object sender, EventArgs e)
       {
           char [] szBuf = new char [] { (char)0x915, (char)0x916, 
                                           (char)0x917, (char)0x918 } ;
           int nCnt = szBuf .Length;
           for (int nC = 0; nC < szBuf.Length; nC++)
                 m_strText  += szBuf[nC];
       }

       private void btnGet_Click(object sender, EventArgs e)
       {
           btnGet.Text = m_strText;
           this.Text = m_strText;
       }
   }
Posted

1 solution

Is the exact font specified in your forms Font property installed on both computers?
If you open Character Map in Accessories->System Tools->Character Map and open the same font on both machines, are all of the characters that you are using present in both?

My guess is that the Visual Studio Designer is using a default font (maybe Segoe UI) which renders fine on Windows 7, but the font is not present on XP, so something else like MS Sans Serif is being substituted at run-time. The substituted font doesn't have all of the same unicode characters that the original did.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 23-May-11 12:42pm    
It could be a problem, my 5. However, the problem is strange: there is not non-unicode texts in .NET. Maybe the subset of the Unicode code point is a bit exotic, but then only "Arial Unicode MS" would help (on XP).
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900