Re: More with imagettfbbox(); absolute url not working? [message #173366 is a reply to message #173363] |
Tue, 05 April 2011 04:19 |
Mr. B-o-B
Messages: 42 Registered: April 2011
Karma:
|
Member |
|
|
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
|
|
|