Cannot change font name for numbers on TChart axes

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Bill Anderson
Newbie
Newbie
Posts: 8
Joined: Tue Jun 07, 2016 12:00 am

Cannot change font name for numbers on TChart axes

Post by Bill Anderson » Mon Apr 17, 2017 4:16 pm

Dear TeeChart technical help,

I am using RAD Studio 10.1 Berlin and a registered version of Steema TeeChart Pro VCL FMX 2016.18, and am updating a project from BDS 2006.

I am trying to change the fonts for the numbers on the left and bottom axis from 'MS Sans Serif' to 'Arial' - and I CANNOT DO THIS! The things I have tried to do include:
1) I have tried changing in the Object Inspector:
TChart->BottomAxis->LabelsFont->Name FROM MS Sans Serif TO Arial
TChart->LeftAxis->LabelsFont->Name FROM MS Sans Serif TO Arial
- this FAILED
2) In the constructor code for a frame that contains the TChart
__fastcall TChartXFrame::TChartXFrame(TComponent* Owner : TFrame(Owner)
{
TChartX->LeftAxis->LabelsFont->Name = "Arial"; // this FAILED - doesn't work to change number font from 'MS Sans Serif' to 'Arial'
}
3) I have File->SaveAll and exited RAD Studio, then restarted RAD Studio, loaded my project in, Project->Build to compile and link it - this FAILED
4) I have deleted ALL *.obj files, then Project->Build to compile and link it - this FAILED
5) I have gone into the *.dfm code and changed every instance of 'MS Sans Serif' to 'Arial' - this FAILED
6) I have CUT out the TChart in a frame and PASTED it back in to the frame - this FAILED

Do you know how can I fix this bug?
It seems that somewhere in my project there is a hard coding of 'MS Sans Serif' that I cannot change to 'Arial'. Do you know where this is?

Alternatively, could this bug have something to do with this warning W8080 I get from most of the files in my project?
[bcc32 Warning]: W8080 'Gdiplus::FlatnessDefault' is declared but never used
[bcc32 Warning]: W8080 'Gdiplus::GenericSansSerifFontFamily' is declared but never used
[bcc32 Warning]: W8080 'Gdiplus::GenericSerifFontFamily' is declared but never used
[bcc32 Warning]: W8080 'Gdiplus::GenericMonospaceFontFamily' is declared but never used
[bcc32 Warning]: W8080 'Gdiplus::GenericSansSerifFontFamilyBuffer' is declared but never used
[bcc32 Warning]: W8080 'Gdiplus::GenericSerifFontFamilyBuffer' is declared but never used
[bcc32 Warning]: W8080 'Gdiplus::GenericMonospaceFontFamilyBuffer' is declared but never used
[bcc32 Warning]: W8080 'Gdiplus::GenericTypographicStringFormatBuffer' is declared but never used
[bcc32 Warning]: W8080 'Gdiplus::GenericDefaultStringFormatBuffer' is declared but never used

Thank you,
Bill Anderson

Yeray
Site Admin
Site Admin
Posts: 9514
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Cannot change font name for numbers on TChart axes

Post by Yeray » Thu Apr 20, 2017 7:58 am

Hello Bill,

I've tried it both with TeeChart v2017.21 and v2016.18 in Berlin, and it seems to work fine for me both through the editor and by code.
I'd edit manually (with notepad or similar) the project files searching for any reference to any font name that may be hard-coded.

If you still find problems with it, please try to arrange a simple example project we can run as-is to reproduce the problem here.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Bill Anderson
Newbie
Newbie
Posts: 8
Joined: Tue Jun 07, 2016 12:00 am

Re: Cannot change font name for numbers on TChart axes

Post by Bill Anderson » Tue Apr 25, 2017 12:41 pm

Dear Yeray,

