php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26635 imagettfbbox() & imagettftext() fontfile does not allow relative path
Submitted: 2003-12-15 13:22 UTC Modified: 2004-01-02 10:52 UTC
Votes:2
Avg. Score:4.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:2 (100.0%)
From: choinet at rocketmail dot com Assigned:
Status: Closed Package: GD related
PHP Version: 4CVS-2003-12-28 OS: Windows XP
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: choinet at rocketmail dot com
New email:
PHP Version: OS:

 

 [2003-12-15 13:22 UTC] choinet at rocketmail dot com
Description:
------------
array imagettfbbox ( int size, int angle, string fontfile, string text)

This is the prototype for the imagettfbbox() function, and the fontfile argument is the same for the imagettftext() function. On Windows, there is a problem with using relative paths to the fontfile. Full absolute pathname must be used.

On Linux systems, however, both absolute and relative pathnames to the fontfile are allowed.

In addition, the absolute pathname to the fontfile must have no spaces in it, and pathnames that do have spaces must use the DOS naming convention (e.g. C:\Progra~1\Apache~1\apache2\arial.ttf). This can become quite annoying.

So in summary, the imagettfbbox() and imagettftext() do not allow relative paths to the fontfile, and do not allow spaces in the paths, either, on Windows. I did not have this problem before in the summertime when I used an earlier release of PHP 4.

Reproduce code:
---------------
[text.php]
<?php
$fp = imagecreate(300, 100);
$color1 = imagecolorallocate($fp, 255, 255, 255);
$color2 = imagecolorallocate($fp, 0, 0, 153);
$path = 'arial.ttf';
imagettftext($fp, 12, 0, 50, 35, $color2, $path, 'test');
?>

the arial true-type font file is in the same directory as text.php.

Expected result:
----------------
I expect to see a white image with the blue text saying 'test.'

Actual result:
--------------
Warning: imagettftext(): Could not find/open font in C:\Program Files\Apache Group\Apache2\htdocs\text.php on line 5

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-12-15 15:31 UTC] iliaa@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 13:01:28 2024 UTC