Back to index

tetex-bin  3.0
fontstruct.h
Go to the documentation of this file.
00001 /* $Header: fontstruct.h,v 1.10 91/07/22 15:37:41 keith Exp $ */
00002 /***********************************************************
00003 Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
00004 and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
00005 
00006                         All Rights Reserved
00007 
00008 Permission to use, copy, modify, and distribute this software and its
00009 documentation for any purpose and without fee is hereby granted,
00010 provided that the above copyright notice appear in all copies and that
00011 both that copyright notice and this permission notice appear in
00012 supporting documentation, and that the names of Digital or MIT not be
00013 used in advertising or publicity pertaining to distribution of the
00014 software without specific, written prior permission.
00015 
00016 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
00017 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
00018 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
00019 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
00020 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
00021 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
00022 SOFTWARE.
00023 
00024        @(#)fontstruct.h     3.2    91/04/15
00025 
00026 ******************************************************************/
00027 
00028 #ifndef FONTSTR_H
00029 #define FONTSTR_H
00030 
00031 #ifdef XSERVER
00032 #include <X11/Xproto.h>
00033 #else
00034 #include "Xstuff.h"
00035 #endif
00036 
00037 #include "font.h"
00038 
00039 /*
00040  * This version of the server font data strucutre is only for describing
00041  * the in memory data structure. The file structure is not necessarily a
00042  * copy of this. That is up to the compiler and the OS layer font loading
00043  * machinery.
00044  */
00045 
00046 #define GLYPHPADOPTIONS 4   /* 1, 2, 4, or 8 */
00047 
00048 typedef enum {
00049     Linear8Bit, TwoD8Bit, Linear16Bit, TwoD16Bit
00050 }           FontEncoding;
00051 
00052 typedef struct _FontProp {
00053     long        name;
00054     long        value;             /* assumes ATOM is not larger than INT32 */
00055 }           FontPropRec;
00056 
00057 typedef struct _FontResolution {
00058     unsigned short x_resolution;
00059     unsigned short y_resolution;
00060     unsigned short point_size;
00061 }           FontResolutionRec;
00062 
00063 typedef struct _ExtentInfo {
00064     DrawDirection drawDirection;
00065     int         fontAscent;
00066     int         fontDescent;
00067     int         overallAscent;
00068     int         overallDescent;
00069     int         overallWidth;
00070     int         overallLeft;
00071     int         overallRight;
00072 }           ExtentInfoRec;
00073 
00074 typedef struct _CharInfo {
00075     xCharInfo   metrics;    /* info preformatted for Queries */
00076     char       *bits;              /* pointer to glyph image */
00077 }           CharInfoRec;
00078 
00079 /*
00080  * Font is created at font load time. It is specific to a single encoding.
00081  * e.g. not all of the glyphs in a font may be part of a single encoding.
00082  */
00083 
00084 typedef struct _FontInfo {
00085     unsigned short firstCol;
00086     unsigned short lastCol;
00087     unsigned short firstRow;
00088     unsigned short lastRow;
00089     unsigned short defaultCh;
00090     unsigned int noOverlap:1;
00091     unsigned int terminalFont:1;
00092     unsigned int constantMetrics:1;
00093     unsigned int constantWidth:1;
00094     unsigned int inkInside:1;
00095     unsigned int inkMetrics:1;
00096     unsigned int allExist:1;
00097     unsigned int drawDirection:2;
00098     unsigned int cachable:1;
00099     unsigned int anamorphic:1;
00100     short       maxOverlap;
00101     short       pad;
00102     xCharInfo   maxbounds;
00103     xCharInfo   minbounds;
00104     xCharInfo   ink_maxbounds;
00105     xCharInfo   ink_minbounds;
00106     short       fontAscent;
00107     short       fontDescent;
00108     int         nprops;
00109     FontPropPtr props;
00110     char       *isStringProp;
00111 }           FontInfoRec;
00112 
00113 typedef struct _Font {
00114     int         refcnt;
00115     FontInfoRec info;
00116     char        bit;
00117     char        byte;
00118     char        glyph;
00119     char        scan;
00120     fsBitmapFormat format;
00121     int         (*get_glyphs) ( /* font, count, chars, encoding, count, glyphs */ );
00122     int         (*get_metrics) ( /* font, count, chars, encoding, count, glyphs */ );
00123     int         (*get_bitmaps) (/* client, font, flags, ranges, nranges,
00124                                 nextents, extents */ );
00125     int         (*get_extents) (/* client, font, format, flags, ranges,
00126                                 nranges, nglyphs, offsets, glyphs */ );
00127     void        (*unload_font) ( /* font */ );
00128     FontPathElementPtr fpe;
00129     pointer     svrPrivate;
00130     pointer     fontPrivate;
00131     pointer     fpePrivate;
00132     int              maxPrivate;
00133     pointer   *devPrivates;
00134 }           FontRec;
00135 
00136 extern Bool   _FontSetNewPrivate (/* pFont, n, ptr */);
00137 extern int    AllocateFontPrivateIndex ();
00138 
00139 #define FontGetPrivate(pFont,n) ((n) > (pFont)->maxPrivate ? (pointer) 0 : \
00140                           (pFont)->devPrivates[n])
00141 
00142 #define FontSetPrivate(pFont,n,ptr) ((n) > (pFont)->maxPrivate ? \
00143                      _FontSetNewPrivate (pFont, n, ptr) : \
00144                      ((((pFont)->devPrivates[n] = (ptr)) != 0) || TRUE))
00145 
00146 typedef struct _FontNames {
00147     int         nnames;
00148     int         size;
00149     int        *length;
00150     char      **names;
00151 }           FontNamesRec;
00152 
00153 /* External view of font paths */
00154 typedef struct _FontPathElement {
00155     int         name_length;
00156     char       *name;
00157     int         type;
00158     int         refcount;
00159     pointer     private;
00160 }           FontPathElementRec;
00161 
00162 typedef struct _FPEFunctions {
00163     int         (*name_check) ( /* name */ );
00164     int         (*init_fpe) ( /* fpe */ );
00165     int         (*reset_fpe) ( /* fpe */ );
00166     int         (*free_fpe) ( /* fpe */ );
00167     int         (*open_font) (     /* client, fpe, flags, name, namelen, format,
00168                                fid,  ppfont, alias */ );
00169     int         (*close_font) ( /* pfont */ );
00170     int         (*list_fonts) (    /* client, fpe, pattern, patlen, maxnames,
00171                                 paths */ );
00172     int         (*start_list_fonts_with_info) (  /* client, fpe, name, namelen,
00173                                               maxnames, data */ );
00174     int         (*list_next_font_with_info) (    /* client, fpe, name, namelen,
00175                                             info, num, data */ );
00176     int         (*wakeup_fpe) ( /* fpe, mask */ );
00177     int              (*client_died) ( /* client, fpe */ );
00178 }           FPEFunctionsRec, FPEFunctions;
00179 
00180 extern int  InitFPETypes();
00181 
00182 /*
00183  * Various macros for computing values based on contents of
00184  * the above structures
00185  */
00186 
00187 #define       GLYPHWIDTHPIXELS(pci) \
00188        ((pci)->metrics.rightSideBearing - (pci)->metrics.leftSideBearing)
00189 
00190 #define       GLYPHHEIGHTPIXELS(pci) \
00191        ((pci)->metrics.ascent + (pci)->metrics.descent)
00192 
00193 #define       GLYPHWIDTHBYTES(pci) (((GLYPHWIDTHPIXELS(pci))+7) >> 3)
00194 
00195 #define GLYPHWIDTHPADDED(bc)       (((bc)+7) & ~0x7)
00196 
00197 #define BYTES_PER_ROW(bits, nbytes) \
00198        ((nbytes) == 1 ? (((bits)+7)>>3)   /* pad to 1 byte */ \
00199        :(nbytes) == 2 ? ((((bits)+15)>>3)&~1)    /* pad to 2 bytes */ \
00200        :(nbytes) == 4 ? ((((bits)+31)>>3)&~3)    /* pad to 4 bytes */ \
00201        :(nbytes) == 8 ? ((((bits)+63)>>3)&~7)    /* pad to 8 bytes */ \
00202        : 0)
00203 
00204 #define BYTES_FOR_GLYPH(ci,pad)    (GLYPHHEIGHTPIXELS(ci) * \
00205                              BYTES_PER_ROW(GLYPHWIDTHPIXELS(ci),pad))
00206 /*
00207  * Macros for computing different bounding boxes for fonts; from
00208  * the font protocol
00209  */
00210 
00211 #define FONT_MAX_ASCENT(pi) ((pi)->fontAscent > (pi)->ink_maxbounds.ascent ? \
00212                          (pi)->fontAscent : (pi)->ink_maxbounds.ascent)
00213 #define FONT_MAX_DESCENT(pi)       ((pi)->fontDescent > (pi)->ink_maxbounds.descent ? \
00214                          (pi)->fontDescent : (pi)->ink_maxbounds.descent)
00215 #define FONT_MAX_HEIGHT(pi) (FONT_MAX_ASCENT(pi) + FONT_MAX_DESCENT(pi))
00216 #define FONT_MIN_LEFT(pi)   ((pi)->ink_minbounds.leftSideBearing < 0 ? \
00217                          (pi)->ink_minbounds.leftSideBearing : 0)
00218 #define FONT_MAX_RIGHT(pi)  ((pi)->ink_maxbounds.rightSideBearing > \
00219                             (pi)->ink_maxbounds.characterWidth ? \
00220                          (pi)->ink_maxbounds.rightSideBearing : \
00221                             (pi)->ink_maxbounds.characterWidth)
00222 #define FONT_MAX_WIDTH(pi)  (FONT_MAX_RIGHT(pi) - FONT_MIN_LEFT(pi))
00223 
00224 #endif                      /* FONTSTR_H */