I made a simple sample project that shows that Ariel 9 fonts are NOT correctly printed as LeftAxis number labels. The Arial 9 fonts appear correctly in the uncompiled Form1 of Unit1.cpp (LEFT side of Anderson_TChartBUG_Arial_vs_SansSerif.png
in the attached Anderson_TChartBUG_Arial_vs_SansSerif.zip file). However, when the program is compiled and run, the numbers appear to be MS Sans Serif in the project1.exe executable (RIGHT side of Anderson_TChartBUG_Arial_vs_SansSerif.png in the attached *.zip file). These 'Sans Serif'-like fonts are block-like and do not show the complex shading of the darker Arial 9 fonts seen in Unit1.cpp.

In Anderson_TChartBUG_Arial_vs_SansSerif.zip I have included the code showing the BUG. One difference, however, is that although I own the licensed to TChart Pro v2016.18, for this project I actually didn't need to use the TChart Pro,
and the TChart code in the project I sent is just the Standard TChart code included in RAD Studio XE 10.1 Berlin, Update 1. Presumably this wont be the cause of the bug.

I have tried for TWO DAYS to upload my attachment file, but your server is NOT WORKING. Therefore, you can download my zip file from my university server:
Anderson_TChartBUG_Arial_vs_SansSerif.zip is now available for download from the following URL:
https://fluff.bris.ac.uk/fluff/u3/anwwa ... yGHyEZQcwp
and will remain there until: Wed May 10 22:59:59 2017 UTC.

Hope to hear from you soon.

Sincerely,
Bill Anderson

Yeray
Site Admin
Site Admin
Posts: 9514
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Cannot change font name for numbers on TChart axes

Post by Yeray » Wed Apr 26, 2017 12:16 pm

Hello,

I added "915" to all "tee" references in the cbproj, opened the project with RAD XE and this is what I get with it:
bds_2017-04-26_14-10-12.png
bds_2017-04-26_14-10-12.png (18.29 KiB) Viewed 17914 times
It seems as if your application was using GDI instead of GDIPlus.
If I open the dfm as text and I change this:

Code: Select all

    DefaultCanvas = 'TGDIPlusCanvas'
for this:

Code: Select all

    DefaultCanvas = 'TCanvas3D'
Then I get the same result you are getting.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Bill Anderson
Newbie
Newbie
Posts: 8
Joined: Tue Jun 07, 2016 12:00 am

Re: Cannot change font name for numbers on TChart axes

Post by Bill Anderson » Fri Apr 28, 2017 1:31 pm

Hi Yeray,

I'm sorry to say this, but the changes you suggested didn't work - I still get SanSerif-like TChart output fonts!!!

I reinstalled my TChart Pro using TeeChartVCLFMX-2016.18.exe - so that I could use your '915' additions ( but I used my '924' rather than your '915')

Then in Project1.cbproj using Notepad, I substituted:
in <AllPackageLibs> replaced 'tee.lib' with 'tee924.lib'
in <PackageImports> replaced 'tee' with 'tee9240'' and then 'DclTeePro924', replaced 'teeDB' with 'teeDB9240', replaced 'teeUI' with 'teeUI9240', replaced 'FMXtee' with 'FMXtee924', and replaced 'FmxTeeUI' with 'FmxTeeUI924'
in <LinkPackageImports> replaced 'tee.bpi' with 'tee924.bpi'

I made sure that in Unit1.dfm, the
Font.name = 'Arial'
This did not fix the problem.

I also tried adding to the Unit1.dfm file
LeftAxis.LabelsFont.Name = 'Arial'
This did not fix the problem.

I also checked that in Unit1.dfm:
DefaultCanvas = 'TGDIPlusCanvas'
(and in fact I rechecked the code I sent you, and in Unit1.dfm, the DefaultCanvas = 'TGDIPlusCanvas')

I have no idea why your code works and mine doesn't.

As a step forward, would you please send me the code you changed to that worked - in particular the *.cbproj file? Thank you.

Sincerely,
Bill Anderson

Yeray
Site Admin
Site Admin
Posts: 9514
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Cannot change font name for numbers on TChart axes

