File: VFlib-3_6.h.in

package info (click to toggle)
vflib3 3.6.14.dfsg-3+nmu3
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 11,536 kB
  • ctags: 3,710
  • sloc: ansic: 35,811; sh: 10,357; asm: 3,290; makefile: 962; lisp: 123; perl: 109; awk: 43
file content (439 lines) | stat: -rw-r--r-- 14,117 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
/*
 * VFlib-3_6.h - a header file for VFlib 
 * by Hirotsugu Kakugawa
 *
 *   1 Mar 1997  VFlib 3.1.4
 *   5 Mar 1997  VFlib 3.1.5  Added printing LGPL feature
 *   2 Apr 1997  Added support for Omega (WL)
 *   4 Aug 1997  VFlib 3.3  Changed API.
 *   9 Jan 1998  VFlib 3.4  Changed vflibcap file syntax.
 *  21 Aug 1998  VFlib 3.5
 *  29 Jul 1999  VFlib 3.6
 */
/*
 * Copyright (C) 1996-1999 Hirotsugu Kakugawa. 
 * All rights reserved.
 *
 * This file is part of the VFlib Library.  This library is free
 * software; you can redistribute it and/or modify it under the terms of
 * the GNU Library General Public License as published by the Free
 * Software Foundation; either version 2 of the License, or (at your
 * option) any later version.  This library is distributed in the hope
 * that it will be useful, but WITHOUT ANY WARRANTY; without even the
 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 * PURPOSE.  See the GNU Library General Public License for more details.
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */


#ifndef __VFLIB_VFLIB_H__
#define __VFLIB_VFLIB_H__


/**
 ** DATA TYPES
 **/

/* Bitmap */
struct vf_s_bitmap {
  int              bbx_width, bbx_height;   /* in PIXEL */
  int              off_x, off_y;            /* in PIXEL */
  int              mv_x,  mv_y;             /* in PIXEL */
  unsigned char    *bitmap;
  int              raster;
};
typedef struct vf_s_bitmap  *VF_BITMAP;

/* Font metric */
struct vf_s_metric1 {
  double    bbx_width, bbx_height;  /* in Point */
  double    off_x, off_y;           /* in Point */
  double    mv_x, mv_y;             /* in Point */
};
typedef struct vf_s_metric1 *VF_METRIC1;

struct vf_s_metric2 {
  int    bbx_width, bbx_height;     /* in Pixel */
  int    off_x, off_y;              /* in Pixel */
  int    mv_x, mv_y;                /* in Pixel */
};
typedef struct vf_s_metric2 *VF_METRIC2;

/* Outline data */
typedef @ol_elem_type@     VF_OUTLINE_ELEM;
typedef VF_OUTLINE_ELEM   *VF_OUTLINE;

/* Bitmap list */
struct vf_s_bitmaplist {
  long                 off_x, off_y; 
  VF_BITMAP            bitmap;
  struct vf_s_bitmaplist *next;
};
typedef struct vf_s_bitmaplist *VF_BITMAPLIST; 


/*
 * Font type
 */
#define VF_FONT_TYPE_UNDEF       0
#define VF_FONT_TYPE_BITMAP      1
#define VF_FONT_TYPE_OUTLINE     2


/*
 * Font object
 */
typedef struct vf_s_font   *VF_FONT;
struct vf_s_font {
                        /* font drivers must not modify the following */
  char   *font_name;
  int     mode;
  double  point_size, dpi_x, dpi_y;   /* when mode==1 */
  int     pixel_size;                 /* when mode==2 */
  double  mag_x, mag_y;
  int     font_class;
  int     link_count;
                        /* font drivers may modify the following */
  int     font_type;
  /* methods */
  VF_BITMAP     (*get_bitmap1)(VF_FONT,long,double,double);
  VF_BITMAP     (*get_bitmap2)(VF_FONT,long,double,double);
  int           (*get_metric1)(VF_FONT,long,VF_METRIC1,double,double);
  int           (*get_metric2)(VF_FONT,long,VF_METRIC2,double,double);
  int           (*get_fontbbx1)(VF_FONT,double,double,
				double*,double*,double*,double*);
  int           (*get_fontbbx2)(VF_FONT,double,double,int*,int*,int*,int*);
  VF_OUTLINE    (*get_outline)(VF_FONT,long,double,double);
  char*         (*get_font_prop)(VF_FONT,char*);
  int           (*query_font_type)(VF_FONT,long);
  int           (*close)(VF_FONT);
  /* private data (font class dependent) */
  void  *private; 
};



