home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / fonts / lib / font / bitmap / snfstr.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-07-17  |  5.7 KB  |  150 lines

  1. /* $XConsortium: snfstr.h,v 1.3 91/07/17 22:12:31 keith Exp $ */
  2. /***********************************************************
  3. Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
  4. and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  5.  
  6.                         All Rights Reserved
  7.  
  8. Permission to use, copy, modify, and distribute this software and its
  9. documentation for any purpose and without fee is hereby granted,
  10. provided that the above copyright notice appear in all copies and that
  11. both that copyright notice and this permission notice appear in
  12. supporting documentation, and that the names of Digital or MIT not be
  13. used in advertising or publicity pertaining to distribution of the
  14. software without specific, written prior permission.
  15.  
  16. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  17. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  18. DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  19. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  20. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  21. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  22. SOFTWARE.
  23.  
  24. ******************************************************************/
  25.  
  26. #ifndef SNFSTR_H
  27. #define SNFSTR_H 1
  28.  
  29. /*-
  30.  * This file describes the Server Natural Font format.
  31.  * SNF fonts are both CPU-dependent and frame buffer bit order dependent.
  32.  * This file is used by:
  33.  *    1)  the server, to hold font information read out of font files.
  34.  *    2)  font converters
  35.  *
  36.  * Each font file contains the following
  37.  * data structures, with no padding in-between.
  38.  *
  39.  *    1)  The XFONTINFO structure
  40.  *        hand-padded to a two-short boundary.
  41.  *        maxbounds.byteoffset is the total number of bytes in the
  42.  *            glpyh array
  43.  *        maxbounds.bitOffset is thetotal width of the unpadded font
  44.  *
  45.  *    2)  The XCHARINFO array
  46.  *        indexed directly with character codes, both on disk
  47.  *        and in memory.
  48.  *
  49.  *    3)  Character glyphs
  50.  *        padded in the server-natural way, and
  51.  *        ordered in the device-natural way.
  52.  *        End of glyphs padded to 32-bit boundary.
  53.  *
  54.  *    4)  nProps font properties
  55.  *
  56.  *    5)  a sequence of null-terminated strings, for font properties
  57.  */
  58.  
  59. #define FONT_FILE_VERSION    4
  60.  
  61. typedef struct _snfFontProp {
  62.     CARD32      name;        /* offset of string */
  63.     INT32       value;        /* number or offset of string */
  64.     Bool        indirect;    /* value is a string offset */
  65. }           snfFontPropRec;
  66.  
  67. /*
  68.  * the following macro definitions describe a font file image in memory
  69.  */
  70. #define ADDRCharInfoRec( pfi)    \
  71.     ((snfCharInfoRec *) &(pfi)[1])
  72.  
  73. #define ADDRCHARGLYPHS( pfi)    \
  74.     (((char *) &(pfi)[1]) + BYTESOFCHARINFO(pfi))
  75.  
  76. /*
  77.  * pad out glyphs to a CARD32 boundary
  78.  */
  79. #define ADDRXFONTPROPS( pfi)  \
  80.     ((snfFontPropRec *) ((char *)ADDRCHARGLYPHS( pfi) + BYTESOFGLYPHINFO(pfi)))
  81.  
  82. #define ADDRSTRINGTAB( pfi)  \
  83.     ((char *)ADDRXFONTPROPS( pfi) + BYTESOFPROPINFO(pfi))
  84.  
  85. #define n2dChars(pfi)    (((pfi)->lastRow - (pfi)->firstRow + 1) * \
  86.              ((pfi)->lastCol - (pfi)->firstCol + 1))
  87. #define    BYTESOFFONTINFO(pfi)    (sizeof(snfFontInfoRec))
  88. #define BYTESOFCHARINFO(pfi)    (sizeof(snfCharInfoRec) * n2dChars(pfi))
  89. #define    BYTESOFPROPINFO(pfi)    (sizeof(snfFontPropRec) * (pfi)->nProps)
  90. #define    BYTESOFSTRINGINFO(pfi)    ((pfi)->lenStrings)
  91. #define    BYTESOFGLYPHINFO(pfi)    (((pfi)->maxbounds.byteOffset+3) & ~0x3)
  92. #define BYTESOFINKINFO(pfi)    (sizeof(snfCharInfoRec) * n2dChars(pfi))
  93.  
  94. typedef struct _snfFontProp *snfFontPropPtr;
  95. typedef struct _snfCharInfo *snfCharInfoPtr;
  96. typedef struct _snfFontInfo *snfFontInfoPtr;
  97.  
  98. typedef struct _snfCharInfo {
  99.     xCharInfo   metrics;    /* info preformatted for Queries */
  100.     unsigned    byteOffset:24;    /* byte offset of the raster from pGlyphs */
  101.     Bool        exists:1;    /* true iff glyph exists for this char */
  102.     unsigned    pad:7;        /* must be zero for now */
  103. }           snfCharInfoRec;
  104.  
  105. typedef struct _snfFontInfo {
  106.     unsigned int version1;    /* version stamp */
  107.     unsigned int allExist;
  108.     unsigned int drawDirection;
  109.     unsigned int noOverlap;    /* true if:
  110.                  * max(rightSideBearing-characterWidth) <=
  111.                  * minbounds->metrics.leftSideBearing */
  112.     unsigned int constantMetrics;
  113.     unsigned int terminalFont;    /* Should be deprecated!  true if: constant
  114.                  * metrics && leftSideBearing == 0 &&
  115.                  * rightSideBearing == characterWidth &&
  116.                  * ascent == fontAscent && descent ==
  117.                  * fontDescent */
  118.     unsigned int linear:1;    /* true if firstRow == lastRow */
  119.     unsigned int constantWidth:1;    /* true if
  120.                      * minbounds->metrics.characterWidth
  121.                      * ==
  122.                      * maxbounds->metrics.characterWidth */
  123.     unsigned int inkInside:1;    /* true if for all defined glyphs:
  124.                  * leftSideBearing >= 0 && rightSideBearing <=
  125.                  * characterWidth && -fontDescent <= ascent <=
  126.                  * fontAscent && -fontAscent <= descent <=
  127.                  * fontDescent */
  128.     unsigned int inkMetrics:1;    /* ink metrics != bitmap metrics */
  129.     /* used with terminalFont */
  130.     /* see font's pInk{CI,Min,Max} */
  131.     unsigned int padding:28;
  132.     unsigned int firstCol;
  133.     unsigned int lastCol;
  134.     unsigned int firstRow;
  135.     unsigned int lastRow;
  136.     unsigned int nProps;
  137.     unsigned int lenStrings;    /* length in bytes of string table */
  138.     unsigned int chDefault;    /* default character */
  139.     int         fontDescent;    /* minimum for quality typography */
  140.     int         fontAscent;    /* minimum for quality typography */
  141.     snfCharInfoRec minbounds;    /* MIN of glyph metrics over all chars */
  142.     snfCharInfoRec maxbounds;    /* MAX of glyph metrics over all chars */
  143.     unsigned int pixDepth;    /* intensity bits per pixel */
  144.     unsigned int glyphSets;    /* number of sets of glyphs, for sub-pixel
  145.                  * positioning */
  146.     unsigned int version2;    /* version stamp double-check */
  147. }           snfFontInfoRec;
  148.  
  149. #endif                /* SNFSTR_H */
  150.