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