Recent

Author Topic: Why DrawText output is different on Bitmap.Canvas and Form.Canvas?  (Read 7749 times)

Yurii

  • Newbie
  • Posts: 4
Why DrawText output is different on Bitmap.Canvas and Form.Canvas for strings which combine arabic and other symbols? (See attachment)
What can I do to fix that?

...
  DrawText(Form1.Canvas.Handle, PChar(s), Length(s), R, DT_WORDBREAK);
  DrawText(Bitmap.Canvas.Handle, PChar(s), Length(s), R, DT_WORDBREAK);
  Form1.Canvas.Draw (10, 40, Bitmap);
...
Lazarus 1.07 r40563 FPC 2.6.0 i386-linux-qt Kubuntu 12.04, Linux 3.8.5, KDE 4.8.5

Blaazen

  • Hero Member
  • *****
  • Posts: 3239
  • POKE 54296,15
    • Eye-Candy Controls
Re: Why DrawText output is different on Bitmap.Canvas and Form.Canvas?
« Reply #1 on: April 27, 2013, 11:59:06 am »
So this is about Themes and Qt4, yes?
I'm not sure, I don't use RightToLeft and I cannot test. I guess Canvas.TextStyle can affect it.
Try:
Code: [Select]
with Bitmap.Canvas.TextStyle do RightToLeft:=True;
EDIT: Better (cross-platform) solution:
Code: [Select]
with Bitmap.Canvas.TextStyle do RightToLeft:=Application.IsRightToLeft;
« Last Edit: April 27, 2013, 12:07:03 pm by Blaazen »
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

Yurii

  • Newbie
  • Posts: 4
Re: Why DrawText output is different on Bitmap.Canvas and Form.Canvas?
« Reply #2 on: April 27, 2013, 05:17:58 pm »
Using Canvas.TextStyle is the same as using DT_RTLREADING flag.
Code: [Select]
DrawText(Form1.Canvas.Handle, PChar(s), Length(s), R, DT_WORDBREAK or DT_RTLREADING);
  DrawText(Bitmap.Canvas.Handle, PChar(s), Length(s), R, DT_WORDBREAK or DT_RTLREADING);
Both don't change anything.
Lazarus 1.07 r40563 FPC 2.6.0 i386-linux-qt Kubuntu 12.04, Linux 3.8.5, KDE 4.8.5

Blaazen

  • Hero Member
  • *****
  • Posts: 3239
  • POKE 54296,15
    • Eye-Candy Controls
Re: Why DrawText output is different on Bitmap.Canvas and Form.Canvas?
« Reply #3 on: April 27, 2013, 06:09:04 pm »
Sorry, the code above does not work (it is packed record).
Try this:
Code: [Select]
var aTS: TTextStyle;
begin
  aTS.RightToLeft:=True;
  Canvas.TextStyle:=aTS;
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

Yurii

  • Newbie
  • Posts: 4
Re: Why DrawText output is different on Bitmap.Canvas and Form.Canvas?
« Reply #4 on: April 27, 2013, 06:51:21 pm »
Nothing changed again.
In Windows many strings  like this ':مایع تحقیق' are shown in a proper way, but not this
Code: [Select]
s := '% ,خطأ نسبي';
Strings like this 'Pa ,تنش' are shown in a proper way both in Linux and Windows.
When I faced this problem for the first time I prepared two Persian language files for Linux and for Windows. But in Linux I couldn't use the same strings for translation data input forms and result presentation. I think that creation of different strings for this purpos is not right.
Lazarus 1.07 r40563 FPC 2.6.0 i386-linux-qt Kubuntu 12.04, Linux 3.8.5, KDE 4.8.5

zeljko

  • Hero Member
  • *****
  • Posts: 1596
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: Why DrawText output is different on Bitmap.Canvas and Form.Canvas?
« Reply #5 on: June 14, 2013, 12:38:04 pm »
Why DrawText output is different on Bitmap.Canvas and Form.Canvas for strings which combine arabic and other symbols? (See attachment)
What can I do to fix that?

...
  DrawText(Form1.Canvas.Handle, PChar(s), Length(s), R, DT_WORDBREAK);
  DrawText(Bitmap.Canvas.Handle, PChar(s), Length(s), R, DT_WORDBREAK);
  Form1.Canvas.Draw (10, 40, Bitmap);
...

http://bugs.freepascal.org/view.php?id=24340  and issue is resolved. Note that it'll work correct only with Qt libs >= 4.7 (I've tested with qt 4.7.4 and 4.8.3(4))



 

TinyPortal © 2005-2018