Recent

Author Topic: [solved] Right-to-left reading direction under Windows XP  (Read 20763 times)

Ocye

  • Hero Member
  • *****
  • Posts: 518
    • Scrabble3D
[solved] Right-to-left reading direction under Windows XP
« on: December 31, 2013, 01:05:17 pm »
I struggle with RTL under Windows XP. My problem is similar to http://forum.lazarus.freepascal.org/index.php?topic=20722.0 and the related bug report http://bugs.freepascal.org/view.php?id=24340. So I updated via svn and run the submitted program (actually, I'm not able to read Arab letter).
Linux shows in both flavors Qt and Gtk2 the expected RTL output but Windows XP doesn't. Surprisingly the Windows app started from Linux via wine works as expected. And when I compile and run under W7 it works too. What can I do?

Lazarus 1.3 r43599M FPC 2.6.2 x86_64-linux-qt (@Windows fpc 2.6.2 and LCL from todays svn)
« Last Edit: January 04, 2014, 11:31:45 am by Ocye »
Lazarus 1.7 (SVN) FPC 3.0.0

Ocye

  • Hero Member
  • *****
  • Posts: 518
    • Scrabble3D
Re: Right-to-left reading direction under Windows XP
« Reply #1 on: January 02, 2014, 01:56:03 pm »
Can somebody confirm this issue?

Sample project is attached.
« Last Edit: January 03, 2014, 07:27:29 am by Ocye »
Lazarus 1.7 (SVN) FPC 3.0.0

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9791
  • Debugger - SynEdit - and more
    • wiki
Re: Right-to-left reading direction under Windows XP
« Reply #2 on: January 02, 2014, 02:01:32 pm »
Best is, if you attach a small (minimum) sample project to demonstrate the problem.

Then you have a better chance, that someone will test it.

Right now, I do not even know what component, or function you used for output.

Ocye

  • Hero Member
  • *****
  • Posts: 518
    • Scrabble3D
Re: Right-to-left reading direction under Windows XP
« Reply #3 on: January 02, 2014, 02:25:50 pm »
I use the same code as in the linked posts/bugreport but not only with Qt as originally reported but with Windows XP. It's a simple DrawText() on a TCanvas; in my program it's wrong for MessageDlg() too.
Lazarus 1.7 (SVN) FPC 3.0.0

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9791
  • Debugger - SynEdit - and more
    • wiki
Re: Right-to-left reading direction under Windows XP
« Reply #4 on: January 02, 2014, 03:01:10 pm »
It is still a lot of work, and a lot of extra to read...
copy and paste it together, find the correct units to use (assuming you use the same (drawtext from LclIntf?)

Most none RTL users will not bother, even though they could test.

--- anyway I did test, on win vista 32 bit. (with and without manifest)
Someone still needs to test xp

Code: [Select]
procedure TForm1.Button1Click(Sender: TObject);
var  s: String;
  R: TRect;
begin
  MessageDlg('% ,خطأ نسبي', '% ,خطأ نسبي', mtInformation, mbYesNo, 0);

s:='% ,خطأ نسبي';
r.Top := 40;
r.Left := 30;
r.Bottom := 88;
r.Right := 222;

  DrawText(Form1.Canvas.Handle, PChar(s), Length(s), R, DT_WORDBREAK);
end;

Note, the editor will display the messagedialog line in an unexpected way. The ', ' is between 2 RTL sections. The chars are have a weak leading, and will be taken an RTL too, meaning they read in the wrong direction.
However the first '% bound to the LTR text before so the % stays at the beginning.

Test results:
The words are displayed correct, but the % is at the left side not the end. I guess this is because my system is LTR.

For drawtext I can do:
Code: [Select]
  DrawText(Form1.Canvas.Handle, PChar(s), Length(s), R, DT_WORDBREAK + DT_RTLREADING);
And I get the correct words, and the % is on the right side
« Last Edit: January 02, 2014, 03:15:00 pm by Martin_fr »

Ocye

  • Hero Member
  • *****
  • Posts: 518
    • Scrabble3D
Re: Right-to-left reading direction under Windows XP
« Reply #5 on: January 02, 2014, 03:11:18 pm »
So the char خ is the left-most painted character on Vista? Actually I don't know what I want to achieve right now. If Vista is okay my users still have problems with their XP. And if someone confirms the issue I still don't know what to do. Perhaps a disclaimer that states a minimum requirement of Linux or W7... ;-)

It is still a lot of work, and a lot of extra to read...
Sorry and thank you. I'll add my code this evening (GMT+1).
Lazarus 1.7 (SVN) FPC 3.0.0

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9791
  • Debugger - SynEdit - and more
    • wiki
Re: Right-to-left reading direction under Windows XP
« Reply #6 on: January 02, 2014, 03:22:49 pm »
Try
    LCLIntf.ExtUTF8Out(Form1.Canvas.Handle, X, Y, fuOptions, @ARect, Text, Length, NIL)

(last param MUST be nil)

And if that works, then the rest needs to be reported as bug.

For more see unit SynTextDrawer


Ocye

  • Hero Member
  • *****
  • Posts: 518
    • Scrabble3D
Re: Right-to-left reading direction under Windows XP
« Reply #7 on: January 03, 2014, 07:26:02 am »
Whatever I do all output is LTR. Even a simple label whose bidiMode I set to RTL sticks to the original orientation.

(Sample project is attached now to the second posting)
« Last Edit: January 03, 2014, 07:27:52 am by Ocye »
Lazarus 1.7 (SVN) FPC 3.0.0

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: Right-to-left reading direction under Windows XP
« Reply #8 on: January 03, 2014, 08:20:07 am »
Whatever I do all output is LTR.
Most likely you tried that, just want to make sure. Pass ETO_RTLREADING = 128 in the options parameter of ExtTextOut.

