upload tizen2.0 source
[framework/uifw/xorg/lib/libxfont.git] / src / fc / fservestr.h
1 /*
2  * Copyright 1990 Network Computing Devices
3  *
4  * Permission to use, copy, modify, distribute, and sell this software and
5  * its documentation for any purpose is hereby granted without fee, provided
6  * that the above copyright notice appear in all copies and that both that
7  * copyright notice and this permission notice appear in supporting
8  * documentation, and that the name of Network Computing Devices not be
9  * used in advertising or publicity pertaining to distribution of the
10  * software without specific, written prior permission.  Network Computing
11  * Devices makes no representations about the suitability of this software
12  * for any purpose.  It is provided "as is" without express or implied
13  * warranty.
14  *
15  * NETWORK COMPUTING DEVICES DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
16  * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
17  * IN NO EVENT SHALL NETWORK COMPUTING DEVICES BE LIABLE FOR ANY SPECIAL,
18  * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
19  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
20  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
21  * OR PERFORMANCE OF THIS SOFTWARE.
22  *
23  * Author:      Dave Lemke, Network Computing Devices, Inc
24  */
25
26 #ifndef _FSERVESTR_H_
27 #define _FSERVESTR_H_
28
29 #include        "fserve.h"
30 #include        "fsio.h"
31
32 /*
33  * font server data structures
34  */
35 /*
36  * font server private storage
37  */
38
39 typedef struct _fs_glyph {
40     struct _fs_glyph    *next;
41 } FSGlyphRec, *FSGlyphPtr;
42
43 typedef struct _fs_font {
44     CharInfoPtr pDefault;
45     CharInfoPtr encoding;
46     CharInfoPtr inkMetrics;
47     FSGlyphPtr  glyphs;
48 }           FSFontRec, *FSFontPtr;
49
50 /* FS special data for the font */
51 typedef struct _fs_font_data {
52     long        fontid;
53     int         generation;     /* FS generation when opened */
54     unsigned long glyphs_to_get;        /* # glyphs remaining to be gotten */
55
56     /* Following data needed in case font needs to be reopened. */
57     int         namelen;
58     char       *name;
59     fsBitmapFormat      format;
60     fsBitmapFormatMask  fmask;
61 }           FSFontDataRec;
62
63 typedef struct fs_clients_depending {
64     pointer     client;
65     struct fs_clients_depending *next;
66 }       FSClientsDependingRec, *FSClientsDependingPtr;
67
68 /* OpenFont specific data for blocked request */
69 typedef struct _fs_blocked_font {
70     FontPtr     pfont;          /* must be first for fs_read_glyphs */
71     long        fontid;
72     int         state;          /* how many of the replies have landed */
73     int         flags;
74     Bool        freeFont;       /* free this font on failure */
75     CARD16      queryInfoSequence;
76     CARD16      queryExtentsSequence;
77     CARD16      queryBitmapsSequence;
78     fsBitmapFormat format;
79     FSClientsDependingPtr       clients_depending;
80 }           FSBlockedFontRec;
81
82 /* LoadGlyphs data for blocked request */
83 typedef struct _fs_blocked_glyphs {
84     FontPtr     pfont;          /* must be first for fs_read_glyphs */
85     int         num_expected_ranges;
86     fsRange     *expected_ranges;
87     FSClientsDependingPtr       clients_depending;
88 }           FSBlockedGlyphRec;
89
90 /* LoadExtents data for blocked request */
91 typedef struct _fs_blocked_extents {
92     FontPtr     pfont;
93     fsRange    *expected_ranges;
94     int         nranges;
95     unsigned long nextents;
96     fsXCharInfo *extents;
97 }           FSBlockedExtentRec;
98
99 /* LoadBitmaps data for blocked request */
100 typedef struct _fs_blocked_bitmaps {
101     FontPtr     pfont;
102     fsRange    *expected_ranges;
103     int         nranges;
104     unsigned long size;
105     unsigned long nglyphs;
106     fsOffset32   *offsets;
107     pointer     gdata;
108 }           FSBlockedBitmapRec;
109
110 /* state for blocked ListFonts */
111 typedef struct _fs_blocked_list {
112     FontNamesPtr names;
113 }           FSBlockedListRec;
114
115 /* state for blocked ListFontsWithInfo */
116 typedef struct _fs_blocked_list_info {
117     int         status;
118     int         namelen;
119     FontInfoRec info;
120     char        name[256];
121     int         remaining;
122 }           FSBlockedListInfoRec;
123
124 /* state for blocked request */
125 typedef struct _fs_block_data {
126     int                     type;           /* Open Font, LoadGlyphs, ListFonts,
127                                              * ListWithInfo */
128     pointer                 client;         /* who wants it */
129     CARD16                  sequenceNumber; /* expected */
130     pointer                 data;           /* type specific data */
131     int                     errcode;        /* Suspended, et al. */
132     struct _fs_block_data   *depending;     /* clients depending on this one */
133     struct _fs_block_data   *next;
134 }           FSBlockDataRec;
135
136 /* state for reconnected to dead font server */
137 typedef struct _fs_reconnect {
138     int     i;
139 } FSReconnectRec, *FSReconnectPtr;
140
141
142 #if !defined(UNIXCPP) || defined(ANSICPP)
143 #define fsCat(x,y) x##_##y
144 #else
145 #define fsCat(x,y) x/**/_/**/y
146 #endif
147
148
149 /* copy XCharInfo parts of a protocol reply into a xCharInfo */
150
151 #define fsUnpack_XCharInfo(packet, structure) \
152     (structure)->leftSideBearing = fsCat(packet,left); \
153     (structure)->rightSideBearing = fsCat(packet,right); \
154     (structure)->characterWidth = fsCat(packet,width); \
155     (structure)->ascent = fsCat(packet,ascent); \
156     (structure)->descent = fsCat(packet,descent); \
157     (structure)->attributes = fsCat(packet,attributes)
158
159
160 /* copy XFontInfoHeader parts of a protocol reply into a FontInfoRec */
161
162 #define fsUnpack_XFontInfoHeader(packet, structure) \
163     (structure)->allExist = ((packet)->font_header_flags & FontInfoAllCharsExist) != 0; \
164     (structure)->drawDirection = \
165         ((packet)->font_header_draw_direction == LeftToRightDrawDirection) ? \
166         LeftToRight : RightToLeft; \
167     (structure)->inkInside = ((packet)->font_header_flags & FontInfoInkInside) != 0; \
168  \
169     (structure)->firstRow = (packet)->font_hdr_char_range_min_char_high; \
170     (structure)->firstCol = (packet)->font_hdr_char_range_min_char_low; \
171     (structure)->lastRow = (packet)->font_hdr_char_range_max_char_high; \
172     (structure)->lastCol = (packet)->font_hdr_char_range_max_char_low; \
173     (structure)->defaultCh = (packet)->font_header_default_char_low \
174                            + ((packet)->font_header_default_char_high << 8); \
175  \
176     (structure)->fontDescent = (packet)->font_header_font_descent; \
177     (structure)->fontAscent = (packet)->font_header_font_ascent; \
178  \
179     fsUnpack_XCharInfo((packet)->font_header_min_bounds, &(structure)->minbounds); \
180     fsUnpack_XCharInfo((packet)->font_header_min_bounds, &(structure)->ink_minbounds); \
181     fsUnpack_XCharInfo((packet)->font_header_max_bounds, &(structure)->maxbounds); \
182     fsUnpack_XCharInfo((packet)->font_header_max_bounds, &(structure)->ink_maxbounds)
183
184 extern void _fs_init_fontinfo ( FSFpePtr conn, FontInfoPtr pfi );
185 extern int _fs_convert_props ( fsPropInfo *pi, fsPropOffset *po, pointer pd,
186                                FontInfoPtr pfi );
187 extern int _fs_convert_lfwi_reply ( FSFpePtr conn, FontInfoPtr pfi,
188                                     fsListFontsWithXInfoReply *fsrep,
189                                     fsPropInfo *pi, fsPropOffset *po,
190                                     pointer pd );
191 extern int fs_build_range ( FontPtr pfont, Bool range_flag,
192                             unsigned int count, int item_size,
193                             unsigned char *data, int *nranges,
194                             fsRange **ranges );
195 extern void _fs_clean_aborted_loadglyphs ( FontPtr pfont,
196                                            int num_expected_ranges,
197                                            fsRange *expected_ranges );
198 extern void _fs_init_font ( FontPtr pfont );
199 extern pointer fs_alloc_glyphs (FontPtr pFont, int size);
200 #endif                          /* _FSERVESTR_H_ */