Recent

Author Topic: Arabic text, problem on Linux  (Read 2389 times)

marius.maximus

  • New Member
  • *
  • Posts: 35
Arabic text, problem on Linux
« on: April 16, 2024, 10:04:39 am »
On Linux I have wrong arabic text
picture: https://i.imgur.com/Yb4lXsw.png

Correct version (from Windows)
picture: https://i.imgur.com/NlgJGMj.png

I have correct font
And font has correct chars, but Lazarus app on Linux uses only main form of char

for example char `seen-arab` has 4 forms:
seen-arab
seen-arab.fina
seen-arab.init
seen-arab.medi
https://i.imgur.com/1jtNnRQ.png

but my app use only `seen-arab`


AlexTP

  • Hero Member
  • *****
  • Posts: 2414
    • UVviewsoft
Re: Arabic text, problem on Linux
« Reply #1 on: April 16, 2024, 10:25:48 am »
Post the code snippet which renders the text. It can be different functions: TCanvas.TextOut, DrawText, ExtTextOut etc.

Thaddy

  • Hero Member
  • *****
  • Posts: 14585
  • Sensorship about opinions does not belong here.
Re: Arabic text, problem on Linux
« Reply #2 on: April 16, 2024, 10:33:18 am »
I suspect it is merely a font issue.
bitrate is always calculated like this:sample rate * bitdepth * number of channels.

marius.maximus

  • New Member
  • *
  • Posts: 35
Re: Arabic text, problem on Linux
« Reply #3 on: April 16, 2024, 10:50:09 am »
I take font from this web page https://arbfonts.com/the-sans-plain-3-font-download.html?preview=%D8%B3%D8%B7%D9%88%D8%B9+1
I am 100% sure this font is used on my Linux after delete .ttf I have squares instead of letters ;)

I open this font in online editor, in my opinion is OK
I use this font in Qt application on Windows and is OK

In Arabic, the appearance of a letter depends on its position , the character at the beginning, middle and end of the word looks different.
In my APP on Linux the Arabic  letter is always the same regardless of position

wp

  • Hero Member
  • *****
  • Posts: 11997
Re: Arabic text, problem on Linux
« Reply #4 on: April 16, 2024, 11:11:54 am »
How is that text drawn? Is it the Caption of a TLabel or TStaticText? Or is it drawn by Canvas.TextOut/.TextRect? In the latter case, is the text drawn as one string, or character by character?

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9986
  • Debugger - SynEdit - and more
    • wiki
Re: Arabic text, problem on Linux
« Reply #5 on: April 16, 2024, 12:17:41 pm »
I guess that happens in SynEdit.

SynEdit uses the "lpDx" width feature EtxTextOut  https://learn.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-exttextouta
On Linux that is emulated (IIRC) by the LCL WS code, which prints the code one char at a time. => which does not work for script languages.

However, without this, many fonts wont be correctly monospaced (at least in my testing, long ago). And that would mean, if you start selecting, and extend the selection letter by letter, then the text on the line starts jumping around... (at least latin based text would...)




To test
components\synedit\syntextdrawer.pp

Code: Pascal  [Select][+][-]
  1. procedure TheTextDrawer.NewTextOut(X, Y: Integer; fuOptions: UINT;
  2.   const ARect: TRect; Text: PChar; ALength: Integer; AnEto: TEtoBuffer);
  3. var
  4.   EtoArray: PInteger;
  5.   {$IFDEF WINDOWS_LIGATURE}
  6.   W: WideString;
  7.   Glyphs: array of WideChar;
  8.   CharPlaceInfo: GCP_RESULTSW;
  9.   {$ENDIF}
  10. begin
  11.   if AnEto <> nil then
  12.     EtoArray := AnEto.Eto
  13.   else
  14.     EtoArray := nil;
  15.  

Remove the if condition and just keep "EtoArray := nil;"

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9986
  • Debugger - SynEdit - and more
    • wiki
Re: Arabic text, problem on Linux
« Reply #6 on: April 16, 2024, 12:23:45 pm »
I just checked, and SynEdit only does that if you
- have extra char spacing in the options (which means spaces must be printed between chars....)
- SynEdit detected that there are chars with different width (even in a monospaced font).

For testing, put this in the editor (after making the change from my last post)
Code: Text  [Select][+][-]
  1. MW@XmTi:'Q-MW@XmTi:'Q-
Then set the cursor at the start of line, and select the text, one char at a time.

marius.maximus

  • New Member
  • *
  • Posts: 35
Re: Arabic text, problem on Linux
« Reply #7 on: April 16, 2024, 12:59:47 pm »
How is that text drawn? Is it the Caption of a TLabel or TStaticText? Or is it drawn by Canvas.TextOut/.TextRect? In the latter case, is the text drawn as one string, or character by character?
It is Caption in TLabel 

Zaher

  • Hero Member
  • *****
  • Posts: 681
    • parmaja.org
Re: Arabic text, problem on Linux
« Reply #8 on: April 17, 2024, 12:34:05 pm »
I Tested it "Lazarus 3.99 (rev main_3_99-983-gf3b042ed9d) FPC 3.3.1 x86_64-linux-gtk2"
It is work fine with default font

nouzi

  • Sr. Member
  • ****
  • Posts: 298
Re: Arabic text, problem on Linux
« Reply #9 on: April 18, 2024, 05:21:27 pm »
see
My English is  bad
Lazarus last version free pascal last version
Lazarus trunk  free pascal trunk 
System : Linux mint  64bit  Windows 7 64bit

Zaher

  • Hero Member
  • *****
  • Posts: 681
    • parmaja.org
Re: Arabic text, problem on Linux
« Reply #10 on: April 20, 2024, 03:29:16 am »
His problem with all characters, but he didn't mentioned which version and which GUI platform used.

 

TinyPortal © 2005-2018