If that does not work, try to call ExtTextOut directly from Windows unit, again using ETO_RTLREADING.

This is just a guess.  :-[

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9791
  • Debugger - SynEdit - and more
    • wiki
Re: Right-to-left reading direction under Windows XP
« Reply #9 on: January 03, 2014, 01:50:53 pm »
I have to dig out my old XP netbook for testing. this will be a while.

But for what I can see there a 2 problems.

1)
The "%" being on the right or left. The "%" is a weak char, so it sticks to the leading of it's neighbouring chars, or the global leading (would have to check the exact unicode doc for the correct expected behaviour....)

When you use DrawText or ExtTextOut or similar, then I would *guess* that this depends on the locale of the windows system. And I would guess, that it is your responsibility to specify  ETO_RTLREADING.

As for labels, and other controls: If there bidi is RTL, then maybe they need to specify ETO_RTLREADING. That may or may not be a bug. I am not an expert on this.


2) The arabic words/sentence (including the space in the middle, that is surrounded by RTL on both sides, and must therefore be RTL itself too)

I do not actually know/read/speak Arab, so I can only judge from the overall appearance. The actual glyphs do not mean anything to me.

It does look as if the text is spelled out letter by letter. Arab is a script language, the letters should be connected. I do not know what breaks them up.

------

- I guess you have tested this text in Microsoft notepad! Does it work there?
- Does it display ok in the IDE (SynEdit) if you run the IDE on XP ?

If it does fail in notepad, then there may be a windows update that is needed for this to work.

If it works in notepad, then this looks like a bug that needs to be reported (with sample app, and all)


If it works in SynEdit, then ExtTextOut should work.


Ocye

  • Hero Member
  • *****
  • Posts: 518
    • Scrabble3D
Re: Right-to-left reading direction under Windows XP
« Reply #10 on: January 03, 2014, 02:14:48 pm »
I have no idea about Arab or Hebrew as well (still in hope for a native speaker; Edit: just PM'd Yurii). Currently I'm on W7, and when I copy خطأ نسبي into notepad or wordpad the left-most u-like letter with two dots below is still on the left side. Its the same as in the browser and in the first three pictures. Furthermore, the cursor goes from right to left within the word when I press cursor right key.
In my examples only the fourth picture which was made with XP is inverted, e.g. the dotted u is on the right. Now I'm completely confused. Could it be that XP flips the correct RTL back to LTR?
« Last Edit: January 03, 2014, 02:18:30 pm by Ocye »
Lazarus 1.7 (SVN) FPC 3.0.0

zariq

  • Full Member
  • ***
  • Posts: 109
Re: Right-to-left reading direction under Windows XP
« Reply #11 on: January 03, 2014, 02:39:43 pm »
Arab is a script language, the letters should be connected.

Depends on the letter and the letters on iether side if any. Some connect some dont. Sorry if you meant something different.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9791
  • Debugger - SynEdit - and more
    • wiki
Re: Right-to-left reading direction under Windows XP
« Reply #12 on: January 03, 2014, 02:50:48 pm »
I just tested, on my XP, in a notepad the "%" is on the left side. I do have an UK locale, so my locale is LTR. Not sure if that makes a difference.

That may be altered by inserting an RTL marker (a special invisible char).

The unicode specs for this are very long and I do not plan to read them. But this is what is implemented in windows anyhow. Not in FPC/Lazarus.

As I said for controls with bidi-mode=rtl, it may be a bug. Maybe they should specify ETO_RTLLeading.

-------------
As for the individual letters versus full words (which may also affect the RTL/LTR of the word): SynEdit on XP does display the words correct.

In the one (win.png) picture that you posted, something is breaking up the words into chars. (or codepoints). That is wrong.

But I can not reproduce. I jusst tested on my XP (home edition)/ latest lazarus trunk 1.3, fpc 2.6.0
- The code I posted works correct ("%" on the left, but I do not know if that is correct or not)
 That is both captions in the dialog, and drawtext work.

I also pasted the text in a labels caption. Works correct too.
And if I set the labels bidi to RTL, then the "%" goes to the right as it should.

------------------
So the point is, I do not know what is different in your code. You never posted an example.

It works fine with my code.


Or maybe you use some other font?
Those thinks can go wrong, if the font does not support them...

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9791
  • Debugger - SynEdit - and more
    • wiki
Re: Right-to-left reading direction under Windows XP
« Reply #13 on: January 03, 2014, 02:55:10 pm »
Arab is a script language, the letters should be connected.

Depends on the letter and the letters on iether side if any. Some connect some dont. Sorry if you meant something different.
Well yes, I was not very exact. As I pointed out my knowledge is from observation, rather than from knowledge.

And well, I did not know, though I could have guessed. But thanks for pointing it out.

What I tried to point out was the difference in his last picture. The effect that happens if you print each letter on its own, rather than printing whole words or sentences.



Ocye

  • Hero Member
  • *****
  • Posts: 518
    • Scrabble3D
Re: Right-to-left reading direction under Windows XP
« Reply #14 on: January 03, 2014, 03:02:51 pm »
So the point is, I do not know what is different in your code. You never posted an example.

It works fine with my code.

Or maybe you use some other font?
Those thinks can go wrong, if the font does not support them...

Code is attached to the second posting. Font was default (Sans?) and is now Tahoma. I don't care too much if the % is on the left or right, but if one system flips the text and the others not somethings apparently goes wrong. I'm running XP in a virtualbox but double-checked it once with an old notebook.
FPC is 2.6.2 with LCL from svn.
Lazarus 1.7 (SVN) FPC 3.0.0

 

TinyPortal © 2005-2018