Bug in GDI+ DrawString

  • Thread starter Thread starter Brian Smith
  • Start date Start date
B

Brian Smith

Try this in a winforms project:
1. add checkbox to form
2. set Text = "abc (def)"
3. set RightToLeft to Yes

On my PC it displays as "(abc (def" - and seems to do this for any type of
punctuation and any text. Bizarre!

A colleague reports the same problem using Graphics.DrawString(), so it
looks like a GDI bug.

This is .Net 1.1 SP1 on WinXP Pro SP2

brian smith
 
Try this in a winforms project:
1. add checkbox to form
2. set Text = "abc (def)"
3. set RightToLeft to Yes

On my PC it displays as "(abc (def" - and seems to do this for any type of
punctuation and any text. Bizarre!

A colleague reports the same problem using Graphics.DrawString(), so it
looks like a GDI bug.

I think that this is not a bug but the expected behavior. This is because
RightToLeft=true applies to arabic texts where the default punctuation is
differerent.

Wiktor Zychla
 
No, RightToLeft is badly named - it just means that the text is drawn to the
left of the checkbox instead of to the right. The text still reads
left-to-right but must be right justified, which is where the problem comes
in.

brian
 
No, RightToLeft is badly named - it just means that the text is drawn to
the
left of the checkbox instead of to the right. The text still reads
left-to-right but must be right justified, which is where the problem
comes
in.

That this is not true.

MSDN:

"... class has a key property for Arabic support: the RightToLeft property,
which specifies whether the text is displayed from right to left, such as
when using Arabic fonts ..."

If you wish to have the text and checkbox aligned in your own style, you
should use TextAlign and CheckAlign properties. Avoid using RightToLeft to
align your controls in non-Arabic interface.

Wiktor Zychla
 
I'm sorry Wiktor - you are absolutely correct.
Me, and I suspect thousands of other developers, have been using RightToLeft
for over 2 years without ever spotting the CheckAlign property, since
without the punctuation it achieves exactly the desired result.

What I don't understand is why the text does not print backwards if
RightToLeft is chosen - it seems a redundant property, since if indeed you
have arabic text you'd expect it the right way round in every control,
wouldn't you?

brian
 
What I don't understand is why the text does not print backwards if
RightToLeft is chosen - it seems a redundant property, since if indeed you
have arabic text you'd expect it the right way round in every control,
wouldn't you?

I am also not an expert on arabic interfaces so I share your doubts. I'd
just stepped into that problem two years ago and someone has explained in to
me.

you can check the thread:
http://tinyurl.com/6u2dv

Regards,
Wiktor Zychla
 
Back
Top