Post by Yeray » Tue May 02, 2017 7:56 am

Hello Bill,

I've modified the cbproj to use TeeChart for Berlin (Tee*924) instead of XE (Tee*915).
TChartBUG_Arial9.zip
(55.68 KiB) Downloaded 577 times
And I believe I found adding this "pragma link" seems to make the difference:

Code: Select all

#pragma link "VclTee.TeeGDIPlus"
Make sure to Clean the project before Building. Sometimes the changes seem not to be applied correctly if I don't Clean the project.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Bill Anderson
Newbie
Newbie
Posts: 8
Joined: Tue Jun 07, 2016 12:00 am

Re: Cannot change font name for numbers on TChart axes

Post by Bill Anderson » Tue May 02, 2017 4:19 pm

Hi Yeray,

Thenk you. I got the code TO WORK at 100% of the native resolution of my monitors: 1920 x 1080 and 3840 x 2160.
(See TChartBUG_1920x1080_100%.png and TChartBUG_3840x2160_100%.png.)

However I did find an additional bug that if you set one of the high resolution monitors to its native resolution (3840 x 2160) and then changed the
size of the text to 200% (by RightMouseButtonClick on WholeScreen -> Settings -> Display -> Change the size of text, apps, and other items: 200%)
which EFFECTIVELY would create a 1920 x 1080 monitor, the project1.exe TChart font sizes were INCORRECTLY HALF those in the RAD Studio XE10.1.
(See TChartBUG_3840x2160_200%.png.) This is a BUG. In contrast, the fonts in TLabels and TPanels appear correct at 3840 x 2160 at 200%.

I just wanted to bring your attention to this which you would not find if you were always using the native resolution of your monitor.
However, higher resolution monitors like 3840x2160 are now available quite cheap (<£300) and so more and more customers will
be using very high resolution monitors at size of text settings > 100%.

Sincerely,
Bill Anderson
Attachments
TChartBUG_3840x2160_200%.png
TChartBUG_3840x2160_200%.png (330.36 KiB) Viewed 17830 times
TChartBUG_3840x2160x_100%.png
TChartBUG_3840x2160x_100%.png (168.66 KiB) Viewed 17833 times
TChartBUG_1920x1080_100%.png
TChartBUG_1920x1080_100%.png (102.14 KiB) Viewed 17830 times

Yeray
Site Admin
Site Admin
Posts: 9514
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Cannot change font name for numbers on TChart axes

Post by Yeray » Wed May 03, 2017 11:50 am

Hello,

Try setting:

Code: Select all

  TChart1->View3DOptions->ZoomText=ztAuto;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Bill Anderson
Newbie
Newbie
Posts: 8
Joined: Tue Jun 07, 2016 12:00 am

Re: Cannot change font name for numbers on TChart axes

Post by Bill Anderson » Wed May 03, 2017 5:45 pm

Hi Versay,

No, this does not work correctly, ie when the high resolution monitor was set to its native resolution (3840 x 2160) and the size of the text was set to 200%,
the project1.exe TChart font sizes were still INCORRECTLY HALF those in the RAD Studio XE10.1.

But now, instead the size of the number font increases when the size of the TChart increases (when manually elongated or increased in height). I definitely don't want this, so
TChart1->View3DOptions->ZoomText=ztAuto; definitely does not seem the way to go.

Also, the Arial number fonts on the left axis do not respond to whether the Windows 10 ClearType check box is checked or unchecked. In other words,
the TChart number fonts just don't respond the way the fonts do in C++Builder's TPanel or TLabel.

I don't know if anything can be done about this. I may have to stick with the old MS Sans Serif which do work correctly when the high resolution monitor
is set to its native resolution (3840 x 2160) and the size of the text is set to 200% - the font sizes were CORRECTLY equal to those in the RAD Studio XE10.1.

Sincerely,
Bill Anderson

Yeray
Site Admin
Site Admin
Posts: 9514
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Cannot change font name for numbers on TChart axes

