home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / x / xibm.zip / mpel / mpelFont.h < prev    next >
C/C++ Source or Header  |  1992-02-11  |  9KB  |  273 lines

  1. /*
  2.  * Copyright IBM Corporation 1987,1988,1989
  3.  *
  4.  * All Rights Reserved
  5.  *
  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 name of IBM not be
  11.  * used in advertising or publicity pertaining to distribution of the
  12.  * software without specific, written prior permission.
  13.  *
  14.  * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  15.  * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  16.  * IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  17.  * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  18.  * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  19.  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  20.  * SOFTWARE.
  21.  *
  22. */
  23. #ifndef MPEL_FONT_SEEN
  24. #define    MPEL_FONT_SEEN 1
  25. /***********************************************************
  26.         Copyright IBM Corporation 1987,1988
  27.  
  28.                       All Rights Reserved
  29.  
  30. Permission to use, copy, modify, and distribute this software and its 
  31. documentation for any purpose and without fee is hereby granted, 
  32. provided that the above copyright notice appear in all copies and that
  33. both that copyright notice and this permission notice appear in 
  34. supporting documentation, and that the name of IBM not be
  35. used in advertising or publicity pertaining to distribution of the
  36. software without specific, written prior permission.  
  37.  
  38. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  39. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  40. IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  41. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  42. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  43. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  44. SOFTWARE.
  45.  
  46. ******************************************************************/
  47.  
  48. /* $Header: /afs/athena.mit.edu/astaff/project/x11r5/src/athena/ibm/mpel/RCS/mpelFont.h,v 5.1 1992/02/12 00:28:06 jfc Exp $ */
  49. /* $Source: /afs/athena.mit.edu/astaff/project/x11r5/src/athena/ibm/mpel/RCS/mpelFont.h,v $ */
  50.  
  51. #if defined(RCS_HDRS) && !defined(lint)
  52. static char *rcsidmpelfont = "$Header: /afs/athena.mit.edu/astaff/project/x11r5/src/athena/ibm/mpel/RCS/mpelFont.h,v 5.1 1992/02/12 00:28:06 jfc Exp $";
  53. #endif
  54.  
  55.     /*
  56.      * Megapel fonts can be up to 32k words, so use BANK2 (64k) 
  57.      * to hold all of the megapel fonts.  The eight fonts share
  58.      * a pattern area (technically, header 1 is in the pattern area
  59.      * of font 0, but hey...)
  60.      * Format of the font region is:
  61.      *     :-------------------------------:
  62.      *    |    ATF Location Table    |    52 bytes
  63.      *    |    Bookeeping info        |    12 bytes
  64.      *    |    ATF Header 0        |    44 bytes each
  65.      *    |        :        |        :
  66.      *    |    ATF Header 7        |        :
  67.      *    |    Pad            |    96 bytes
  68.      *    |-------------------------------|
  69.      *    |      Pattern area        |  
  70.      *    |      238 bands of 256 bytes    |    60928 bytes
  71.      *    |    each            |
  72.      *    |-------------------------------|
  73.      *    |    Lookup table 0          |    512 bytes each
  74.      *    |        :        |        :
  75.      *    |    Lookup table 7        |        :
  76.      *    `-------------------------------'
  77.      *
  78.      * One megapel font may hold characters from many X fonts
  79.      * (all that are the same width).  Bands in the pattern
  80.      * area are allocated to X fonts (not megapel fonts) and each band
  81.      * has a (one byte) index of the previous band in the font, a (one
  82.      * byte) index of the next free (16 bit) word in the band, a sequence
  83.      * number (so bands within a font can be freed LRU) and 252 bytes (126 
  84.      * words) of pattern data.
  85.      *
  86.      * For each X font we need to maintain:
  87.      *    mpelFont:    (0-7) index of the corresponding megapel font
  88.      *    mpelId:        (0-1024) megapel id of the corresponding font
  89.      *    currentBand:    (0-237) index of the most recently allocated
  90.      *            pattern band.  A value of MPEL_ATF_NOBAND
  91.      *            indicates that no bands have been allocated.
  92.      *    numMapped:    The number of characters mapped in this font.
  93.      *            (used by FreeSpace to figure out which fonts
  94.      *            to clean out)
  95.      *    width,height:    width and height (in pels) of the font.
  96.      *    nChars        the total number of characters in the X font.
  97.      *    mpelMap:    mapping from X character index onto
  98.      *            megapel character index.  Since many X fonts
  99.      *            may share a single megapel font, this is not
  100.      *            a direct mapping.  A value of 0 indicates that
  101.      *            the character is not currently mapped.
  102.      *    lastUse:    fonts are freed on a least recently used basis,
  103.      *            so we need to keep the sequence number of the
  104.      *            most recent use of this X font.
  105.      *    nextXFont:    each megapel font must keep a linked list of X
  106.      *            fonts using it, so it can free things up when
  107.      *            it has to.
  108.      * For the megapel font region we need to maintain:
  109.      *    myFonts:    (mpelMpelFont *[8]) array of pointers to 
  110.      *            structures (in system memory) describing the
  111.      *            megapel fonts that live in the font region.
  112.      *    nextFreeBand:    (0-238) next free pattern band.  A vaue of
  113.      *            MPEL_ATF_NOBAND indicates there are no more free
  114.      *            bands.
  115.      *    nextUse:    highest sequence number for the megapel font
  116.      *            to date.
  117.      * For each megapel font we need to maintain (in system memory):
  118.      *    myRegion:    (mpelSysRegion *) Pointer to the region this
  119.      *            font lives in.
  120.      *    mpelHeader:    (mpelATFHeader *) pointer to header (on megapel
  121.      *            adapter) describing font.
  122.      *    myLookup:    pointer to font lookup table for this megapel 
  123.      *            font.
  124.      *    nextFreePt:    (0-255) next free code point.  Lookup table 
  125.      *            entries that do not correspond to X font 
  126.      *            characters should form a list of free points.
  127.      *            A value of zero indicates there are no more free
  128.      *            points.
  129.      *    xFonts:        (mpelXFont *) pointer to a linked list of X 
  130.      *            fonts using this megapel font.
  131.      */
  132.  
  133.     /*
  134.      * band stuff
  135.      */
  136.  
  137. #define    MPEL_ATF_NUMBANDS    238
  138. #define    MPEL_ATF_MAXBAND    (MPEL_ATF_NUMBANDS-1)
  139. #define    MPEL_ATF_NOBAND        255
  140. #define    MPEL_BAND_PTRNSIZE    127
  141.  
  142. #define    bandSpaceLeft(b)    (MPEL_BAND_PTRNSIZE-(b)->nextPtrn)
  143. #define    bandNextSpace(b)    (&((b)->pattern[(b)->nextPtrn]))
  144.  
  145.     /*
  146.      * mpelMpelFont stuff
  147.      */
  148.  
  149. #define    fontWordSize(m)        (((m)->myHeader->fd.bitsperchar)/16)
  150. #define    mfontWidth(m)        ((m)->myHeader->fd.width)
  151. #define    mfontHeight(m)        ((m)->myHeader->fd.height)
  152.  
  153.     /*
  154.      * mpelXFont stuff
  155.      */
  156. #define    MPEL_ATF_NUMFONTS    8
  157. #define    MPEL_XCHAR_UNDEFINED    0
  158. #define    fontWidth(x)        ((x)->width)
  159. #define    fontHeight(x)        ((x)->height)
  160. #define    fontNChars(x)        ((x)->nChars)
  161. #define    setFontDimensions(x)    \
  162.     {\
  163.         if ((mfontHeight((x)->myMpelFont)!=(x)->height)||\
  164.             (mfontWidth((x)->myMpelFont)!=(x)->width)) {\
  165.             MPELWaitFifo();\
  166.             (x)->myMpelFont->myHeader->fd.width=(x)->width;\
  167.             (x)->myMpelFont->myHeader->fd.height=(x)->height;\
  168.         }\
  169.     }
  170.  
  171.     /*
  172.      * miscellany
  173.      */
  174.  
  175. #define    MPEL_ATF_PADSIZE        96
  176.  
  177.     /*
  178.      * structures located in adapter memory
  179.      */
  180.  
  181. typedef    struct {
  182.     CARD16    numEntries;
  183.     struct {
  184.         CARD16    fid;
  185.         CARD16    addrHigh;
  186.         CARD16    addrLow;
  187.     } entries[8];
  188.     CARD16    pad;
  189. } mpelATFLocTable;
  190.  
  191. typedef struct {
  192.     CARD32        size;
  193.     CARD16        class;
  194.     CARD16        fontId;
  195.     CARD32        fontStyle;
  196.     CARD32        fontAttribute;
  197.     struct FontDescriptor {
  198.         CARD32    fontTotalChars;
  199.         CARD32    tblWordSize;
  200.         CARD16    baseline;
  201.         CARD16    capline;
  202.         CARD16    width;
  203.         CARD16    height;
  204.         CARD16    bitsperchar;
  205.         CARD16    underlineTop;
  206.         CARD16    underlineBase;
  207.         CARD8    monoPitch;
  208.         CARD8    pad;
  209.         CARD32    lookupTblOffset;
  210.     } fd;
  211. } mpelATFHeader;
  212.  
  213. typedef struct {
  214.     CARD32         nextFreeBand;
  215.     CARD32         nextUse;
  216.     struct MPMFONT    *myFonts;
  217. } mpelATFBookeeping;
  218.  
  219. typedef struct {
  220.     CARD8    nextBand;
  221.     CARD8    nextPtrn;
  222.     CARD16    pattern[MPEL_BAND_PTRNSIZE];
  223. } mpelATFBand;
  224.  
  225. typedef CARD16    mpelATFLookup[256];
  226.  
  227. typedef struct {
  228.     mpelATFLocTable        atfLocations;
  229.     mpelATFBookeeping    usage;
  230.     mpelATFHeader        atfHeaders[MPEL_ATF_NUMFONTS];
  231.     CARD8            pad[MPEL_ATF_PADSIZE];
  232.     mpelATFBand        bands[MPEL_ATF_NUMBANDS];
  233.     mpelATFLookup        lookup[MPEL_ATF_NUMFONTS];
  234. } mpelATFRegion;
  235.  
  236.     /*
  237.      * structures in system memory:
  238.      */
  239.  
  240.  
  241. typedef struct MPMFONT {
  242.     mpelATFRegion    *myRegion;
  243.     mpelATFHeader    *myHeader;
  244.     CARD16        *myLookup;
  245.     int         nextFreePt;
  246.     struct MPXFONT    *xFonts;
  247. } mpelMpelFont;
  248.  
  249. typedef struct MPXFONT {
  250.     mpelMpelFont    *myMpelFont;
  251.     unsigned int     mpelId;
  252.     unsigned int     currentBand;
  253.     int         numMapped;
  254.     int         nChars;
  255.     int         width,height;
  256.     unsigned short     firstcol, fontcols, firstrow, fontrows;
  257.     unsigned short     defaultCh;
  258.     CARD8         *mpelMap;
  259.     unsigned int     lastUse;
  260.     struct MPXFONT    *nextXFont;
  261. } mpelXFont;
  262.  
  263. extern int mpelFontPrivateIndex;
  264.  
  265. #ifndef NO_FUNCTION_PROTOTYPES
  266. extern void mpelRemap(mpelXFont *, int, unsigned char *, unsigned char *,
  267.             CharInfoPtr *, FontEncoding);
  268. #else
  269. extern void mpelRemap();
  270. #endif
  271.  
  272. #endif /* ndef MPEL_FONT_SEEN */
  273.