Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / programs / dtudcfonted / include / FaLib.h
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* $XConsortium: FaLib.h /main/5 1996/06/25 20:08:31 cde-fuj $ */
24 /*
25  *  (c) Copyright 1995 FUJITSU LIMITED
26  *  This is source code modified by FUJITSU LIMITED under the Joint
27  *  Development Agreement for the CDEnext PST.
28  *  This is unpublished proprietary source code of FUJITSU LIMITED
29  */
30
31 #ifndef _FALIB_H
32 #define _FALIB_H
33
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37
38 #define FAL_ERROR               -1
39
40 extern int fal_utyerror;        /* library error information */
41 extern int fal_utyderror;       /* library error information */
42 extern int fal_utyexists;       /* existence's flag of font pattern */
43
44 extern  unsigned long fal_utyerrno ;    /* library error information */
45 extern  char    fal_err_file[] ;
46
47 /*
48  *
49  * structure of the font information
50  *
51  */
52
53 /*
54  * the equipment of output permission
55  */
56 #define FAL_FONT_DISPLAY        1
57 #define FAL_FONT_PRINTER        2
58
59
60 #define FAL_FONT_GLYPH_INDEX    -1
61 /*
62  * codeset
63  */
64 #define FAL_FONT_CS0            1
65 #define FAL_FONT_CS1            2
66 #define FAL_FONT_CS2            3
67 #define FAL_FONT_CS3            4
68
69 #define FAL_FONT_CS4            5
70 #define FAL_FONT_CS5            6
71 #define FAL_FONT_CS6            7
72 #define FAL_FONT_CS7            8
73 #define FAL_FONT_CS8            9
74
75 /*
76  * font search mask
77  */
78 #define FAL_FONT_MASK_XLFDNAME          (1L<<1)
79 #define FAL_FONT_MASK_SIZE_W            (1L<<2)
80 #define FAL_FONT_MASK_SIZE_H            (1L<<3)
81 #define FAL_FONT_MASK_LETTER_W          (1L<<4)
82 #define FAL_FONT_MASK_LETTER_H          (1L<<5)
83 #define FAL_FONT_MASK_LETTER_X          (1L<<6)
84 #define FAL_FONT_MASK_LETTER_Y          (1L<<7)
85 #define FAL_FONT_MASK_STYLE_DEF         (1L<<8)
86 #define FAL_FONT_MASK_STYLE_NAME        (1L<<9)
87 #define FAL_FONT_MASK_SHAPE_DEF         (1L<<10)
88 #define FAL_FONT_MASK_SHAPE_NAME        (1L<<11)
89
90
91 #define FAL_FONT_MASK_CODE_SET          (1L<<14)
92 #define FAL_FONT_MASK_PERMISSION        (1L<<15)
93 #define FAL_FONT_MASK_DEL_EQUALDATA     (1L<<16)
94 #define FAL_FONT_MASK_CHECK_ALL         0x1FFFF
95
96 #define FAL_FONT_MASK_GLYPH_INDEX       (1L<<17)
97 #define FAL_FONT_MASK_UPDATE            (1L<<18)
98 #define FAL_FONT_MASK_DEFINED           (1L<<19)
99 #define FAL_FONT_MASK_UNDEFINED         (1L<<20)
100
101
102 /*
103  * undefined the character style,shape
104  */
105 #define FAL_FONT_UNKNOWN        0
106
107 /*
108  * definition's data of character style
109  */
110 #define FAL_FONT_MINCHO                 1
111 #define FAL_FONT_STR_MINCHO             "mincho"
112 #define FAL_FONT_GOTHIC                 2
113 #define FAL_FONT_STR_GOTHIC             "gothic"
114 #define FAL_FONT_MARU_GOTHIC            3
115 #define FAL_FONT_STR_MARU_GOTHIC        "maru_gothic"
116 #define FAL_FONT_TEXTBOOK               4
117 #define FAL_FONT_STR_TEXTBOOK           "textbook"
118 #define FAL_FONT_BRASH_GYOU             5
119 #define FAL_FONT_STR_BRASH_GYOU         "brash_gyou"
120 #define FAL_FONT_BRASH_KAI              6
121 #define FAL_FONT_STR_BRASH_KAI          "brash_kai"
122 #define FAL_FONT_HANDWRITING            7
123 #define FAL_FONT_STR_HANDWRITING        "handwriting"
124
125 /*
126  * definition's data of character shape
127  */
128 #define FAL_FONT_ZENKAKU                1
129 #define FAL_FONT_STR_ZENKAKU            "zenkaku"
130 #define FAL_FONT_HANKAKU                2
131 #define FAL_FONT_STR_HANKAKU            "hankaku"
132 #define FAL_FONT_QUARTER                3
133 #define FAL_FONT_STR_QUARTER            "1/4kaku"
134
135 /*
136  *      structures for font informations
137  */
138 typedef struct {
139         int     width;          /* width */
140         int     height;         /* height */
141         int     top;            /* the head code */
142         int     bottom;         /* the final code */
143 } FalFontinfo ;
144
145 typedef struct {
146         int     num;
147         char    **path;
148 } FalFontPath;
149
150 typedef struct {
151         int     def;            /* definition data */
152         char    *name;          /* the information of the character line */
153 }FalFontDB;
154
155
156 /*
157  * structure of the font information
158  */
159 typedef struct {
160         char    *xlfdname;      /* xlfd name */
161         struct {
162                 int     w;      /* the width of the character size */
163                 int     h;      /* the height of the character size */
164         }size;
165         struct {
166                 int     w;      /* the width of the letter size */
167                 int     h;      /* the height of the letter size */
168                 int     x;      /* position x of the letter size */
169                 int     y;      /* position y of the letter size */
170         }letter;
171         FalFontDB       style;  /* character style */
172         FalFontDB       shape;  /* character shape */
173         FalFontDB       reserve ; /* reserve  */
174         int     cd_set;         /* codeset */
175         int     prm;            /* the equipment of output permission */
176 }FalFontData;
177
178 typedef struct {
179         int     num;            /* the number of font data*/
180         FalFontData     *list;  /* the pointer to the array of 
181                                         FalFontData structure */
182 }FalFontDataList;
183
184 /*
185  *      UDC infomations
186  */
187 typedef struct _FalCodeRegion {
188         int     start ;         /* first code */
189         int     end ;           /* last code */
190 } FalCodeRegion ;
191
192 typedef struct _FalGlyphRegion {
193         int     start ;         /* first glyph index */
194         int     end ;           /* last glyph index */
195 } FalGlyphRegion ;
196
197 typedef struct _FalGIInf {
198         char    *charset_str;   /* charcter set */
199         int     glyph_index;    /* glyph index */
200 } FalGIInf;
201
202 /*
203  * structure of the font identifier
204  */
205 #include <X11/Xos.h>
206 #include <X11/Xmd.h>
207 #include <X11/X.h>
208 #include <X11/Xproto.h>
209 #include <stdlib.h>
210 #include <dirent.h>
211
212 #ifdef  Bool
213 #undef  Bool
214 #endif
215
216 #include  "snfstruct.h"
217 #include  "fontstruct.h"
218 #include  "pcf.h"
219
220 struct  pcf_inf {
221         FontInfoRec     info;
222         xCharInfo       org_bounds;
223         PCFTablePtr     tables;
224         int     ntables;
225         CARD32  bmp_fmt;        /* bitOrder ,byteOrder, glyph, scan */
226         int     nbitmaps;
227         CARD32  *offsets;
228         int     sizebitmaps;
229         char    *bitmaps;
230         CARD32  enc_fmt;
231         CARD16  *encodingOffsets;
232 };
233
234 typedef struct _Oak_Finf {
235     int         ismmap;         /* used mmap()? */
236     int         fsize;          /* file size */
237     int         fd;             /* file descripter */
238     int         isFef;
239     char        *buf;           /* font file allocated on memory */
240     char        *fname;         /* name of font file */
241 /* added by Rudie */
242     int         isPcf;  
243     struct      pcf_inf pcfinf;
244 /* added by Rudie */
245     FontInfoPtr   pFinf;
246     CharInfoPtr   pCinf;
247     unsigned char *pGlyphs;
248     unsigned int  width;
249     unsigned int  height;
250     unsigned int  start;
251     unsigned int  end;
252     int           sptnBufL;
253     char          *sptnBuf;
254     int           dptnBufL;
255     char          *dptnBuf;
256     int           dbufL;
257     char          *dbuf;
258 } Oak_FontInf;
259
260 typedef Oak_FontInf * FalFontID;        /* font distinction */
261
262 /*
263  *      function prototypes
264  */
265 extern  FalFontID       FalOpenSysFont(
266 #if NeedFunctionPrototypes
267         FalFontData*            /* open_font_data */,
268         int                     /* font_data_mask */,
269         FalFontDataList**       /* missing_font_list_return */
270 #endif
271 ) ;
272
273 extern  int     FalGetFontList(
274 #if NeedFunctionPrototypes
275         FalFontData*            /* key_data */,
276         int                     /* mask */,
277         FalFontDataList**       /* list_ret */
278 #endif
279 ) ;
280
281 extern  int     FalFreeFontList(
282 #if NeedFunctionPrototypes
283         FalFontDataList*        /* list */
284 #endif
285 ) ;
286
287 extern  char    *
288 FalReadFont(
289 #if NeedFunctionPrototypes
290         FalFontID       /* fid */ ,
291         int             /* code */ ,
292         int             /* width */ ,
293         int             /* height */
294 #endif
295 ) ;
296
297 extern  int     FalQueryFont(
298 #if NeedFunctionPrototypes
299         FalFontID       /* fid */ ,
300         FalFontinfo*    /* fontinfo */
301 #endif
302 ) ;
303
304 extern  int     FalFontOfFontID(
305 #if NeedFunctionPrototypes
306         FalFontID       /* fid */,
307         FalFontData*    /* fontdata */
308 #endif
309 ) ;
310
311 extern  int     FalCloseFont(
312 #if NeedFunctionPrototypes
313         FalFontID       /* fid */
314 #endif
315 ) ;
316
317 extern  int     FalFontIDToFileName(
318 #if NeedFunctionPrototypes
319         FalFontID       /* fid */ ,
320         char**          /* file_name */ 
321 #endif
322 ) ;
323
324 extern  int     FalFree(
325 #if NeedFunctionPrototypes
326         void*   /* list */ 
327 #endif
328 ) ;
329
330 extern  int     FalGetUDCCPArea(
331 #if NeedFunctionPrototypes
332         char*           /* locale */ ,
333         int             /* code_set */ ,
334         char*           /* charset_str */ ,
335         FalCodeRegion** /* cr */ ,
336         int*            /* num_cr */
337 #endif
338 ) ;
339
340 extern  int     FalGetUDCGIArea(
341 #if NeedFunctionPrototypes
342         char*           /* locale */ ,
343         int             /* codeset */ ,
344         char*           /* charset_str */ ,
345         FalGlyphRegion**        /* gr */ ,
346         int*            /* num_gr */
347 #endif
348 ) ;
349
350 extern  FalFontID       FalOpenFont() ;
351
352 /*
353  * Code set
354  */
355 #define FALGETFALCODESET( cd_set )      ( ((cd_set)==-1) ? FAL_FONT_GLYPH_INDEX : (cd_set)+1 )
356
357 #define FALCODESETTONUM( cd_set ) ( ((cd_set)==FAL_FONT_GLYPH_INDEX) ? -1 : (cd_set)-1 )
358
359 /*
360  * fal_utyerrno
361  */
362 #define FAL_FUNCNUM_GFLST       0x0
363 #define FAL_FUNCNUM_SRCHFNM     0x0
364 #define FAL_FUNCNUM_OPNFNT      0x0
365 #define FAL_FUNCNUM_FRFLST      0x0
366 #define FAL_FUNCNUM_RDFNT       0x0
367 #define FAL_FUNCNUM_QRY         0x0
368 #define FAL_FUNCNUM_FID         0x0
369 #define FAL_FUNCNUM_IDTOFNM     0x0
370 #define FAL_FUNCNUM_CLSFNT      0x0
371 #define FAL_FUNCNUM_CPA         0x0
372 #define FAL_FUNCNUM_GIA         0x0
373 #define FAL_FUNCNUM_FREE        0x0
374
375 #define FAL_ERR_NON             0x00
376
377 #define FAL_ERR_FNT_OPN         0x01
378 #define FAL_ERR_FNT_RD          0x02
379 #define FAL_ERR_MALLOC          0x03
380 #define FAL_ERR_PARM            0x04
381 #define FAL_ERR_STAT            0x05
382 #define FAL_ERR_FONT            0x06
383 #define FAL_ERR_FDATA_OPN       0x07
384 #define FAL_ERR_FDATA_RD        0x08
385 #define FAL_ERR_FDATA_DSC       0x09
386 #define FAL_ERR_FPATH           0x0a
387
388 #define FAL_ERR_FNTDIR_OPN      0x0b
389 #define FAL_ERR_FNTDIR_RD       0x0c
390 #define FAL_ERR_PROP_RD         0x0d
391 #define FAL_ERR_PROP_FONT       0x0e
392 #define FAL_ERR_PROP_FNAME      0x0f
393 #define FAL_ERR_LCKD            0x10
394 #define FAL_ERR_FILELCK         0x11
395 #define FAL_ERR_FILEUNLCK       0x12
396 #define FAL_ERR_FILEGETLCK      0x13
397 #define FAL_ERR_NOFONT          0x14
398
399 #define FAL_ERR_XLC_CRTDB       0x15
400 #define FAL_ERR_XLC_GETCHARST   0x16
401 #define FAL_ERR_XLC_NOCHARST    0x17
402
403 #define FAL_ERR_FID_RD          0x18
404 #define FAL_ERR_FATAL           0x19
405
406
407 #ifdef __cplusplus
408 }
409 #endif
410 #endif /* _FALIB_H */
411