Back to index

tetex-bin  3.0
Defines | Functions | Variables
gdft.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "gd.h"
#include "gdhelpers.h"
#include "entities.h"
#include <unistd.h>

Go to the source code of this file.

Defines

#define NUMCOLORS   8
#define LISTSEPARATOR   ";"
#define FALSE   0
#define TRUE   !FALSE
#define MAX(a, b)   ((a)>(b)?(a):(b))
#define MIN(a, b)   ((a)<(b)?(a):(b))

Functions

static char * font_path (char **fontpath, char *name_list)
static char * font_pattern (char **fontpath, char *fontpattern)
 BGD_DECLARE (char *)
 BGD_DECLARE (int)

Variables

static int fontConfigFlag = 0

Define Documentation

#define FALSE   0

Definition at line 66 of file gdft.c.

#define LISTSEPARATOR   ";"

Definition at line 46 of file gdft.c.

#define MAX (   a,
  b 
)    ((a)>(b)?(a):(b))

Definition at line 70 of file gdft.c.

#define MIN (   a,
  b 
)    ((a)<(b)?(a):(b))

Definition at line 71 of file gdft.c.

#define NUMCOLORS   8

Definition at line 29 of file gdft.c.

#define TRUE   !FALSE

Definition at line 67 of file gdft.c.


Function Documentation

BGD_DECLARE ( char *  )

Definition at line 74 of file gdft.c.

{
  /* 2.0.6: valid return */
  return gdImageStringFT (im, brect, fg, fontlist, ptsize,
                       angle, x, y, string);
}

Definition at line 1617 of file gdft.c.

{
#ifdef HAVE_LIBFONTCONFIG
       fontConfigFlag = 1;
       return 1;
#else
       return 0;
#endif /* HAVE_LIBFONTCONFIG */
}
static char * font_path ( char **  fontpath,
char *  name_list 
) [static]

Definition at line 1514 of file gdft.c.

{
  int font_found = 0;
  char *fontsearchpath, *fontlist;
  char *fullname = NULL;
  char *name, *path, *dir;
  char *strtok_ptr;

  /*
   * Search the pathlist for any of a list of font names.
   */
  *fontpath = NULL;
  fontsearchpath = getenv ("GDFONTPATH");
  if (!fontsearchpath)
    fontsearchpath = DEFAULT_FONTPATH;
  fontlist = strdup (name_list);

  /*
   * Must use gd_strtok_r else pointer corrupted by strtok in nested loop.
   */
  for (name = gd_strtok_r (fontlist, LISTSEPARATOR, &strtok_ptr); name;
       name = gd_strtok_r (0, LISTSEPARATOR, &strtok_ptr))
    {

      /* make a fresh copy each time - strtok corrupts it. */
      path = strdup (fontsearchpath);
      /*
       * Allocate an oversized buffer that is guaranteed to be
       * big enough for all paths to be tested.
       */
      /* 2.0.22: Thorben Kundinger: +8 is needed, not +6. */
      fullname = gdRealloc (fullname,
                          strlen (fontsearchpath) + strlen (name) + 8);
      /* if name is an absolute or relative pathname then test directly */
      if (strchr (name, '/')
         || (name[0] != 0 && name[1] == ':'
             && (name[2] == '/' || name[2] == '\\')))
       {
         sprintf (fullname, "%s", name);
         if (access (fullname, R_OK) == 0)
           {
             font_found++;
              /* 2.0.16: memory leak fixed, Gustavo Scotti */
              gdFree (path);
             break;
           }
       }
      for (dir = strtok (path, PATHSEPARATOR); dir;
          dir = strtok (0, PATHSEPARATOR))
       {
          if (strchr (name, '.'))
           {
             sprintf (fullname, "%s/%s", dir, name);
             if (access (fullname, R_OK) == 0)
               {
                 font_found++;
                 break;
               }
             else
              {
                continue;
              }
            }
         sprintf (fullname, "%s/%s.ttf", dir, name);
         if (access (fullname, R_OK) == 0)
           {
             font_found++;
             break;
           }
         sprintf (fullname, "%s/%s.pfa", dir, name);
         if (access (fullname, R_OK) == 0)
           {
             font_found++;
             break;
           }
         sprintf (fullname, "%s/%s.pfb", dir, name);
         if (access (fullname, R_OK) == 0)
           {
             font_found++;
             break;
           }
         sprintf (fullname, "%s/%s.dfont", dir, name);
         if (access (fullname, R_OK) == 0)
           {
             font_found++;
             break;
           }
       }
      gdFree (path);
      if (font_found)
       break;
    }
  gdFree (fontlist);
  if (!font_found)
    {
      free (fullname);
      return "Could not find/open font";
    }

  *fontpath = fullname;
  return NULL;
}

Here is the call graph for this function:

static char* font_pattern ( char **  fontpath,
char *  fontpattern 
) [static]

Variable Documentation

int fontConfigFlag = 0 [static]

Definition at line 31 of file gdft.c.