PageRenderTime 49ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/Build/source/texk/ps2pkm/fontstruct.h

https://bitbucket.org/preining/tex-live
C Header | 224 lines | 150 code | 29 blank | 45 comment | 6 complexity | aade26ff67b4fa9da490dac17b8b01b9 MD5 | raw file
  1. /* $Header: fontstruct.h,v 1.10 91/07/22 15:37:41 keith Exp $ */
  2. /***********************************************************
  3. Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
  4. and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  5. All Rights Reserved
  6. Permission to use, copy, modify, and distribute this software and its
  7. documentation for any purpose and without fee is hereby granted,
  8. provided that the above copyright notice appear in all copies and that
  9. both that copyright notice and this permission notice appear in
  10. supporting documentation, and that the names of Digital or MIT not be
  11. used in advertising or publicity pertaining to distribution of the
  12. software without specific, written prior permission.
  13. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  14. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  15. DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  16. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  17. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  18. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  19. SOFTWARE.
  20. @(#)fontstruct.h 3.2 91/04/15
  21. ******************************************************************/
  22. #ifndef FONTSTR_H
  23. #define FONTSTR_H
  24. #ifdef XSERVER
  25. #include <X11/Xproto.h>
  26. #else
  27. #include "Xstuff.h"
  28. #endif
  29. #include "font.h"
  30. /*
  31. * This version of the server font data strucutre is only for describing
  32. * the in memory data structure. The file structure is not necessarily a
  33. * copy of this. That is up to the compiler and the OS layer font loading
  34. * machinery.
  35. */
  36. #define GLYPHPADOPTIONS 4 /* 1, 2, 4, or 8 */
  37. typedef enum {
  38. Linear8Bit, TwoD8Bit, Linear16Bit, TwoD16Bit
  39. } FontEncoding;
  40. typedef struct _FontProp {
  41. long name;
  42. long value; /* assumes ATOM is not larger than INT32 */
  43. } FontPropRec;
  44. typedef struct _FontResolution {
  45. unsigned short x_resolution;
  46. unsigned short y_resolution;
  47. unsigned short point_size;
  48. } FontResolutionRec;
  49. typedef struct _ExtentInfo {
  50. DrawDirection drawDirection;
  51. int fontAscent;
  52. int fontDescent;
  53. int overallAscent;
  54. int overallDescent;
  55. int overallWidth;
  56. int overallLeft;
  57. int overallRight;
  58. } ExtentInfoRec;
  59. typedef struct _CharInfo {
  60. xCharInfo metrics; /* info preformatted for Queries */
  61. char *bits; /* pointer to glyph image */
  62. } CharInfoRec;
  63. /*
  64. * Font is created at font load time. It is specific to a single encoding.
  65. * e.g. not all of the glyphs in a font may be part of a single encoding.
  66. */
  67. typedef struct _FontInfo {
  68. unsigned short firstCol;
  69. unsigned short lastCol;
  70. unsigned short firstRow;
  71. unsigned short lastRow;
  72. unsigned short defaultCh;
  73. unsigned int noOverlap:1;
  74. unsigned int terminalFont:1;
  75. unsigned int constantMetrics:1;
  76. unsigned int constantWidth:1;
  77. unsigned int inkInside:1;
  78. unsigned int inkMetrics:1;
  79. unsigned int allExist:1;
  80. unsigned int drawDirection:2;
  81. unsigned int cachable:1;
  82. unsigned int anamorphic:1;
  83. short maxOverlap;
  84. short pad;
  85. xCharInfo maxbounds;
  86. xCharInfo minbounds;
  87. xCharInfo ink_maxbounds;
  88. xCharInfo ink_minbounds;
  89. short fontAscent;
  90. short fontDescent;
  91. int nprops;
  92. FontPropPtr props;
  93. char *isStringProp;
  94. } FontInfoRec;
  95. typedef struct _Font {
  96. int refcnt;
  97. FontInfoRec info;
  98. char bit;
  99. char byte;
  100. char glyph;
  101. char scan;
  102. fsBitmapFormat format;
  103. int (*get_glyphs) ( /* font, count, chars, encoding, count, glyphs */ );
  104. int (*get_metrics) ( /* font, count, chars, encoding, count, glyphs */ );
  105. int (*get_bitmaps) (/* client, font, flags, ranges, nranges,
  106. nextents, extents */ );
  107. int (*get_extents) (/* client, font, format, flags, ranges,
  108. nranges, nglyphs, offsets, glyphs */ );
  109. void (*unload_font) ( /* font */ );
  110. FontPathElementPtr fpe;
  111. pointer svrPrivate;
  112. pointer fontPrivate;
  113. pointer fpePrivate;
  114. int maxPrivate;
  115. pointer *devPrivates;
  116. } FontRec;
  117. extern Bool _FontSetNewPrivate (/* pFont, n, ptr */);
  118. extern int AllocateFontPrivateIndex ();
  119. #define FontGetPrivate(pFont,n) ((n) > (pFont)->maxPrivate ? (pointer) 0 : \
  120. (pFont)->devPrivates[n])
  121. #define FontSetPrivate(pFont,n,ptr) ((n) > (pFont)->maxPrivate ? \
  122. _FontSetNewPrivate (pFont, n, ptr) : \
  123. ((((pFont)->devPrivates[n] = (ptr)) != 0) || TRUE))
  124. typedef struct _FontNames {
  125. int nnames;
  126. int size;
  127. int *length;
  128. char **names;
  129. } FontNamesRec;
  130. /* External view of font paths */
  131. typedef struct _FontPathElement {
  132. int name_length;
  133. char *name;
  134. int type;
  135. int refcount;
  136. pointer private;
  137. } FontPathElementRec;
  138. typedef struct _FPEFunctions {
  139. int (*name_check) ( /* name */ );
  140. int (*init_fpe) ( /* fpe */ );
  141. int (*reset_fpe) ( /* fpe */ );
  142. int (*free_fpe) ( /* fpe */ );
  143. int (*open_font) ( /* client, fpe, flags, name, namelen, format,
  144. fid, ppfont, alias */ );
  145. int (*close_font) ( /* pfont */ );
  146. int (*list_fonts) ( /* client, fpe, pattern, patlen, maxnames,
  147. paths */ );
  148. int (*start_list_fonts_with_info) ( /* client, fpe, name, namelen,
  149. maxnames, data */ );
  150. int (*list_next_font_with_info) ( /* client, fpe, name, namelen,
  151. info, num, data */ );
  152. int (*wakeup_fpe) ( /* fpe, mask */ );
  153. int (*client_died) ( /* client, fpe */ );
  154. } FPEFunctionsRec, FPEFunctions;
  155. extern int InitFPETypes();
  156. /*
  157. * Various macros for computing values based on contents of
  158. * the above structures
  159. */
  160. #define GLYPHWIDTHPIXELS(pci) \
  161. ((pci)->metrics.rightSideBearing - (pci)->metrics.leftSideBearing)
  162. #define GLYPHHEIGHTPIXELS(pci) \
  163. ((pci)->metrics.ascent + (pci)->metrics.descent)
  164. #define GLYPHWIDTHBYTES(pci) (((GLYPHWIDTHPIXELS(pci))+7) >> 3)
  165. #define GLYPHWIDTHPADDED(bc) (((bc)+7) & ~0x7)
  166. #define BYTES_PER_ROW(bits, nbytes) \
  167. ((nbytes) == 1 ? (((bits)+7)>>3) /* pad to 1 byte */ \
  168. :(nbytes) == 2 ? ((((bits)+15)>>3)&~1) /* pad to 2 bytes */ \
  169. :(nbytes) == 4 ? ((((bits)+31)>>3)&~3) /* pad to 4 bytes */ \
  170. :(nbytes) == 8 ? ((((bits)+63)>>3)&~7) /* pad to 8 bytes */ \
  171. : 0)
  172. #define BYTES_FOR_GLYPH(ci,pad) (GLYPHHEIGHTPIXELS(ci) * \
  173. BYTES_PER_ROW(GLYPHWIDTHPIXELS(ci),pad))
  174. /*
  175. * Macros for computing different bounding boxes for fonts; from
  176. * the font protocol
  177. */
  178. #define FONT_MAX_ASCENT(pi) ((pi)->fontAscent > (pi)->ink_maxbounds.ascent ? \
  179. (pi)->fontAscent : (pi)->ink_maxbounds.ascent)
  180. #define FONT_MAX_DESCENT(pi) ((pi)->fontDescent > (pi)->ink_maxbounds.descent ? \
  181. (pi)->fontDescent : (pi)->ink_maxbounds.descent)
  182. #define FONT_MAX_HEIGHT(pi) (FONT_MAX_ASCENT(pi) + FONT_MAX_DESCENT(pi))
  183. #define FONT_MIN_LEFT(pi) ((pi)->ink_minbounds.leftSideBearing < 0 ? \
  184. (pi)->ink_minbounds.leftSideBearing : 0)
  185. #define FONT_MAX_RIGHT(pi) ((pi)->ink_maxbounds.rightSideBearing > \
  186. (pi)->ink_maxbounds.characterWidth ? \
  187. (pi)->ink_maxbounds.rightSideBearing : \
  188. (pi)->ink_maxbounds.characterWidth)
  189. #define FONT_MAX_WIDTH(pi) (FONT_MAX_RIGHT(pi) - FONT_MIN_LEFT(pi))
  190. #endif /* FONTSTR_H */