Font file not found

Recommend this page to a friend!

      Captcha Numbers V2.1  >  All threads  >  Font file not found  >  (Un) Subscribe thread alerts  
Subject:Font file not found
Summary:Debian truetype fonts not where GD expects them...
Messages:3
Author:Richard Munroe
Date:2005-11-04 14:43:02
Update:2006-04-11 07:29:55
 

  1. Font file not found   Reply   Report abuse  
Richard Munroe - 2005-11-04 14:43:02
Included is a patch to Captcha Numbers V2 to allow fonts (with paths) to be specified in the constructor. I needed this on a Debian Linux system to get to the Arial font which is provided by MicroSoft and installed in a sub-directory of /usr/share/fonts/truetype (which is where GD is looking for them).

Index: captcha_numbersV2.php
===================================================================
RCS file: /home/Repository/captcha/captcha_numbersV2.php,v
retrieving revision 1.1
retrieving revision 1.3
diff -c -4 -r1.1 -r1.3
*** captcha_numbersV2.php 4 Nov 2005 11:26:47 -0000 1.1
--- captcha_numbersV2.php 4 Nov 2005 14:31:38 -0000 1.3
***************
*** 1,5 ****
--- 1,13 ----
<?
+ /*
+ ** Edit History:
+ **
+ ** Dick Munroe (munroe@csworks.com) 04-Nov-2005
+ ** Add a font specifier to the constructor allowing
+ ** font paths to be specified.
+ */
+
/**
* CaptchaV2 File
* Generates CAPRCHA Numbers and Chars Image
* @author Albert Demeter <borex8@hotmail.com>
***************
*** 24,32 ****
/**
* CaptchaNumbersV2 Class
* @access public
* @author Albert Demeter <borex8@hotmail.com>
! * @version 2.0
*/

class CaptchaNumbersV2 {
var $length = 6;
--- 32,40 ----
/**
* CaptchaNumbersV2 Class
* @access public
* @author Albert Demeter <borex8@hotmail.com>
! * @version 2.0.1
*/

class CaptchaNumbersV2 {
var $length = 6;
***************
*** 43,56 ****
* @return void
* @param int $length string length
* @param int $size font size
* @param String $type image type
! * @param String $captchaType text contain digits, chars or mixed
* @desc generate the main image
*/
! function CaptchaNumbersV2($length = '', $size = '', $type = '', $captchaType = '') {

! if ($length!='') $this -> length = $length;
if ($size!='') $this -> size = $size;
if ($type!='') $this -> type = $type;
if ($captchaType!='') $this -> captchaType = $captchaType;

--- 51,66 ----
* @return void
* @param int $length string length
* @param int $size font size
* @param String $type image type
! * @param String $captchaType text contain digits, chars or mixed
! * @param String $font the font and optionally path to be used.
* @desc generate the main image
*/
! function CaptchaNumbersV2($length = '', $size = '', $type = '', $captchaType = '', $font = '') {

! if ($length!='') $this -> length = $length;
! if ($font!='') $this -> font = $font ;
if ($size!='') $this -> size = $size;
if ($type!='') $this -> type = $type;
if ($captchaType!='') $this -> captchaType = $captchaType;


Thanks for the effort to produce this class.

Dick Munroe

  2. Re: Font file not found   Reply   Report abuse  
Chris Smith - 2006-04-11 07:29:55 - In reply to message 1 from Richard Munroe
Strange what you are saying: I have tried it on Debian Sarge, with an Freetype font (which was mentioned in the readme file) outside the htdocs-dir (one dir upper), the virtualhost is "open_basedir"-ed (so it can't include fonts from the filesystem), and it's working perfectly (I have just edit the class to specify the path of the font, which is also outside the htdocs-dir).
(Also I had to install the php4-gd package which was not installed by default.)

BTW: Thanks for this class ! (And greetings from Hungary)

  3. Re: Font file not found   Reply   Report abuse  
Albert Demeter - 2019-03-17 11:16:57 - In reply to message 1 from Richard Munroe
Modified class ctor to allow setting fonts folder. If folder is set in ctor then fonts are loaded from this folder.

 

For more information send a message to info at phpclasses dot org.