Recent

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

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9791
  • Debugger - SynEdit - and more
    • wiki
Re: Right-to-left reading direction under Windows XP
« Reply #15 on: January 03, 2014, 03:27:48 pm »
Sorry, I missed that. I tested that now.

It works fine on my XP.

Except: If I switch the label's font to "times new roman" then lazarus on xp hangs. while it works on vista.

So it seems there is some code going wrong.

I'd say it is worth a bug report. Though with no guaranteed method to  reproduce, it will be hard to track.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9791
  • Debugger - SynEdit - and more
    • wiki
Re: Right-to-left reading direction under Windows XP
« Reply #16 on: January 03, 2014, 03:34:52 pm »
OK single stepping, shows that the string is converted to utf16, and handed to the windows API...

try this.

uses windows;

var
  w: WideString;

    W := UTF8ToUTF16(yourtext);
    Result := Windows.ExtTextOutW(form.canvas.handle, X, Y, Options, LPRECT(Rect), PWideChar(W), Length(W), Dx);


Or the same with DrawText.

If that screws up, then it points to an issue in XP. Though something must be triggering it, because my XP does better.


----------
Maybe I did install the support at some time (I do not remember)
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/int_pr_install_complex_languages.mspx?mfr=true

-- EDIT: I just checked: I have them installed
« Last Edit: January 03, 2014, 03:42:15 pm by Martin_fr »

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: Right-to-left reading direction under Windows XP
« Reply #17 on: January 03, 2014, 04:14:31 pm »
Control Panel
   - Regional and Language Options
      - Languages tab
         - Install files for complex script and right-to-left languages

Make sure to put a check mark next to that option.
« Last Edit: January 03, 2014, 07:16:18 pm by engkin »

Ocye

  • Hero Member
  • *****
  • Posts: 518
    • Scrabble3D
Re: Right-to-left reading direction under Windows XP
« Reply #18 on: January 03, 2014, 07:50:49 pm »
Quote
Pass ETO_RTLREADING = 128 in the options parameter of ExtTextOut.
Nothing changes with 128.
Plus I completely removed Lazarus and built it new. Same result.

Quote
try...ExtTextOutW
ExtTextOutW does not paint successfully (-1), either with i:=0 or nil as parameter 7, with or without ETO_RTLREADING. How should I use DrawText() with widestring?

Code: [Select]
uses ...lclintf, lcltype, lclproc, windows;
var
  s: string;
  w: WideString;
  R: TRect;
  ts:TTextStyle;
  i:integer;
begin
  s := '% ,خطأ نسبي';
  W := UTF8ToUTF16(s);
  R := Bounds(10, 10, 200, 40);
  i:=0;
  Caption:=BoolToStr(Windows.ExtTextOutW(form1.canvas.handle, 1, 1,  ETO_RTLREADING, @r, PWideChar(W), Length(W), @i));

Quote
...files for complex script and right-to-left languages
This feature requires the original CD which I don't find anymore.
Lazarus 1.7 (SVN) FPC 3.0.0

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: Right-to-left reading direction under Windows XP
« Reply #19 on: January 03, 2014, 08:28:54 pm »
Quote
...files for complex script and right-to-left languages
This feature requires the original CD which I don't find anymore.
I am sure that is the real problem.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9791
  • Debugger - SynEdit - and more
    • wiki
Re: Right-to-left reading direction under Windows XP
« Reply #20 on: January 03, 2014, 08:43:05 pm »
Well without that feature it will not work. (that is to the best of my knowledge)

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: Right-to-left reading direction under Windows XP
« Reply #21 on: January 03, 2014, 09:07:00 pm »
I agree with Martin.

Quote
ExtTextOutW does not paint successfully (-1), either with i:=0 or nil as parameter 7, with or without ETO_RTLREADING.
If you are not using clipping ETO_CLIPPED you don't need the fifth parameter, pass nil for it. If you leave the spacing between letters to default values then also pass nil for the last parameter. Provide the address of the first letter in your WideString variable @w[1],
Code: [Select]
procedure TForm1.Button1Click(Sender: TObject);
var
  s: String;
  w: WideString;
begin
  s := 'ABCDEF % ,خطأ نسبي';
  w := UTF8ToUTF16(s);
  Windows.ExtTextOutW(Canvas.Handle {dc}, 1 {x}, 1 {y}, 0{ETO_RTLREADING} {options}, nil {pRect}, @w[1] {pWideChar}, Length(w) {count}, nil {lpDx});
end;

Edit:
Are you aware of/familiar with Uniscribe?
« Last Edit: January 03, 2014, 09:16:20 pm by engkin »

Ocye

  • Hero Member
  • *****
  • Posts: 518
    • Scrabble3D
Re: Right-to-left reading direction under Windows XP
« Reply #22 on: January 04, 2014, 11:31:34 am »
I am sure that is the real problem.
And you are right. With this feature all letters are nicely connected.

Are you aware of/familiar with Uniscribe?
Now I am. I love my Linux :-)

Many thanks to you both. Not only my problem is solved but as well I read Arab a little bit better.
Lazarus 1.7 (SVN) FPC 3.0.0

 

TinyPortal © 2005-2018