/**
 ** VFLIB API 
 **/

/*
 * Initialization of VFlib
 *    VF_Init(char* vflibcap_path, char *variable_list) 
 *
 *  The second argument 'variable_list' is a string of a form
 *  "KEY1=VALUE1, KEY2=VALUE2, ...".  This is used for parameterized
 *  vflibcap.
 */
extern int  VF_Init(char *vflibcap_path, char *variable_list);

/*
 * VFlib version number
 */
extern char   *VF_GetVersion(void);

/*
 * Clear errors in VFlib
 */
extern void  VF_ClearError(void);

/*
 * Open a font  
 * Font ID (font_id) is returned
 */
/* high-resolution oriented  */
extern int  VF_OpenFont1(char *font_name,
			 double dpi_x, double dpi_y, 
			 double point_size, double mag_x, double mag_y);
/* low-resolution oriented */
extern int  VF_OpenFont2(char *font_name, 
			 int pixel_size, double mag_x, double mag_y);

/* 
 * Close a font
 */
extern int  VF_CloseFont(int font_id);

/*
 * Get a bitmap of a character
 */
/* high-resolution oriented */
extern VF_BITMAP  VF_GetBitmap1(int font_id, long code_point,
				double mag_x, double mag_y);
/* low-resolution oriented */
extern VF_BITMAP  VF_GetBitmap2(int font_id, long code_point,
				double mag_x, double mag_y);

/*
 * Get a metric of a character
 */
/* high-resolution oriented */
extern VF_METRIC1  VF_GetMetric1(int font_id, long code_point,
				 VF_METRIC1 metric1,
				 double mag_x, double mag_y);
/* low-resolution oriented */
extern VF_METRIC2  VF_GetMetric2(int font_id, long code_point,
				 VF_METRIC2 metric2,
				 double mag_x, double mag_y);

/*
 * Get bounding-box of a font
 */
/* high-resolution oriented */
extern int  VF_GetFontBoundingBox1(int font_id, double mag_x, double mag_y,
				   double *width_p, double *height_p,
				   double *xoff_p, double *yoff_p);
/* low-resolution oriented */
extern int  VF_GetFontBoundingBox2(int font_id, double mag_x, double mag_y,
				   int *width_p, int *height_p,
				   int *xoff_p, int *yoff_p);


/*
 * Get an outline data of a character 
 * (only for high-resolution oriented fonts)
 */
extern VF_OUTLINE  VF_GetOutline(int font_id, long code_point,
				 double mag_x, double mag_y);
/*
 * Get font property (font class dependent)
 * (Caller must release the resulting string area.)
 */
extern char   *VF_GetFontProp(int font_id, char *prop_name);

/*
 * Get font type (bitmap or outline):
 */
extern int   VF_QueryFontType(int font_id, long code_point);

/*
 * Make a copy of a bitmap
 */
extern VF_BITMAP  VF_CopyBitmap(VF_BITMAP bm);

/*
 * Make a rotated bitmap
 */
extern VF_BITMAP  VF_RotatedBitmap(VF_BITMAP bm, int rotate_angle);
#define VF_BM_ROTATE_0      0
#define VF_BM_ROTATE_90    90
#define VF_BM_ROTATE_180  180
#define VF_BM_ROTATE_270  270

/*
 * Make a reflected bitmap
 */
extern VF_BITMAP  VF_ReflectedBitmap(VF_BITMAP bm, int ref_x, int ref_y);

/*
 * Make a scaled bitmap
 */
extern VF_BITMAP  VF_MakeScaledBitmap(VF_BITMAP bm, 
				      double mag_x, double mag_y);

/* 
 * Make a minimized bitmap (make a bitmap with minimum bounding box)
 */
extern VF_BITMAP  VF_MinimizeBitmap(VF_BITMAP bm);

/* 
 * Fill/Clear bitmap
 */
extern void       VF_FillBitmap(VF_BITMAP bm);
extern void       VF_ClearBitmap(VF_BITMAP bm);

/* 
 * Make a copy of a metric
 */
extern VF_METRIC1 VF_CopyMetric1(VF_METRIC1 metric1);
extern VF_METRIC2 VF_CopyMetric2(VF_METRIC2 metric2);

/*
 * Create a bitmap data from an outline data
 */
extern VF_BITMAP  VF_OutlineToBitmap(VF_OUTLINE outline, 
				     double dpi_x, double dpi_y, 
				     double point_size,
				     double mag_x, double mag_y);

/*
 * Create an outline data from a bitmap data
 */
