home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Tcl-Tk 8.0 / Pre-installed version / tk8.0 / generic / tkFont.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-15  |  6.8 KB  |  209 lines  |  [TEXT/CWIE]

  1. /*
  2.  * tkFont.h --
  3.  *
  4.  *    Declarations for interfaces between the generic and platform-
  5.  *    specific parts of the font package.  This information is not
  6.  *    visible outside of the font package.
  7.  *
  8.  * Copyright (c) 1996 Sun Microsystems, Inc.
  9.  *
  10.  * See the file "license.terms" for information on usage and redistribution
  11.  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  12.  *
  13.  * SCCS: @(#) tkFont.h 1.11 97/05/07 14:44:13
  14.  */
  15.  
  16. #ifndef _TKFONT
  17. #define _TKFONT
  18.  
  19. /*
  20.  * The following structure keeps track of the attributes of a font.  It can
  21.  * be used to keep track of either the desired attributes or the actual
  22.  * attributes gotten when the font was instantiated.
  23.  */
  24.  
  25. typedef struct TkFontAttributes {
  26.     Tk_Uid family;        /* Font family. The most important field. */
  27.     int pointsize;        /* Pointsize of font, 0 for default size, or
  28.                  * negative number meaning pixel size. */
  29.     int weight;            /* Weight flag; see below for def'n. */
  30.     int slant;            /* Slant flag; see below for def'n. */
  31.     int underline;        /* Non-zero for underline font. */
  32.     int overstrike;        /* Non-zero for overstrike font. */
  33. } TkFontAttributes;
  34.  
  35. /*
  36.  * Possible values for the "weight" field in a TkFontAttributes structure.
  37.  * Weight is a subjective term and depends on what the company that created
  38.  * the font considers bold.
  39.  */
  40.  
  41. #define TK_FW_NORMAL    0
  42. #define TK_FW_BOLD    1
  43.  
  44. #define TK_FW_UNKNOWN    -1    /* Unknown weight.  This value is used for
  45.                  * error checking and is never actually stored
  46.                  * in the weight field. */
  47.  
  48. /*
  49.  * Possible values for the "slant" field in a TkFontAttributes structure.
  50.  */
  51.  
  52. #define TK_FS_ROMAN    0    
  53. #define TK_FS_ITALIC    1
  54. #define TK_FS_OBLIQUE    2    /* This value is only used when parsing X
  55.                  * font names to determine the closest
  56.                  * match.  It is only stored in the
  57.                  * XLFDAttributes structure, never in the
  58.                  * slant field of the TkFontAttributes. */
  59.  
  60. #define TK_FS_UNKNOWN    -1    /* Unknown slant.  This value is used for
  61.                  * error checking and is never actually stored
  62.                  * in the slant field. */
  63.  
  64. /*
  65.  * The following structure keeps track of the metrics for an instantiated
  66.  * font.  The metrics are the physical properties of the font itself.
  67.  */
  68.  
  69. typedef struct TkFontMetrics {
  70.     int    ascent;            /* From baseline to top of font. */
  71.     int    descent;        /* From baseline to bottom of font. */
  72.     int maxWidth;        /* Width of widest character in font. */
  73.     int fixed;            /* Non-zero if this is a fixed-width font,
  74.                  * 0 otherwise. */
  75. } TkFontMetrics;
  76.  
  77. /*
  78.  * The following structure is used to keep track of the generic information
  79.  * about a font.  Each platform-specific font is represented by a structure
  80.  * with the following structure at its beginning, plus any platform-
  81.  * specific stuff after that.
  82.  */
  83.  
  84. typedef struct TkFont {
  85.     /*
  86.      * Fields used and maintained exclusively by generic code.
  87.      */
  88.  
  89.     int refCount;        /* Number of users of the TkFont. */
  90.     Tcl_HashEntry *cacheHashPtr;/* Entry in font cache for this structure,
  91.                  * used when deleting it. */
  92.     Tcl_HashEntry *namedHashPtr;/* Pointer to hash table entry that
  93.                  * corresponds to the named font that the
  94.                  * tkfont was based on, or NULL if the tkfont
  95.                  * was not based on a named font. */
  96.     int tabWidth;        /* Width of tabs in this font (pixels). */
  97.     int    underlinePos;        /* Offset from baseline to origin of
  98.                  * underline bar (used for drawing underlines
  99.                  * on a non-underlined font). */
  100.     int underlineHeight;    /* Height of underline bar (used for drawing
  101.                  * underlines on a non-underlined font). */
  102.  
  103.     /*
  104.      * Fields in the generic font structure that are filled in by
  105.      * platform-specific code.
  106.      */
  107.  
  108.     Font fid;            /* For backwards compatibility with XGCValues
  109.                  * structures.  Remove when TkGCValues is
  110.                  * implemented.  */
  111.     TkFontAttributes fa;    /* Actual font attributes obtained when the
  112.                  * the font was created, as opposed to the
  113.                  * desired attributes passed in to
  114.                  * TkpGetFontFromAttributes().  The desired
  115.                  * metrics can be determined from the string
  116.                  * that was used to create this font. */
  117.     TkFontMetrics fm;        /* Font metrics determined when font was
  118.                  * created. */
  119. } TkFont;
  120.  
  121. /*
  122.  * The following structure is used to return attributes when parsing an
  123.  * XLFD.  The extra information is of interest to the Unix-specific code
  124.  * when attempting to find the closest matching font.
  125.  */
  126.  
  127. typedef struct TkXLFDAttributes {
  128.     TkFontAttributes fa;    /* Standard set of font attributes. */
  129.     Tk_Uid foundry;        /* The foundry of the font. */
  130.     int slant;            /* The tristate value for the slant, which
  131.                  * is significant under X. */
  132.     int setwidth;        /* The proportionate width, see below for
  133.                  * definition. */
  134.     int charset;        /* The character set encoding (the glyph
  135.                  * family), see below for definition. */
  136.     int encoding;        /* Variations within a charset for the
  137.                  * glyphs above character 127. */
  138. } TkXLFDAttributes;
  139.  
  140. /*
  141.  * Possible values for the "setwidth" field in a TkXLFDAttributes structure.
  142.  * The setwidth is whether characters are considered wider or narrower than
  143.  * normal.
  144.  */
  145.  
  146. #define TK_SW_NORMAL    0
  147. #define TK_SW_CONDENSE    1
  148. #define TK_SW_EXPAND    2
  149. #define TK_SW_UNKNOWN    3    /* Unknown setwidth.  This value may be
  150.                  * stored in the setwidth field. */
  151.  
  152. /*
  153.  * Possible values for the "charset" field in a TkXLFDAttributes structure.
  154.  * The charset is the set of glyphs that are used in the font.
  155.  */
  156.  
  157. #define TK_CS_NORMAL    0
  158. #define TK_CS_SYMBOL    1
  159. #define TK_CS_OTHER    2
  160.  
  161. /*
  162.  * The following defines specify the meaning of the fields in a fully
  163.  * qualified XLFD.
  164.  */
  165.  
  166. #define XLFD_FOUNDRY        0
  167. #define XLFD_FAMILY        1
  168. #define XLFD_WEIGHT        2
  169. #define XLFD_SLANT        3
  170. #define XLFD_SETWIDTH        4
  171. #define XLFD_ADD_STYLE        5
  172. #define XLFD_PIXEL_SIZE        6
  173. #define XLFD_POINT_SIZE        7
  174. #define XLFD_RESOLUTION_X   8
  175. #define XLFD_RESOLUTION_Y   9
  176. #define XLFD_SPACING        10
  177. #define XLFD_AVERAGE_WIDTH  11
  178. #define XLFD_REGISTRY        12
  179. #define XLFD_ENCODING        13
  180. #define XLFD_NUMFIELDS        14    /* Number of fields in XLFD. */
  181.  
  182. /*
  183.  * Exported from generic code to platform-specific code.
  184.  */
  185.  
  186. EXTERN int        TkCreateNamedFont _ANSI_ARGS_((Tcl_Interp *interp,
  187.                 Tk_Window tkwin, CONST char *name,
  188.                 TkFontAttributes *faPtr));
  189. EXTERN void        TkInitFontAttributes _ANSI_ARGS_((
  190.                 TkFontAttributes *faPtr));
  191. EXTERN int        TkParseXLFD _ANSI_ARGS_((CONST char *string, 
  192.                 TkXLFDAttributes *xaPtr));
  193.  
  194. /*
  195.  * Common APIs exported to tkFont.c from all platform-specific
  196.  * implementations. 
  197.  */
  198.  
  199. EXTERN void        TkpDeleteFont _ANSI_ARGS_((TkFont *tkFontPtr));
  200. EXTERN TkFont *        TkpGetFontFromAttributes _ANSI_ARGS_((
  201.                 TkFont *tkFontPtr, Tk_Window tkwin,
  202.                 CONST TkFontAttributes *faPtr));
  203. EXTERN void        TkpGetFontFamilies _ANSI_ARGS_((Tcl_Interp *interp,
  204.                 Tk_Window tkwin));
  205. EXTERN TkFont *        TkpGetNativeFont _ANSI_ARGS_((Tk_Window tkwin,
  206.                 CONST char *name));
  207.  
  208. #endif    /* _TKFONT */
  209.