Recent

Author Topic: Tchart legend font size setting?  (Read 990 times)

stephanweber

  • Jr. Member
  • **
  • Posts: 54
Tchart legend font size setting?
« on: July 12, 2024, 08:50:31 am »
Hi,

the legend seems to use font size = 0, so it is quite large. How can I made the legend smaller. I found no size scale factor and also no place to change the font size. Also changing the chart font sizes seems to have no impact.
This is a simple thing and should work easy, but it looks not...

Does anybody know how to get a more compact legend?

Bye Stephan

wp

  • Hero Member
  • *****
  • Posts: 12459
Re: Tchart legend font size setting?
« Reply #1 on: July 12, 2024, 11:57:21 am »
Size 0 in Lazarus is always the default font size, which is the size of the system font. You certainly can use any different size for Chart.Legend.Font.Size (which is in typographic points then (1pt = 1/72 inch)).

If you want to know the size of the default font you can call GetFontData from the Graphics unit. It returns a TTextMetric record with the font height as element. Font height, however is in pixels, and you must do a small calculation to get the size in points:

Code: Pascal  [Select][+][-]
  1. var
  2.   metric: TTextMetric;
  3.   fontSize: Integer;
  4. begin
  5.   metric := GetFontData(Font.Handle);
  6.   fontSize := round(-metric.Height/Screen.PixelsPerInch*72);
  7. ...

 

TinyPortal © 2005-2018