Jump to content
John Kouraklis

Right To Left Components

Recommended Posts

Does anyone have experience with RTL languages in Delphi FMX?

 

I've seen FMXRTL.com but I am unable to download any of the demos and code from that website

Share this post


Link to post

try this from github

https://github.com/Zeus64/alcinoe

I don't test it

this app https://play.google.com/store/apps/details?id=club.kiskis.app&hl=en was made with it

Share this post


Link to post
6 hours ago, limelect said:

@John Kouraklis  Sorry It was long ago. I do not know where the demo is.

I think i had a BPL specific to Delphi.

 

No worries. I emailed the owner of the page and the download links work. 

 

Thanks anyway

Share this post


Link to post

Hi,

I don't write nor read RTL languages, I wrote a function to detect if the text starts with a RTL char

function checkRtl (S : string; Exceptions : String = '' ) : TTextAlign;
var carray : array of WideChar;
    i : int64;
    ws : String;
begin
   for I := 0 to 9 do
      S:=StringReplace(S,i.ToString,'',[rfReplaceAll]);
  // supprime autres caractères spéciaux
    S:=StringReplace(S,'(','',[rfReplaceAll]);
    S:=StringReplace(S,')','',[rfReplaceAll]);
    S:=StringReplace(S,'"','',[rfReplaceAll]);
    S:=StringReplace(S,'''','',[rfReplaceAll]);
    S:=StringReplace(S,'-','',[rfReplaceAll]);
   if not E.IsEmpty then
     begin
        for I := 1 to Length(Exceptions) do
                S:=StringReplace(S,Exceptions[i],'',[rfReplaceAll]);
     end;

   S:=Trim(S);
   // arabic + hebrew
   SetLength(carray,$6ff-$590);
   for I := $590 to $6ff do carray[i-$590]:=Char(I);
   // there are some farsi char to be added 
   
   result:=TTextAlign.Trailing;
   if S.IsEmpty then exit;
   if inOpArray(S[1],carray) then result:=TTextAlign.Leading;
end;

And, with Nabil's Help I test my ideas in a grid.

 

You can find (french) discussion here and my tutorial  https://serge-girard.developpez.com/tutoriels/Delphi/Livebindings/Grilles/#LVII-C-1 

I did not test for TEdit and TLabel though but my guess it is possible

TextLayoutFull.PNG

  • Like 1
  • Thanks 1

Share this post


Link to post

@Serge_G This is for WIN project or IOS (not tested) BUT not for Android.

No solution yet. No TStringColumn in Android.

Share this post


Link to post

@John Kouraklis For now RTL is working in Android Studio where i

developed a few applications.

 

Delphi FMX Android is good , now a days , only for English.

Share this post


Link to post

Oh, it seem that was the TTextLayout.RighttoLeft who do the trick but did not work for Android 😣  and I do not know if it works for those Apple things

My friend Nabil just send me an intyeresting link
 

 

  • Like 1

Share this post


Link to post

FMX use different methods for text rendering on mobile and desktop platforms. On desktop platforms native OS methods are used (f.e. Direct2D text layout or CGContext) but on mobile platforms text is rendered as bitmap combination - each font symbol is stored in cache as bitmap.

This leads to no RTL support, bad kerning, etc and also is slow., This is why I had to write native canvas support for these platforms.

  • Sad 1

Share this post


Link to post
41 minutes ago, John Kouraklis said:

@Alexander Sviridenkov So, you don't use bitmaps on those platforms? but the native engines?

 

Do your components support then RTL?

Depends on selected canvas,  For iOS, Android and OSX there are both native and FMX canvases.

RTL is supported internally, library has own BIDI processor because even on native canvases each word is rendered separately, so layout should be prepared before passing to renderer.

Share this post


Link to post

@John Kouraklis It works.

I used this link

 

http://arabteam2000-forum.com/applications/core/interface/file/attachment.php?id=159065

1. with Delphi 10.2.3 i used the berlin version

2. My test project is fmx+memo

3. I added THE 3 pas files

4. i added FMX.Canvas.GPU.pas from the Delphi fmx source

5. I added path of Delphi source fmx to my project

6. compiled

7. apk to my samsung s6 phone

8. DID NOT CHANGE NOTHING IN THE SOURCE !!!!

9. AND IT WORKS !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

10-. in my case it is HEBREW !!

 

P.S 4 not needed as you have 5

Edited by limelect
  • Like 1

Share this post


Link to post

@Serge_G Thank you for your help

The link in your answer did the TRICK.

I had many weeks of search for the answer

 

Share this post


Link to post

Last thought. 

It is still not perfect solution.

As it is not a REAL BIDI. it is specific to Arabic or Hebrew but other 

languages do not apply. So it cannot be given to the world.

Share this post


Link to post

Further investigating it seem that my last statement (not real BIDI) mite

be wrong since

 

    if Char > 3000 then
      if ((Char = 3633) or ((Char >= 3635) and (Char <= 3642)) or
        ((Char >= 3655) and (Char <= 3662))) then
      begin
        if LastThaiChar = 0 then
          LastThaiChar := 3585;
        // DoLogInfo(format('Detected new advance from %d + %d',[ FLastThaiChar,char]));
        // Advance := FPaint.measureText(StringToJString(System.Char.ConvertFromUtf32(3585)+System.Char.ConvertFromUtf32(Char)));

        if Char = 3635 then // ׂ

          Advance := FPaint.measureText
            (StringToJString(System.Char.ConvertFromUtf32(LastThaiChar) +
            System.Char.ConvertFromUtf32(Char))) -
            FPaint.measureText
            (StringToJString(System.Char.ConvertFromUtf32(LastThaiChar)))
        else

          Advance := 0;

      end;

    if Char >= 3585 then
      if Char <= 3630 then
        LastThaiChar := Char;
 

since above section has nothing to do with MY !!! Hebrew fonts.

is it useless ???? i do not know.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×