Re: More with imagettfbbox(); absolute url not working? [message #173372 is a reply to message #173366] |
Tue, 05 April 2011 09:09 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma:
|
Senior Member |
|
|
On 4/5/2011 12:19 AM, Mr. B-o-B wrote:
> jwcarlton cried from the depths of the abyss...
>
>> I'm still working with imagettfbbox(). The problem I'm having now is
>> that I can't seem to refer to the TTF file unless it's in the actual
>> directory as the index.php file; if I give a relative or absolute
>> path, I'm getting an error:
>>
>> Warning: imagettfbbox() [function.imagettfbbox]: Could not find/open
>> font in /home/accountname/public_html/variables.php on line 152
>>
>> For this system, I have a variables.php file, located at the /
>> public_html/ directory. This is the file that uses imagettfbbox(),
>> like so:
>>
>> $home = "http://www.example.com";
>>
>> define("F_SIZE", 9);
>>
>> // This is the problem line, # 152 in the error
>> define("F_FONT", "arialbd.ttf");
>>
>> function get_bbox($text) {
>> return imagettfbbox(F_SIZE, 0, F_FONT, $text);
>> }
>>
>>
>> Now, if I'm loading index.php that's in the same directory as
>> variables.php, then this works fine (obviously). In other directories,
>> though, it (obviously) can't find the arialbd.ttf file.
>>
>> In all files, I'm including variables.php like so:
>>
>> include "../variables.php";
>>
>> I've tried the following variations, but still get the same errors:
>>
>> // Found this recommendation somewhere
>> define("F_FONT", "./arialbd.ttf");
>>
>> // URLs are supposed to be OK
>> define("F_FONT", "$home/arialbd.ttf");
>>
>> // Using no variables, just type the URL straight in
>> define("F_FONT", "http://www.example.com/arialbd.ttf");
>>
>> // Thought that a relative path would at least work
>> // on the second-level directories
>> define("F_FONT", "../arialbd.ttf");
>>
>>
>> Finally, I tried removing define(), and switching to global variables,
>> but had the same error:
>>
>> $f_size = "9";
>> $f_font = "$home/arialbd.ttf";
>>
>> function get_bbox($text) {
>> global $f_size;
>> global $f_font;
>>
>> return imagettfbbox($f_size, 0, $f_font, $text);
>> }
>>
>>
>> Can you guys tell me the correct way to define the path to arialbd.ttf
>> here?
>>
>> TIA,
>>
>> Jason
>>
>
>
> Are you running this on a *nix or windows box?
>
> If $fontfile is a Windows UNC path, it *must* start with //SERVER rather
> than \\SERVER
Incorrect. Windows boxes do not need UNC paths if they are on the same
machine, so you do NOT need to use //SERVER to access the file.
But in this case it makes no difference whether this is Windows or
Linux. His problem is accessing the file via relative path.
P.S. ////SERVER also works quite well where it is required.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|