pcf_private.h 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. /*
  2. * CDDL HEADER START
  3. *
  4. * The contents of this file are subject to the terms of the
  5. * Common Development and Distribution License (the "License").
  6. * You may not use this file except in compliance with the License.
  7. *
  8. * You can obtain a copy of the license at src/OPENSOLARIS.LICENSE
  9. * or http://www.opensolaris.org/os/licensing.
  10. * See the License for the specific language governing permissions
  11. * and limitations under the License.
  12. *
  13. * When distributing Covered Code, include this CDDL HEADER in each
  14. * file and include the License file at src/OPENSOLARIS.LICENSE.
  15. * If applicable, add the following below this CDDL HEADER, with the
  16. * fields enclosed by brackets "[]" replaced with your own identifying
  17. * information: Portions Copyright [yyyy] [name of copyright owner]
  18. *
  19. * CDDL HEADER END
  20. */
  21. /*
  22. * Copyright (c) 1999 by Sun Microsystems, Inc.
  23. * All rights reserved.
  24. */
  25. /*
  26. * Copyright (C) 1994 X Consortium
  27. *
  28. * Permission is hereby granted, free of charge, to any person obtaining a copy
  29. * of this software and associated documentation files (the "Software"), to
  30. * deal in the Software without restriction, including without limitation the
  31. * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  32. * sell copies of the Software, and to permit persons to whom the Software is
  33. * furnished to do so, subject to the following conditions:
  34. *
  35. * The above copyright notice and this permission notice shall be included in
  36. * all copies or substantial portions of the Software.
  37. *
  38. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  39. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  40. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  41. * X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  42. * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
  43. * TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  44. *
  45. * Except as contained in this notice, the name of the X Consortium shall not
  46. * be used in advertising or otherwise to promote the sale, use or other deal-
  47. * ings in this Software without prior written authorization from the X Consor-
  48. * tium.
  49. *
  50. * X Window System is a trademark of X Consortium, Inc.
  51. */
  52. #ifndef _PCF_PRIVATE_H
  53. #define _PCF_PRIVATE_H
  54. /* #include <X11/Xproto.h> */
  55. #include "general_header.h"
  56. #include "pcf.h"
  57. #define GLYPHPADOPTIONS 4
  58. #define BUFFILESIZE 8192
  59. #define BUFFILEEOF -1
  60. #ifndef LSBFirst
  61. #define LSBFirst 0
  62. #define MSBFirst 1
  63. #endif
  64. #ifndef TRUE
  65. #define TRUE 1
  66. #endif
  67. #ifndef FALSE
  68. #define FALSE 0
  69. #endif
  70. #ifndef DEBUG
  71. #define debug(x)
  72. #define Ndebug(x)
  73. #else
  74. #define debug(x) x
  75. #define Ndebug(x)
  76. #endif
  77. #define None 0l
  78. #define BITS 16
  79. #define Successful 85
  80. #define AllocError 80
  81. #define OPTARG_SET 1
  82. #define OPTARG_ADD 2
  83. #define OPTARG_SUB 3
  84. #define NBPB 8
  85. typedef unsigned char *pointer;
  86. typedef struct _Font *FontPtr;
  87. typedef struct _FontInfo *FontInfoPtr;
  88. typedef unsigned long fsBitmapFormat;
  89. typedef struct _FontProp *FontPropPtr;
  90. typedef unsigned char BufChar;
  91. typedef unsigned long Atom;
  92. #if BITS > 15
  93. typedef long int code_int;
  94. #else
  95. typedef int code_int;
  96. #endif
  97. #ifdef NO_UCHAR
  98. typedef char char_type;
  99. #else
  100. typedef unsigned char char_type;
  101. #endif /* UCHAR */
  102. char_type magic_header[] = { "\037\235" }; /* 1F 9D */
  103. #define BIT_MASK 0x1f
  104. #define BLOCK_MASK 0x80
  105. #define INIT_BITS 9 /* initial number of bits/code */
  106. #define FIRST 257 /* first free entry */
  107. #define CLEAR 256 /* table clear output code */
  108. #define CUF_ILCH -1
  109. #define CUF_NICH -2
  110. #ifndef UCS4_MAXVAL
  111. #define UCS4_MAXVAL 0x0000ffff
  112. #endif
  113. #ifdef COMPATIBLE /* But wrong! */
  114. # define MAXCODE(n_bits) (1 << (n_bits) - 1)
  115. #else
  116. # define MAXCODE(n_bits) ((1 << (n_bits)) - 1)
  117. #endif /* COMPATIBLE */
  118. #define dprintf2(f,a1,a2) fprintf(stderr,f,a1,a2)
  119. #define dprintf3(f,a1,a2,a3) fprintf(stderr,f,a1,a2,a3)
  120. #define dprintf6(f,a1,a2,a3,a4,a5,a6) fprintf(stderr,f,a1,a2,a3,a4,a5,a6)
  121. #define xalloc(n) Xalloc ((unsigned) n)
  122. #define xfree(p) if ((p)) free(p)
  123. #define xrealloc(p,n) Xrealloc ((pointer)p,n)
  124. #define lowbit(x) ((x) & (~(x) + 1))
  125. #define FontFileRead(f,b,n) BufFileRead(f,b,n)
  126. #define NO_SUCH_CHAR -1
  127. #define PCF_BIT_MASK (1<<3)
  128. #define PCF_SIZE_TO_INDEX(s) ((s) == 4 ? 2 : (s) == 2 ? 1 : 0)
  129. #define PCF_ACCEL_W_INKBOUNDS 0x00000100
  130. #define PCF_BDF_ENCODINGS (1<<5)
  131. #define PCF_BYTE_MASK (1<<2)
  132. #define PCF_COMPRESSED_METRICS 0x00000100
  133. #define PCF_DEFAULT_FORMAT 0x00000000
  134. #define PCF_FORMAT_MASK 0xffffff00
  135. #define PCF_FORMAT_MATCH(a,b) (((a)&PCF_FORMAT_MASK) == ((b)&PCF_FORMAT_MASK))
  136. #define PCF_FILE_VERSION (('p'<<24)|('c'<<16)|('f'<<8)|1)
  137. #define PCF_BYTE_ORDER(f) (((f) & PCF_BYTE_MASK)?MSBFirst:LSBFirst)
  138. #define PCF_BIT_ORDER(f) (((f) & PCF_BIT_MASK)?MSBFirst:LSBFirst)
  139. #define PCF_PROPERTIES (1<<0)
  140. #define PCF_ACCELERATORS (1<<1)
  141. #define PCF_METRICS (1<<2)
  142. #define PCF_BITMAPS (1<<3)
  143. #define PCF_INK_METRICS (1<<4)
  144. #define PCF_BDF_ENCODINGS (1<<5)
  145. #define PCF_SWIDTHS (1<<6)
  146. #define PCF_GLYPH_NAMES (1<<7)
  147. #define PCF_BDF_ACCELERATORS (1<<8)
  148. #define PCF_GLYPH_PAD_MASK (3<<0)
  149. #define PCF_GLYPH_PAD_INDEX(f) ((f) & PCF_GLYPH_PAD_MASK)
  150. #define PCF_GLYPH_PAD(f) (1<<PCF_GLYPH_PAD_INDEX(f))
  151. #define PCF_SCAN_UNIT_MASK (3<<4)
  152. #define PCF_SCAN_UNIT_INDEX(f) (((f) & PCF_SCAN_UNIT_MASK) >> 4)
  153. #define PCF_SCAN_UNIT(f) (1<<PCF_SCAN_UNIT_INDEX(f))
  154. #define BufFileSkip(f,c) ((*(f)->skip) (f, c))
  155. #define BufFileGet(f) ((f)->left-- ? *(f)->bufp++ : (*(f)->io) (f))
  156. #define GLYPHWIDTHPIXELS(pci) \
  157. ((pci)->metrics.rightSideBearing - (pci)->metrics.leftSideBearing)
  158. #define GLYPHHEIGHTPIXELS(pci) \
  159. ((pci)->metrics.ascent + (pci)->metrics.descent)
  160. #define GLYPHWIDTHBYTES(pci) (((GLYPHWIDTHPIXELS(pci))+7) >> 3)
  161. #define GLYPHWIDTHPADDED(bc) (((bc)+7) & ~0x7)
  162. typedef unsigned long ulong_t;
  163. typedef struct _AtomList {
  164. char *name;
  165. int len;
  166. int hash;
  167. Atom atom;
  168. } AtomListRec, *AtomListPtr;
  169. typedef struct _PCFTable {
  170. CARD32 type;
  171. CARD32 format;
  172. CARD32 size;
  173. CARD32 offset;
  174. } PCFTableRec, *PCFTablePtr;
  175. typedef struct _buffile {
  176. BufChar *bufp;
  177. int left;
  178. BufChar buffer[BUFFILESIZE];
  179. int (*io)(/* BufFilePtr f */);
  180. int (*skip)(/* BufFilePtr f, int count */);
  181. int (*close)(/* BufFilePtr f */);
  182. char *_private;
  183. } BufFileRec, *BufFilePtr;
  184. typedef BufFilePtr FontFilePtr;
  185. #define FontFileGetc(f) BufFileGet(f)
  186. #define FontFileSkip(f,n) (BufFileSkip (f, n) != BUFFILEEOF)
  187. typedef struct _FontProp {
  188. long name;
  189. long value; /* assumes ATOM is not larger than INT32 */
  190. } FontPropRec;
  191. typedef struct _FontInfo {
  192. unsigned short firstCol;
  193. unsigned short lastCol;
  194. unsigned short firstRow;
  195. unsigned short lastRow;
  196. unsigned short defaultCh;
  197. unsigned int noOverlap:1;
  198. unsigned int terminalFont:1;
  199. unsigned int constantMetrics:1;
  200. unsigned int constantWidth:1;
  201. unsigned int inkInside:1;
  202. unsigned int inkMetrics:1;
  203. unsigned int allExist:1;
  204. unsigned int drawDirection:2;
  205. unsigned int cachable:1;
  206. unsigned int anamorphic:1;
  207. short maxOverlap;
  208. short pad;
  209. xCharInfo maxbounds;
  210. xCharInfo minbounds;
  211. xCharInfo ink_maxbounds;
  212. xCharInfo ink_minbounds;
  213. short fontAscent;
  214. short fontDescent;
  215. int nprops;
  216. FontPropPtr props;
  217. char *isStringProp;
  218. } FontInfoRec;
  219. typedef struct _BitmapExtra {
  220. Atom *glyphNames;
  221. int *sWidths;
  222. CARD32 bitmapsSizes[GLYPHPADOPTIONS];
  223. FontInfoRec info;
  224. } BitmapExtraRec , *BitmapExtraPtr;
  225. typedef struct _BitmapFont {
  226. unsigned version_num;
  227. int num_chars;
  228. int num_tables;
  229. CharInfoPtr metrics; /* font metrics, including glyph pointers */
  230. xCharInfo *ink_metrics; /* ink metrics */
  231. char *bitmaps; /* base of bitmaps, useful only to free */
  232. CharInfoPtr *encoding; /* array of char info pointers */
  233. CharInfoPtr pDefault; /* default character */
  234. BitmapExtraPtr bitmapExtra; /* stuff not used by X server */
  235. } BitmapFontRec, *BitmapFontPtr;
  236. typedef struct _FontPathElement {
  237. int name_length;
  238. char *name;
  239. int type;
  240. int refcount;
  241. pointer _private;
  242. } FontPathElementRec;
  243. typedef struct _FontPathElement *FontPathElementPtr;
  244. typedef struct _Font {
  245. int refcnt;
  246. FontInfoRec info;
  247. char bit;
  248. char byte;
  249. char glyph;
  250. char scan;
  251. fsBitmapFormat format;
  252. int (*get_glyphs) ( /* font, count, chars, encoding, count, glyphs */ );
  253. int (*get_metrics) ( /* font, count, chars, encoding, count, glyphs */ );
  254. void (*unload_font) ( /* font */ );
  255. FontPathElementPtr fpe;
  256. pointer svrPrivate;
  257. pointer fontPrivate;
  258. pointer fpePrivate;
  259. int maxPrivate;
  260. pointer *devPrivates;
  261. } FontRec;
  262. #define STACK_SIZE 8192
  263. typedef struct _compressedFILE {
  264. BufFilePtr file;
  265. char_type *stackp;
  266. code_int oldcode;
  267. char_type finchar;
  268. int block_compress;
  269. int maxbits;
  270. code_int maxcode, maxmaxcode;
  271. code_int free_ent;
  272. int clear_flg;
  273. int n_bits;
  274. /* bit buffer */
  275. int offset, size;
  276. char_type buf[BITS];
  277. char_type de_stack[STACK_SIZE];
  278. char_type *tab_suffix;
  279. unsigned short *tab_prefix;
  280. } CompressedFile;
  281. #endif /*_PCF_PRIVATE_H */