tkFont.h
上传用户:kellyonhid
上传日期:2013-10-12
资源大小:932k
文件大小:7k
源码类别:

3D图形编程

开发平台:

Visual C++

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