Bug #64314 [Opn]: imagettfbbox loads wrong fontname if using ../ and underscore in font name

From: Date: Thu, 28 Feb 2013 22:26:09 +0000
Subject: Bug #64314 [Opn]: imagettfbbox loads wrong fontname if using ../ and underscore in font name
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-177482@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=64314&edit=1

 ID:                 64314
 User updated by:    ctcrmcou at opm dot gov
 Reported by:        ctcrmcou at opm dot gov
 Summary:            imagettfbbox loads wrong fontname if using ../ and
                     underscore in font name
 Status:             Open
 Type:               Bug
 Package:            GD related
 Operating System:   W7
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

I'd be happy to but it will be a few days before I can get to it.


Previous Comments:
------------------------------------------------------------------------
[2013-02-28 22:15:29] mail+php at requinix dot net

This is quite unusual, to see a filename being treated differently depending whether it has an
underscore. Can you include a complete, 
hopefully smallish script demonstrating the problem? That way someone (like me) can grab a handful
of font files and look for the cause.

------------------------------------------------------------------------
[2013-02-27 20:28:09] ctcrmcou at opm dot gov

Description:
------------
Assuming a subdirectory named "fonts" contains 30 fonts named font_1.ttf - font_30.ttf,
calling imagettfbox with a fontname such as "../fonts/font_10.ttf" loads incorrect font,
the number part is somehow being altered and the wrong font is loading.

Somehow the combination of ../ and _ in the finename param are screwing things up.  This is not a
file/font not found error.  This is the font that loads font_13.ttf is actually loading font_14.ttf,
or font_28.ttf is loading font_10.ttf.  I can only guess the underscore is changing the meaning of
the number or the number is being converted.

Test script:
---------------
Works:

$box=imagettfbbox(100,0,"fonts/font_10.ttf","some text");

Doesn't work (wrong font loads):

$box=imagettfbbox(100,0,"../fonts/font_10.ttf","some text");

Workaround 1: remove underscore from font names

$box=imagettfbbox(100,0,"../fonts/font10.ttf","some text");

Workaround 2: move app that loads font to higher directory level (no ../ in path)

$box=imagettfbbox(100,0,"fonts/font_10.ttf","some text");





------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=64314&edit=1


Thread (5 messages)

« previous php.bugs (#177482) next »