extern VF_OUTLINE  VF_BitmapToOutline(VF_BITMAP bm);

/*
 * Release bitmap, outline, matric objects:
 */
extern void  VF_FreeBitmap(VF_BITMAP bm);
extern void  VF_FreeOutline(VF_OUTLINE outline);
extern void  VF_FreeMetric1(VF_METRIC1 metric1);
extern void  VF_FreeMetric2(VF_METRIC2 metric2);

/* 
 * Bitmap list
 */
extern int       VF_BitmapListInit(VF_BITMAPLIST);
extern int       VF_BitmapListPut(VF_BITMAPLIST,VF_BITMAP,long,long);
extern VF_BITMAP VF_BitmapListCompose(VF_BITMAPLIST);
extern int       VF_BitmapListFinish(VF_BITMAPLIST);

/*
 * Installation of a font driver
 */
extern int  VF_InstallFontDriver(char* class_name, 
				 int(*driver_entry)(VF_FONT font,
						    char *class_name,
						    char *font_name, 
						    int implicit_flag,
						    void *font_db_entry));

/*
 * Get a list of installed font driver names
 */
extern char **VF_FontDriverList(void);


/*
 * Output a bitmap to a file
 */
/* PBM ASCII format output */
extern int  VF_ImageOut_PBMAscii(VF_BITMAP bm, FILE *fp, 
				 int image_width, int image_height,
				 int position_x, int position_y, 
				 int margin_l, int margin_r, 
				 int margin_t, int margin_b,
				 int reverse, int shrink,
				 char *prog, char *title);
/* PGM ASCII format output */
extern int  VF_ImageOut_PGMAscii(VF_BITMAP bm, FILE *fp, 
				 int image_width, int image_height,
				 int position_x, int position_y, 
				 int margin_l, int margin_r,
				 int margin_t, int margin_b,
				 int reverse, int shrink,
				 char *prog, char *title);
/* PGM Row format output */
extern int  VF_ImageOut_PGMRaw(VF_BITMAP bm, FILE *fp, 
			       int image_width, int image_height,
			       int position_x, int position_y, 
			       int margin_l, int margin_r, 
			       int margin_t, int margin_b,
			       int reverse, int shrink,
			       char *prog, char *title);
/* EPS format output */
extern int  VF_ImageOut_EPS(VF_BITMAP bm, FILE *fp, 
			    int image_width, int image_height,
			    int position_x, int position_y, 
			    int margin_l, int margin_r,
			    int margin_t, int margin_b,
			    int reverse, int shrink,
			    char *prog, char *title,
			    double ptsize, int pixsize);
/* ASCII Art format output */
extern int  VF_ImageOut_ASCIIArt(VF_BITMAP bm, FILE *fp, 
				 int image_width, int image_height,
				 int position_x, int position_y, 
				 int margin_l, int margin_r, 
				 int margin_t, int margin_b,
				 int reverse, int shrink);
/* ASCII Art format output (rotated clockwise, 90 degree) */
extern int  VF_ImageOut_ASCIIArtV(VF_BITMAP bm, FILE *fp, 
				  int image_width, int image_height,
				  int position_x, int position_y, 
				  int margin_l, int margin_r, 
				  int margin_t, int margin_b,
				  int reverse, int shrink);

#define VF_IMAGEOUT_POSITION_NONE    0
#define VF_IMAGEOUT_POSITION_CENTER  1
#define VF_IMAGEOUT_POSITION_TOP     2
#define VF_IMAGEOUT_POSITION_BOTTOM  3
#define VF_IMAGEOUT_POSITION_LEFT    4
#define VF_IMAGEOUT_POSITION_RIGHT   5


/*
 * Display a bitmap as an ASCII art
 */
extern void VF_DumpBitmap(VF_BITMAP bm);



/** 
 ** Outline Data
 **/
#define VF_OL_INSTR_TOKEN       0x80000000L
#define VF_OL_INSTR_CHAR        0x00000001L
#define VF_OL_INSTR_CWCURV      0x00000002L
#define VF_OL_INSTR_CCWCURV     0x00000004L
#define VF_OL_INSTR_LINE        0x00000008L
#define VF_OL_INSTR_ARC         0x00000010L
#define VF_OL_INSTR_BEZ         0x00000020L
#define VF_OL_GET_X(n)          (((n)&0x7fff0000L) >> 16)
#define VF_OL_GET_Y(n)          (((n)&0x00007fffL))
#define VF_OL_MAKE_XY(x,y)   (((VF_OUTLINE_ELEM)(x)<<16)|(VF_OUTLINE_ELEM)(y))
#define	VF_OL_COORD_MAX               32768 
#define	VF_OL_COORD_RANGE              8192
#define	VF_OL_COORD_OFFSET      (VF_OL_COORD_MAX/2 - VF_OL_COORD_RANGE/2)

