]> git.sesse.net Git - rdpsrv/blob - Xserver/lib/font/util/format.c
Import X server from vnc-3.3.7.
[rdpsrv] / Xserver / lib / font / util / format.c
1 /* $XConsortium: format.c,v 1.5 94/04/17 20:17:34 dpw Exp $ */
2 /*
3  * Copyright 1990, 1991 Network Computing Devices;
4  * Portions Copyright 1987 by Digital Equipment Corporation
5  *
6  * Permission to use, copy, modify, distribute, and sell this software and its
7  * documentation for any purpose is hereby granted without fee, provided that
8  * the above copyright notice appear in all copies and that both that
9  * copyright notice and this permission notice appear in supporting
10  * documentation, and that the names of Network Computing Devices or Digital 
11  * not be used in advertising or publicity pertaining to distribution of the 
12  * software without specific, written prior permission. Network Computing 
13  * Devices and Digital make no representations about the suitability of 
14  * this software for any purpose.  It is provided "as is" without express 
15  * or implied warranty.
16  *
17  * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH
18  * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
19  * AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES OR DIGITAL BE
20  * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
21  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
22  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
23  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
24  */
25
26 /*
27
28 Copyright (c) 1987  X Consortium
29
30 Permission is hereby granted, free of charge, to any person obtaining
31 a copy of this software and associated documentation files (the
32 "Software"), to deal in the Software without restriction, including
33 without limitation the rights to use, copy, modify, merge, publish,
34 distribute, sublicense, and/or sell copies of the Software, and to
35 permit persons to whom the Software is furnished to do so, subject to
36 the following conditions:
37
38 The above copyright notice and this permission notice shall be included
39 in all copies or substantial portions of the Software.
40
41 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
42 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
43 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
44 IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
45 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
46 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
47 OTHER DEALINGS IN THE SOFTWARE.
48
49 Except as contained in this notice, the name of the X Consortium shall
50 not be used in advertising or otherwise to promote the sale, use or
51 other dealings in this Software without prior written authorization
52 from the X Consortium.
53
54 */
55
56 #include        "FSproto.h"
57 #include        "font.h"
58
59 int
60 CheckFSFormat(format, fmask, bit_order, byte_order, scan, glyph, image)
61     fsBitmapFormat format;
62     fsBitmapFormatMask fmask;
63     int        *bit_order,
64                *byte_order,
65                *scan,
66                *glyph,
67                *image;
68 {
69     /* convert format to what the low levels want */
70     if (fmask & BitmapFormatMaskBit) {
71         *bit_order = format & BitmapFormatBitOrderMask;
72         *bit_order = (*bit_order == BitmapFormatBitOrderMSB)
73                      ? MSBFirst : LSBFirst;
74     }
75     if (fmask & BitmapFormatMaskByte) {
76         *byte_order = format & BitmapFormatByteOrderMask;
77         *byte_order = (*byte_order == BitmapFormatByteOrderMSB)
78                       ? MSBFirst : LSBFirst;
79     }
80     if (fmask & BitmapFormatMaskScanLineUnit) {
81         *scan = format & BitmapFormatScanlineUnitMask;
82         /* convert byte paddings into byte counts */
83         switch (*scan) {
84         case BitmapFormatScanlineUnit8:
85             *scan = 1;
86             break;
87         case BitmapFormatScanlineUnit16:
88             *scan = 2;
89             break;
90         case BitmapFormatScanlineUnit32:
91             *scan = 4;
92             break;
93         default:
94             return BadFontFormat;
95         }
96     }
97     if (fmask & BitmapFormatMaskScanLinePad) {
98         *glyph = format & BitmapFormatScanlinePadMask;
99         /* convert byte paddings into byte counts */
100         switch (*glyph) {
101         case BitmapFormatScanlinePad8:
102             *glyph = 1;
103             break;
104         case BitmapFormatScanlinePad16:
105             *glyph = 2;
106             break;
107         case BitmapFormatScanlinePad32:
108             *glyph = 4;
109             break;
110         default:
111             return BadFontFormat;
112         }
113     }
114     if (fmask & BitmapFormatMaskImageRectangle) {
115         *image = format & BitmapFormatImageRectMask;
116
117         if (*image != BitmapFormatImageRectMin &&
118                 *image != BitmapFormatImageRectMaxWidth &&
119                 *image != BitmapFormatImageRectMax)
120             return BadFontFormat;
121     }
122     return Successful;
123 }