Lazarus

Programming => Graphics and Multimedia => TAChart => Topic started by: MaartenJB on September 15, 2021, 11:25:34 am

Title: TAChart demo nogui does not output text
Post by: MaartenJB on September 15, 2021, 11:25:34 am
Hi, I'm trying out the nogui tachart demo, this does output an image, only it's without text. The output looks like the attached picture.

Demo location: C:\lazarus\components\tachart\demo\nogui

I've done a clean installation of the latest version of lazarus.
I've downloaded the freetype.dll and freetype.lib from this site, and put it in the executable folder. ( https://github.com/ubawurinna/freetype-windows-binaries/tree/master/release%20dll/win64 )

I've also tested this in Debian with the same result, I'm trying to figure this out for days, but I'm not able to get it to work.
Title: Re: TAChart demo nogui does not output text
Post by: wp on September 15, 2021, 12:17:57 pm
I know...

Checking various Laz versions, I see that the issue came in between Laz 2.0.8/FPC 3.0.4 and Laz 2.0.10/FPC3.2. I am still investigating. It looks as if some scaling factor for the text is missing somewhere. I am also looking at the freetype font handling in FPC which saw some changes but they should have made it into 3.2.0, and stand-alone text output using ftFont (e.g. fpc/.../fcl-image/examples/textout.pp) is correct.
Title: Re: TAChart demo nogui does not output text
Post by: wp on September 16, 2021, 12:57:16 am
Please check out the new revision from Lazarus-main. I could find some issues in the TADrawerFPCanvas unit, and I think there were also some issues in the FCL-Image Freetype units which, however, seem to have been fixed at some point in the near past - I did not try to go through the steps through finding the correct FPC revision.

For me, the nogui demo runs fine with the new Laz main in combination with FPC-main or FPC-fixes. The combination with FPC 3.2.2 or 3.2.0 still has the missing texts (probably because the FreeType fix came after the release of FPC 3.2.2). This is for windows; but on Linux the texts do show up also with FPC 3.2.2 - I don't understand why this happens... I did not check cocoa because I did not yet switch to the git version of Laz there.

