php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26764 Spaces in Font Pathnames
Submitted: 2004-01-01 23:43 UTC Modified: 2004-01-04 00:43 UTC
From: choinet at rocketmail dot com Assigned:
Status: Not a bug Package: GD related
PHP Version: 4.3.4 OS: Windows/Linux
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:

 

 [2004-01-01 23:43 UTC] choinet at rocketmail dot com
Description:
------------
This report stems from bug report #26635, where spaces are not allowed in the pathname. There are more details towards the end of that report (http://bugs.php.net/26635) as to how I am sure that pathnames with spaces do not work.

In fact, I have found out that spaces in the fontfile argument gd functions, such as imagettftext() are used to denote multiple fonts, which explains why trying to open pathnames with spaces in them did not work. I have found this by inserting two working paths into the fontfile argument of the above function and alternating their order to verify that they are both being opened correctly.

What I am wondering is if there can be a different font list separator character than a space, such as &, that is not used in the directory naming convention to delimit the fonts specified in the fontfile argument, so that users may link to a font file with a space-containing pathname.

Reproduce code:
---------------
<?php
$image = imagecreate(100, 100);

// Example 1: no spaces in pathname
$path = 'c:\arial.ttf';
imagettftext($image, 12, 0, 50, 50, $color, $path, "Hello");

// Example 2: space in pathname
$path = 'c:\test folder\arial.ttf';
imagettftext($image, 12, 0, 50, 50, $color, $path, "Hello");

// Example 3: no spaces in multiple font pathnames
$path = 'c:\arial.ttf';
$path2 = 'c:\cour.ttf';
imagettftext($image, 12, 0, 50, 50, $color, "$path $path2", "Hello"); //note the space between the two pathnames

// Example 4: spaces in multiple font pathnames
$path = 'c:\test folder\arial.ttf';
$path2 = 'c:\test folder\cour.ttf';
imagettftext($image, 12, 0, 50, 50, $color, "$path $path2", "Hello"); //note the space between the two pathnames
?>

Expected result:
----------------
I expect no errors in each case.

Actual result:
--------------
(Taking each example one at a time by commenting out the others)
Example 1:
(no error)

Example 2:
Warning: imagettftext(): Could not find/open font in C:\Program Files\Apache Group\Apache2\htdocs\index.php on line 10

Example 3:
(no error)

Example 4:
Warning: imagettftext(): Could not find/open font in C:\Program Files\Apache Group\Apache2\htdocs\index.php on line 20

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-01-02 10:59 UTC] sniper@php.net
There is no bug here, can't you accept that? 
(and no, you can NOT pass multiple font files to these functions)

 [2004-01-03 13:06 UTC] choinet at rocketmail dot com
Au contraire, Rasmus says:

---
Since libgd supports multiple alternate font paths separated by spaces, it is not possible to use individual font paths with spaces in them.

Example: 

$path = 'c:\test folder\arial.ttf';
imagettftext($image, 12, 0, 50, 50, $color, $path, "Hello");

...
It is obvious from looking at the code that it is just doing a simple strtok on the separator without any further logic.  The relevant code is:

[code segment in ext/gd/libgd/gdft.c]
---

He also said to either get Boutell to fix it or go create a patch on my own. I understand that there was some deep confusion surrounding the problem, but nevertheless I'm currently in the process of resolving this issue.
 [2004-01-03 13:15 UTC] derick@php.net
It's still bogus, as it's not a bug in PHP
 [2004-01-03 13:27 UTC] choinet at rocketmail dot com
In other words, the external code must be changed by Boutell?
 [2004-01-03 20:59 UTC] a at b dot c dot de
I mentioned this to Thomas Boutell when I learned about it; GD_Lib 2.0.18 is expected to use a semicolon ';' as path separator instead of a space.

If you want to recompile it yourself, the change is to
#define LISTSEPARATOR
in gdft.c
 [2004-01-04 00:43 UTC] choinet at rocketmail dot com
Nice to hear, that's exactly what I had suggested to Thomas Boutell.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed May 15 17:01:33 2024 UTC