OSDN Git Service

Merge branch 'master' of git://github.com/monaka/binutils
[pf3gnuchains/pf3gnuchains3x.git] / tk / generic / tkFont.h
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-1997 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  * RCS: @(#) $Id$
14  */
15
16 #ifndef _TKFONT
17 #define _TKFONT
18
19 #ifdef BUILD_tk
20 # undef TCL_STORAGE_CLASS
21 # define TCL_STORAGE_CLASS DLLEXPORT
22 #endif
23
24 /*
25  * The following structure keeps track of the attributes of a font.  It can
26  * be used to keep track of either the desired attributes or the actual
27  * attributes gotten when the font was instantiated.
28  */
29
30 typedef struct TkFontAttributes {
31     Tk_Uid family;              /* Font family, or NULL to represent
32                                  * plaform-specific default system font. */
33     int size;                   /* Pointsize of font, 0 for default size, or
34                                  * negative number meaning pixel size. */
35     int weight;                 /* Weight flag; see below for def'n. */
36     int slant;                  /* Slant flag; see below for def'n. */
37     int underline;              /* Non-zero for underline font. */
38     int overstrike;             /* Non-zero for overstrike font. */
39 } TkFontAttributes;
40
41 /*
42  * Possible values for the "weight" field in a TkFontAttributes structure.
43  * Weight is a subjective term and depends on what the company that created
44  * the font considers bold.
45  */
46
47 #define TK_FW_NORMAL    0
48 #define TK_FW_BOLD      1
49
50 #define TK_FW_UNKNOWN   -1      /* Unknown weight.  This value is used for
51                                  * error checking and is never actually stored
52                                  * in the weight field. */
53
54 /*
55  * Possible values for the "slant" field in a TkFontAttributes structure.
56  */
57
58 #define TK_FS_ROMAN     0       
59 #define TK_FS_ITALIC    1
60 #define TK_FS_OBLIQUE   2       /* This value is only used when parsing X
61                                  * font names to determine the closest
62                                  * match.  It is only stored in the
63                                  * XLFDAttributes structure, never in the
64                                  * slant field of the TkFontAttributes. */
65
66 #define TK_FS_UNKNOWN   -1      /* Unknown slant.  This value is used for
67                                  * error checking and is never actually stored
68                                  * in the slant field. */
69
70 /*
71  * The following structure keeps track of the metrics for an instantiated
72  * font.  The metrics are the physical properties of the font itself.
73  */
74
75 typedef struct TkFontMetrics {
76     int ascent;                 /* From baseline to top of font. */
77     int descent;                /* From baseline to bottom of font. */
78     int maxWidth;               /* Width of widest character in font. */
79     int fixed;                  /* Non-zero if this is a fixed-width font,
80                                  * 0 otherwise. */
81 } TkFontMetrics;
82
83 /*
84  * The following structure is used to keep track of the generic information
85  * about a font.  Each platform-specific font is represented by a structure
86  * with the following structure at its beginning, plus any platform-
87  * specific stuff after that.
88  */
89
90 typedef struct TkFont {
91     /*
92      * Fields used and maintained exclusively by generic code.
93      */
94
95     int resourceRefCount;       /* Number of active uses of this font (each
96                                  * active use corresponds to a call to
97                                  * Tk_AllocFontFromTable or Tk_GetFont).
98                                  * If this count is 0, then this TkFont
99                                  * structure is no longer valid and it isn't
100                                  * present in a hash table: it is being
101                                  * kept around only because there are objects
102                                  * referring to it.  The structure is freed
103                                  * when resourceRefCount and objRefCount
104                                  * are both 0. */
105     int objRefCount;            /* The number of Tcl objects that reference
106                                  * this structure. */
107     Tcl_HashEntry *cacheHashPtr;/* Entry in font cache for this structure,
108                                  * used when deleting it. */
109     Tcl_HashEntry *namedHashPtr;/* Pointer to hash table entry that
110                                  * corresponds to the named font that the
111                                  * tkfont was based on, or NULL if the tkfont
112                                  * was not based on a named font. */
113     Screen *screen;             /* The screen where this font is valid. */
114     int tabWidth;               /* Width of tabs in this font (pixels). */
115     int underlinePos;           /* Offset from baseline to origin of
116                                  * underline bar (used for drawing underlines
117                                  * on a non-underlined font). */
118     int underlineHeight;        /* Height of underline bar (used for drawing
119                                  * underlines on a non-underlined font). */
120
121     /*
122      * Fields used in the generic code that are filled in by
123      * platform-specific code.
124      */
125
126     Font fid;                   /* For backwards compatibility with XGCValues
127                                  * structures.  Remove when TkGCValues is
128                                  * implemented.  */
129     TkFontAttributes fa;        /* Actual font attributes obtained when the
130                                  * the font was created, as opposed to the
131                                  * desired attributes passed in to
132                                  * TkpGetFontFromAttributes().  The desired
133                                  * metrics can be determined from the string
134                                  * that was used to create this font. */
135     TkFontMetrics fm;           /* Font metrics determined when font was
136                                  * created. */
137     struct TkFont *nextPtr;     /* Points to the next TkFont structure with
138                                  * the same name.  All fonts with the
139                                  * same name (but different displays) are
140                                  * chained together off a single entry in
141                                  * a hash table. */
142 } TkFont;
143
144 /*
145  * The following structure is used to return attributes when parsing an
146  * XLFD.  The extra information is of interest to the Unix-specific code
147  * when attempting to find the closest matching font.
148  */
149
150 typedef struct TkXLFDAttributes {
151     Tk_Uid foundry;             /* The foundry of the font. */
152     int slant;                  /* The tristate value for the slant, which
153                                  * is significant under X. */
154     int setwidth;               /* The proportionate width, see below for
155                                  * definition. */
156     Tk_Uid charset;             /* The actual charset string. */
157 } TkXLFDAttributes;
158
159 /*
160  * Possible values for the "setwidth" field in a TkXLFDAttributes structure.
161  * The setwidth is whether characters are considered wider or narrower than
162  * normal.
163  */
164
165 #define TK_SW_NORMAL    0
166 #define TK_SW_CONDENSE  1
167 #define TK_SW_EXPAND    2
168 #define TK_SW_UNKNOWN   3       /* Unknown setwidth.  This value may be
169                                  * stored in the setwidth field. */
170
171 /*
172  * The following defines specify the meaning of the fields in a fully
173  * qualified XLFD.
174  */
175
176 #define XLFD_FOUNDRY        0
177 #define XLFD_FAMILY         1
178 #define XLFD_WEIGHT         2
179 #define XLFD_SLANT          3
180 #define XLFD_SETWIDTH       4
181 #define XLFD_ADD_STYLE      5
182 #define XLFD_PIXEL_SIZE     6
183 #define XLFD_POINT_SIZE     7
184 #define XLFD_RESOLUTION_X   8
185 #define XLFD_RESOLUTION_Y   9
186 #define XLFD_SPACING        10
187 #define XLFD_AVERAGE_WIDTH  11
188 #define XLFD_CHARSET        12
189 #define XLFD_NUMFIELDS      13  /* Number of fields in XLFD. */
190
191 /*
192  * Low-level API exported by generic code to platform-specific code.
193  */
194
195 #define TkInitFontAttributes(fa)   memset((fa), 0, sizeof(TkFontAttributes));
196 #define TkInitXLFDAttributes(xa)   memset((xa), 0, sizeof(TkXLFDAttributes));
197
198 EXTERN int              TkFontParseXLFD _ANSI_ARGS_((CONST char *string,
199                             TkFontAttributes *faPtr, TkXLFDAttributes *xaPtr));
200 EXTERN char **          TkFontGetAliasList _ANSI_ARGS_((CONST char *faceName));
201 EXTERN char ***         TkFontGetFallbacks _ANSI_ARGS_((void));
202 EXTERN int              TkFontGetPixels _ANSI_ARGS_((Tk_Window tkwin, 
203                             int size));
204 EXTERN int              TkFontGetPoints _ANSI_ARGS_((Tk_Window tkwin, 
205                             int size));
206 EXTERN char **          TkFontGetGlobalClass _ANSI_ARGS_((void));
207 EXTERN char **          TkFontGetSymbolClass _ANSI_ARGS_((void));
208
209 /*
210  * Low-level API exported by platform-specific code to generic code. 
211  */
212
213 EXTERN void             TkpDeleteFont _ANSI_ARGS_((TkFont *tkFontPtr));
214 EXTERN void             TkpFontPkgInit _ANSI_ARGS_((TkMainInfo *mainPtr));
215 EXTERN TkFont *         TkpGetFontFromAttributes _ANSI_ARGS_((
216                             TkFont *tkFontPtr, Tk_Window tkwin,
217                             CONST TkFontAttributes *faPtr));
218 EXTERN void             TkpGetFontFamilies _ANSI_ARGS_((Tcl_Interp *interp,
219                             Tk_Window tkwin));
220 EXTERN TkFont *         TkpGetNativeFont _ANSI_ARGS_((Tk_Window tkwin,
221                             CONST char *name));
222
223 # undef TCL_STORAGE_CLASS
224 # define TCL_STORAGE_CLASS DLLIMPORT
225
226 #endif  /* _TKFONT */