pChart 2.x forum
http://wiki.pchart.net/forum/

Pathname of fonts
http://wiki.pchart.net/forum/viewtopic.php?f=1&t=30
Page 1 of 1

Author:  Jo van Duin [ Wed Dec 15, 2010 4:31 pm ]
Post subject:  Pathname of fonts

Hello,

I can't get any chart to work in my project. The examples do work.

I have the following directory-structure:

output (this is my root-directory)
|__libs
...|__Pchart
.........|__classes
.........|__fonts
.........|__examples

If I run localhost/output/libs/Pchart/examples/example.basic.php this works.

I copied the example.basic.php to the output-directory and changed the path.

When I run localhost/output/example.basic.php I get an error:
De afbeelding “http://localhost/output/example.basic.php” kan niet worden weergegeven, omdat deze fouten bevat.
(The image could not be loaded because it contains errors).

Sometimes I get the error: imagettfbbox() [function.imagettfbbox]: Invalid font filename
on line 168 of D:\wamp\www\output\libs\pChart\class\pImage.class

I have tried many different path's to the fonts directory but it doesn't work.

The altered source is show below.

<?php
/* @ 700x230 Really basic code. */

/* Include all the classes */
include("libs/pChart/class/pData.class");
include("libs/pChart/class/pDraw.class");
include("libs/pChart/class/pImage.class");

/* Create your dataset object */
$myData = new pData();

/* Add data in your dataset */
$myData->addPoints(array(1,3,4,3,5));

/* Create a pChart object and associate your dataset */
$myPicture = new pImage(700,230,$myData);

/* Choose a nice font */
$myPicture->setFontProperties(array("FontName"=>"libs/pChart/fonts/Forgotte.ttf","FontSize"=>10));

/* Define the boundaries of the graph area */
$myPicture->setGraphArea(60,40,670,190);

/* Draw the scale, keep everything automatic */
$myPicture->drawScale();

/* Draw the scale, keep everything automatic */
$myPicture->drawSplineChart();

/* Render the picture (choose the best way) */
$myPicture->autoOutput("basic.png");
?>

Author:  jovanduin@ziggo.nl [ Sat Dec 18, 2010 4:46 pm ]
Post subject:  Re: Pathname of fonts

Problem solved.

Author:  Rexyboy [ Wed Jan 05, 2011 12:12 am ]
Post subject:  Re: Pathname of fonts

jovanduin,
Can you let me know what you did to resolve this. I am sure that it is a simple solution but it appears that I am having the same problem at the moment.

Thanks.

Author:  mice32 [ Wed Jan 05, 2011 1:53 am ]
Post subject:  Re: Pathname of fonts

Rexyboy, try this (path to font from pImage class):
Code:
$myPicture->setFontProperties(array("FontName"=>"../fonts/Forgotte.ttf","FontSize"=>10));


Maybe, It will work :?

Author:  Rexyboy [ Wed Jan 05, 2011 8:05 am ]
Post subject:  Re: Pathname of fonts

I found the problem. As expected it was a silly one. I had a directory of fonts from v1.x and classes from 2.0.8. When I put a clean copy of classes and fonts from 2.0.10 all was good.

Thanks for your help.

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/