Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.4.0

Bug #16929 SVG incorrectly contains absolute path to font file in font-family
Submitted: 2009-12-19 02:29 UTC
From: daveo Assigned:
Status: Open Package: Image_Canvas (version 0.3.2)
PHP Version: Irrelevant OS: Linux
Roadmaps: (Not assigned)    
Subscription  


 [2009-12-19 02:29 UTC] daveo (Steve Cho)
Description: ------------ having the absolute path will make the SVG file machine specific. Not all machines will have the font in the same location. The line 761 in SVG.php needs to be changed. Easiest fix would be to enclose this->_font['name'] in the basename function Expected result: ---------------- <text x="0" y="0" style="font-family:verdana.ttf;font-size:8px;fill:rgb(0,0,0);text-anchor:end;">500</text> Actual result: -------------- <text x="0" y="0" style="font-family:/abosolute/path/to/font/on/linux/verdana.ttf;font-size:8px;fill:rgb(0,0,0);text-anchor:end;">500</text>

Comments

 [2009-12-19 02:37 UTC] daveo (Steve Cho)
I take that back about basename. It isn't enitrely correct. I would recommend pathinfo and use the 'filename' element. That way, the extension will be stripped off. The presense of the extension could cause a problem when a machine doens't have an OpenType version of a TrueType font and vice-versa, and other combinations etc...
 [2009-12-20 18:16 UTC] doconnor (Daniel O'Connor)
Are you able to provide a small executable test case to demonstrate this bug?
 [2009-12-24 18:45 UTC] daveo (Steve Cho)
<?php require_once 'Image/Graph.php'; // create the graph $Graph =& Image_Graph::factory('graph', array(400, 300)); // add a TrueType font $Font =& $Graph->addNew('font', '/var/www/htdocs/o3map/verdana.ttf'); // set the font size to 11 pixels $Font->setSize(8); $Graph->setFont($Font); $Matrix =& $Graph->addNew('Image_Graph_Layout_Matrix', array(2, 2)); $Graph->add( Image_Graph::vertical( Image_Graph::factory('title', array('X-axis Angle Sample', 12)), Image_Graph::vertical( $Plotarea = Image_Graph::factory('plotarea'), $Legend = Image_Graph::factory('legend'), 90 ), 5 ) ); //$Legend->setPlotarea($Plotarea); // create the dataset $Dataset1 =& Image_Graph::factory('random', array(10, 2, 15, false)); $Dataset2 =& Image_Graph::factory('random', array(10, 2, 15, false)); $Dataset3 =& Image_Graph::factory('random', array(10, 2, 15, false)); $Dataset4 =& Image_Graph::factory('random', array(10, 2, 15, false)); $Plotarea =& $Matrix->getEntry(0, 0); $Plot =& $Plotarea->addNew('bar', array(&$Dataset1)); $Plot->setLineColor('gray'); $Plot->setFillColor('red@0.2'); $Plot->setSpacing(2); $Marker =& $Plot->addNew('Image_Graph_Marker_Value', IMAGE_GRAPH_VALUE_Y); $PointingMarker =& $Plot->addNew('Image_Graph_Marker_Pointing_Angular', array(20, &$Marker)); $Plot->setMarker($PointingMarker); $Plotarea->setAxisPadding(1, 'left'); $Plotarea->addNew('title', array('x-axis angle should be at 335', array('size' => 7))); $Plotarea->setAxisPadding(40, 'top'); $AxisX =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X); $AxisX->setFontAngle(335); $AxisX->setLabelOption('offset', 10); $AxisX->setFont(&$Font); $AxisX->setFontColor('red@0.5'); $Plotarea =& $Matrix->getEntry(0, 1); $Plot =& $Plotarea->addNew('bar', array(&$Dataset2)); $Plot->setLineColor('gray'); $Plot->setFillColor('blue@0.2'); $Plot->setSpacing(2); $Marker =& $Plot->addNew('Image_Graph_Marker_Value', IMAGE_GRAPH_VALUE_Y); $PointingMarker =& $Plot->addNew('Image_Graph_Marker_Pointing_Angular', array(20, &$Marker)); $Plot->setMarker($PointingMarker); $Plotarea->setAxisPadding(1, 'left'); $Plotarea->addNew('title', array('x-axis angle should be at 90', array('size' => 7))); $Plotarea->setAxisPadding(40, 'top'); $AxisX =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X); $AxisX->setFontAngle(90); $AxisX->setLabelOption('offset', 10); $AxisX->setFont(&$Font); $Plotarea =& $Matrix->getEntry(1, 0); $Plot =& $Plotarea->addNew('bar', array(&$Dataset3)); $Plot->setLineColor('gray'); $Plot->setFillColor('orange@0.2'); $Plot->setSpacing(2); $Marker =& $Plot->addNew('Image_Graph_Marker_Value', IMAGE_GRAPH_VALUE_Y); $PointingMarker =& $Plot->addNew('Image_Graph_Marker_Pointing_Angular', array(20, &$Marker)); $Plot->setMarker($PointingMarker); $Plotarea->setAxisPadding(1, 'left'); $Plotarea->addNew('title', array('x-axis angle should be at 45', array('size' => 7))); $Plotarea->setAxisPadding(40, 'top'); $AxisX =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X); $AxisX->setFontAngle(45); $AxisX->setLabelOption('offset', 10); $AxisX->setFont(&$Font); //$Graph->done(); //exit; // output the graph using the GD canvas $Graph->done(array('filename' => './temp/foo1.svg')); // create a new SVG canvas $Canvas =& Image_Canvas::factory('svg', array( 'width' => 600, 'height' => 400 ) ); // make the graph use this now instead $Graph->setCanvas($Canvas); // 're'-output the graph, but not using the SVG canvas $Graph->done(array('filename' => './temp/foo1.svg')); ?> <html> <head> <title>PEAR Image_Graph sample</title> </head> <body> <object data="./temp/foo1.svg" type="image/svg+xml" style="width: 8in; height: 11in"> <img src="./temp/foo1.svg" alt="Alt text" width="144" height="144" /> </object> </body> </html>