Font Sizes in Charts

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Ed Dressel
Newbie
Newbie
Posts: 10
Joined: Wed Aug 16, 2023 12:00 am

Font Sizes in Charts

Post by Ed Dressel » Thu Aug 24, 2023 10:17 pm

2023.38

I am having a problem with some of my charts and font sizes related to Windows Display Scale options: when I go to 200%, sometimes the fonts appear at about 400%. I assign the font sizes to my charts because I need to manage them for creating reports (when I don't want the fonts to be large). I have a few charts that work fine--but I can't find the difference (and I have had a few other programmers look over my shoulder).

It seems that some of the charts are managing the Windows' scaling for me and other charts are letting me manage it.

Here is what I am seeing when I go from 100% to 200%--the chart font size goes 4x. (And gain, I explicitly set the font size in the chart so that I can get an image from it when I am wanting to print without the larger fonts).

http://www.tbinc.com/misc/ChartFontSize.jpg

How do I get this to work right?

(And I accidently spelt my last name incorrectly when I logged in and it won't let me fix it).

Ed Dressel

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

Re: Font Sizes in Charts

Post by Yeray » Fri Aug 25, 2023 1:24 pm

Hello Ed,

Can you please arrange a simple example project we can run as-is to reproduce the problem here?
Thanks in advance.
Ed Dressel wrote:
Thu Aug 24, 2023 10:17 pm
(And I accidently spelt my last name incorrectly when I logged in and it won't let me fix it).
I've edited it, but you should be able to modify it 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

Ed Dressel
Newbie
Newbie
Posts: 10
Joined: Wed Aug 16, 2023 12:00 am

Re: Font Sizes in Charts

Post by Ed Dressel » Fri Aug 25, 2023 4:08 pm

(Thanks for fixing my name--I tried several times on the page, but it did not save the changes).

I've attached a demo that reproduces part of what I'm seeing. You have to run this very specifically to see the problem:

Problem #1: Fonts are the wrong size:

1) Start the app on a monitor with normal DPI. The "Chart #1" tab page should be showing.
2) Without changing pages, drag the application to a monitor with 200% DPI.
3) Switch to the "Chart #2" tab page. You should see that the fonts are at 100%, not 200%
4) Drag the app back to the normal font monitor. You should see the fonts on Chart #2 are way too small.

Here are images of what I am seeing that correspond to each step (the image option still not seem to be working):

www.tbinc.com/misc/ChartFontSize2.jpg

Problem #2: Unable to create an image with normal font sizes

I create a copy of the image without scaled fonts for my reports, but it does not always work:

1) Run the app and put it on a monitor with 200% font size. You should see this on the active tab page with large fonts.
2) Click the "Create Image". The code should create an image with unscaled fonts, but the fonts in the BMP are scaled.


Thank you,

Ed Dressel
Attachments
DPI Issue.zip
(13.19 KiB) Downloaded 749 times

Ed Dressel
Newbie
Newbie
Posts: 10
Joined: Wed Aug 16, 2023 12:00 am

Re: Font Sizes in Charts

Post by Ed Dressel » Fri Aug 25, 2023 5:22 pm

I inadvertently left some CodeSite code in there. It is removed in the updated attachment.
Attachments
DPI Issue.zip
(13.16 KiB) Downloaded 754 times

Ed Dressel
Newbie
Newbie
Posts: 10
Joined: Wed Aug 16, 2023 12:00 am

Re: Font Sizes in Charts

Post by Ed Dressel » Fri Aug 25, 2023 6:01 pm

I found another problem in the demo that I am seeing in my application:

1) Start the app and put it on a monitor with the display set to 200%.
2) Click on the "create image" button
3) Go back to the tab that the image was created on--the fonts are now 400%, not 200%.

I look forward to your comments. Much appreciated.

Ed Dressel

Ed Dressel
Newbie
Newbie
Posts: 10
Joined: Wed Aug 16, 2023 12:00 am

Re: Font Sizes in Charts

Post by Ed Dressel » Thu Aug 31, 2023 8:40 pm

No comment on this? Is there any support here?

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

Re: Font Sizes in Charts

Post by Yeray » Mon Sep 04, 2023 1:44 pm

Hello,

Sorry for the delayed reply here.
Ed Dressel wrote:
Fri Aug 25, 2023 4:08 pm
Problem #1: Fonts are the wrong size:

1) Start the app on a monitor with normal DPI. The "Chart #1" tab page should be showing.
2) Without changing pages, drag the application to a monitor with 200% DPI.
3) Switch to the "Chart #2" tab page. You should see that the fonts are at 100%, not 200%
4) Drag the app back to the normal font monitor. You should see the fonts on Chart #2 are way too small.
I see removing the Showing condition at TCustomTeePanel.ChangeScale at {VCLTee.}TeeProcs.pas unit fixes it, but I have to check for any collateral damages:

Code: Select all

procedure TCustomTeePanel.ChangeScale(M, D: Integer{$IFDEF D24}; isDpiChange: Boolean{$ENDIF});
//...
  if not (csLoading in ComponentState) and (M <> D) {and Showing <-- remove this} then
     SetAutoFontZoom(MulDiv(FView3DOptions.FontZoom, M, D));
end;
Ed Dressel wrote:
Fri Aug 25, 2023 4:08 pm
Problem #2: Unable to create an image with normal font sizes

I create a copy of the image without scaled fonts for my reports, but it does not always work:

1) Run the app and put it on a monitor with 200% font size. You should see this on the active tab page with large fonts.
2) Click the "Create Image". The code should create an image with unscaled fonts, but the fonts in the BMP are scaled.
Ed Dressel wrote:
Fri Aug 25, 2023 6:01 pm
I found another problem in the demo that I am seeing in my application:

1) Start the app and put it on a monitor with the display set to 200%.
2) Click on the "create image" button
3) Go back to the tab that the image was created on--the fonts are now 400%, not 200%.
I see you are playing with the font sizes at ConfigChartFontSize. You should set the aChart.View3DOptions.FontZoom property accordingly so the internal drawing can use it.

Code: Select all

class procedure TChartConfig.ConfigChartFontSize(aChart: TChart; aScaleFonts: boolean);
//...
begin
  if aScaleFonts then begin
    aChart.View3DOptions.FontZoom := aChart.PixelsPerInch * 100 div 96;  // <-- add this
    lScale := (aChart.PixelsPerInch / 96) / (aChart.View3DOptions.FontZoom * 0.01);

    lFont12 := Round(lScale * 12);
    lFont10 := Round(lScale * 10);
    lFont9 := Round(lScale * 9);
    lFont8 := Round(lScale * 8);
  end else begin
    aChart.View3DOptions.FontZoom := 100;  // <-- add this
    lFont12 := 12;
    lFont10 := 10;
    lFont9 := 9;
    lFont8 := 8;
  end;
  //...
This seems to fix both issues for me 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

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

Re: Font Sizes in Charts

Post by Yeray » Wed Sep 13, 2023 10:34 am

Yeray wrote:
Mon Sep 04, 2023 1:44 pm
I see removing the Showing condition at TCustomTeePanel.ChangeScale at {VCLTee.}TeeProcs.pas unit fixes it, but I have to check for any collateral damages:

Code: Select all

procedure TCustomTeePanel.ChangeScale(M, D: Integer{$IFDEF D24}; isDpiChange: Boolean{$ENDIF});
//...
  if not (csLoading in ComponentState) and (M <> D) {and Showing <-- remove this} then
     SetAutoFontZoom(MulDiv(FView3DOptions.FontZoom, M, D));
end;
I've pushed this change to the code base for #2633.
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

Post Reply