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