00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "gu.h"
00025
00026
00027 #include "libttf.h"
00028
00029
00030 #include <setjmp.h>
00031
00032
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
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
00053
00054 typedef struct
00055 {
00056 short int whole;
00057 unsigned short int fraction;
00058 } Fixed;
00059
00060
00061
00062
00063 #define TTF_SIGNITURE 1442
00064
00065
00066
00067
00068
00069 struct TTFONT
00070 {
00071 int signiture;
00072
00073 TTF_RESULT errno;
00074
00075 jmp_buf exception;
00076
00077 const char *filename;
00078 FILE *file;
00079
00080 unsigned int numTables;
00081 char *PostName;
00082 char *FullName;
00083 char *FamilyName;
00084 char *Style;
00085 char *Copyright;
00086 char *Trademark;
00087 char *Version;
00088 int llx,lly,urx,ury;
00089
00090 Fixed TTVersion;
00091 Fixed MfrRevision;
00092
00093 BYTE *offset_table;
00094
00095
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;
00104 int HUPM;
00105
00106 int numGlyphs;
00107
00108 int indexToLocFormat;
00109
00110 void (*putc)(int c);
00111 void (*puts)(const char *string);
00112 void (*printf)(const char *format, ...);
00113 } ;
00114
00115
00116
00117
00118
00119 ULONG getULONG(BYTE *p);
00120 USHORT getUSHORT(BYTE *p);
00121 Fixed getFixed(BYTE *p);
00122
00123
00124
00125
00126
00127
00128 #define getFWord(x) (FWord)getUSHORT(x)
00129 #define getuFWord(x) (uFWord)getUSHORT(x)
00130
00131
00132
00133
00134 #define getSHORT(x) (SHORT)getUSHORT(x)
00135
00136
00137
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
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
00164
00165 #define topost(x) (int)( ((int)(x) * 1000 + font->HUPM) / font->unitsPerEm )
00166
00167
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
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
00180