There is a new procedure, InitFonts, which sets the search path for the FTFont FontMgr to the standard font directories for Linux and mac. Call this very early in your program and you will not have to specify fonts names with path any more.
Title: Re: TAChart demo nogui does not output text
Post by: MaartenJB on September 16, 2021, 10:40:52 am
I've tested it with Lazarus RC1 on Windows and Linux, both didn't show text for me. (Windows you already said it wouldn't)

lazarus-project/now 2.2.0RC1 amd64 [installed,local]
fpc-laz/now 3.2.2 amd64 [installed,local]
fpc-src/now 3.2.2 amd64 [installed,local]

Title: Re: TAChart demo nogui does not output text
Post by: wp on September 16, 2021, 11:03:15 am
I've tested it with Lazarus RC1
The fix is not in RC1, but in only "main" (what used to be trunk in the pre-git days); when it is confirmed to work I'll put it into "fixes_2_2" as well.
Title: Re: TAChart demo nogui does not output text
Post by: MaartenJB on September 16, 2021, 11:44:52 am
Is there an official git repository? I thought everything was still on subversion.
Title: Re: TAChart demo nogui does not output text
Post by: wp on September 16, 2021, 11:54:05 am
https://gitlab.com/freepascal.org/lazarus/lazarus

Search the forum - there were numerous discussions related to the svn-to-git transition which occured a few weeks ago.
Title: Re: TAChart demo nogui does not output text
Post by: MaartenJB on September 16, 2021, 12:06:35 pm
Ah, nice, thx. I checked the wiki page...
Title: Re: TAChart demo nogui does not output text
Post by: MaartenJB on September 28, 2021, 02:49:03 pm

Which version do I need to try to get it to work?

I've just tried the nogui demo with Lazarus 2.2.0RC2(fixes) / FPC 3.2.3(trunk) and this didn't produce any text. The trunk version of Lazarus made the demo hang on chart.Draw.
Title: Re: TAChart demo nogui does not output text
Post by: wp on September 28, 2021, 03:06:40 pm
The fix is in Lazarus trunk (or, as it is named now: main), not yet in fixes_2_2 because I want confirmation by somebody else before I cherry-pick it to fixes. But note that it requires FPC-trunk or FPC-fixes - FPC 3.2.2 or earlier will still prevent the text from showing, at least on Windows.

Please re-read my reply #2.
Title: Re: TAChart demo nogui does not output text
Post by: MaartenJB on September 28, 2021, 03:25:58 pm
aah, you changed the demo as well. now it works. Thanks! I do still need to specify the location of the fonts.


Title: Re: TAChart demo nogui does not output text
Post by: wp on September 28, 2021, 03:41:05 pm
I do still need to specify the location of the fonts.
Is this the demo which comes with Lazarus-main? It should call the new procedure InitFonts as first instruction; it tells the FreeType Font Manager the common locations of the fonts.
Title: Re: TAChart demo nogui does not output text
Post by: MaartenJB on September 28, 2021, 04:01:22 pm
yes it's the demo from lazarus-main, and it's the first call the application does.
Title: Re: TAChart demo nogui does not output text
Post by: wp on September 28, 2021, 04:13:05 pm
Then I don't understand what you want to say with "I do still need to specify the location of the fonts". Is there an error "Font not found" or so when you run the unmodified nogui demo? Or what is the problem?
Title: Re: TAChart demo nogui does not output text
Post by: MaartenJB on September 28, 2021, 04:19:50 pm
yes, and I'd attached the error in my previous post (third image)

I mean, I still have to specify the full path instead of the filename only.

Generates error from above
Code: Pascal  [Select][+][-]
  1.   FONT_NAME = 'LiberationSans-Regular.ttf';

Works
Code: Pascal  [Select][+][-]
  1.   FONT_NAME = '/usr/share/fonts/truetype/liberation2/LiberationSans-Regular.ttf';
Title: Re: TAChart demo nogui does not output text
Post by: wp on September 28, 2021, 04:52:49 pm
OK, I understand now. InitFont, simplified for Linux, does this:
Code: Pascal  [Select][+][-]
  1. procedure InitFonts;
  2. begin
  3.   InitEngine;
  4.   FontMgr.SearchPath :=
  5.     '/usr/share/cups/fonts/;' +
  6.     '/usr/share/fonts/truetype/;' +
  7.     '/usr/share/fonts/truetype/liberation/;' +
  8.     '/usr/local/lib/X11/fonts/;' +
  9.     GetUserDir + '.fonts/';
  10. end;
The font manager's SearchPath contains only a "liberation" folder, not the "liberation2" of your example. I looked in my Mint-VM, and I see that there should be many more. I'm no Linux specialist so that I cannot say that the situation in Mint is typical of all Linux versions around today. Probably every type of Linux distribution and every major application adds some dozens of font folders to the system. My intention with InitFonts was to provide a minimal solution which covers "most" cases (whatever that means). The user (you) still has the possibility to extend the SearchPath to any level:
Code: Pascal  [Select][+][-]
  1. procedure MyInitFonts;
  2. begin
  3.   InitFonts;
  4.   FontMgr.SearchPath := FontMgr.SearchPath +  ';' +
  5.     '/usr/share/fonts/truetype/liberation2/;'
  6.     '/usr/share/fonts/truetype/noto/;'+
  7.     '/usr/share/fonts/truetype/openoffice/;'+
  8.     '/usr/share/fonts/truetype/dejavu/;'+
  9.     '/usr/share/fonts/truetype/freefont/';   // plus many more...
  10. end;
Of course, I am willing to modify the font list in the InitFonts procedure if it is not typical.
Title: Re: TAChart demo nogui does not output text
Post by: MaartenJB on September 29, 2021, 08:18:00 am
Those things are indeed pretty hard with all distros available. I think for my project I just specify the exact font path I want to use. Do you need me to test anything else for this fix to be applied?
Title: Re: TAChart demo nogui does not output text
Post by: wp on September 29, 2021, 09:55:48 am
That's fine, thanks. The changes should be in fixes_2_2 now.
Title: Re: TAChart demo nogui does not output text
Post by: MaartenJB on September 29, 2021, 10:09:05 am
Ok nice, thanks for your help!
TinyPortal © 2005-2018