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 39typedef struct _fs_glyph { 40 struct _fs_glyph *next; 41} FSGlyphRec, *FSGlyphPtr; 42 43typedef 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 */ 51typedef 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 63typedef struct fs_clients_depending { 64 pointer client; 65 struct fs_clients_depending *next; 66} FSClientsDependingRec, *FSClientsDependingPtr; 67 68/* OpenFont specific data for blocked request */ 69typedef 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 */ 83typedef 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 */ 91typedef 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 */ 100typedef 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 */ 111typedef struct _fs_blocked_list { 112 FontNamesPtr names; 113} FSBlockedListRec; 114 115/* state for blocked ListFontsWithInfo */ 116typedef 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 */ 125typedef 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 */ 137typedef struct _fs_reconnect { 138 int i; 139} FSReconnectRec, *FSReconnectPtr; 140 141 142#define fsCat(x,y) x##_##y 143 144/* copy XCharInfo parts of a protocol reply into a xCharInfo */ 145 146#define fsUnpack_XCharInfo(packet, structure) \ 147 (structure)->leftSideBearing = fsCat(packet,left); \ 148 (structure)->rightSideBearing = fsCat(packet,right); \ 149 (structure)->characterWidth = fsCat(packet,width); \ 150 (structure)->ascent = fsCat(packet,ascent); \ 151 (structure)->descent = fsCat(packet,descent); \ 152 (structure)->attributes = fsCat(packet,attributes) 153 154 155/* copy XFontInfoHeader parts of a protocol reply into a FontInfoRec */ 156 157#define fsUnpack_XFontInfoHeader(packet, structure) \ 158 (structure)->allExist = ((packet)->font_header_flags & FontInfoAllCharsExist) != 0; \ 159 (structure)->drawDirection = \ 160 ((packet)->font_header_draw_direction == LeftToRightDrawDirection) ? \ 161 LeftToRight : RightToLeft; \ 162 (structure)->inkInside = ((packet)->font_header_flags & FontInfoInkInside) != 0; \ 163 \ 164 (structure)->firstRow = (packet)->font_hdr_char_range_min_char_high; \ 165 (structure)->firstCol = (packet)->font_hdr_char_range_min_char_low; \ 166 (structure)->lastRow = (packet)->font_hdr_char_range_max_char_high; \ 167 (structure)->lastCol = (packet)->font_hdr_char_range_max_char_low; \ 168 (structure)->defaultCh = (packet)->font_header_default_char_low \ 169 + ((packet)->font_header_default_char_high << 8); \ 170 \ 171 (structure)->fontDescent = (packet)->font_header_font_descent; \ 172 (structure)->fontAscent = (packet)->font_header_font_ascent; \ 173 \ 174 fsUnpack_XCharInfo((packet)->font_header_min_bounds, &(structure)->minbounds); \ 175 fsUnpack_XCharInfo((packet)->font_header_min_bounds, &(structure)->ink_minbounds); \ 176 fsUnpack_XCharInfo((packet)->font_header_max_bounds, &(structure)->maxbounds); \ 177 fsUnpack_XCharInfo((packet)->font_header_max_bounds, &(structure)->ink_maxbounds) 178 179extern void _fs_init_fontinfo ( FSFpePtr conn, FontInfoPtr pfi ); 180extern int _fs_convert_props ( fsPropInfo *pi, fsPropOffset *po, pointer pd, 181 FontInfoPtr pfi ); 182extern int _fs_convert_lfwi_reply ( FSFpePtr conn, FontInfoPtr pfi, 183 fsListFontsWithXInfoReply *fsrep, 184 fsPropInfo *pi, fsPropOffset *po, 185 pointer pd ); 186extern int fs_build_range ( FontPtr pfont, Bool range_flag, 187 unsigned int count, int item_size, 188 unsigned char *data, int *nranges, 189 fsRange **ranges ); 190extern void _fs_clean_aborted_loadglyphs ( FontPtr pfont, 191 int num_expected_ranges, 192 fsRange *expected_ranges ); 193extern void _fs_init_font ( FontPtr pfont ); 194extern pointer fs_alloc_glyphs (FontPtr pFont, int size); 195#endif /* _FSERVESTR_H_ */ 196