Jump to content
John Kouraklis

Right To Left Components

Recommended Posts

What about using TTextService ?

I just had a (deep) look into Delphi source and found TTextServiceAndroid.DrawSingleLine

      {$IFDEF ANDROID}
      if SupportsPlatformService(IFMXTextService,aService) then
        begin
          alignement:=CheckRtl(Value.ToString,'');
          if alignement=TTextAlign.Trailing
             then flag := [TFillTextFlag.RightToLeft]
             else flag:=[];
// had to get font
          aService.DrawSingleLine(Canvas,Value.ToString,Bounds,Afont,
                                  1,flag, alignement);
        end;
      {$ENDIF}

My only problem is to get the right font though (the one in the style i presume).

 

I don't go further with this for now.. 

Share this post


Link to post
Guest

Those files/patches looks promising, but they are useless for someone with Delphi Professional or Community, like me !, unless there is a way to patch the dcu files themselves .

For Arabic support only Delphi HTML components helped me, yet this forced me to use HTML for most of the UI

 

 

On 11/2/2019 at 4:08 AM, Alexander Sviridenkov said:

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.

Would you please post a detailed instructions with a sample code for rendering right-to-left languages on Android and iOS ? this might help many.

and please the difference/comparison between available canvases with your components each platform, i am using them for two years and still don't have full details about the real differences ( quality and anti-aliasing, rendering speed, font types ....)

I remember trying to benchmark and find if there is performance increase/decrease based on the font used ( ttf or otf ) in rendering huge page, i can't recall the result now 😞

Share this post


Link to post

OK, several samples. FMX form with HtPanel on left and standard memo on right.

Windows, standard FMX canvas:

2136995520_2019-11-0414_50_39.thumb.png.9a4d6705de141f7fbc395f7f0051281a.png

 

Here kerning pairs are correct on both sides and arabic letters are connected as it should and have correct order because FMX canvas use windows Direct2D layout for rendering. But word order in sentense with mixed english/arabic text is incorrect on right side and correct on left, because in HtPanel text is prepared by internal BiDi processor.

 

Android, standard FMX canvas:

Screenshot_20191104_150411_com.embarcadero.AndroidScroll.thumb.jpg.c58f2f07690d128b682c1498c66bab0e.jpg

 

On mobile platforms FMX output each letter as single bitmap. So kerning pairs are not processed and arabic letters are not connected. Word and letter order is correct on left side because of internal BiDi processor, but still no kerning and letter connectors.

 

Android, native Android canvas:

Screenshot_20191104_150544_com.embarcadero.AndroidScroll.thumb.jpg.6bfbdaf28487eb88dce6e7aa51da9ecd.jpg

 

Kerning and letter connectors are correct.

 

There is also another issue with FMX canvas ion mobiles. Here is the same form with scaling set to 10x for both components.

Screenshot_20191104_151119_com.embarcadero.AndroidScroll.thumb.jpg.7934c76a1ac1825ade4461a56ae762c2.jpg

 

FMX use bitmap scaling instead of preparing bitmaps for each font size. This leads to visual artefacts and blurred text.

 

 

 

  • Sad 1

Share this post


Link to post

@Alexander SviridenkovI cannot comment on what you wrote since Arabic

is not my native lang.

But in my case i used the source i shown before and it works

even for mixing Hebrew and English.

Can you elaborate on the problem in your case

showing very simple text here.

I using memo and 10.2.3

 

Edited by limelect

Share this post


Link to post

@limelect try to display the following text in Android

 

Student: How do you write "What's your name?" in Arabic?

Teacher: ما اسمك؟

Student: Thanks.

Teacher: That's written "شكرًا".

Teacher: Do you know how to write "Please"?

Student: "من فضلك", right?

Share this post


Link to post

@Alexander SviridenkovI do not have Arabic on my keyboard

And i do not know the Alpha.

How ever in Hebrew i can mix with English with no problem

Have a look at the top right corner on the memo

I have   abcdeשלמהfgh

"שלמה" is my name in Hebrew

The mix is OK!!!

 

device-2019-11-07-180506.png

Share this post


Link to post
14 hours ago, limelect said:

@Alexander Sviridenkov  Then is this guy wrong ?

https://serge-girard.developpez.com/tutoriels/Delphi/Livebindings/Grilles/#LVII-C-1

Yes, I only check for windows  not for other platforms. I think Interface IFMXTextService and DrawSingleLine is a track to follow, but I am blocked with this Font argument (needed to be retrieve in style ?) 

 

 

  • Like 1

Share this post


Link to post

@Maher Tannous For Hebrew I am using the above solution. It works great. changing those 3 files FMX.TextLayout.GPU,

FMX.FontGlyphs and FMX.FontGlyphs.Android.

Since i do not know Arabic i cannot check for it.

What i will do in the future add Arabic K.B and see the connection of characters. 

May be some one around me will help with this.

Further on my project see a new problem

 

Edited by limelect

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

×