fonts

TeeChart for PHP
Post Reply
ISVA7655
Newbie
Newbie
Posts: 16
Joined: Tue Aug 23, 2011 12:00 am

fonts

Post by ISVA7655 » Wed Oct 12, 2011 7:32 pm

Having a bit of trouble with the textHeight method. I'm creating a blank canvas and writing 1-12 character string on to it using textOut. I then need to draw a rectangle or ellipse around that text.. actually I do it in the reverse order but it works fine. I use the textHeight($text) method to find the height in pixels to use for the rectangle. I notice that it always returns a height of 15 pixels, regardless of what point size i set the canvas pen to.

What font setting does the textHeight method reference ? I can set the canvas font size to default and textheight tells me what ever string I give it is 15 pixels high. I can then set the canvas font size to 20 pt and it tells me the height in pixels is 15. It always produces the same size rectangle regardless of the size of the actual height of the text "measured".

It's like it's referencing one of the other pens, footer, header etc.. ( I know it's not header).

$chart1->getGraphics3D()->textHeight("A");
$chart1->getGraphics3D()->textHeight("-");

I quick example to illustrate the problem:

// prep graph area

$xchartwidth = 800;
$ychartheight = 600;
$chart1 = new TChart($xchartwidth,$ychartheight);
$chart1->getChart()->getHeader()->getFont()->setSize(14);
$chart1->getChart()->getHeader()->setText("SCATTER PLOTTER");
$chart1->getAspect()->setView3D(false);
$chart1->getAxes()->setVisible(true); //false turns off the frame.....

// default font size is 8pt.

$chart1->render("chart1.png");
$g=$chart1->getGraphics3D();
$g->getBrush()->setVisible(true); //this turned on the color in the free canvas forms
$fs= $g->getFont()->getFontSize();
echo "font stuff fs = $fs <br>";
$hA = $g->textHeight("A");
$hu= $g->textHeight("-");
echo " fontsize ($fs) --text height of A = $hA -- height = $hu <br>";

// change font size to 6pt and repeat all measurements.

$chart1->getGraphics3D()->getFont()->setSize(6); // text written to canvas is now 6 point.
$fs= $g->getFont()->getFontSize();
echo "font stuff fs = $fs <br>";
$hA = $g->textHeight("A");
$hU= $g->textHeight("-");
echo " fontsize ($fs) --text height of A = $hA -- height = $hu <br>";

imagepng($chart1->getChart()->getGraphics3d()->img, "chart1.png"); //this seems to draw the image when ready
print '<font face="Verdana" size="2">Annotation Tool<p>';
print '<img src="chart1.png?rand='.$rand.'"><p>';

// end code

The result is textHeight returns the same value for the default font size (8pt) and for 6pt.

What's going on ?

**** New point.. I also use the textWidth method to get the width of the text string and use that to determine the width of the rectangle that is drawn around the text.. that works perfectly. If the font gets bigger the width returned are correct. Only the TextHeight value seems to be broken it's always 15 regardless of the size of the font used.

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

Re: fonts

Post by Yeray » Fri Oct 14, 2011 1:25 pm

Hello,

I've reproduce the situation here. We're investigating it and we'll be back here asap.
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

ISVA7655
Newbie
Newbie
Posts: 16
Joined: Tue Aug 23, 2011 12:00 am

Re: fonts

Post by ISVA7655 » Fri Oct 14, 2011 4:49 pm

Woohoo!!
I'm happy it's not my server this time. I bet this amounts to little more than a typo in the source code.

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

Re: fonts

Post by Yeray » Tue Oct 18, 2011 7:36 am

Hello,

We've corrected the textHeight function. Find the affected files attached.
TextHeight_fix.zip
(49.11 KiB) Downloaded 2660 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

ISVA7655
Newbie
Newbie
Posts: 16
Joined: Tue Aug 23, 2011 12:00 am

Re: fonts

Post by ISVA7655 » Tue Oct 18, 2011 3:38 pm

Excellent!! That appears to have done the trick.

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

Re: fonts

Post by Yeray » Wed Oct 19, 2011 7:16 am

Hi,

I'm glad to hear it! :)
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