Re: More with imagettfbbox(); absolute url not working? [message #173369 is a reply to message #173363] |
Tue, 05 April 2011 07:17 |
alvaro.NOSPAMTHANX
Messages: 277 Registered: September 2010
Karma:
|
Senior Member |
|
|
El 05/04/2011 5:19, jwcarlton escribió/wrote:
> 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?
I think you've tried all combinations except absolute paths on *disc*:
define('F_FONT', '/home/accountname/public_html/arialbd.ttf')
Relative paths aren't practical because they are relative to the main
script's working directory and loading local files through the web
server is overkill.
--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--
|
|
|