/*
 *   ttf2tfm.h
 *
 *   This file is part of the ttf2pk package.
 *
 *   Copyright 1997-1998 by
 *     Frederic Loyer <loyer@ensta.fr>
 *     Werner Lemberg <wl@gnu.org>
 */

#ifndef TTF2TFM_H
#define TTF2TFM_H

#include <stdio.h>


enum Boolean_
{
  False = 0,
  True = 1
};

typedef enum Boolean_ Boolean;


struct _encoding
{
  char *name;
  char *vec[256];
};
typedef struct _encoding encoding;


/*
 *   This is what we store character data in.
 */

struct _ttfinfo;
typedef struct _ttfinfo ttfinfo;
struct _lig;
typedef struct _lig lig;
struct _kern;
typedef struct _kern kern;
struct _ttfptr;
typedef struct _ttfptr ttfptr;
struct _pcc;
typedef struct _pcc pcc;


struct _ttfinfo
{
  ttfinfo *next;
  long charcode;                /* the TTF character code (or glyph index */
                                /* if bit 17 is set)                      */
  unsigned short glyphindex;    /* the TTF glyph number */
  short incode;                 /* the code position in the raw TeX font */
  short outcode;                /* the code position in the virtual font */
  char *adobename;

  short width;
  short llx, lly, urx, ury;

  lig *ligs;
  kern *kerns;
  ttfptr *kern_equivs;
  pcc *pccs;                    /* we use the composite feature for */
                                /* `germandbls' <--> `SS' only      */
  unsigned char wptr, hptr, dptr, iptr;
};


struct _lig
{
  lig *next;
  char *succ, *sub;
  short op, boundleft;
};


struct _kern
{
  kern *next;
  char *succ;
  short delta;
};


struct _ttfptr
{
  ttfptr *next;
  ttfinfo *ch;
};


struct _pcc
{
  pcc *next;
  char *partname;
  short xoffset, yoffset;
};


struct _Font
{
  char *ttfname;

  /*
   *   Full path and extension of the tfm file
   */

  char *tfm_path;
  char *tfm_ext;

  /*
   *   The final tfm name is composed of the following three parts.
   */

  char *outname;            /* only namestem without extension */
  char *subfont_name;       /* NULL if not used */
  char *outname_postfix;    /* NULL if not used */
  char *fullname;           /* outname + subfont_name + outname_postfix */

  FILE *vplout;
  FILE *tfmout;

  /*
   *   The input encoding maps from the TrueType font the raw TeX font.
   */

  char *inencname;                  /* name of input encoding file */
  encoding *inencoding;             /* the input encoding vector */
  ttfinfo *inencptrs[256];          /* the input mapping table.  Will be
                                       filled initially with the first
                                       256 characters in the selected
                                       cmap of the TrueType font */
  /*
   *   The output encoding maps from the raw TeX font to the virtual font.
   */

  char *outencname;                 /* name of output encoding file */
  encoding *outencoding;            /* the output encoding vector */
  ttfinfo *outencptrs[256];         /* the output mapping table */

  short nextout[256];               /* for characters encoded multiple times
                                       in output */

  Boolean sawligkern;               /* there were LIGKERN lines in the
                                       output encoding file */

  ttfinfo *charlist;                /* a linked list of all valid chars */

  ttfinfo *uppercase[256];          /* needed for small caps fonts */
  ttfinfo *lowercase[256];          /* ditto */

  short boundarychar;               /* the boundary character */
  char *codingscheme;               /* coding scheme for TeX */
  char *titlebuf;

  /*
   *   The name of the subfont definition file.
   */

  char *sfdname;
  long sf_code[256];

  /*
   *   We get the following three values from the TTF's postscript table.
   */

  short units_per_em;
  float italicangle;
  char fixedpitch;

  unsigned long fontindex;          /* font number in TTC */

  unsigned short pid;               /* the TTF platform ID */
  unsigned short eid;               /* the TTF encoding ID */

  short xheight;                    /* xheight for TeX */
  short fontspace;                  /* font space for TeX */

  /*
   *   These values can be specified on the command line.
   */

  float efactor;                    /* to extend the glyphs horizontally */
  float slant;                      /* to slant the font */
  float capheight;                  /* the height of small caps glyphs */

  /*
   *   The command line parameter strings.
   */

  char *efactorparam;
  char *slantparam;
  char *fontindexparam;
  char *pidparam;
  char *eidparam;
};
typedef struct _Font Font;

#endif /* TEX2TFM_H */


/* end */
