Main Page | Data Structures | File List | Globals

libttf/libttf_private.h

00001 /*
00002 ** mouse:~ppr/src/libttf/libttf_private.h
00003 ** Copyright 1995--2000, Trinity College Computing Center.
00004 ** Written by David Chappell.
00005 **
00006 ** Permission to use, copy, modify, and distribute this software and its
00007 ** documentation for any purpose and without fee is hereby granted, provided
00008 ** that the above copyright notice appear in all copies and that both that
00009 ** copyright notice and this permission notice appear in supporting
00010 ** documentation.  This software is provided "as is" without express or
00011 ** implied warranty.
00012 **
00013 ** Last modified 21 November 2000.
00014 */
00015 
00016 /*
00017 ** This file is included by all of the modules in the library
00018 ** "libttf".  This file defines things the modules must know
00019 ** but that an external caller needn't.
00020 */
00021 
00022 /* For the time being, we will rely on some parts of PPR's
00023    libgu, so we must include its include file: */
00024 #include "gu.h"
00025 
00026 /* We should know everything an external caller will: */
00027 #include "libttf.h"
00028 
00029 /* We use setjmp/longjmp heavily */
00030 #include <setjmp.h>
00031 
00032 /* Turns on debugging */
00033 #if 0
00034 #define DEBUG 1
00035 #define DEBUG_INLINE 1
00036 #define DODEBUG(a) debug a
00037 #else
00038 #undef DEBUG
00039 #undef DEBUG_INLINE
00040 #define DODEBUG(a)
00041 #endif
00042 
00043 /* Types used in TrueType font files. */
00044 #define BYTE unsigned char
00045 #define USHORT unsigned short int
00046 #define SHORT short signed int
00047 #define ULONG unsigned int
00048 #define FIXED long signed int
00049 #define FWord short signed int
00050 #define uFWord short unsigned int
00051 
00052 /* This structure stores a 16.16 bit fixed
00053    point number. */
00054 typedef struct
00055         {
00056         short int whole;
00057         unsigned short int fraction;
00058         } Fixed;
00059 
00060 /* We use this magic value to be sure that the
00061    pointer passed to a libttf routine really points
00062    to a struct TTFONT. */
00063 #define TTF_SIGNITURE 1442
00064 
00065 /*
00066 ** This structure tells what we have found out about
00067 ** the current font.
00068 */
00069 struct TTFONT
00070         {
00071         int signiture;
00072 
00073         TTF_RESULT errno;                                       /* last error code */
00074 
00075         jmp_buf exception;                                      /* exception handling job */
00076 
00077         const char *filename;                           /* Name of TT file */
00078         FILE *file;                                                     /* the open TT file */
00079 
00080         unsigned int numTables;                         /* number of tables present */
00081         char *PostName;                                         /* Font's PostScript name */
00082         char *FullName;                                         /* Font's full name */
00083         char *FamilyName;                                       /* Font's family name */
00084         char *Style;                                            /* Font's style string */
00085         char *Copyright;                                        /* Font's copyright string */
00086         char *Trademark;                                        /* Font's trademark string */
00087         char *Version;                                          /* Font's version string */
00088         int llx,lly,urx,ury;                            /* bounding box */
00089 
00090         Fixed TTVersion;                                        /* Truetype version number from offset table */
00091         Fixed MfrRevision;                                      /* Revision number of this font */
00092 
00093         BYTE *offset_table;                                     /* Offset is loaded right away. */
00094 
00095         /* These table are loaded when they are first needed. */
00096         BYTE *post_table;
00097         BYTE *loca_table;
00098         BYTE *glyf_table;
00099         BYTE *hmtx_table;
00100         BYTE *name_table;
00101 
00102         USHORT numberOfHMetrics;
00103         int unitsPerEm;                                         /* unitsPerEm converted to int */
00104         int HUPM;                                                       /* half of above */
00105 
00106         int numGlyphs;                                          /* from 'post' table */
00107 
00108         int indexToLocFormat;                           /* short or long offsets */
00109 
00110         void (*putc)(int c);
00111         void (*puts)(const char *string);
00112         void (*printf)(const char *format, ...);
00113         } ;
00114 
00115 /*===================================================================
00116 ** Prototype for endian conversion routines
00117 ===================================================================*/
00118 
00119 ULONG getULONG(BYTE *p);
00120 USHORT getUSHORT(BYTE *p);
00121 Fixed getFixed(BYTE *p);
00122 
00123 /*
00124 ** Get an funits word.
00125 ** since it is 16 bits long, we can
00126 ** use getUSHORT() to do the real work.
00127 */
00128 #define getFWord(x) (FWord)getUSHORT(x)
00129 #define getuFWord(x) (uFWord)getUSHORT(x)
00130 
00131 /*
00132 ** We can get a SHORT by making USHORT signed.
00133 */
00134 #define getSHORT(x) (SHORT)getUSHORT(x)
00135 
00136 /*=====================================================================
00137 ** Other library routines
00138 =====================================================================*/
00139 
00140 int ttf_Open(struct TTFONT *font, const char filename[]);
00141 int ttf_Close(struct TTFONT *font);
00142 int ttf_Read_head(struct TTFONT *font);
00143 int ttf_Read_name(struct TTFONT *font);
00144 const char *ttf_charindex2name(struct TTFONT *font, int charindex);
00145 BYTE *ttf_LoadTable(struct TTFONT *font, const char name[]);
00146 char *ttf_loadname(struct TTFONT *font, int get_platform, int get_nameid);
00147 
00148 void ttf_PS_header(struct TTFONT *font, int target_type);
00149 void ttf_PS_encoding(struct TTFONT *font);
00150 void ttf_PS_FontInfo(struct TTFONT *font);
00151 void ttf_PS_trailer(struct TTFONT *font, int target_type);
00152 void ttf_PS_CharStrings(struct TTFONT *font, int target_type);
00153 void ttf_PS_type3_charproc(struct TTFONT *font, int charindex);
00154 void ttf_PS_sfnts(struct TTFONT *font);
00155 
00156 /* Our memory allocators: */
00157 void *ttf_alloc(struct TTFONT *font, size_t number, size_t size);
00158 char *ttf_strdup(struct TTFONT *font, const char *string);
00159 char *ttf_strndup(struct TTFONT *font, const char *string, size_t len);
00160 void *ttf_realloc(struct TTFONT *font, void *ptr, size_t number, size_t size);
00161 void ttf_free(struct TTFONT *font, void *ptr);
00162 
00163 /* This routine converts a number in the font's character coordinate
00164    system to a number in a 1000 unit character system. */
00165 #define topost(x) (int)( ((int)(x) * 1000 + font->HUPM) / font->unitsPerEm )
00166 
00167 /* Composite glyph values. */
00168 #define ARG_1_AND_2_ARE_WORDS 1
00169 #define ARGS_ARE_XY_VALUES 2
00170 #define ROUND_XY_TO_GRID 4
00171 #define WE_HAVE_A_SCALE 8
00172 /* RESERVED 16 */
00173 #define MORE_COMPONENTS 32
00174 #define WE_HAVE_AN_X_AND_Y_SCALE 64
00175 #define WE_HAVE_A_TWO_BY_TWO 128
00176 #define WE_HAVE_INSTRUCTIONS 256
00177 #define USE_MY_METRICS 512
00178 
00179 /* end of file */
00180 

Generated on Fri Feb 20 15:17:50 2004 for PPR Libraries by doxygen 1.3.5