Page 1 of 1

axis title/labels not using Arial font

Posted: Mon Oct 22, 2012 2:58 pm
by 16863434
I just upgraded to TChart 2012 for RAD Studio 2009. The problem is the chart's left/right/bottom axis title and labels now display in a font that is not Arial font. The text is drawn with a very thin line (you can clearly see individual pixels) - thus hard to read.

At run time, my debug environment says the axis LabelsFont is Arial. Version 8 that came with RAD Studio displays in Arial as expected.

To see at design time:
Create a new form, add a standard TChart. Bring up the chart editor and add a FastLineSeries. Edit the left axis maximum or minimum so one of them starts with the number 900. Change the chart background from gray to white so you can see the text clearly.

Look at the 9 in axis label "900" (font sizes 8 and 9) - it is not Arial. Compare to a 9 in Windows Notepad formated as Arial.

Strangely, if you turn on Bold for the font, the "900" looks like Arial!

Please fix.

Thanks.

Re: axis title/labels not using Arial font

Posted: Tue Oct 23, 2012 9:21 am
by yeray
Hi,

Try setting the labels font quality to fqDefault:

Code: Select all

uses Series, TeCanvas;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1.AddSeries(TFastLineSeries);
  Chart1.Axes.Left.SetMinMax(0, 900);

  Chart1.Gradient.Visible:=false;
  Chart1.Color:=clWhite;

  Chart1.Axes.Left.LabelsFont.Name:='Arial';
  Chart1.Axes.Left.LabelsFont.Size:=15;
  Chart1.Axes.Left.LabelsFont.Quality:=fqDefault;

  Color:=clWhite;
end;

procedure TForm1.FormPaint(Sender: TObject);
begin
  Canvas.Font.Name:='Arial';
  Canvas.Font.Size:=15;
  Canvas.TextOut(Chart1.Left+20, Chart1.Top-20, '900');
end;

Re: axis title/labels not using Arial font

Posted: Tue Oct 23, 2012 8:04 pm
by 16863434
Yeray,

Setting font.Quality to fqNormal for all titles and labels fixes text drawing that TChart does. Great.

But the Arial text drawing I do in ChartAfterDraw event to the TChart canvas still looks bad. Since the TChart canvas.font does not does not have the Quality property, what do I set?

Thanks.

Re: axis title/labels not using Arial font

Posted: Tue Oct 23, 2012 8:11 pm
by 16863434
my typo

I set the Quality to fqDefault as you suggested, not fqNormal as in my previous post.

Re: axis title/labels not using Arial font

Posted: Thu Oct 25, 2012 8:51 am
by yeray
Hi,

The easiest will probably be using GDI+:

Code: Select all

  g:=TGDIPlusCanvas.Create;
  Chart1.Canvas:=g;
  g.AntiAliasText:=gpfDefault;
  //g.AntiAlias:=false;