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