Problem to show fonts
Posted by: psn (---.tbcn.telia.com)
Date: April 17, 2008 11:37PM

Hi,

I'm using a tracking system called pphlogger and I have som problem due to show the fonts. I get an error in my php log file:

[17-Apr-2008 23:27:14] PHP Warning: imagettfbbox() [<a href='function.imagettfbbox'>function.imagettfbbox</a>]: Invalid font filename in E:\wamp\www\pphlogger\modules\image_gen.php on line 59

[17-Apr-2008 23:27:14] PHP Warning: imagettftext() [<a href='function.imagettftext'>function.imagettftext</a>]: Invalid font filename in E:\wamp\www\pphlogger\modules\image_gen.php on line 76

The code for image_gen.php:
<?php


if (!$visible || $showme == 'n') {
Header("Content-type: image/gif; charset=ISO-8859-1"winking smiley;
readfile(CFG_IMG_PATH.'clear.gif');
} else {
$img_format = get_gd_type();

if (!isset($show_txt)) $show_txt = $hits;

// include the color array
include INC_COLORARRAY;

//default values:
if(!isset($bg_c)) $bg_c = "black";
if(!isset($bg_trans)) $bg_trans = 0;
if(!isset($fg_c)) $fg_c = "#C9C1FF";
if(!isset($ttf_file)) $ttf_file = "/usr/local/fonts/arialbd.ttf";
if(!isset($show_txt)) $show_txt = "undefined";
if(!isset($ttf_size)) $ttf_size = 14;
$txt_length = strlen($show_txt);



/*
* This workaround should fix the famous Freetype bug in any
* GD2.x versions and buggy GD in PHP 4.0.6.
*
* [bugs.php.net]
* --> [bugs.php.net]
* --> [bugs.php.net]
*/

// make sure we got an absolute path - this is required in GD2!
if (@$ttf_location == 'relative' || @$ttf_location == '') {
$ttf_realdir = (function_exists('realpath')) ? realpath(CFG_TTF_PATH).'/' : CFG_TTF_PATH;
} else {
$ttf_realdir = @$ttf_location;
}
// Set the path to you fonts dir
$putenv_gdfontpath = @putenv('GDFONTPATH='.$ttf_realdir);
if(CFG_OLDGD || !$putenv_gdfontpath) {
// In some ancient GD1 versions (mainly in PHP3), ImageTTFBBox only accepts
// filenames including their path.
$ttf_file = $ttf_realdir.$ttf_file;
} else {
// Make sure there is no .ttf extension, GD2 doesn't like this!
$ttf_file = eregi_replace('.ttf','',$ttf_file);
}


if ($Freetype_enabled) {
$size=ImageTTFBBox($ttf_size,0,$ttf_file,$show_txt);//THIS IS ROW 59
$SizeX = $size[2]-$size[0] + 6;
$SizeY = $size[1]-$size[5] + 4;
} else {
$SizeX = strlen($show_txt)*($gd_font + 5);
$SizeY = ($gd_font == 1) ? 15 : 20;
}

$im = imagecreate($SizeX, $SizeY);

$c = getRGB($bg_c);
$bgcolor = ImageColorAllocate($im, $c["red"], $c["green"], $c["blue"]);
if ($bg_trans) $bgcolortrans = ImageColorTransparent($im, $bgcolor);
$c = getRGB($fg_c);
$fgcolor = ImageColorAllocate($im, $c["red"], $c["green"], $c["blue"]);

if ($Freetype_enabled) {
ImageTTFText($im,$ttf_size,0,2,-$size[5],$fgcolor,$ttf_file,$show_txt);//THIS IS ROW 76
} else {
ImageString($im, $gd_font, 3, 3, $show_txt, $fgcolor);
}

if ($img_format != 'auto') { // GIF support was removed in GDlib v.1.6
$fct_image = 'image'.$img_format;
Header('Content-type: image/'.$img_format);
$fct_image($im);
} else {
Header("Content-type: image/gif; charset=ISO-8859-1"winking smiley;
readfile(CFG_IMG_PATH."clear.gif"winking smiley;
}
ImageDestroy($im);
}
?>

I have my gd enabled and I run php 5.2.5 (The above works for lower version as 4.7.x), how can I correct this part?

Regards/Per

Options: ReplyQuote
Re: Problem to show fonts
Posted by: psn (---.tbcn.telia.com)
Date: April 18, 2008 06:26AM

Anyone have an ide about this problem?

Regards/Per

Options: ReplyQuote
Re: Problem to show fonts
Posted by: stevenmartin99 (193.120.116.---)
Date: April 18, 2008 08:13AM

i dunno.. Look up php webite for the differences in php 4 and 5 . It will tell u wat has changed

Options: ReplyQuote
Re: Problem to show fonts
Posted by: toivo (203.19.130.---)
Date: April 18, 2008 03:13PM

Hi Per,

In the Wamp environment you are unlikely to have the path "/usr/local/fonts/arialbd.ttf". You need to modify the following line to point to the font file:

if(!isset($ttf_file)) $ttf_file = "/usr/local/fonts/arialbd.ttf";

The script seems to have a number of path constants which must be set correctly in a configuration or initialization script of some sort:

CFG_IMG_PATH
CFG_TTF_PATH
GDFONTPATH

Regards,

toivo
Sydney, Australia

Options: ReplyQuote
Re: Problem to show fonts
Posted by: yfastud (Moderator)
Date: April 18, 2008 05:39PM

I've been using it for years and never had that problem, and as toivo pointed out, the path in your script is for *nix, so make sure to check w/ your host to have the correct path, and for testing on windows, you have to change the path to the proper one. Anyway, try this code which is in my file

if(!isset($ttf_file)) $ttf_file  = "arialbd.ttf";

Have fun,

FREE One A Day
FREE Photo
FREE Games
FREE Websites
FREE Portable GPS
FREE WAMP Guides

Options: ReplyQuote
Re: Problem to show fonts
Posted by: psn (---.tbcn.telia.com)
Date: April 18, 2008 11:10PM

I tried to change the above path but it still get no fonts showned.

Regards/Per

Options: ReplyQuote
Re: Problem to show fonts
Posted by: toivo (---.nsw.bigpond.net.au)
Date: April 18, 2008 11:53PM

Hi Per,

Do a search in the Windows folder or file system to find out where exactly the file arialbd.ttf is located. That is the path you need. It may just be the standard folder C:\Windows\Fonts where all the fonts usually are.

If you do not find arialbd.ttf, try using one of the other *.ttf files instead.


Regards,

toivo
Sydney, Australia



Edited 1 time(s). Last edit at 04/18/2008 11:54PM by toivo.

Options: ReplyQuote
Re: Problem to show fonts
Posted by: yfastud (Moderator)
Date: April 19, 2008 04:14AM

Actually, the correct path is pphlogger/ttf_fonts, but as mentioned above, that line of code works fine on my server

Have fun,

FREE One A Day
FREE Photo
FREE Games
FREE Websites
FREE Portable GPS
FREE WAMP Guides

Options: ReplyQuote
Re: Problem to show fonts
Posted by: psn (---.tbcn.telia.com)
Date: April 22, 2008 07:59AM

Ok but I can't seems to solve this. When I chose the option in admin setup part 2 "Freetype Enabled
If you cannot get your Freetype-library run at all or if your hosting provider doesn't wnat to install it, you could disable this. Users won't be able to use TTF-fonts for their counter display. Built-in fonts should be available, though." to be set false then I get the image but then I can't change font types from edit profile page.

Can it be anything that I have missed to ticked in around PHP settings in wamp? As we have this part up, can you explain more in details for each settings or can this part be found any where else?

Another quest around path, should I change this in the main.location page:
if(!defined('PPHL_SCRIPT_PATH')) define('PPHL_SCRIPT_PATH', './');
??

Regards/Per



Edited 2 time(s). Last edit at 04/22/2008 08:47AM by psn.

Options: ReplyQuote
Re: Problem to show fonts
Posted by: psn (---.tbcn.telia.com)
Date: April 22, 2008 09:04AM

yfastud Wrote:
-------------------------------------------------------
> I've been using it for years and never had that
> problem, and as toivo pointed out, the path in
> your script is for *nix, so make sure to check w/
> your host to have the correct path, and for
> testing on windows, you have to change the path to
> the proper one. Anyway, try this code which is in
> my file
>
>
> if(!isset($ttf_file)) $ttf_file =
> "arialbd.ttf";
>


Just a small clarification, its working with my host but not in the wampserver!
Also to Toivo: All path is set what I can see correctly only outstanding see my prev thread.

Regards/Per

Options: ReplyQuote
Re: Problem to show fonts
Posted by: yfastud (Moderator)
Date: April 22, 2008 01:33PM

You might want to post the screenshot to show the error since I have no problem to run it w/ wamp 1.6.6 on xp before and w/ wamp 2 on vista now ;-)

Have fun,

FREE One A Day
FREE Photo
FREE Games
FREE Websites
FREE Portable GPS
FREE WAMP Guides

Options: ReplyQuote
Re: Problem to show fonts
Posted by: psn (---.tbcn.telia.com)
Date: April 22, 2008 06:39PM

I don't get any error showned on screen, the fonts for imgage countern just don't shows. I do get error in php errorlog as I mentioned in my first thread. So I feel its concerning the image_gen.php but I can't figure out whats wrong and my guts is saying its around the ttf files or path to the same thats not working as expected.

I some respect I do get some strange error in the source code for showhits:
‰PNG

���
IHDR���������—ÊÜ����PLTEÿÿ€��€‹&à”���tRNS�@æØf��� IDATxœc`€����·Xs•����IEND®B`‚

So t seems that the image-gen cant generate image and I have tested all auto, png, gif and jpeg none works

I'm running wamp 2,0 on windows xp

Regards/Per



Edited 1 time(s). Last edit at 04/22/2008 06:56PM by psn.

Options: ReplyQuote
Re: Problem to show fonts
Posted by: psn (---.tbcn.telia.com)
Date: April 23, 2008 09:12PM

Yfastud, question to you: Have you change anything in the main_location.inc file, I was tmost thinking around this:
if(!defined('PPHL_CFG_PATH'))    define('PPHL_CFG_PATH'   , PPHL_SCRIPT_PATH);

Regards/Per



Edited 2 time(s). Last edit at 04/23/2008 10:56PM by psn.

Options: ReplyQuote
Re: Problem to show fonts
Posted by: yfastud (Moderator)
Date: April 24, 2008 03:07AM

No, I only change some other files, mainly to prevent people to access my log, but nothing w/ the font ;-)

Have fun,

FREE One A Day
FREE Photo
FREE Games
FREE Websites
FREE Portable GPS
FREE WAMP Guides

Options: ReplyQuote
Re: Problem to show fonts
Posted by: psn (---.tbcn.telia.com)
Date: April 24, 2008 10:26PM

Now its working when I changed to lower version of php (4.4.7) so it seems this image_gen.php doesn't work for hihger versions. Do anyone know why?

Regards/Per

Options: ReplyQuote
Re: Problem to show fonts
Posted by: yfastud (Moderator)
Date: April 24, 2008 11:43PM

Syntax!!! most of them are not compatible w/ php5 :-(

Have fun,

FREE One A Day
FREE Photo
FREE Games
FREE Websites
FREE Portable GPS
FREE WAMP Guides

Options: ReplyQuote
Re: Problem to show fonts
Posted by: psn (---.tbcn.telia.com)
Date: April 24, 2008 11:56PM

Ok, every part of the code or can you point out which part where we need to change the code?

Regards/Per

Options: ReplyQuote
Re: Problem to show fonts
Posted by: yfastud (Moderator)
Date: April 25, 2008 01:15AM

well, not sure which part exactly, so you might want to check codes to make sure they're php5 compatible; however, I still wonder why I don't have any problem at all even I'm using it w/ latest wamp2

Have fun,

FREE One A Day
FREE Photo
FREE Games
FREE Websites
FREE Portable GPS
FREE WAMP Guides

Options: ReplyQuote
Re: Problem to show fonts
Posted by: psn (---.tbcn.telia.com)
Date: April 25, 2008 05:12PM

One question, if your part is working and you are using this function in php 5,2,5 then it must be a setting problem. Can you tell me which settings you have and which extention you have chosen for your php version?

Regards/Per

Options: ReplyQuote
Re: Problem to show fonts
Posted by: psn (---.tbcn.telia.com)
Date: April 29, 2008 07:10AM

Hi,

yfastud which settings and extension have you chosen in your php version 5,2,5 if this is working for you?

Regards/Per

Options: ReplyQuote


Sorry, only registered users may post in this forum.