PHP forum

More with imagettfbbox(); absolute url not working?

Apr 5, 2011 3:19 am
Jwcarlton

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

Apr 5, 2011 4:19 am
Mr. B-o-B
Re: More with imagettfbbox(); absolute url not working?

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


Apr 5, 2011 5:23 am
Jwcarlton
Re: More with imagettfbbox(); absolute url not working?

> 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

No, it's on Linux, with GD2 installed.


Apr 5, 2011 7:17 am
?lvaro G. Vicario
Re: More with imagettfbbox(); absolute url not working?

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
--


Previous Thread: Firefox PHP error report
Next Thread: Problem getting session through CURL

Related Forum Topics
Imagettfbbox() Probleme
Ich nutze imagettfbbox erfolgreich. mein Problem ist, dass es local
wunderbar geht. Ich nutzte es um einen Text der unterschiedliche länge
hat auszurichten.

Doch Local geht es wunderbar. Teste ich es auf dem Server, ist der Text
nicht mehr so wie gewolt ausgerichte. Jemand eine...
Using imagettfbbox with Arial Bold
I'm using imagettfbbox() to find the width of a variable-driven text
object. Like this:

$variable = "Business";
$fontsize = "9";
$fontface = "arialbd.ttf";

function get_bbox($text) { return imagettfbbox($fontsize, 0,
$fontface, $text); }

function t_width($text) {
$box =...
Relative v. absolute paths
I have a php file that when I include it from my homepage, I specify:

require_once './library/php/head.php';

head.php itself includes another php file in the middle of its text:

require_once './library/php/javascript.php';

That works and is all well and good.

However, if I...
Seeking help with relative and absolute paths
Hi Everyone,

Just playing with some PHP and getting my head around some of the 'gotchas' that this language and its use contain. I am hoping that there is a simple answer to this issue I am facing...so here goes:

I am designing a site (shock and horror) where I have the different elements...
Sql query not working
Hello,

I have the following sql line

$query = "select * from codes where " . user_code . "= binary " . "'"
. $result1 . "'" . "&&" . user_password . "= binary " . "'" . $result2
. "'" . "&&" . demo . "='yes'";

which works fine but if I use

. demo . "!='yes'

when a demo field in...
Defines not working
I have the following style of define in my code and they appear not to work:

define('myPrefix','Prefix') ;
define('item_1',myPrefix.'_1') ;
etc ...

The second define exapnds as myPrefix_1 instead of Prefix_1, any suggestions
what I am doing wrong?
Thanks,
Sid.



Got it working finally
www.mroldies.net

At least it is functioanl as I want it.


ODBC not working with PHP under Eclipse
Hi,
I'm trying to debug a simple page of PHP under Eclipse, with Zend
debugger.
I'm working on a local machine with Windows XP, IIS and SqlServer.

The problem is:
- if I run the PHP script directly from a browser, it's all OK (I can
connect to a db using odbc and execute queries).
- if I...
Isset not working with select
http://mroldies.net/showtable.php?year=1960



$result = mysql_query("SELECT acover,bcover FROM A$year WHERE id =
$number");
if (!$result) { echo 'Could not run query: ' . mysql_error(); exit; }
$cov = mysql_fetch_row($result);


if (isset($cov[0]))
{echo "<img...
Session stopped working?
I've been using FF2.n in developing a hideously complex FAMP app.
Last week, session seemed to stop working for no good reason. I
went into my zen-of-debugging mode, and investigated everything
in greater and greater depth, feeling sure I was somehow stepping
on something without realising...