Recent

Author Topic: VirtualTreeView shows Kanji characters half dissapeared on Ubuntu  (Read 7267 times)

torumyax

  • New Member
  • *
  • Posts: 34
Hi! (from Japan)

I just started using Lazarus a few weeks ago. (and am very happy, thank you guys!)

Then I just realized VirtualTreeView-Lazarus 5.5.3-r1 does not show Kanji characters correctly on Ubuntu. It displays fine on Windows.
(see attachment)

Strangely, Hiragana and Katakana characters are displayed correctly. It gets half disappeared only when string contains Kanji characters.

Setting DefaultNodeHeight and changing the font setting don't seem to change anything.

Could you give me any suggestion? Much appreciated.


-------------------------------------------------------
Windows 10:
Lazarus 1.8.0 r56594 FPC 3.0.4 x86_64-win64-win32/win64

Ubuntu 17.10
Lazarus 1.8.0 rc4+dfsg-1 FPC 3.0.2 x86_64-linux-gtk2
« Last Edit: February 10, 2018, 06:49:27 pm by torumyax »

torumyax

  • New Member
  • *
  • Posts: 34
Re: VirtualTreeView shows Kanji characters half dissapeared on Ubuntu
« Reply #1 on: February 10, 2018, 07:36:08 pm »
OK, I just created and attached the simplest project with a test file. Thanks!

balazsszekely

  • Guest
Re: VirtualTreeView shows Kanji characters half dissapeared on Ubuntu
« Reply #2 on: February 10, 2018, 07:48:55 pm »
Hi torumyax,

Where you display in VTV "< not good" how should the correct text look like? I compared the text with the one from the txt file and it looks the same to me. Can you paste here the correct versions?


PS: If you paste the text in a TEdit, it displays correctly?
« Last Edit: February 10, 2018, 07:52:40 pm by GetMem »

torumyax

  • New Member
  • *
  • Posts: 34
Re: VirtualTreeView shows Kanji characters half dissapeared on Ubuntu
« Reply #3 on: February 10, 2018, 07:56:46 pm »
Hello GetMem. Thanks for the reply.

I posted the screenshot in the first post where it shows both wrong (on Ubuntu) and correct (on Windows).

https://forum.lazarus.freepascal.org/index.php?action=dlattach;topic=40042.0;attach=25209;image

Cheers!

PS: A TEdit displays it correctly.
« Last Edit: February 10, 2018, 08:06:05 pm by torumyax »

torumyax

  • New Member
  • *
  • Posts: 34
Re: VirtualTreeView shows Kanji characters half dissapeared on Ubuntu
« Reply #4 on: February 10, 2018, 08:10:54 pm »
The example project I attached shows, on Ubuntu, like this (see attachment).

balazsszekely

  • Guest
Re: VirtualTreeView shows Kanji characters half dissapeared on Ubuntu
« Reply #5 on: February 10, 2018, 08:11:31 pm »
@torumyax
Ok. I see now. Unfortunately I don't have Ubuntu to test, strangely enough on Linux Mint the text is displayed correctly. Please try the following(OnPaintText event):
Code: Pascal  [Select][+][-]
  1. procedure TForm1.VirtualStringTree1PaintText(Sender: TBaseVirtualTree;
  2.   const TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;
  3.   TextType: TVSTTextType);
  4. begin
  5.   if TextType = ttNormal then
  6.     TargetCanvas.Font.Size := ; //decrease the font here, try to change the font type if necessary
  7. end;

« Last Edit: February 10, 2018, 08:52:00 pm by GetMem »

torumyax

  • New Member
  • *
  • Posts: 34
Re: VirtualTreeView shows Kanji characters half dissapeared on Ubuntu
« Reply #6 on: February 10, 2018, 08:19:38 pm »
@GetMem
Tried. No luck... orz
(see the attachment)

balazsszekely

  • Guest
Re: VirtualTreeView shows Kanji characters half dissapeared on Ubuntu
« Reply #7 on: February 10, 2018, 08:26:30 pm »
OK then. The next thing we should try is to draw the text manually. Please set DefaultNodeHight to a slightly larger value 25 for example, then:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.VirtualStringTree1PaintText(Sender: TBaseVirtualTree;
  2.   const TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;
  3.   TextType: TVSTTextType);
  4. var
  5.   Data: PNodeData;
  6.   R: TRect;
  7. begin
  8.   if TextType = ttNormal then
  9.   begin
  10.     Data := VirtualStringTree1.GetNodeData(Node);
  11.     SetBKMode(TargetCanvas.Handle, TRANSPARENT);
  12.     TargetCanvas.Font.Name := 'Sans Serif';
  13.     TargetCanvas.Font.Size := 12;
  14.     R := TBaseVirtualTree(Sender).GetDisplayRect(Node, Column, False);
  15.     DrawText(Canvas.Handle, PChar(Data^.Column0), Length(Data^.Column0), R, DT_LEFT or DT_BOTTOM or DT_SINGLELINE);
  16.   end;
  17. end;
You can play with the values(Font size, font type, DT_Bottom, etc..).

torumyax

  • New Member
  • *
  • Posts: 34
Re: VirtualTreeView shows Kanji characters half dissapeared on Ubuntu
« Reply #8 on: February 10, 2018, 08:36:58 pm »
Done. But I got compile errors...

balazsszekely

  • Guest
Re: VirtualTreeView shows Kanji characters half dissapeared on Ubuntu
« Reply #9 on: February 10, 2018, 08:37:57 pm »
Quote
Done. But I got compile errors...
uses LCLIntf, LCLType; 

torumyax

  • New Member
  • *
  • Posts: 34
Re: VirtualTreeView shows Kanji characters half dissapeared on Ubuntu
« Reply #10 on: February 10, 2018, 08:45:59 pm »
Opps, newbie... Thank you.

It gets little better.

balazsszekely

  • Guest
Re: VirtualTreeView shows Kanji characters half dissapeared on Ubuntu
« Reply #11 on: February 10, 2018, 08:49:32 pm »
Quote
It gets little better.
Try to change the font size to 10 or 9. You can play with other font types too.

torumyax

  • New Member
  • *
  • Posts: 34
Re: VirtualTreeView shows Kanji characters half dissapeared on Ubuntu
« Reply #12 on: February 10, 2018, 08:57:38 pm »
It got better, but this seems to be a temp workaround. It still shows a line with Kanji character slightly lower than other lines...

balazsszekely

  • Guest
Re: VirtualTreeView shows Kanji characters half dissapeared on Ubuntu
« Reply #13 on: February 10, 2018, 09:02:21 pm »
Quote
It got better, but this seems to be a temp workaround. It still shows a line with Kanji character slightly lower than other lines...
Instead of  DT_BOTTOM you can use DT_VCENTER (vertical center).

torumyax

  • New Member
  • *
  • Posts: 34
Re: VirtualTreeView shows Kanji characters half dissapeared on Ubuntu
« Reply #14 on: February 10, 2018, 09:09:44 pm »
Quote
Instead of  DT_BOTTOM you can use DT_VCENTER (vertical center).

I thought "That's it" But it did not affect...

I set DefaultNodeHeight to default this time. See the lines with Kanji are lower than other?

 

TinyPortal © 2005-2018