Post by Yeray » Thu May 04, 2017 2:09 pm

Hello Bill,

Looking at it again I found this seems to work in Delphi:

Code: Select all

type TCustomTeePanelAccess=class(TCustomTeePanel);

procedure TForm2.FormAfterMonitorDpiChanged(Sender: TObject; OldDPI,
  NewDPI: Integer);
begin
  TCustomTeePanelAccess(TChart1).ChangeScale(NewDPI, OldDPI);
end;
I'm not sure how to translate it to CBuilder.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Bill Anderson
Newbie
Newbie
Posts: 8
Joined: Tue Jun 07, 2016 12:00 am

Re: Cannot change font name for numbers on TChart axes

Post by Bill Anderson » Fri May 05, 2017 2:18 pm

Hi Veray,

I had no progress with the Delphi code you provided. I really don't know Delphi, and I have enough trouble with C/C++!!!

Could you please send me a C++ Builder equivalent, and also tell me where you got the OldDPI and NewDPI.
Sending me all the code in this project would actually be much appreciated.

Sincerely,
Bill Anderson

Yeray
Site Admin
Site Admin
Posts: 9514
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Cannot change font name for numbers on TChart axes

Post by Yeray » Fri May 05, 2017 2:43 pm

Hello Bill,

The trick consists on creating a helper class to allow accessing a protected method.
Here is how you can do it in CBuilder:

Code: Select all

class TCustomTeePanelAccess : public TCustomTeePanel
{
  public:
	DYNAMIC void __fastcall ChangeScale(int M, int D)
	{
	  TCustomTeePanel::ChangeScale(M,D);
	}
};

void __fastcall TForm1::FormAfterMonitorDpiChanged(TObject *Sender, int OldDPI, int NewDPI)

{
  ((TCustomTeePanelAccess*)TChart1)->ChangeScale(NewDPI, OldDPI);
}
Note you have to create the FormAfterMonitorDpiChanged method using the Object Inspector:
bds_2017-05-05_16-43-09.png
bds_2017-05-05_16-43-09.png (10.22 KiB) Viewed 17798 times
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Bill Anderson
Newbie
Newbie
Posts: 8
Joined: Tue Jun 07, 2016 12:00 am

Re: Cannot change font name for numbers on TChart axes

Post by Bill Anderson » Mon May 08, 2017 4:08 pm

Hi Yeray,

I was successful in implementing your code from 5 May, 14:43 using FormAfterMonitorDpiChanged() so that when I CHANGE FROM 1920x1080 at 100% TO 3840x2160 pixels at 200% the LeftAxis fonts scaled correctly to the right size.

However if I START the program at 3840 pixels at 200% then the LeftAxis fonts are still INCORRECTLY at HALF the size they should be. How can I fix this?

Sincerely,
Bill Anderson

Yeray
Site Admin
Site Admin
Posts: 9514
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Cannot change font name for numbers on TChart axes

Post by Yeray » Tue May 09, 2017 7:01 am

Hello Bill,

What about calling the event manually when the form is created?

Code: Select all

__fastcall TForm1::TForm1(TComponent* Owner)
	: TForm(Owner)
{
  FormAfterMonitorDpiChanged(this, 96, Monitor->PixelsPerInch);
}
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Bill Anderson
Newbie
Newbie
Posts: 8
Joined: Tue Jun 07, 2016 12:00 am

Re: Cannot change font name for numbers on TChart axes

Post by Bill Anderson » Tue May 09, 2017 4:52 pm

Hi Yeray,

That suggestion to put
FormAfterMonitorDpiChanged(this, 96, Monitor->PixelsPerInch);
into the Form1 constructor solved the problem!

I just have one more question on controlling the fonts in TChart: I am having difficulty in bringing the bottom axis numbers closer to the axis. I cant seem to bring them closer than 6 pixels (with 2 pixel long outer tic marks). Is there any way to control this?

Sincerely,
Bill Anderson

Post Reply