#define	VF_OL_HEADER_ENCODE(x)  (VF_OUTLINE_ELEM)((double)(x)*(double)0x10000)
#define	VF_OL_HEADER_DECODE(y)  ((VF_OUTLINE_ELEM)((y)/(double)0x10000))
#define	VF_OL_OUTLINE_HEADER_SIZE_TYPE0  16
#define	VF_OL_OUTLINE_HEADER_TYPE0        0

#define	VF_OL_HEADER_INDEX_HEADER_TYPE  0  /* format type */
#define	VF_OL_HEADER_INDEX_DATA_SIZE    1  /* data size, incl. header */
#define	VF_OL_HEADER_INDEX_DPI_X        2  /* h-dpi (encoded) */
#define	VF_OL_HEADER_INDEX_DPI_Y        3  /* v-dpi (encoded) */
#define	VF_OL_HEADER_INDEX_POINT_SIZE   4  /* point size (encoded) */
#define	VF_OL_HEADER_INDEX_EM           5  /* 1em, in outline coordinate */
#define	VF_OL_HEADER_INDEX_MAX_X        6  /* in outline coordinate */
#define	VF_OL_HEADER_INDEX_MAX_Y        7  /* in outline coordinate */
#define	VF_OL_HEADER_INDEX_REF_X        8  /* in outline coordinate */
#define	VF_OL_HEADER_INDEX_REF_Y        9  /* in outline coordinate */
#define	VF_OL_HEADER_INDEX_MV_X        10  /* in outline coordinate */
#define	VF_OL_HEADER_INDEX_MV_Y        11  /* in outline coordinate */


/**
 ** Error code
 **/
extern int  vf_error;
#define  VF_ERR_INTERNAL             1  /* Internal error */
#define  VF_ERR_NO_MEMORY            2  /* Out of memory */
#define  VF_ERR_CANT_OPEN            3  /* Can't open a file */
#define  VF_ERR_NOT_SUPPORTED_OP     4  /* Operation not supported */
#define  VF_ERR_ILL_FONTID           5  /* Illegal font id */
#define  VF_ERR_OPEN_NESTING         6  /* Too many nesting for font open */
#define  VF_ERR_USED_CLASS_NAME      7  /* The class name is already used */
#define  VF_ERR_ILL_MODE             8  /* Illegal font mode (high/low res.) */
#define  VF_ERR_BITMAP2OUTLINE       9  /* Illegal bitmap for bitmap2outline */
#define  VF_ERR_BOGUS_OUTLINE       10  /* Bogus outline data */
#define  VF_ERR_NO_VFLIBCAP         11  /* Vflibcap file not found */
#define  VF_ERR_UNCOMPRESS          12  /* Font uncompression error */
#define  VF_ERR_ILL_FONT_FILE       13  /* Font file format error */
#define  VF_ERR_TOO_MANY_OPEN       14  /* Too many open fonts */

#define  VF_ERR_CLASS_UNKNOWN       20  /* Font class is unknown */
#define  VF_ERR_NO_FONT_ENTRY       21  /* Font entry not found */
#define  VF_ERR_NO_FONT_CLASS       22  /* No such font class name */
#define  VF_ERR_NO_FONT_FILE_PATH   23  /* No font file path in vflibcap */
#define  VF_ERR_NO_FONT_FILE        24  /* No font file */
#define  VF_ERR_NO_METRIC_FILE      25  /* No metric file */
#define  VF_ERR_NO_AUX_FONT_NAME    26  /* No auxiliary font name */
#define  VF_ERR_NOT_JFM             27  /* Not a JFM file */
#define  VF_ERR_NO_FONT_IMP         28  /* No font in implicit font classes */
#define  VF_ERR_WRONG_OFM           29  /* Wrong OFM version */
#define  VF_ERR_INVALID_METRIC      30  /* Invalid metric file */
#define  VF_ERR_ILL_CODE_POINT      31  /* Illegal code point */
#define  VF_ERR_NO_GLYPH            32  /* Glyph not found */

#define  VF_ERR_FREETYPE_INIT       50  /* FreeType initialization error */
#define  VF_ERR_T1LIB_INIT          51  /* T1Lib initialization error */


#endif /*__VFLIB_VFLIB_H__*/ 

/*EOF*/