Adjusting line height of TRectagleTool

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
jens.mertelmeyer
Newbie
Newbie
Posts: 31
Joined: Fri Nov 21, 2014 12:00 am

Adjusting line height of TRectagleTool

Post by jens.mertelmeyer » Wed Sep 02, 2015 3:36 pm

Hi there.
Please have a look at the following image:
Form2_2015-09-02_17-30-11.png
Form2_2015-09-02_17-30-11.png (40.42 KiB) Viewed 9084 times
On the left you see a normal TMemo straight from the VCL.
On the right, we have a TeeChart with a TRectangleTool on it. By themselves, they both look fine.

However, I am puzzled about the different line height of the TRectangleTool. There is more space between the lines. Is there a way to adjust the "line spacing"? I have found no way.

Many thanks in advance.

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

Re: Adjusting line height of TRectagleTool

Post by Yeray » Fri Sep 04, 2015 12:53 pm

Hello,

Can you please attach here that simple test 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

jens.mertelmeyer
Newbie
Newbie
Posts: 31
Joined: Fri Nov 21, 2014 12:00 am

Re: Adjusting line height of TRectagleTool

Post by jens.mertelmeyer » Fri Sep 04, 2015 3:49 pm

Sure. There's not much magic involved:

Code: Select all

procedure TForm3.createTool();
begin
	textRectangle := TRectangleTool.Create(Chart);
	textRectangle.ParentChart := Chart;

	textRectangle.Shape.Font.Assign(Font);
	textRectangle.Shape.Font.Color := TColors.Black; // I have no clue why this is necessary

	textRectangle.Text := Memo1.Lines.Text;
	textRectangle.Bounds := textRectangle.ParentChart.ClientRect;
	textRectangle.Shape.Transparency := 0;

	Chart.Tools.Add(textRectangle);
end;
Attachments
TextRectangleTool.zip
(5.14 KiB) Downloaded 697 times

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

Re: Adjusting line height of TRectagleTool

Post by Yeray » Mon Sep 07, 2015 10:49 am

Hello,

Thanks for sharing the test project.

This is because TeeChart uses GDIPlus by default since a few releases ago and different techniques are used to calculate the TextHeight.
Adding this to your test project gives a more similar result at both sides:

Code: Select all

type
  TCanvasAccess=class(TTeeCanvas3D);

//...

  Chart.Canvas:=TTeeCanvas3D.Create;
  TCanvasAccess(Chart.Canvas).FontQuality:=fqClearType;
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

jens.mertelmeyer
Newbie
Newbie
Posts: 31
Joined: Fri Nov 21, 2014 12:00 am

Re: Adjusting line height of TRectagleTool

Post by jens.mertelmeyer » Mon Sep 07, 2015 10:56 am

Yes, they're almost identical now. Thank you.

It still has a pretty different ... padding compared to a TMemo but I think I can sort that out. Thanks again.

Post Reply