Less strict monospaced().
[grace.git] / T1lib / t1lib / t1lib.h
blob5df4335efb6512fc2802c5d80309de58ff9dac6c
1 /*--------------------------------------------------------------------------
2 ----- File: t1lib.h
3 ----- Author: Rainer Menzner (Rainer.Menzner@web.de)
4 ----- Date: 2004-02-04
5 ----- Description: This file is part of the t1-library. It must be
6 included by the user of the t1lib. It contains
7 function declarations and some basic data types, the
8 user must deal with.
9 ----- Copyright: t1lib is copyrighted (c) Rainer Menzner, 1996-2004.
10 As of version 0.5, t1lib is distributed under the
11 GNU General Public Library Lincense. The
12 conditions can be found in the files LICENSE and
13 LGPL, which should reside in the toplevel
14 directory of the distribution. Please note that
15 there are parts of t1lib that are subject to
16 other licenses:
17 The parseAFM-package is copyrighted by Adobe Systems
18 Inc.
19 The type1 rasterizer is copyrighted by IBM and the
20 X11-consortium.
21 ----- Warranties: Of course, there's NO WARRANTY OF ANY KIND :-)
22 ----- Credits: I want to thank IBM and the X11-consortium for making
23 their rasterizer freely available.
24 Also thanks to Piet Tutelaers for his ps2pk, from
25 which I took the rasterizer sources in a format
26 independent from X11.
27 Thanks to all people who make free software living!
28 --------------------------------------------------------------------------*/
31 #ifndef T1LIB_H_INCLUDED
33 #define T1LIB_H_INCLUDED
35 /* type definitions, needed by the user: */
37 #if defined(__cplusplus) || defined(c_plusplus)
38 extern "C" {
39 #endif
41 /* Version information filled in by configure */
42 #define T1LIB_VERSION 5
43 #define T1LIB_REVISION 0
44 #define T1LIB_PATCHLEVEL 2
45 #define T1LIB_VERSIONSTRING "5.0.2"
48 /* the data structure which contains the character bitmap description */
49 typedef struct
51 char *bits; /* A pointer to the characters local bitmap */
52 struct /* A struct containing diverse metric information */
54 int ascent;
55 int descent;
56 int leftSideBearing;
57 int rightSideBearing;
58 int advanceX;
59 int advanceY;
60 } metrics;
61 void *pFontCacheInfo;
62 unsigned long bpp;
63 } GLYPH;
66 /* A structure representing a matrix */
67 typedef struct
69 double cxx;
70 double cyx;
71 double cxy;
72 double cyy;
73 } T1_TMATRIX;
76 /* the bounding box data structure: */
77 typedef struct
79 int llx; /* lower left x-position */
80 int lly; /* lower left y-position */
81 int urx; /* upper right x-position */
82 int ury; /* upper right y-position */
83 } BBox;
86 /* A data that makes most important information available to user. */
87 typedef struct
89 int width; /* The glyph's width */
90 BBox bbox; /* The glyph's bounding box */
91 int numchars; /* The number of characters in the glyph (string) */
92 int *charpos; /* A pointer to an integer array were the horizontal
93 positions in (afm units) of the individual
94 characters in the string are stored */
95 } METRICSINFO;
98 #define PAD(bits, pad) (((bits)+(pad)-1)&-(pad))
101 /* def's for T1_InitLib() */
102 #define NO_LOGFILE 0x0
103 #define LOGFILE 0x1
104 #define IGNORE_FONTDATABASE 0x2 /* Default is to read database */
105 #define IGNORE_CONFIGFILE 0x4 /* Default is to read config file */
106 #define T1_AA_CACHING 0x8 /* Cache aa-bytes */
107 #define T1_NO_AFM 0x10 /* Do not load or generate AFM data */
111 /* common 'yes'/'no' */
112 #define T1_YES 0x1
113 #define T1_NO 0x0
116 /* logfile levels: */
117 #define T1LOG_ERROR 1
118 #define T1LOG_WARNING 2
119 #define T1LOG_STATISTIC 3
120 #define T1LOG_DEBUG 4
123 /* #define's for manipulating searchpaths */
124 #define T1_PFAB_PATH 0x01
125 #define T1_AFM_PATH 0x02
126 #define T1_ENC_PATH 0x04
127 #define T1_FDB_PATH 0x08
128 #define T1_APPEND_PATH 0x00
129 #define T1_PREPEND_PATH 0x01
132 /* #define's for character/string properties (not all implemented) */
133 #define T1_DEFAULT 0x0000
134 #define T1_UNDERLINE 0x0001
135 #define T1_OVERLINE 0x0002
136 #define T1_OVERSTRIKE 0x0004
137 #define T1_DOUBLEOVERSTRIKE 0x0008
138 #define T1_RIGHT_TO_LEFT 0x0010
139 #define T1_SUBSCRIPT 0x0100
140 #define T1_SUPERSCRIPT 0x0200
141 #define T1_STROKED 0x1000
142 #define T1_KERNING 0x2000
145 /* Setting the subsampling value */
146 #define T1_AA_NONE 1
147 #define T1_AA_LOW 2
148 #define T1_AA_HIGH 4
151 /* Error handling: */
152 extern int T1_errno;
154 /* These are from scanning a font file */
155 #define T1ERR_SCAN_FONT_FORMAT -5
156 #define T1ERR_SCAN_FILE_OPEN_ERR -4
157 #define T1ERR_SCAN_OUT_OF_MEMORY -3
158 #define T1ERR_SCAN_ERROR -2
159 #define T1ERR_SCAN_FILE_EOF -1
160 /* These are from generating paths */
161 #define T1ERR_PATH_ERROR 1
162 #define T1ERR_PARSE_ERROR 2
163 #define T1ERR_TYPE1_ABORT 3
164 /* These are from t1lib */
165 #define T1ERR_INVALID_FONTID 10
166 #define T1ERR_INVALID_PARAMETER 11
167 #define T1ERR_OP_NOT_PERMITTED 12
168 #define T1ERR_ALLOC_MEM 13
169 #define T1ERR_FILE_OPEN_ERR 14
170 #define T1ERR_UNSPECIFIED 15
171 #define T1ERR_NO_AFM_DATA 16
172 #define T1ERR_X11 17
173 #define T1ERR_COMPOSITE_CHAR 18
174 #define T1ERR_SCAN_ENCODING 19
177 /* Flags to control the rasterizer */
178 #define T1_IGNORE_FORCEBOLD 0x0001
179 #define T1_IGNORE_FAMILYALIGNMENT 0x0002
180 #define T1_IGNORE_HINTING 0x0004
182 #define T1_DEBUG_LINE 0x0100
183 #define T1_DEBUG_REGION 0x0200
184 #define T1_DEBUG_PATH 0x0400
185 #define T1_DEBUG_FONT 0x0800
186 #define T1_DEBUG_HINT 0x1000
189 /* definitions for outline handling */
190 #define FRACTBITS 16 /* number of fractional bits in 'fractpel' */
191 /* From/to conversion of pels/fractpels */
192 #define T1_TOPATHPOINT(p) (((long)p)<<FRACTBITS)
193 #define PPHALF (1<<(FRACTBITS-1))
194 #define T1_NEARESTPOINT(fp) (((fp)+PPHALF)>>FRACTBITS)
196 /* A fractional point */
197 typedef struct {
198 long x;
199 long y;
200 } T1_PATHPOINT;
203 /* A straight outline segment, stroked or not stroked */
204 typedef struct pathsegment {
205 char type; /* type of segment (line or move) */
206 unsigned char flag; /* type1 rasterizer internal stuff */
207 short references; /* type1 rasterizer internal stuff */
208 unsigned char size; /* size of the structure */
209 unsigned char context; /* index to device context */
210 struct pathsegment *link; /* pointer to next structure in linked list */
211 struct pathsegment *last; /* pointer to last structure in list */
212 T1_PATHPOINT dest; /* relative ending location of path segment */
213 } T1_PATHSEGMENT;
215 /* A third order bezier segment */
216 typedef struct bezierpathsegment {
217 char type; /* type of segment (bezier) */
218 unsigned char flag; /* type1 rasterizer internal stuff */
219 short references; /* type1 rasterizer internal stuff */
220 unsigned char size; /* as with any 'segment' type */
221 unsigned char context; /* as with any 'segment' type */
222 T1_PATHSEGMENT *link; /* as with any 'segment' type */
223 T1_PATHSEGMENT *last; /* as with any 'segment' type */
224 T1_PATHPOINT dest; /* ending point (D) */
225 T1_PATHPOINT B; /* control point B */
226 T1_PATHPOINT C; /* control point C */
227 } T1_BEZIERSEGMENT;
229 typedef T1_PATHSEGMENT T1_OUTLINE;
231 #define T1_PATHTYPE_LINE 0x10
232 #define T1_PATHTYPE_BEZIER 0x12
233 #define T1_PATHTYPE_MOVE 0x15
236 /* Definitions for font subsetting */
237 #define T1_SUBSET_DEFAULT 0x00
238 #define T1_SUBSET_FORCE_REENCODE 0x01
239 #define T1_SUBSET_SKIP_REENCODE 0x02
240 #define T1_SUBSET_ENCRYPT_BINARY 0x04
241 /* This is only for debugging, it does not produce valid font-files!
242 This flag is not in the documented API!. */
243 #define T1_SUBSET_ENCRYPT_NONE 0x08
246 /* Two structures for handling composite character data */
247 /* One structure for each symbol of the composite character */
248 typedef struct
250 int piece; /* the index of the current symbol */
251 int deltax; /* horizontal displacement of current symbol in CS */
252 int deltay; /* vertical displacement of current symbol in CS */
253 } T1_COMP_PIECE;
255 /* This one defines the composite character, the number of pieces and how to
256 access their data. */
257 typedef struct
259 int compchar; /* the base character in the current encoding */
260 int numPieces; /* the number of defined pieces including the base char */
261 T1_COMP_PIECE *pieces; /* a pointer to the pieces' information */
262 } T1_COMP_CHAR_INFO;
266 /* function declarations: */
268 /* from t1base.c */
269 extern void *T1_InitLib( int log);
270 extern int T1_CloseLib( void);
271 extern int T1_AddFont( char *fontfilename);
272 extern void T1_PrintLog( char *func_ident, char *msg_txt, int level, ...);
273 extern void T1_SetLogLevel( int level);
274 extern int T1_CheckForInit(void);
275 extern int T1_CheckForFontID( int FontID);
276 extern char *T1_GetFontFileName( int FontID);
277 extern int T1_GetNoFonts(void);
278 extern int T1_SetDeviceResolutions( float x_res, float y_res);
279 extern int T1_CopyFont( int FontID);
280 extern int T1_QueryX11Support( void);
281 extern int T1_CheckEndian(void);
282 extern int T1_SetBitmapPad( int pad);
283 extern int T1_GetBitmapPad( void);
284 extern char *T1_GetLibIdent( void);
285 extern void T1_SetRasterFlags( int flags);
286 extern char *T1_GetAfmFileName( int FontID);
287 extern int T1_SetAfmFileName( int FontId, char *afm_name);
288 extern char *T1_GetFontFilePath( int FontID);
289 extern char *T1_GetAfmFilePath( int FontID);
290 extern const char *T1_StrError( int t1err);
292 /* from t1delete.c */
293 extern int T1_DeleteSize( int FontID, float size);
294 extern int T1_DeleteAllSizes( int FontID);
295 extern int T1_FreeGlyph( GLYPH *glyph);
296 extern int T1_FreeCompCharData( T1_COMP_CHAR_INFO *cci);
297 extern int T1_DeleteFont( int FontID);
299 /* from t1enc.c */
300 extern char **T1_LoadEncoding( char *FileName);
301 extern int T1_DeleteEncoding( char **encoding);
302 extern int T1_ReencodeFont( int FontID, char **Encoding);
303 extern int T1_SetDefaultEncoding( char **encoding);
304 extern char *T1_GetEncodingScheme( int FontID);
306 /* from t1env.c */
307 extern int T1_SetFileSearchPath( int type, char *pathname);
308 extern int T1_AddToFileSearchPath( int pathtype, int mode, char *pathname);
309 extern char *T1_GetFileSearchPath( int type);
310 extern int T1_SetFontDataBase( char *filename);
311 extern int T1_AddFontDataBase( int mode, char *filename);
313 /* from t1finfo.c */
314 extern int T1_GetKerning( int FontID, char char1,
315 char char2);
316 extern int T1_GetCharWidth( int FontID, char char1);
317 extern BBox T1_GetCharBBox( int FontID, char char1);
318 extern float T1_GetUnderlinePosition( int FontID);
319 extern float T1_GetUnderlineThickness( int FontID);
320 extern float T1_GetItalicAngle( int FontID);
321 extern int T1_GetIsFixedPitch( int FontID);
322 extern char *T1_GetFontName( int FontID);
323 extern char *T1_GetFullName( int FontID);
324 extern char *T1_GetFamilyName( int FontID);
325 extern char *T1_GetWeight( int FontID);
326 extern char *T1_GetVersion( int FontID);
327 extern char *T1_GetNotice( int FontID);
328 extern char *T1_GetCharName( int FontID, char char1);
329 extern int T1_QueryLigs( int FontID,
330 char char1,
331 char **successors,
332 char **ligatures);
333 extern int T1_GetEncodingIndex( int FontID, char *char1);
334 extern int *T1_GetEncodingIndices( int FontID, char *char1);
335 extern int T1_GetStringWidth( int FontID, char *string,
336 int len, long spaceoff, int kerning);
337 extern BBox T1_GetStringBBox( int FontID, char *string,
338 int len, long spaceoff, int kerning);
339 extern METRICSINFO T1_GetMetricsInfo( int FontID, char *string,
340 int len, long spaceoff, int kerning);
341 extern BBox T1_GetFontBBox( int FontID);
342 extern char **T1_GetAllCharNames( int FontID);
343 extern int T1_GetNoKernPairs( int FontID);
344 extern int T1_GetNoCompositeChars( int FontID);
345 extern int T1_QueryCompositeChar( int FontID, char char1);
346 extern T1_COMP_CHAR_INFO *T1_GetCompCharData( int FontID, char char1);
347 extern T1_COMP_CHAR_INFO *T1_GetCompCharDataByIndex( int FontID, int index);
348 extern int T1_IsInternalChar( int FontID, char char1);
350 /* from t1load.c */
351 extern int T1_LoadFont( int FontID);
352 extern void *T1_QueryFontSize( int FontID, float size, int aa);
354 /* from t1set.c */
355 extern GLYPH *T1_SetChar( int FontID, char charcode,
356 float size, T1_TMATRIX *transform);
357 extern GLYPH *T1_SetString( int FontID, char *string, int len,
358 long spaceoff, int modflag,
359 float size, T1_TMATRIX *transform);
360 extern GLYPH* T1_SetRect( int FontID, float size,
361 float width, float height,
362 T1_TMATRIX *transform);
363 extern GLYPH *T1_CopyGlyph(GLYPH *glyph);
364 extern void T1_DumpGlyph( GLYPH *glyph);
365 extern GLYPH *T1_ConcatGlyphs( GLYPH *glyph1, GLYPH *glyph2,
366 int x_off, int y_off, int modflag);
367 extern void T1_DumpPixmap( GLYPH *glyph);
368 extern GLYPH *T1_FillOutline( T1_OUTLINE *path, int modflag);
370 /* from t1trans.c */
371 extern int T1_ExtendFont( int FontID, double extend);
372 extern int T1_SlantFont( int FontID, double slant);
373 extern int T1_TransformFont( int FontID, T1_TMATRIX *matrix);
374 extern double T1_GetExtend( int FontID);
375 extern double T1_GetSlant( int FontID);
376 extern T1_TMATRIX T1_GetTransform( int FontID);
377 extern int T1_SetLinePosition( int FontID, int linetype, float value);
378 extern int T1_SetLineThickness( int FontID, int linetype, float value);
379 extern float T1_GetLinePosition( int FontID, int linetype);
380 extern float T1_GetLineThickness( int FontID, int linetype);
381 extern T1_TMATRIX *T1_RotateMatrix( T1_TMATRIX *matrix, double angle);
382 extern T1_TMATRIX *T1_MirrorHMatrix( T1_TMATRIX *matrix);
383 extern T1_TMATRIX *T1_MirrorVMatrix( T1_TMATRIX *matrix);
384 extern T1_TMATRIX *T1_ShearHMatrix( T1_TMATRIX *matrix, double shear);
385 extern T1_TMATRIX *T1_ShearVMatrix( T1_TMATRIX *matrix, double shear);
386 extern T1_TMATRIX *T1_ExtendHMatrix( T1_TMATRIX *matrix, double extent);
387 extern T1_TMATRIX *T1_ExtendVMatrix( T1_TMATRIX *matrix, double extent);
388 extern T1_TMATRIX *T1_TransformMatrix( T1_TMATRIX *matrix,
389 double cxx, double cyx,
390 double cxy, double cyy);
391 extern int T1_StrokeFont( int FontID, int dostroke);
392 extern int T1_SetStrokeFlag( int FontID);
393 extern int T1_ClearStrokeFlag( int FontID);
394 extern int T1_GetStrokeMode( int FontID);
395 extern int T1_SetStrokeWidth( int FontID, float strokewidth);
396 extern float T1_GetStrokeWidth( int FontID);
399 /* from t1aaset.c */
400 extern GLYPH *T1_AASetChar( int FontID, char charcode,
401 float size, T1_TMATRIX *transform);
402 extern GLYPH *T1_AASetString( int FontID, char *string, int len,
403 long spaceoff, int modflag,
404 float size, T1_TMATRIX *transform);
405 extern GLYPH* T1_AASetRect( int FontID, float size,
406 float width, float height,
407 T1_TMATRIX *transform);
408 extern int T1_AASetGrayValues(unsigned long white,
409 unsigned long gray75,
410 unsigned long gray50,
411 unsigned long gray25,
412 unsigned long black);
413 extern int T1_AAHSetGrayValues( unsigned long *grayvals);
414 extern int T1_AANSetGrayValues( unsigned long bg, unsigned long fg);
415 extern int T1_AAGetGrayValues( long *pgrayvals);
416 extern int T1_AAHGetGrayValues( long *pgrayvals);
417 extern int T1_AANGetGrayValues( long *pgrayvals);
418 extern int T1_AASetBitsPerPixel( int bpp);
419 extern int T1_AAGetBitsPerPixel( void);
420 extern int T1_AASetLevel( int level);
421 extern int T1_AAGetLevel( void);
422 extern GLYPH *T1_AAFillOutline( T1_OUTLINE *path, int modflag);
423 extern int T1_AASetSmartLimits( float limit1, float limit2);
424 extern int T1_AASetSmartMode( int smart);
427 /* from t1afmtool.c */
428 extern int T1_WriteAFMFallbackFile( int FontID);
430 /* from t1outline.c */
431 extern T1_OUTLINE *T1_GetCharOutline( int FontID, char charcode,
432 float size, T1_TMATRIX *transform);
433 extern T1_OUTLINE *T1_GetStringOutline( int FontID, char *string, int len,
434 long spaceoff, int modflag,
435 float size, T1_TMATRIX *transform);
436 extern T1_OUTLINE *T1_ConcatOutlines( T1_OUTLINE *path1,
437 T1_OUTLINE *path2);
438 extern T1_OUTLINE *T1_ScaleOutline( T1_OUTLINE *path, float scale);
439 extern T1_OUTLINE *T1_GetMoveOutline( int FontID, int deltax, int deltay, int modflag,
440 float size, T1_TMATRIX *transform);
441 extern void T1_DumpPath( T1_OUTLINE *path);
442 extern void T1_AbsolutePath( T1_OUTLINE *rpath);
443 extern void T1_RelativePath( T1_OUTLINE *apath);
444 extern void T1_ManipulatePath( T1_OUTLINE *path,
445 void (*manipulate)(long *x,long *y,int type));
446 extern T1_OUTLINE *T1_CopyOutline( T1_OUTLINE *path);
447 extern void T1_FreeOutline( T1_OUTLINE *path);
450 /* from t1subset.c */
451 extern char *T1_SubsetFont( int FontID,
452 char *mask,
453 unsigned int flags,
454 int linewidth,
455 unsigned long maxblocksize,
456 unsigned long *bufsize);
457 extern char *T1_GetCharString( int FontID, char *charname, int *len);
458 extern int T1_GetlenIV( int FontID);
461 #if defined(__cplusplus) || defined(c_plusplus)
463 #endif
465 #endif /* T1LIB_H_INCLUDED */