2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: Font.c /main/11 1996/04/13 11:54:17 ageorge $ */
24 /************************************<+>*************************************
25 ****************************************************************************
27 ** (c) Copyright 1987, 1988, 1989, 1990, 1991, 1992 Hewlett-Packard Company
29 ** (c) Copyright 1993, 1994 Hewlett-Packard Company
30 ** (c) Copyright 1993, 1994 International Business Machines Corp.
31 ** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
32 ** (c) Copyright 1993, 1994 Novell, Inc.
34 ****************************************************************************
35 ************************************<+>*************************************/
42 #include <X11/Xlibint.h>
43 #include <X11/Xresource.h>
49 #include "DisplayAreaP.h"
56 #include "StringFuncsI.h"
61 /******** Private Function Declarations ********/
62 /******** End Public Function Declarations ********/
64 /******************************************************************************
66 * Private variables and defines.
68 *****************************************************************************/
69 static const char *FontResources[] =
71 /*! The serif proportional family */
73 "*p.6.roman.medium.serif.*.ISO-8859-1: -dt-application-medium-r-normal-serif-*-80-*-*-p-*-iso8859-1",
74 "*p.8.roman.medium.serif.*.ISO-8859-1: -dt-application-medium-r-normal-serif-*-100-*-*-p-*-iso8859-1",
75 "*p.10.roman.medium.serif.*.ISO-8859-1: -dt-application-medium-r-normal-serif-*-120-*-*-p-*-iso8859-1",
76 "*p.12.roman.medium.serif.*.ISO-8859-1: -dt-application-medium-r-normal-serif-*-140-*-*-p-*-iso8859-1",
77 "*p.14.roman.medium.serif.*.ISO-8859-1: -dt-application-medium-r-normal-serif-*-180-*-*-p-*-iso8859-1",
80 "*p.6.roman.bold.serif.*.ISO-8859-1: -dt-application-bold-r-normal-serif-*-80-*-*-p-*-iso8859-1",
81 "*p.8.roman.bold.serif.*.ISO-8859-1: -dt-application-bold-r-normal-serif-*-100-*-*-p-*-iso8859-1",
82 "*p.10.roman.bold.serif.*.ISO-8859-1: -dt-application-bold-r-normal-serif-*-120-*-*-p-*-iso8859-1",
83 "*p.12.roman.bold.serif.*.ISO-8859-1: -dt-application-bold-r-normal-serif-*-140-*-*-p-*-iso8859-1",
84 "*p.14.roman.bold.serif.*.ISO-8859-1: -dt-application-bold-r-normal-serif-*-180-*-*-p-*-iso8859-1",
87 "*p.6.italic.medium.serif.*.ISO-8859-1: -dt-application-medium-i-normal-serif-*-80-*-*-p-*-iso8859-1",
88 "*p.8.italic.medium.serif.*.ISO-8859-1: -dt-application-medium-i-normal-serif-*-100-*-*-p-*-iso8859-1",
89 "*p.10.italic.medium.serif.*.ISO-8859-1: -dt-application-medium-i-normal-serif-*-120-*-*-p-*-iso8859-1",
90 "*p.12.italic.medium.serif.*.ISO-8859-1: -dt-application-medium-i-normal-serif-*-140-*-*-p-*-iso8859-1",
91 "*p.14.italic.medium.serif.*.ISO-8859-1: -dt-application-medium-i-normal-serif-*-180-*-*-p-*-iso8859-1",
94 "*p.6.italic.bold.serif.*.ISO-8859-1: -dt-application-bold-i-normal-serif-*-80-*-*-p-*-iso8859-1",
95 "*p.8.italic.bold.serif.*.ISO-8859-1: -dt-application-bold-i-normal-serif-*-100-*-*-p-*-iso8859-1",
96 "*p.10.italic.bold.serif.*.ISO-8859-1: -dt-application-bold-i-normal-serif-*-120-*-*-p-*-iso8859-1",
97 "*p.12.italic.bold.serif.*.ISO-8859-1: -dt-application-bold-i-normal-serif-*-140-*-*-p-*-iso8859-1",
98 "*p.14.italic.bold.serif.*.ISO-8859-1: -dt-application-bold-i-normal-serif-*-180-*-*-p-*-iso8859-1",
100 /*! The sans serif proportional family */
101 /*! medium upright */
102 "*p.6.roman.medium.sans_serif.*.ISO-8859-1: -dt-application-medium-r-normal-sans-*-80-*-*-p-*-iso8859-1",
103 "*p.8.roman.medium.sans_serif.*.ISO-8859-1: -dt-application-medium-r-normal-sans-*-100-*-*-p-*-iso8859-1",
104 "*p.10.roman.medium.sans_serif.*.ISO-8859-1: -dt-application-medium-r-normal-sans-*-120-*-*-p-*-iso8859-1",
105 "*p.12.roman.medium.sans_serif.*.ISO-8859-1: -dt-application-medium-r-normal-sans-*-140-*-*-p-*-iso8859-1",
106 "*p.14.roman.medium.sans_serif.*.ISO-8859-1: -dt-application-medium-r-normal-sans-*-180-*-*-p-*-iso8859-1",
109 "*p.6.roman.bold.sans_serif.*.ISO-8859-1: -dt-application-bold-r-normal-sans-*-80-*-*-p-*-iso8859-1",
110 "*p.8.roman.bold.sans_serif.*.ISO-8859-1: -dt-application-bold-r-normal-sans-*-100-*-*-p-*-iso8859-1",
111 "*p.10.roman.bold.sans_serif.*.ISO-8859-1: -dt-application-bold-r-normal-sans-*-120-*-*-p-*-iso8859-1",
112 "*p.12.roman.bold.sans_serif.*.ISO-8859-1: -dt-application-bold-r-normal-sans-*-140-*-*-p-*-iso8859-1",
113 "*p.14.roman.bold.sans_serif.*.ISO-8859-1: -dt-application-bold-r-normal-sans-*-180-*-*-p-*-iso8859-1",
116 "*p.6.italic.medium.sans_serif.*.ISO-8859-1: -dt-application-medium-i-normal-sans-*-80-*-*-p-*-iso8859-1",
117 "*p.8.italic.medium.sans_serif.*.ISO-8859-1: -dt-application-medium-i-normal-sans-*-100-*-*-p-*-iso8859-1",
118 "*p.10.italic.medium.sans_serif.*.ISO-8859-1: -dt-application-medium-i-normal-sans-*-120-*-*-p-*-iso8859-1",
119 "*p.12.italic.medium.sans_serif.*.ISO-8859-1: -dt-application-medium-i-normal-sans-*-140-*-*-p-*-iso8859-1",
120 "*p.14.italic.medium.sans_serif.*.ISO-8859-1: -dt-application-medium-i-normal-sans-*-180-*-*-p-*-iso8859-1",
123 "*p.6.italic.bold.sans_serif.*.ISO-8859-1: -dt-application-bold-i-normal-sans-*-80-*-*-p-*-iso8859-1",
124 "*p.8.italic.bold.sans_serif.*.ISO-8859-1: -dt-application-bold-i-normal-sans-*-100-*-*-p-*-iso8859-1",
125 "*p.10.italic.bold.sans_serif.*.ISO-8859-1: -dt-application-bold-i-normal-sans-*-120-*-*-p-*-iso8859-1",
126 "*p.12.italic.bold.sans_serif.*.ISO-8859-1: -dt-application-bold-i-normal-sans-*-140-*-*-p-*-iso8859-1",
127 "*p.14.italic.bold.sans_serif.*.ISO-8859-1: -dt-application-bold-i-normal-sans-*-180-*-*-p-*-iso8859-1",
129 /*! The monospace family - lump serif & sans serif together */
130 /*! medium upright */
131 "*m.6.roman.medium.*.*.ISO-8859-1: -dt-application-medium-r-normal-*-*-80-*-*-m-*-iso8859-1",
132 "*m.8.roman.medium.*.*.ISO-8859-1: -dt-application-medium-r-normal-*-*-100-*-*-m-*-iso8859-1",
133 "*m.10.roman.medium.*.*.ISO-8859-1: -dt-application-medium-r-normal-*-*-120-*-*-m-*-iso8859-1",
134 "*m.12.roman.medium.*.*.ISO-8859-1: -dt-application-medium-r-normal-*-*-140-*-*-m-*-iso8859-1",
135 "*m.14.roman.medium.*.*.ISO-8859-1: -dt-application-medium-r-normal-*-*-180-*-*-m-*-iso8859-1",
138 "*m.6.roman.bold.*.*.ISO-8859-1: -dt-application-bold-r-normal-*-*-80-*-*-m-*-iso8859-1",
139 "*m.8.roman.bold.*.*.ISO-8859-1: -dt-application-bold-r-normal-*-*-100-*-*-m-*-iso8859-1",
140 "*m.10.roman.bold.*.*.ISO-8859-1: -dt-application-bold-r-normal-*-*-120-*-*-m-*-iso8859-1",
141 "*m.12.roman.bold.*.*.ISO-8859-1: -dt-application-bold-r-normal-*-*-140-*-*-m-*-iso8859-1",
142 "*m.14.roman.bold.*.*.ISO-8859-1: -dt-application-bold-r-normal-*-*-180-*-*-m-*-iso8859-1",
145 "*m.6.italic.medium.*.*.ISO-8859-1: -dt-application-medium-i-normal-*-*-80-*-*-m-*-iso8859-1",
146 "*m.8.italic.medium.*.*.ISO-8859-1: -dt-application-medium-i-normal-*-*-100-*-*-m-*-iso8859-1",
147 "*m.10.italic.medium.*.*.ISO-8859-1: -dt-application-medium-i-normal-*-*-120-*-*-m-*-iso8859-1",
148 "*m.12.italic.medium.*.*.ISO-8859-1: -dt-application-medium-i-normal-*-*-140-*-*-m-*-iso8859-1",
149 "*m.14.italic.medium.*.*.ISO-8859-1: -dt-application-medium-i-normal-*-*-180-*-*-m-*-iso8859-1",
152 "*m.6.italic.bold.*.*.ISO-8859-1: -dt-application-bold-i-normal-*-*-80-*-*-m-*-iso8859-1",
153 "*m.8.italic.bold.*.*.ISO-8859-1: -dt-application-bold-i-normal-*-*-100-*-*-m-*-iso8859-1",
154 "*m.10.italic.bold.*.*.ISO-8859-1: -dt-application-bold-i-normal-*-*-120-*-*-m-*-iso8859-1",
155 "*m.12.italic.bold.*.*.ISO-8859-1: -dt-application-bold-i-normal-*-*-140-*-*-m-*-iso8859-1",
156 "*m.14.italic.bold.*.*.ISO-8859-1: -dt-application-bold-i-normal-*-*-180-*-*-m-*-iso8859-1",
159 "*6.*.*.*.*.DT-SYMBOL-1: -dt-application-medium-r-normal-*-*-80-*-*-*-*-dtsymbol-1",
160 "*8.*.*.*.*.DT-SYMBOL-1: -dt-application-medium-r-normal-*-*-100-*-*-*-*-dtsymbol-1",
161 "*10.*.*.*.*.DT-SYMBOL-1: -dt-application-medium-r-normal-*-*-120-*-*-*-*-dtsymbol-1",
162 "*12.*.*.*.*.DT-SYMBOL-1: -dt-application-medium-r-normal-*-*-140-*-*-*-*-dtsymbol-1",
163 "*14.*.*.*.*.DT-SYMBOL-1: -dt-application-medium-r-normal-*-*-180-*-*-*-*-dtsymbol-1",
166 "*.6.*.*.*.*.ISO-8859-2: -dt-interface user-medium-r-normal-xs*-*-*-*-*-*-*-*-*:",
167 "*.8.*.*.*.*.ISO-8859-2: -dt-interface user-medium-r-normal-s*-*-*-*-*-*-*-*-*:",
168 "*.10.*.*.*.*.ISO-8859-2: -dt-interface user-medium-r-normal-m*-*-*-*-*-*-*-*-*:",
169 "*.12.*.*.*.*.ISO-8859-2: -dt-interface user-medium-r-normal-l*-*-*-*-*-*-*-*-*:",
170 "*.14.*.*.*.*.ISO-8859-2: -dt-interface user-medium-r-normal-xl*-*-*-*-*-*-*-*-*:",
172 "*.6.*.*.*.*.ISO-8859-5: -dt-interface user-medium-r-normal-xs*-*-*-*-*-*-*-*-*:",
173 "*.8.*.*.*.*.ISO-8859-5: -dt-interface user-medium-r-normal-s*-*-*-*-*-*-*-*-*:",
174 "*.10.*.*.*.*.ISO-8859-5: -dt-interface user-medium-r-normal-m*-*-*-*-*-*-*-*-*:",
175 "*.12.*.*.*.*.ISO-8859-5: -dt-interface user-medium-r-normal-l*-*-*-*-*-*-*-*-*:",
176 "*.14.*.*.*.*.ISO-8859-5: -dt-interface user-medium-r-normal-xl*-*-*-*-*-*-*-*-*:",
178 "*.6.*.*.*.*.ISO-8859-6: -dt-interface user-medium-r-normal-xs*-*-*-*-*-*-*-*-*:",
179 "*.8.*.*.*.*.ISO-8859-6: -dt-interface user-medium-r-normal-s*-*-*-*-*-*-*-*-*:",
180 "*.10.*.*.*.*.ISO-8859-6: -dt-interface user-medium-r-normal-m*-*-*-*-*-*-*-*-*:",
181 "*.12.*.*.*.*.ISO-8859-6: -dt-interface user-medium-r-normal-l*-*-*-*-*-*-*-*-*:",
182 "*.14.*.*.*.*.ISO-8859-6: -dt-interface user-medium-r-normal-xl*-*-*-*-*-*-*-*-*:",
184 "*.6.*.*.*.*.ISO-8859-7: -dt-interface user-medium-r-normal-xs*-*-*-*-*-*-*-*-*:",
185 "*.8.*.*.*.*.ISO-8859-7: -dt-interface user-medium-r-normal-s*-*-*-*-*-*-*-*-*:",
186 "*.10.*.*.*.*.ISO-8859-7: -dt-interface user-medium-r-normal-m*-*-*-*-*-*-*-*-*:",
187 "*.12.*.*.*.*.ISO-8859-7: -dt-interface user-medium-r-normal-l*-*-*-*-*-*-*-*-*:",
188 "*.14.*.*.*.*.ISO-8859-7: -dt-interface user-medium-r-normal-xl*-*-*-*-*-*-*-*-*:",
190 "*.6.*.*.*.*.ISO-8859-8: -dt-interface user-medium-r-normal-xs*-*-*-*-*-*-*-*-*:",
191 "*.8.*.*.*.*.ISO-8859-8: -dt-interface user-medium-r-normal-s*-*-*-*-*-*-*-*-*:",
192 "*.10.*.*.*.*.ISO-8859-8: -dt-interface user-medium-r-normal-m*-*-*-*-*-*-*-*-*:",
193 "*.12.*.*.*.*.ISO-8859-8: -dt-interface user-medium-r-normal-l*-*-*-*-*-*-*-*-*:",
194 "*.14.*.*.*.*.ISO-8859-8: -dt-interface user-medium-r-normal-xl*-*-*-*-*-*-*-*-*:",
196 "*.6.*.*.*.*.ISO-8859-9: -dt-interface user-medium-r-normal-xs*-*-*-*-*-*-*-*-*:",
197 "*.8.*.*.*.*.ISO-8859-9: -dt-interface user-medium-r-normal-s*-*-*-*-*-*-*-*-*:",
198 "*.10.*.*.*.*.ISO-8859-9: -dt-interface user-medium-r-normal-m*-*-*-*-*-*-*-*-*:",
199 "*.12.*.*.*.*.ISO-8859-9: -dt-interface user-medium-r-normal-l*-*-*-*-*-*-*-*-*:",
200 "*.14.*.*.*.*.ISO-8859-9: -dt-interface user-medium-r-normal-xl*-*-*-*-*-*-*-*-*:",
202 "*.6.*.*.*.*.EUC-KR: -dt-interface user-medium-r-normal-xs*-*-*-*-*-*-*-*-*:",
203 "*.8.*.*.*.*.EUC-KR: -dt-interface user-medium-r-normal-s*-*-*-*-*-*-*-*-*:",
204 "*.10.*.*.*.*.EUC-KR: -dt-interface user-medium-r-normal-m*-*-*-*-*-*-*-*-*:",
205 "*.12.*.*.*.*.EUC-KR: -dt-interface user-medium-r-normal-l*-*-*-*-*-*-*-*-*:",
206 "*.14.*.*.*.*.EUC-KR: -dt-interface user-medium-r-normal-xl*-*-*-*-*-*-*-*-*:",
208 "*.6.*.*.*.*.EUC-JP: -dt-interface user-medium-r-normal-xs*-*-*-*-*-*-*-*-*:",
209 "*.8.*.*.*.*.EUC-JP: -dt-interface user-medium-r-normal-s*-*-*-*-*-*-*-*-*:",
210 "*.10.*.*.*.*.EUC-JP: -dt-interface user-medium-r-normal-m*-*-*-*-*-*-*-*-*:",
211 "*.12.*.*.*.*.EUC-JP: -dt-interface user-medium-r-normal-l*-*-*-*-*-*-*-*-*:",
212 "*.14.*.*.*.*.EUC-JP: -dt-interface user-medium-r-normal-xl*-*-*-*-*-*-*-*-*:",
214 "*.6.*.*.*.*.EUC-TW: -dt-interface user-medium-r-normal-xs*-*-*-*-*-*-*-*-*:",
215 "*.8.*.*.*.*.EUC-TW: -dt-interface user-medium-r-normal-s*-*-*-*-*-*-*-*-*:",
216 "*.10.*.*.*.*.EUC-TW: -dt-interface user-medium-r-normal-m*-*-*-*-*-*-*-*-*:",
217 "*.12.*.*.*.*.EUC-TW: -dt-interface user-medium-r-normal-l*-*-*-*-*-*-*-*-*:",
218 "*.14.*.*.*.*.EUC-TW: -dt-interface user-medium-r-normal-xl*-*-*-*-*-*-*-*-*:",
220 "*.6.*.*.*.*.EUC-CN: -dt-interface user-medium-r-normal-xs*-*-*-*-*-*-*-*-*:",
221 "*.8.*.*.*.*.EUC-CN: -dt-interface user-medium-r-normal-s*-*-*-*-*-*-*-*-*:",
222 "*.10.*.*.*.*.EUC-CN: -dt-interface user-medium-r-normal-m*-*-*-*-*-*-*-*-*:",
223 "*.12.*.*.*.*.EUC-CN: -dt-interface user-medium-r-normal-l*-*-*-*-*-*-*-*-*:",
224 "*.14.*.*.*.*.EUC-CN: -dt-interface user-medium-r-normal-xl*-*-*-*-*-*-*-*-*:",
226 "*.6.*.*.*.*.IBM-437: -dt-interface user-medium-r-normal-xs*-*-*-*-*-*-*-*-*:",
227 "*.8.*.*.*.*.IBM-437: -dt-interface user-medium-r-normal-s*-*-*-*-*-*-*-*-*:",
228 "*.10.*.*.*.*.IBM-437: -dt-interface user-medium-r-normal-m*-*-*-*-*-*-*-*-*:",
229 "*.12.*.*.*.*.IBM-437: -dt-interface user-medium-r-normal-l*-*-*-*-*-*-*-*-*:",
230 "*.14.*.*.*.*.IBM-437: -dt-interface user-medium-r-normal-xl*-*-*-*-*-*-*-*-*:",
232 "*.6.*.*.*.*.IBM-850: -dt-interface user-medium-r-normal-xs*-*-*-*-*-*-*-*-*:",
233 "*.8.*.*.*.*.IBM-850: -dt-interface user-medium-r-normal-s*-*-*-*-*-*-*-*-*:",
234 "*.10.*.*.*.*.IBM-850: -dt-interface user-medium-r-normal-m*-*-*-*-*-*-*-*-*:",
235 "*.12.*.*.*.*.IBM-850: -dt-interface user-medium-r-normal-l*-*-*-*-*-*-*-*-*:",
236 "*.14.*.*.*.*.IBM-850: -dt-interface user-medium-r-normal-xl*-*-*-*-*-*-*-*-*:",
238 "*.6.*.*.*.*.IBM-856: -dt-interface user-medium-r-normal-xs*-*-*-*-*-*-*-*-*:",
239 "*.8.*.*.*.*.IBM-856: -dt-interface user-medium-r-normal-s*-*-*-*-*-*-*-*-*:",
240 "*.10.*.*.*.*.IBM-856: -dt-interface user-medium-r-normal-m*-*-*-*-*-*-*-*-*:",
241 "*.12.*.*.*.*.IBM-856: -dt-interface user-medium-r-normal-l*-*-*-*-*-*-*-*-*:",
242 "*.14.*.*.*.*.IBM-856: -dt-interface user-medium-r-normal-xl*-*-*-*-*-*-*-*-*:",
244 "*.6.*.*.*.*.IBM-932: -dt-interface user-medium-r-normal-xs*-*-*-*-*-*-*-*-*:",
245 "*.8.*.*.*.*.IBM-932: -dt-interface user-medium-r-normal-s*-*-*-*-*-*-*-*-*:",
246 "*.10.*.*.*.*.IBM-932: -dt-interface user-medium-r-normal-m*-*-*-*-*-*-*-*-*:",
247 "*.12.*.*.*.*.IBM-932: -dt-interface user-medium-r-normal-l*-*-*-*-*-*-*-*-*:",
248 "*.14.*.*.*.*.IBM-932: -dt-interface user-medium-r-normal-xl*-*-*-*-*-*-*-*-*:",
250 "*.6.*.*.*.*.IBM-1046: -dt-interface user-medium-r-normal-xs*-*-*-*-*-*-*-*-*:",
251 "*.8.*.*.*.*.IBM-1046: -dt-interface user-medium-r-normal-s*-*-*-*-*-*-*-*-*:",
252 "*.10.*.*.*.*.IBM-1046: -dt-interface user-medium-r-normal-m*-*-*-*-*-*-*-*-*:",
253 "*.12.*.*.*.*.IBM-1046: -dt-interface user-medium-r-normal-l*-*-*-*-*-*-*-*-*:",
254 "*.14.*.*.*.*.IBM-1046: -dt-interface user-medium-r-normal-xl*-*-*-*-*-*-*-*-*:",
256 "*.6.*.*.*.*.UTF-8: -dt-interface user-medium-r-normal-xs*-*-*-*-*-*-*-*-*:",
257 "*.8.*.*.*.*.UTF-8: -dt-interface user-medium-r-normal-s*-*-*-*-*-*-*-*-*:",
258 "*.10.*.*.*.*.UTF-8: -dt-interface user-medium-r-normal-m*-*-*-*-*-*-*-*-*:",
259 "*.12.*.*.*.*.UTF-8: -dt-interface user-medium-r-normal-l*-*-*-*-*-*-*-*-*:",
260 "*.14.*.*.*.*.UTF-8: -dt-interface user-medium-r-normal-xl*-*-*-*-*-*-*-*-*:",
266 static Boolean QuarksInited = FALSE;
267 static XrmQuark StringFontQuark = 0;
268 static XrmName DefaultFontQuarks[_DtHelpFontQuarkNumber];
269 static XrmBinding FontBindings[_DtHelpFontQuarkNumber] =
270 { XrmBindLoosely, XrmBindLoosely, XrmBindLoosely, XrmBindLoosely,
271 XrmBindLoosely, XrmBindLoosely, XrmBindLoosely };
273 static DtHelpDAFSMetrics DefaultMetrics = { FALSE, { 0, 0 } };
274 static DtHelpDAFontInfo DefFontInfo = { NULL, NULL, NULL, NULL, NULL,
275 NULL, 0, NULL, 0, 0, 0, 0, 0};
277 /******************************************************************************
279 * Semi Public variables.
281 *****************************************************************************/
282 /******************************************************************************
286 *****************************************************************************/
287 /******************************************************************************
288 * Function: SaveFontStruct (font_struct)
290 *****************************************************************************/
293 XFontStruct *font_struct,
294 DtHelpDAFontInfo *font_info)
298 fontIndex = font_info->struct_cnt++;
299 if (font_info->struct_cnt >= font_info->max_structs)
301 font_info->max_structs += GROW_SIZE;
302 if (font_info->font_structs != NULL)
303 font_info->font_structs = (XFontStruct **) realloc (
304 ((char *) font_info->font_structs),
305 (sizeof (XFontStruct *) * font_info->max_structs));
307 font_info->font_structs = (XFontStruct **) malloc (
308 sizeof (XFontStruct *) * font_info->max_structs);
311 font_info->font_structs[fontIndex] = font_struct;
316 /******************************************************************************
317 * Function: SaveFontSet (font_set)
319 *****************************************************************************/
323 DtHelpDAFontInfo *font_info)
327 fontIndex = font_info->set_cnt++;
328 if (font_info->set_cnt >= font_info->max_sets)
330 font_info->max_sets += GROW_SIZE;
331 if (font_info->font_sets != NULL)
333 font_info->font_sets = (XFontSet *) realloc (
334 ((char *) font_info->font_sets),
335 (sizeof (XFontSet) * font_info->max_sets));
336 font_info->fs_metrics = (DtHelpDAFSMetrics *) realloc (
337 ((char *) font_info->fs_metrics),
338 (sizeof (DtHelpDAFSMetrics) * font_info->max_sets));
342 font_info->font_sets = (XFontSet *) malloc (
343 sizeof(XFontSet) * font_info->max_sets);
344 font_info->fs_metrics = (DtHelpDAFSMetrics *) malloc (
345 sizeof (DtHelpDAFSMetrics) * font_info->max_sets);
349 font_info->font_sets[fontIndex] = font_set;
350 font_info->fs_metrics[fontIndex] = DefaultMetrics;
353 * want the font sets to go from -1 to -n because negative numbers
354 * indicate a font set.
360 /******************************************************************************
361 * Function: LoadFont (char *font_string, int *ret_index)
363 *****************************************************************************/
367 DtHelpDAFontInfo *font_info,
376 char **missingFontSet = NULL;
377 XFontStruct *fontStruct = NULL;
380 strPtr = font_string;
383 * if working with one byte environment, do it the fast, cheap way.
387 len = strlen(strPtr);
391 while (len > 0 && strPtr[len] == ' ')
394 if (strPtr[len] == ':')
403 * Multibyte environment, have to go through the characters one at
406 while (*strPtr != '\0')
409 * Process looking for a colon.
411 len = mblen(strPtr, MB_CUR_MAX);
415 else if (len == 1 && *strPtr == ':')
420 else if (len != 1 || *strPtr != ' ')
429 fontStruct = XLoadQueryFont (dpy, font_string);
430 if (fontStruct != NULL)
432 *ret_index = SaveFontStruct (fontStruct, font_info);
439 fontSet = XCreateFontSet (dpy, font_string, &missingFontSet,
444 * want the font sets to go from -1 to -n because 0 is
447 *ret_index = SaveFontSet (fontSet, font_info);
452 XFreeStringList (missingFontSet);
463 /******************************************************************************
465 * Semi Public Functions
467 *****************************************************************************/
468 /******************************************************************************
469 * Function: int __DtHelpFontIndexGet (Display dpy, XrmQuarkList xrm_list)
471 * Parameters: xrm_list Specifies the quark list for the font desired.
473 * Return Value: 0 if successful, -1 if using default font index.
475 * Purpose: Find the appropriate font to use for a quark set.
477 *****************************************************************************/
479 __DtHelpFontIndexGet (
480 DtHelpDispAreaStruct *pDAS,
481 XrmQuarkList xrm_list,
485 long fontIndex = pDAS->font_info.def_idx;
486 XrmRepresentation retType;
491 DtHelpDAFontInfo *fontInfo = &(pDAS->font_info);
492 Display *dpy = XtDisplay(pDAS->dispWid);
495 * look in my font data base to see if I've already processed
496 * this sequence of quarks.
498 if (XrmQGetResource (fontInfo->font_idx_db, xrm_list, xrm_list, &retType,
501 fontIndex = *((int *)retValue.addr);
507 * Check my parent's data base for an XLFD spec.
510 if (XrmQGetResource (XrmGetDatabase(dpy), xrm_list, xrm_list,
511 &retType, &retValue))
513 fontSpec = ((char *) retValue.addr);
514 if (LoadFont (dpy, fontInfo, fontSpec, &fontIndex))
519 * If my parent didn't have anything, check my private database.
522 XrmQGetResource (fontInfo->def_font_db, xrm_list, xrm_list,
523 &retType, &retValue))
525 fontSpec = ((char *) retValue.addr);
526 if (LoadFont (dpy, fontInfo, fontSpec, &fontIndex))
532 * if unsuccessful on finding a font for this quark list.
533 * save out using the default font
535 retValue.size = sizeof (int);
536 retValue.addr = (XtPointer) &fontIndex;
537 XrmQPutResource (&(fontInfo->font_idx_db),
538 ((XrmBindingList) FontBindings),
539 xrm_list, _DtHelpXrmInt, &retValue);
542 * remember the character set for this font.
544 sprintf (buffer, "%ld", fontIndex);
545 retValue.size = sizeof (XrmQuark);
546 retValue.addr = (XtPointer) &xrm_list[_DT_HELP_FONT_CHAR_SET];
547 xrmList[0] = XrmStringToQuark (buffer);
548 xrmList[1] = XrmStringToQuark ("code_set");
550 XrmQPutResource (&(fontInfo->font_idx_db),
551 ((XrmBindingList) FontBindings),
552 xrmList, _DtHelpXrmQuark, &retValue);
555 * remember the language for this font.
557 retValue.addr = (XtPointer) &xrm_list[_DT_HELP_FONT_LANG_TER];
558 xrmList[1] = XrmStringToQuark ("language");
559 XrmQPutResource (&(fontInfo->font_idx_db),
560 ((XrmBindingList) FontBindings),
561 xrmList, _DtHelpXrmQuark, &retValue);
565 *ret_idx = fontIndex;
569 /******************************************************************************
570 * Function: int __DtHelpFontCharSetQuarkGet (font_index, XrmQuark *ret_quark)
572 * Parameters: font_index Specifies the font in the font table.
573 * ret_quark Returns the quark specifying the character
576 * Return Value: Returns 0 if successful, -1 if failed.
578 * Purpose: Gets the character set associated with a font.
580 *****************************************************************************/
582 __DtHelpFontCharSetQuarkGet (
583 DtHelpDispAreaStruct *pDAS,
585 XrmQuark *ret_quark )
587 XrmRepresentation retType;
594 * quarkize the font index
596 sprintf (buffer, "%ld", font_index);
597 xrmList[0] = XrmStringToQuark (buffer);
598 xrmList[1] = XrmStringToQuark ("code_set");
602 * look in my font data base for the quark.
604 if (XrmQGetResource (pDAS->font_info.font_idx_db, xrmList, xrmList,
605 &retType, &retValue))
606 *ret_quark = *((XrmQuark *)retValue.addr);
613 /******************************************************************************
614 * Function: int __DtHelpFontLangQuarkGet (font_index, XrmQuark *ret_quark)
616 * Parameters: font_index Specifies the font in the font table.
617 * ret_quark Returns the quark specifying the character
620 * Return Value: Returns 0 if successful, -1 if failed.
622 * Purpose: Gets the character set associated with a font.
624 *****************************************************************************/
626 __DtHelpFontLangQuarkGet (
627 DtHelpDispAreaStruct *pDAS,
629 XrmQuark *ret_quark )
631 XrmRepresentation retType;
638 * quarkize the font index
640 sprintf (buffer, "%ld", font_index);
641 xrmList[0] = XrmStringToQuark (buffer);
642 xrmList[1] = XrmStringToQuark ("language");
646 * look in my font data base for the quark.
648 if (XrmQGetResource (pDAS->font_info.font_idx_db, xrmList, xrmList,
649 &retType, &retValue))
650 *ret_quark = *((XrmQuark *)retValue.addr);
657 /******************************************************************************
658 * Function: void _DtHelpCopyDefaultList (xrm_name)
660 * Parameters: xrm_name The quark list to fill out.
664 * Purpose: Initializes the font data base.
665 *****************************************************************************/
667 _DtHelpCopyDefaultList (
672 for (n = 0; n < _DT_HELP_FONT_END + 1; n++)
673 xrm_list[n] = DefaultFontQuarks[n];
676 /******************************************************************************
677 * Function: void _DtHelpGetStringQuarks (xrm_name)
679 * Parameters: xrm_name The quark list to fill out.
683 * Purpose: Initializes the font data base.
684 *****************************************************************************/
686 _DtHelpGetStringQuarks (
689 _DtHelpCopyDefaultList(xrm_list);
691 xrm_list[_DT_HELP_FONT_CHAR_SET] = StringFontQuark;
694 /******************************************************************************
695 * Function: void __DtHelpFontDatabaseInit (dpy, default_font, type, tmp)
697 * Parameters: dpy Specifies the connection to the display server.
698 * default_font Specifies the base font.
699 * type Specifies the type of font 'default_font' is.
703 * Purpose: Initializes the font data base.
705 *****************************************************************************/
707 __DtHelpFontDatabaseInit (
708 DtHelpDispAreaStruct *pDAS,
709 XtPointer string_font,
711 XFontStruct *user_font)
717 Display *dpy = XtDisplay(pDAS->dispWid);
718 DtHelpDAFontInfo *fontInfo = &(pDAS->font_info);
720 XrmRepresentation retType;
721 XrmName xrmList[_DtHelpFontQuarkNumber];
724 * build our default data base
726 *fontInfo = DefFontInfo;
727 for (n = 0; FontResources[n]; n++)
728 XrmPutLineResource (&(fontInfo->def_font_db), FontResources[n]);
731 * build the default quark set.
733 _DtHelpProcessLock();
734 if (QuarksInited == False)
736 StringFontQuark = XrmStringToQuark ("String");
737 DefaultFontQuarks[_DT_HELP_FONT_SPACING] = XrmStringToQuark ("p");
738 DefaultFontQuarks[_DT_HELP_FONT_SIZE] = XrmStringToQuark ("10");
739 DefaultFontQuarks[_DT_HELP_FONT_ANGLE] = XrmStringToQuark ("roman");
740 DefaultFontQuarks[_DT_HELP_FONT_WEIGHT] = XrmStringToQuark ("medium");
741 DefaultFontQuarks[_DT_HELP_FONT_TYPE] =
742 XrmStringToQuark ("sans_serif");
743 DefaultFontQuarks[_DT_HELP_FONT_LANG_TER] = XrmStringToQuark ("C");
744 DefaultFontQuarks[_DT_HELP_FONT_CHAR_SET] =
745 XrmStringToQuark ("ISO-8859-1");
746 DefaultFontQuarks[_DT_HELP_FONT_END] = 0;
749 _DtHelpProcessUnlock();
752 * if the string_font is null, used the default user's font for strings.
754 if (string_font == NULL)
757 * WARNING...what if the user_font is null? And what type is it?
759 string_font = (XtPointer) user_font;
760 type = XmFONT_IS_FONT;
764 * save the string font in the lists
766 if (type == XmFONT_IS_FONTSET)
767 strIdx = SaveFontSet ((XFontSet) string_font, fontInfo);
769 strIdx = SaveFontStruct ((XFontStruct *) string_font, fontInfo);
772 * Save this idx font for ascii files and strings.
774 _DtHelpGetStringQuarks(xrmList);
776 retValue.size = sizeof (int);
777 retValue.addr = (XtPointer) &(strIdx);
778 XrmQPutResource (&(fontInfo->font_idx_db), ((XrmBindingList) FontBindings),
779 xrmList, _DtHelpXrmInt, &retValue);
782 * try to get the default font for help information
783 * from the parent's database.
785 if (XrmQGetResource (XrmGetDatabase(dpy), DefaultFontQuarks,
786 DefaultFontQuarks, &retType, &retValue))
787 found = LoadFont (dpy, fontInfo, ((char *) retValue.addr),
788 &(fontInfo->def_idx));
791 * If the XLFD font spec wasn't in the parent's database,
792 * look at my private database.
794 if (found == False &&
795 XrmQGetResource (fontInfo->def_font_db,
796 DefaultFontQuarks, DefaultFontQuarks,
797 &retType, &retValue))
798 found = LoadFont (dpy, fontInfo, ((char *) retValue.addr),
799 &(fontInfo->def_idx));
802 * If still no luck, use the string font passed in.
805 fontInfo->def_idx = strIdx;
808 * Remember we got this font for this quark string.
810 retValue.size = sizeof (int);
811 retValue.addr = (XtPointer) &(fontInfo->def_idx);
812 XrmQPutResource (&(fontInfo->font_idx_db), ((XrmBindingList) FontBindings),
813 DefaultFontQuarks, _DtHelpXrmInt, &retValue);
816 /******************************************************************************
817 * Function: XFontStruct *__DtHelpFontStructGet (long font_index );
819 * Parameters: font_index Specifies an index into the Font Structure
822 * Return Value: Returns the font structure.
826 *****************************************************************************/
828 __DtHelpFontStructGet (
829 DtHelpDAFontInfo font_info,
833 if (font_index > -1 && font_index < font_info.struct_cnt)
834 return font_info.font_structs[font_index];
839 /******************************************************************************
840 * Function: XFontSet __DtHelpFontSetGet (long font_index);
842 * Parameters: font_index Specifies an index into the Font Set List.
844 * Return Value: Returns the font structure.
848 *****************************************************************************/
851 DtHelpDAFontInfo font_info,
857 font_index = -font_index;
859 if (font_index < font_info.set_cnt)
860 return font_info.font_sets[font_index];
866 /******************************************************************************
867 * Function: long __DtHelpDefaultFontIndexGet ();
871 * Return Value: Returns the index for the default font set/structure.
875 *****************************************************************************/
877 __DtHelpDefaultFontIndexGet (
878 DtHelpDispAreaStruct *pDAS)
880 return (pDAS->font_info.def_idx);
883 /******************************************************************************
884 * Function: int __DtHelpFontMetrics (int font_index, int &ret_ascent,
889 * Return Value: Returns the index for the default font set/structure.
893 *****************************************************************************/
895 __DtHelpFontMetrics (
896 DtHelpDAFontInfo font_info,
898 _DtCvUnit *ret_ascent,
899 _DtCvUnit *ret_descent,
900 _DtCvUnit *ret_char_width,
901 _DtCvUnit *ret_super,
904 XFontStruct **fontList;
907 _DtCvUnit maxAscent = -1;
908 _DtCvUnit maxDescent = -1;
909 _DtCvUnit maxCharW = -1;
910 _DtCvUnit superOffset = 0;
911 _DtCvUnit subOffset = 0;
916 font_index = -font_index;
918 if (font_index < font_info.set_cnt)
920 if (font_info.fs_metrics[font_index].inited == True)
922 maxAscent = font_info.fs_metrics[font_index].fm.ascent;
923 maxDescent = font_info.fs_metrics[font_index].fm.descent;
924 maxCharW = font_info.fs_metrics[font_index].fm.average_width;
926 else /* if (font_info.fs_metrics[font_index].inited == False) */
928 fontCount = XFontsOfFontSet(font_info.font_sets[font_index],
929 &fontList, &fontNames);
930 for (i = 0; i < fontCount; i++)
932 if (fontList[i]->ascent > maxAscent)
933 maxAscent = fontList[i]->ascent;
935 if (fontList[i]->descent > maxDescent)
936 maxDescent = fontList[i]->descent;
938 if (fontList[i]->max_bounds.width > maxCharW)
939 maxCharW = fontList[i]->max_bounds.width;
941 font_info.fs_metrics[font_index].fm.ascent = maxAscent;
942 font_info.fs_metrics[font_index].fm.descent = maxDescent;
943 font_info.fs_metrics[font_index].fm.average_width = maxCharW;
944 font_info.fs_metrics[font_index].inited = True;
948 else if (font_index < font_info.struct_cnt)
950 maxAscent = font_info.font_structs[font_index]->ascent;
951 maxDescent = font_info.font_structs[font_index]->descent;
952 maxCharW = font_info.font_structs[font_index]->max_bounds.width;
955 superOffset = (maxAscent * 40) / 100 + ((maxAscent % 40) > 19 ? 1 : 0);
956 subOffset = superOffset;
959 *ret_ascent = maxAscent;
961 *ret_descent = maxDescent;
963 *ret_char_width = maxCharW;
965 *ret_super = superOffset;
967 *ret_sub = subOffset;
970 /******************************************************************************
971 * Function: int _DtHelpGetExactFontIndex(Display dpy, char *xlfd_spec)
975 * Return Value: 0 if successful, -1 if using default font index.
977 * Purpose: Try to load the specified font.
979 *****************************************************************************/
981 _DtHelpGetExactFontIndex (
982 DtHelpDispAreaStruct *pDAS,
984 const char *char_set,
990 long fontIndex = pDAS->font_info.def_idx;
992 DtHelpDAFontInfo *fontInfo = &(pDAS->font_info);
993 Display *dpy = XtDisplay(pDAS->dispWid);
996 * look in my font data base to see if I've already processed
1000 #define REALLOC_INCR 10
1002 nameList = fontInfo->exact_fonts;
1003 if (NULL != nameList)
1005 for (i = 0; NULL != *nameList && strcmp(*nameList, xlfd_spec); i++)
1009 if (NULL != nameList && NULL != *nameList)
1011 fontIndex = fontInfo->exact_idx[i];
1014 else if (LoadFont(dpy, fontInfo, xlfd_spec, &fontIndex))
1017 * make a copy of the font spec
1019 xlfd_spec = strdup(xlfd_spec);
1020 if (NULL != xlfd_spec)
1023 * now save it away for later tests.
1025 fontInfo->exact_fonts = (char **) _DtHelpCeAddPtrToArray(
1026 (void **)fontInfo->exact_fonts,
1027 (void *) xlfd_spec);
1028 if (NULL != fontInfo->exact_fonts)
1030 if (NULL == fontInfo->exact_idx)
1031 fontInfo->exact_idx = (int *) malloc(
1032 sizeof(int)*REALLOC_INCR);
1033 else if ((i + 1) % REALLOC_INCR == 0)
1034 fontInfo->exact_idx = (int *) realloc(fontInfo->exact_idx,
1035 sizeof(int) * (i + 1 + REALLOC_INCR));
1037 if (NULL != fontInfo->exact_idx)
1044 fontInfo->exact_idx[i] = fontIndex;
1048 * remember the character set for this font.
1050 myQuark = XrmStringToQuark(char_set);
1051 sprintf (buffer, "%ld", fontIndex);
1052 retValue.size = sizeof (XrmQuark);
1053 retValue.addr = (XtPointer) &myQuark;
1054 xrmList[0] = XrmStringToQuark (buffer);
1055 xrmList[1] = XrmStringToQuark ("code_set");
1057 XrmQPutResource (&(fontInfo->font_idx_db),
1058 ((XrmBindingList) FontBindings),
1059 xrmList, _DtHelpXrmQuark, &retValue);
1062 * remember the language for this font.
1064 myQuark = XrmStringToQuark(lang);
1065 xrmList[1] = XrmStringToQuark ("language");
1066 XrmQPutResource (&(fontInfo->font_idx_db),
1067 ((XrmBindingList) FontBindings),
1068 xrmList, _DtHelpXrmQuark, &retValue);
1074 *ret_idx = fontIndex;