Fix for crash in shared tag allocation on Solaris (compiler bug?)
[nedit.git] / util / fontsel.c
blobb95ece4a043f78b8d10896bc6bb5a3e702dd2e0f
1 static const char CVSID[] = "$Id: fontsel.c,v 1.10 2001/08/14 08:37:16 jlous Exp $";
2 /*******************************************************************************
3 * *
4 * fontsel.c -- Nirvana Font Selector *
5 * *
6 * Copyright (C) 1999 Mark Edel *
7 * *
8 * This is free software; you can redistribute it and/or modify it under the *
9 * terms of the GNU General Public License as published by the Free Software *
10 * Foundation; either version 2 of the License, or (at your option) any later *
11 * version. *
12 * *
13 * This software is distributed in the hope that it will be useful, but WITHOUT *
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License *
16 * for more details. *
17 * *
18 * You should have received a copy of the GNU General Public License along with *
19 * software; if not, write to the Free Software Foundation, Inc., 59 Temple *
20 * Place, Suite 330, Boston, MA 02111-1307 USA *
21 * *
22 * Nirvana Text Editor *
23 * June 2, 1993 *
24 * *
25 * Written by Suresh Ravoor (assisted by Mark Edel) *
26 * *
27 *******************************************************************************/
28 #include <stdio.h>
29 #include <stdlib.h>
30 #include <string.h>
31 #include <X11/Intrinsic.h>
32 #include <Xm/Xm.h>
33 #include <Xm/Form.h>
34 #include <Xm/PushB.h>
35 #include <Xm/List.h>
36 #include <Xm/Label.h>
37 #include <Xm/Text.h>
38 #include <Xm/ToggleB.h>
39 #include <Xm/MessageB.h>
40 #include <Xm/DialogS.h>
41 #include "DialogF.h"
42 #include "misc.h"
43 #include "fontsel.h"
45 #define MAX_ARGS 20
46 #define MAX_NUM_FONTS 32767
47 #define MAX_FONT_NAME_LEN 256
48 #define MAX_ENTRIES_IN_LIST 5000
49 #define MAX_DISPLAY_SIZE 150
50 #define DELIM '-'
51 #define NUM_COMPONENTS_FONT_NAME 14
52 #define TEMP_BUF_SIZE 256
53 #define DISPLAY_HEIGHT 90
55 enum listSpecifier { NONE, FONT, STYLE, SIZE };
58 /* local data structures and types */
60 typedef struct
62 Widget form; /* widget id */
63 Widget okButton; /* widget id */
64 Widget cancelButton; /* widget id */
65 Widget fontList; /* widget id */
66 Widget styleList; /* widget id */
67 Widget sizeList; /* widget id */
68 Widget fontNameField; /* widget id */
69 Widget sizeToggle; /* widget id */
70 Widget propFontToggle; /* widget id */
71 Widget dispLabel; /* widget id */
72 char **fontData; /* font name info */
73 int numFonts; /* number of fonts */
74 char *sel1; /* selection from list 1 */
75 char *sel2; /* selection from list 2 */
76 char *sel3; /* selection from list 3 */
77 int showPropFonts; /* toggle state - show prop fonts */
78 int showSizeInPixels;/* toggle state - size in pixels */
79 char *fontName; /* current font name */
80 XFontStruct *oldFont; /* font data structure for dispSample */
81 XmFontList oldFontList; /* font data structure for dispSample */
82 int exitFlag; /* used for program exit control */
83 } xfselControlBlkType;
86 /* local function prototypes */
88 static void getStringComponent(char *inStr, int pos, char *outStr);
89 static void setupScrollLists(int dontChange, xfselControlBlkType ctrlBlk);
90 static int notPropFont(char *font);
91 static int styleMatch(xfselControlBlkType *ctrlBlk, char *font);
92 static int sizeMatch(xfselControlBlkType *ctrlBlk, char *font);
93 static int fontMatch(xfselControlBlkType *ctrlBlk, char *font);
94 static void addItemToList(char **buf, char *item, int *count);
95 static void getFontPart(char *font, char *buff1);
96 static void getStylePart(char *font, char *buff1);
97 static void getSizePart(char *font, char *buff1, int inPixels);
98 static void propFontToggleAction(Widget widget,
99 xfselControlBlkType *ctrlBlk,
100 XmToggleButtonCallbackStruct *call_data);
101 static void sizeToggleAction(Widget widget,
102 xfselControlBlkType *ctrlBlk,
103 XmToggleButtonCallbackStruct *call_data);
104 static void fontAction(Widget widget, xfselControlBlkType *ctrlBlk,
105 XmListCallbackStruct *call_data);
106 static void styleAction(Widget widget, xfselControlBlkType *ctrlBlk,
107 XmListCallbackStruct *call_data);
108 static void sizeAction(Widget widget, xfselControlBlkType *ctrlBlk,
109 XmListCallbackStruct *call_data);
110 static void choiceMade(xfselControlBlkType *ctrlBlk);
111 static void dispSample(xfselControlBlkType *ctrlBlk);
112 static void cancelAction(Widget widget, xfselControlBlkType *ctrlBlk,
113 XmListCallbackStruct *call_data);
114 static void okAction(Widget widget, xfselControlBlkType *ctrlBlk,
115 XmPushButtonCallbackStruct *call_data);
116 static void startupFont(xfselControlBlkType *ctrlBlk, char *font);
117 static void setFocus(Widget w, xfselControlBlkType *ctrlBlk, XEvent *event,
118 Boolean *continueToDispatch);
119 static void FindBigFont(xfselControlBlkType *ctrlBlk, char *bigFont);
121 /*******************************************************************************
123 * FontSel () *
126 * Function to put up a modal font selection dialog box. The purpose *
127 * of this routine is to allow the user to interactively view sample *
128 * fonts and to choose a font for current use. *
130 * Arguments: *
132 * Widget parent - parent widget ID *
134 * int showPropFont - ONLY_FIXED : shows only fixed fonts *
135 * doesn't show prop font *
136 * toggle button also. *
137 * PREF_FIXED : can select either fixed *
138 * or proportional fonts; *
139 * but starting option is *
140 * Fixed fonts. *
141 * PREF_PROP : can select either fixed *
142 * or proportional fonts; *
143 * but starting option is *
144 * proportional fonts. *
146 * char * currFont - ASCII string that contains the name *
147 * of the currently selected font. *
149 * Returns: *
151 * pointer to an ASCII character string that contains the name of *
152 * the selected font (in X format for naming fonts); it is the users *
153 * responsibility to free the space allocated to this string. *
155 * Comments: *
157 * The calling function has to call the appropriate routines to set *
158 * the current font to the one represented by the returned string. *
160 *******************************************************************************/
162 char *FontSel(Widget parent, int showPropFonts, char *currFont)
164 Widget dialog, form, okButton, cancelButton;
165 Widget styleList, sizeList, fontName, fontList;
166 Widget sizeToggle, propFontToggle = NULL, dispLabel;
167 Widget nameLabel;
168 Arg args[MAX_ARGS];
169 int n;
170 XmString tempStr;
171 char bigFont[MAX_FONT_NAME_LEN];
172 xfselControlBlkType ctrlBlk;
174 ctrlBlk.fontData = XListFonts(XtDisplay(parent),
175 "-*-*-*-*-*-*-*-*-*-*-*-*-*-*",
176 MAX_NUM_FONTS, &ctrlBlk.numFonts);
177 FindBigFont(&ctrlBlk, bigFont);
178 ctrlBlk.oldFont = XLoadQueryFont(XtDisplay(parent), bigFont);
179 ctrlBlk.oldFontList = XmFontListCreate(ctrlBlk.oldFont,
180 XmSTRING_DEFAULT_CHARSET);
182 dialog = CreateDialogShell(parent, "Font Selector", args, 0);
184 /* Set up window sizes for form widget */
186 n = 0;
187 XtSetArg(args[n], XmNautoUnmanage, FALSE); n++;
188 XtSetArg(args[n], XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL); n++;
190 /* Create form popup dialog widget */
192 form = XtCreateWidget ("Font Selector", xmFormWidgetClass, dialog,
193 args, n);
195 /* Create pushbutton widgets */
197 n = 0;
198 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
199 XtSetArg(args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
200 XtSetArg(args[n], XmNbottomOffset, 4); n++;
201 XtSetArg(args[n], XmNtopOffset, 1); n++;
202 XtSetArg(args[n], XmNrightPosition, 45); n++;
203 XtSetArg(args[n], XmNwidth, 110); n++;
204 XtSetArg(args[n], XmNheight, 28); n++;
205 XtSetArg(args[n], XmNshowAsDefault, TRUE); n++;
206 okButton = XtCreateManagedWidget("OK", xmPushButtonWidgetClass, form,
207 args, n);
209 n = 0;
210 XtSetArg(args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
211 XtSetArg(args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
212 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
213 XtSetArg(args[n], XmNtopWidget, okButton); n++;
214 XtSetArg(args[n], XmNbottomWidget, okButton); n++;
215 XtSetArg(args[n], XmNleftPosition, 55); n++;
216 XtSetArg(args[n], XmNwidth, 110); n++;
217 XtSetArg(args[n], XmNheight, 28); n++;
218 cancelButton = XtCreateManagedWidget("Cancel", xmPushButtonWidgetClass,
219 form, args, n);
221 /* create font name text widget and the corresponding label */
223 n = 0;
224 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
225 XtSetArg(args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
226 XtSetArg(args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
227 XtSetArg(args[n], XmNbottomWidget, okButton); n++;
228 XtSetArg(args[n], XmNleftPosition, 1); n++;
229 XtSetArg(args[n], XmNrightPosition, 99); n++;
230 XtSetArg(args[n], XmNeditable, True); n++;
231 XtSetArg(args[n], XmNeditMode, XmSINGLE_LINE_EDIT); n++;
232 XtSetArg(args[n], XmNmaxLength, MAX_FONT_NAME_LEN); n++;
233 fontName = XtCreateManagedWidget("fontname", xmTextWidgetClass, form,
234 args, n);
235 RemapDeleteKey(fontName); /* kludge to handle delete and BS */
237 n = 0;
238 tempStr = XmStringCreate("Font Name:", XmSTRING_DEFAULT_CHARSET);
239 XtSetArg(args[n], XmNlabelString, tempStr); n++;
240 XtSetArg(args[n], XmNmnemonic, 'N'); n++;
241 XtSetArg(args[n], XmNuserData, fontName); n++;
242 XtSetArg(args[n], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
243 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
244 XtSetArg(args[n], XmNleftWidget, fontName); n++;
245 XtSetArg(args[n], XmNbottomWidget, fontName); n++;
246 XtSetArg(args[n], XmNtopOffset, 1); n++;
247 nameLabel = XtCreateManagedWidget("Font Name:", xmLabelWidgetClass,
248 form, args, n);
249 XmStringFree(tempStr);
251 /* create sample display label widget */
253 n = 0;
254 XtSetArg(args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
255 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
256 XtSetArg(args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
257 XtSetArg(args[n], XmNrightPosition, 99); n++;
258 XtSetArg(args[n], XmNbottomWidget, nameLabel); n++;
259 XtSetArg(args[n], XmNleftPosition, 1); n++;
260 XtSetArg(args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
261 XtSetArg(args[n], XmNrecomputeSize, FALSE); n++;
262 XtSetArg(args[n], XmNfontList, ctrlBlk.oldFontList); n++;
263 dispLabel = XtCreateManagedWidget(" ", xmLabelWidgetClass, form,
264 args, n);
266 /* create toggle buttons */
268 n = 0;
269 tempStr = XmStringCreate("Show Size in Points",
270 XmSTRING_DEFAULT_CHARSET);
271 XtSetArg(args[n], XmNlabelString, tempStr); n++;
272 XtSetArg(args[n], XmNmnemonic, 'P'); n++;
273 XtSetArg(args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
274 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
275 XtSetArg(args[n], XmNleftPosition, 2); n++;
276 XtSetArg(args[n], XmNtopOffset, 1); n++;
277 XtSetArg(args[n], XmNbottomWidget, dispLabel); n++;
278 sizeToggle = XtCreateManagedWidget("sizetoggle",
279 xmToggleButtonWidgetClass, form, args, n);
280 XmStringFree(tempStr);
282 if (showPropFonts != ONLY_FIXED)
284 n = 0;
285 tempStr = XmStringCreate("Show Proportional Width Fonts",
286 XmSTRING_DEFAULT_CHARSET);
287 XtSetArg(args[n], XmNlabelString, tempStr); n++;
288 XtSetArg(args[n], XmNmnemonic, 'W'); n++;
289 XtSetArg(args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
290 XtSetArg(args[n], XmNtopAttachment,
291 XmATTACH_OPPOSITE_WIDGET); n++;
292 XtSetArg(args[n], XmNbottomAttachment,
293 XmATTACH_OPPOSITE_WIDGET); n++;
294 XtSetArg(args[n], XmNrightPosition, 98); n++;
295 XtSetArg(args[n], XmNtopWidget, sizeToggle); n++;
296 XtSetArg(args[n], XmNbottomWidget, sizeToggle); n++;
297 XtSetArg(args[n], XmNtopOffset, 1); n++;
298 propFontToggle = XtCreateManagedWidget("propfonttoggle",
299 xmToggleButtonWidgetClass, form, args, n);
300 XmStringFree(tempStr);
303 /* create scroll list widgets */
304 /* "Font" list */
306 n = 0;
307 tempStr = XmStringCreate("Font:", XmSTRING_DEFAULT_CHARSET);
308 XtSetArg(args[n], XmNlabelString, tempStr); n++;
309 XtSetArg(args[n], XmNmnemonic, 'F'); n++;
310 XtSetArg(args[n], XmNtopOffset, 2); n++;
311 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
312 XtSetArg(args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
313 XtSetArg(args[n], XmNleftPosition, 1); n++;
314 nameLabel = XtCreateManagedWidget("Font:", xmLabelWidgetClass, form,
315 args, n);
316 XmStringFree(tempStr);
318 n = 0;
319 XtSetArg(args[n], XmNvisibleItemCount, 15); n++;
320 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
321 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
322 XtSetArg(args[n], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
323 XtSetArg(args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
324 XtSetArg(args[n], XmNbottomWidget, sizeToggle); n++;
325 XtSetArg(args[n], XmNtopWidget, nameLabel); n++;
326 XtSetArg(args[n], XmNleftWidget, nameLabel); n++;
327 XtSetArg(args[n], XmNrightPosition, 52); n++;
328 fontList = XmCreateScrolledList(form, "fontlist", args, n);
329 XtManageChild(fontList);
330 XtVaSetValues(nameLabel, XmNuserData, fontList, NULL);
332 /* "Style" list */
334 n = 0;
335 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
336 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
337 XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
338 XtSetArg(args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
339 XtSetArg(args[n], XmNtopWidget, nameLabel); n++;
340 XtSetArg(args[n], XmNleftOffset, 5); n++;
341 XtSetArg(args[n], XmNleftWidget, XtParent(fontList)); n++;
342 XtSetArg(args[n], XmNbottomWidget, XtParent(fontList)); n++;
343 XtSetArg(args[n], XmNrightPosition, 85); n++;
344 styleList = XmCreateScrolledList(form, "stylelist", args, n);
345 XtManageChild(styleList);
347 n = 0;
348 tempStr = XmStringCreate("Style:", XmSTRING_DEFAULT_CHARSET);
349 XtSetArg(args[n], XmNmnemonic, 'y'); n++;
350 XtSetArg(args[n], XmNuserData, styleList); n++;
351 XtSetArg(args[n], XmNlabelString, tempStr); n++;
352 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
353 XtSetArg(args[n], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
354 XtSetArg(args[n], XmNbottomWidget, XtParent(styleList)); n++;
355 XtSetArg(args[n], XmNleftWidget, XtParent(styleList)); n++;
356 XtCreateManagedWidget("Style:", xmLabelWidgetClass, form, args, n);
357 XmStringFree(tempStr);
359 /* "Size" list */
361 n = 0;
362 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
363 XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
364 XtSetArg(args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
365 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
366 XtSetArg(args[n], XmNtopWidget, nameLabel); n++;
367 XtSetArg(args[n], XmNleftWidget, XtParent(styleList)); n++;
368 XtSetArg(args[n], XmNbottomWidget, XtParent(fontList)); n++;
369 XtSetArg(args[n], XmNleftOffset, 5); n++;
370 XtSetArg(args[n], XmNrightPosition, 99); n++;
371 sizeList = XmCreateScrolledList(form, "sizelist", args, n);
372 XtManageChild(sizeList);
374 n = 0;
375 tempStr = XmStringCreate("Size:", XmSTRING_DEFAULT_CHARSET);
376 XtSetArg(args[n], XmNlabelString, tempStr); n++;
377 XtSetArg(args[n], XmNmnemonic, 'z'); n++;
378 XtSetArg(args[n], XmNuserData, sizeList); n++;
379 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
380 XtSetArg(args[n], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
381 XtSetArg(args[n], XmNbottomWidget, XtParent(sizeList)); n++;
382 XtSetArg(args[n], XmNleftWidget, XtParent(sizeList)); n++;
383 XtCreateManagedWidget("Size:", xmLabelWidgetClass, form, args, n);
384 XmStringFree(tempStr);
386 /* update form widgets cancel button */
388 n = 0;
389 XtSetArg(args[n], XmNcancelButton, cancelButton); n++;
390 XtSetValues(form, args, n);
393 /* update application's control block structure */
395 ctrlBlk.form = form;
396 ctrlBlk.okButton = okButton;
397 ctrlBlk.cancelButton = cancelButton;
398 ctrlBlk.fontList = fontList;
399 ctrlBlk.styleList = styleList;
400 ctrlBlk.sizeList = sizeList;
401 ctrlBlk.fontNameField = fontName;
402 ctrlBlk.sizeToggle = sizeToggle;
403 if (showPropFonts != ONLY_FIXED)
404 ctrlBlk.propFontToggle = propFontToggle;
405 ctrlBlk.dispLabel = dispLabel;
406 ctrlBlk.exitFlag = FALSE;
407 ctrlBlk.showPropFonts = showPropFonts;
408 ctrlBlk.showSizeInPixels= TRUE;
409 ctrlBlk.sel1 = NULL;
410 ctrlBlk.sel2 = NULL;
411 ctrlBlk.sel3 = NULL;
412 ctrlBlk.fontName = NULL;
414 setupScrollLists(NONE, ctrlBlk); /* update scroll lists */
416 if (showPropFonts == PREF_PROP)
417 XmToggleButtonSetState(propFontToggle, TRUE, FALSE);
419 /* Register callback functions */
421 if (showPropFonts != ONLY_FIXED)
422 XtAddCallback(propFontToggle, XmNvalueChangedCallback,
423 (XtCallbackProc)propFontToggleAction, (char *)&ctrlBlk);
424 XtAddCallback(sizeToggle, XmNvalueChangedCallback,
425 (XtCallbackProc)sizeToggleAction, (char *)&ctrlBlk);
426 XtAddCallback(fontList, XmNbrowseSelectionCallback,
427 (XtCallbackProc)fontAction, (char *)&ctrlBlk);
428 XtAddCallback(styleList, XmNbrowseSelectionCallback,
429 (XtCallbackProc)styleAction, (char *)&ctrlBlk);
430 XtAddCallback(sizeList, XmNbrowseSelectionCallback,
431 (XtCallbackProc)sizeAction, (char *)&ctrlBlk);
432 XtAddCallback(okButton, XmNactivateCallback,
433 (XtCallbackProc)okAction, (char *)&ctrlBlk);
434 XtAddCallback(cancelButton, XmNactivateCallback,
435 (XtCallbackProc)cancelAction, (char *)&ctrlBlk);
437 /* add event handler to setup input focus at start to scroll list */
439 XtAddEventHandler(fontList, FocusChangeMask, FALSE,
440 (XtEventHandler)setFocus, (char *)&ctrlBlk);
441 XmProcessTraversal(fontList, XmTRAVERSE_CURRENT);
443 /* setup tabgroups */
445 XmAddTabGroup(fontList);
446 XmAddTabGroup(styleList);
447 XmAddTabGroup(sizeList);
448 XmAddTabGroup(sizeToggle);
449 if (showPropFonts != ONLY_FIXED)
450 XmAddTabGroup(propFontToggle);
451 XmAddTabGroup(fontName);
452 XmAddTabGroup(okButton);
453 XmAddTabGroup(cancelButton);
455 /* Link Motif Close option to cancel action */
457 AddMotifCloseCallback(dialog, (XtCallbackProc)cancelAction, &ctrlBlk);
459 /* Handle dialog mnemonics */
461 AddDialogMnemonicHandler(form, FALSE);
463 /* Realize Widgets */
465 ManageDialogCenteredOnPointer(form);
467 /* set up current font parameters */
469 if (currFont[0] != '\0')
470 startupFont(&ctrlBlk, currFont);
472 /* enter event loop */
474 while (! ctrlBlk.exitFlag)
475 XtAppProcessEvent(XtWidgetToApplicationContext(form), XtIMAll);
477 XtDestroyWidget(dialog);
479 if (ctrlBlk.oldFont != NULL)
481 XFreeFont(XtDisplay(form), ctrlBlk.oldFont);
482 XmFontListFree(ctrlBlk.oldFontList);
485 return(ctrlBlk.fontName);
489 /* gets a specific substring from a string */
491 static void getStringComponent(char *inStr, int pos, char *outStr)
493 int i, j;
495 *outStr = '\0';
497 if (pos > NUM_COMPONENTS_FONT_NAME)
499 fprintf(stderr, "Warning: getStringComponent being used for ");
500 fprintf(stderr, "pos > %d\nIf such ", NUM_COMPONENTS_FONT_NAME);
501 fprintf(stderr, "use is intended remove these warning lines\n");
504 for (i = 0; (pos > 0) && (inStr[i] != '\0'); i++)
505 if (inStr[i] == DELIM)
506 pos--;
508 if (inStr[i] == '\0')
509 return;
511 for (j = 0; (inStr[i] != DELIM) && (inStr[i] != '\0'); i++, j++)
512 outStr[j] = inStr[i];
513 outStr[j] = '\0';
517 /* parse through the fontlist data and set up the three scroll lists */
519 static void setupScrollLists(int dontChange, xfselControlBlkType ctrlBlk)
521 char *itemBuf1[MAX_ENTRIES_IN_LIST];
522 char *itemBuf2[MAX_ENTRIES_IN_LIST];
523 char *itemBuf3[MAX_ENTRIES_IN_LIST];
524 int itemCount1, itemCount2, itemCount3;
525 char buff1[TEMP_BUF_SIZE];
526 XmString items[MAX_ENTRIES_IN_LIST];
527 int i;
529 itemCount1 = 0;
530 itemCount2 = 0;
531 itemCount3 = 0;
533 for (i = 0; i < ctrlBlk.numFonts && i < MAX_ENTRIES_IN_LIST; i++)
535 if ((dontChange != FONT) &&
536 (styleMatch(&ctrlBlk, ctrlBlk.fontData[i])) &&
537 (sizeMatch (&ctrlBlk, ctrlBlk.fontData[i])) &&
538 ((ctrlBlk.showPropFonts == PREF_PROP) ||
539 (notPropFont(ctrlBlk.fontData[i]))))
541 getFontPart(ctrlBlk.fontData[i], buff1);
542 addItemToList(itemBuf1, buff1, &itemCount1);
545 if ((dontChange != STYLE) &&
546 (fontMatch(&ctrlBlk, ctrlBlk.fontData[i])) &&
547 (sizeMatch (&ctrlBlk, ctrlBlk.fontData[i])) &&
548 ((ctrlBlk.showPropFonts == PREF_PROP) ||
549 (notPropFont(ctrlBlk.fontData[i]))))
551 getStylePart(ctrlBlk.fontData[i], buff1);
552 addItemToList(itemBuf2, buff1, &itemCount2);
555 if ((dontChange != SIZE) &&
556 (fontMatch(&ctrlBlk, ctrlBlk.fontData[i])) &&
557 (styleMatch (&ctrlBlk, ctrlBlk.fontData[i])) &&
558 ((ctrlBlk.showPropFonts == PREF_PROP) ||
559 (notPropFont(ctrlBlk.fontData[i]))))
561 getSizePart(ctrlBlk.fontData[i], buff1,
562 ctrlBlk.showSizeInPixels);
563 addItemToList(itemBuf3, buff1, &itemCount3);
565 } /* end - for (i = 0; i < ctrlBlk.numFonts; i++) */
567 /* recreate all three scroll lists where necessary */
568 if (dontChange != FONT)
570 for (i = 0; i < itemCount1; i++)
572 items[i] = XmStringCreate(itemBuf1[i],
573 XmSTRING_DEFAULT_CHARSET);
574 XtFree(itemBuf1[i]);
576 XmListDeleteAllItems(ctrlBlk.fontList);
577 XmListAddItems(ctrlBlk.fontList, items, itemCount1, 1);
578 if (ctrlBlk.sel1 != NULL)
580 XmStringFree(items[0]);
581 items[0] = XmStringCreate(ctrlBlk.sel1,
582 XmSTRING_DEFAULT_CHARSET);
583 XmListSelectItem(ctrlBlk.fontList, items[0], FALSE);
584 XmListSetBottomItem(ctrlBlk.fontList, items[0]);
586 for (i = 0; i < itemCount1; i++)
587 XmStringFree(items[i]);
590 if (dontChange != STYLE)
592 for (i = 0; i < itemCount2; i++)
594 items[i] = XmStringCreate(itemBuf2[i],
595 XmSTRING_DEFAULT_CHARSET);
596 XtFree(itemBuf2[i]);
598 XmListDeleteAllItems(ctrlBlk.styleList);
599 XmListAddItems(ctrlBlk.styleList, items, itemCount2, 1);
600 if (ctrlBlk.sel2 != NULL)
602 XmStringFree(items[0]);
603 items[0] = XmStringCreate(ctrlBlk.sel2,
604 XmSTRING_DEFAULT_CHARSET);
605 XmListSelectItem(ctrlBlk.styleList, items[0], FALSE);
606 XmListSetBottomItem(ctrlBlk.styleList, items[0]);
608 for (i = 0; i < itemCount2; i++)
609 XmStringFree(items[i]);
612 if (dontChange != SIZE)
614 for (i = 0; i < itemCount3; i++)
616 items[i] = XmStringCreate(itemBuf3[i],
617 XmSTRING_DEFAULT_CHARSET);
618 XtFree(itemBuf3[i]);
620 XmListDeleteAllItems(ctrlBlk.sizeList);
621 XmListAddItems(ctrlBlk.sizeList, items, itemCount3, 1);
622 if (ctrlBlk.sel3 != NULL)
624 XmStringFree(items[0]);
625 items[0] = XmStringCreate(ctrlBlk.sel3,
626 XmSTRING_DEFAULT_CHARSET);
627 XmListSelectItem(ctrlBlk.sizeList, items[0], FALSE);
628 XmListSetBottomItem(ctrlBlk.sizeList, items[0]);
630 for (i = 0; i < itemCount3; i++)
631 XmStringFree(items[i]);
636 /* returns TRUE if argument is not name of a proportional font */
638 static int notPropFont(char *font)
640 char buff1[TEMP_BUF_SIZE];
642 getStringComponent(font, 11, buff1);
643 if ((strcmp(buff1, "p") == 0) || (strcmp(buff1, "P") == 0))
644 return(FALSE);
645 else
646 return(TRUE);
650 /* returns TRUE if the style portion of the font matches the currently
651 selected style */
653 static int styleMatch(xfselControlBlkType *ctrlBlk, char *font)
655 char buff[TEMP_BUF_SIZE];
657 if (ctrlBlk->sel2 == NULL)
658 return(TRUE);
660 getStylePart(font, buff);
662 if (strcmp(buff, ctrlBlk->sel2) == 0)
663 return(TRUE);
664 else
665 return(FALSE);
669 /* returns TRUE if the size portion of the font matches the currently
670 selected size */
672 static int sizeMatch(xfselControlBlkType *ctrlBlk, char *font)
674 char buff[TEMP_BUF_SIZE];
676 if (ctrlBlk->sel3 == NULL)
677 return(TRUE);
679 getSizePart(font, buff, ctrlBlk->showSizeInPixels);
680 if (strcmp(buff, ctrlBlk->sel3) == 0)
681 return(TRUE);
682 else
683 return(FALSE);
687 /* returns TRUE if the font portion of the font matches the currently
688 selected font */
690 static int fontMatch(xfselControlBlkType *ctrlBlk, char *font)
692 char buff[TEMP_BUF_SIZE];
694 if (ctrlBlk->sel1 == NULL)
695 return(TRUE);
697 getFontPart(font, buff);
698 if (strcmp(buff, ctrlBlk->sel1) == 0)
699 return(TRUE);
700 else
701 return(FALSE);
705 /* inserts a string into correct sorted position in a list */
707 static void addItemToList(char **buf, char *item, int *count)
709 int i, j;
711 if (*count == MAX_ENTRIES_IN_LIST)
713 fprintf(stderr, "Trying to add more than MAX_ENTRIES_IN_LIST ");
714 fprintf(stderr, "(%d) entries to array\n", MAX_ENTRIES_IN_LIST);
715 return;
718 for (i = 0; i < *count; i++)
720 if (strcmp(buf[i], item) == 0)
721 return;
722 if (strcmp(buf[i], item) > 0)
723 break;
726 for (j = *count; j > i; j--)
727 buf[j] = buf[j-1];
728 buf[i] = XtMalloc(strlen(item) + 1);
729 strcpy(buf[i], item);
730 (*count)++;
734 /* given a font name this function returns the part used in the first
735 scroll list */
737 static void getFontPart(char *font, char *buff1)
739 char buff2[TEMP_BUF_SIZE], buff3[TEMP_BUF_SIZE];
740 char buff4[TEMP_BUF_SIZE];
742 getStringComponent(font, 2, buff1);
743 getStringComponent(font, 1, buff2);
745 sprintf(buff3, "%s (%s", buff1, buff2);
747 getStringComponent(font, 13, buff1);
748 getStringComponent(font, 14, buff4);
750 if (((strncmp(buff1, "iso8859", 7) == 0) ||
751 (strncmp(buff1, "ISO8859", 7) == 0)) && (strcmp(buff4, "1") == 0))
752 sprintf(buff1, "%s)", buff3);
753 else
755 sprintf(buff2, "%s, %s,", buff3, buff1);
756 sprintf(buff1, "%s %s)", buff2, buff4);
761 /* given a font name this function returns the part used in the second
762 scroll list */
764 static void getStylePart(char *font, char *buff1)
766 char buff2[TEMP_BUF_SIZE], buff3[TEMP_BUF_SIZE];
768 getStringComponent(font, 3, buff3);
769 getStringComponent(font, 5, buff2);
771 if ((strcmp(buff2, "normal") != 0) && (strcmp(buff2, "Normal") != 0) &&
772 (strcmp(buff2, "NORMAL") != 0))
773 sprintf(buff1, "%s %s", buff3, buff2);
774 else
775 strcpy(buff1, buff3);
777 getStringComponent(font, 6, buff2);
779 if (buff2[0] != '\0')
780 sprintf(buff3, "%s %s", buff1, buff2);
781 else
782 strcpy(buff3, buff1);
784 getStringComponent(font, 4, buff2);
786 if ((strcmp(buff2, "o") == 0) || (strcmp(buff2, "O") == 0))
787 sprintf(buff1, "%s oblique", buff3);
788 else if ((strcmp(buff2, "i") == 0) || (strcmp(buff2, "I") == 0))
789 sprintf(buff1, "%s italic", buff3);
791 if (strcmp(buff1, " ") == 0)
792 strcpy(buff1, "-");
796 /* given a font name this function returns the part used in the third
797 scroll list */
799 static void getSizePart(char *font, char *buff1, int inPixels)
801 int size;
802 float temp;
804 if (inPixels)
806 getStringComponent(font, 7, buff1);
807 size = atoi(buff1);
808 sprintf(buff1, "%2d", size);
810 else
812 getStringComponent(font, 8, buff1);
813 size = atoi(buff1);
814 temp = (float)size / 10.0;
815 size = temp;
816 if (buff1[strlen(buff1) - 1] == '0')
817 sprintf(buff1, "%2d", size);
818 else
819 sprintf(buff1, "%4.1f", temp);
824 /* Call back functions start from here - suffix Action in the function name
825 is for the callback function for the corresponding widget */
827 static void propFontToggleAction(Widget widget,
828 xfselControlBlkType *ctrlBlk,
829 XmToggleButtonCallbackStruct *call_data)
831 int n;
832 Arg args[2];
833 XmString str;
835 if (call_data->reason == XmCR_VALUE_CHANGED)
837 if (ctrlBlk->showPropFonts == PREF_FIXED)
838 ctrlBlk->showPropFonts = PREF_PROP;
839 else
840 ctrlBlk->showPropFonts = PREF_FIXED;
842 if (ctrlBlk->sel1 != NULL)
843 XtFree(ctrlBlk->sel1);
844 ctrlBlk->sel1 = NULL;
846 if (ctrlBlk->sel2 != NULL)
847 XtFree(ctrlBlk->sel2);
848 ctrlBlk->sel2 = NULL;
850 if (ctrlBlk->sel3 != NULL)
851 XtFree(ctrlBlk->sel3);
852 ctrlBlk->sel3 = NULL;
854 setupScrollLists(NONE, *ctrlBlk);
856 n = 0;
857 str = XmStringCreate("", XmSTRING_DEFAULT_CHARSET);
858 XtSetArg(args[n], XmNlabelString, str); n++;
859 XtSetValues(ctrlBlk->dispLabel, args, n);
860 XmTextSetString(ctrlBlk->fontNameField, "");
861 XmStringFree(str);
866 static void sizeToggleAction(Widget widget,
867 xfselControlBlkType *ctrlBlk,
868 XmToggleButtonCallbackStruct *call_data)
870 int i, makeSelection;
871 char newSize[10];
872 XmString str;
874 if (call_data->reason == XmCR_VALUE_CHANGED)
876 makeSelection = (ctrlBlk->sel3 != NULL);
878 for (i = 0; (makeSelection) && (i < ctrlBlk->numFonts); i++)
879 if ((fontMatch(ctrlBlk, ctrlBlk->fontData[i])) &&
880 (styleMatch(ctrlBlk, ctrlBlk->fontData[i])) &&
881 (sizeMatch(ctrlBlk, ctrlBlk->fontData[i])))
883 getSizePart(ctrlBlk->fontData[i], newSize,
884 !ctrlBlk->showSizeInPixels);
885 break;
888 if (ctrlBlk->showSizeInPixels)
889 ctrlBlk->showSizeInPixels = FALSE;
890 else
891 ctrlBlk->showSizeInPixels = TRUE;
893 if (ctrlBlk->sel3 != NULL)
894 XtFree(ctrlBlk->sel3);
896 ctrlBlk->sel3 = NULL;
897 setupScrollLists(NONE, *ctrlBlk);
899 if (makeSelection)
901 str = XmStringCreate(newSize, XmSTRING_DEFAULT_CHARSET);
902 XmListSelectItem(ctrlBlk->sizeList, str, TRUE);
903 XmListSetBottomItem(ctrlBlk->sizeList, str);
904 XmStringFree(str);
910 static void fontAction(Widget widget, xfselControlBlkType *ctrlBlk,
911 XmListCallbackStruct *call_data)
913 char *sel;
915 XmStringGetLtoR(call_data->item, XmSTRING_DEFAULT_CHARSET, &sel);
917 if (ctrlBlk->sel1 == NULL)
919 ctrlBlk->sel1 = XtMalloc(strlen(sel) + 1);
920 strcpy(ctrlBlk->sel1, sel);
922 else
924 if (strcmp(ctrlBlk->sel1, sel) == 0)
925 { /* Unselecting current selection */
926 XtFree(ctrlBlk->sel1);
927 ctrlBlk->sel1 = NULL;
928 XmListDeselectItem(widget, call_data->item);
930 else
932 XtFree(ctrlBlk->sel1);
933 ctrlBlk->sel1 = XtMalloc(strlen(sel) + 1);
934 strcpy(ctrlBlk->sel1, sel);
938 XtFree(sel);
939 setupScrollLists(FONT, *ctrlBlk);
940 if ((ctrlBlk->sel1 != NULL) && (ctrlBlk->sel2 != NULL) &&
941 (ctrlBlk->sel3 != NULL))
942 choiceMade(ctrlBlk);
943 else
945 int n;
946 XmString str;
947 Arg args[2];
949 n = 0;
950 str = XmStringCreate("", XmSTRING_DEFAULT_CHARSET);
951 XtSetArg(args[n], XmNlabelString, str); n++;
952 XtSetValues(ctrlBlk->dispLabel, args, n);
953 XmTextSetString(ctrlBlk->fontNameField, "");
954 XmStringFree(str);
959 static void styleAction(Widget widget, xfselControlBlkType *ctrlBlk,
960 XmListCallbackStruct *call_data)
962 char *sel;
964 XmStringGetLtoR(call_data->item, XmSTRING_DEFAULT_CHARSET, &sel);
966 if (ctrlBlk->sel2 == NULL)
968 ctrlBlk->sel2 = XtMalloc(strlen(sel) + 1);
969 strcpy(ctrlBlk->sel2, sel);
971 else
973 if (strcmp(ctrlBlk->sel2, sel) == 0)
974 { /* unselecting current selection */
975 XtFree(ctrlBlk->sel2);
976 ctrlBlk->sel2 = NULL;
977 XmListDeselectItem(widget, call_data->item);
979 else
981 XtFree(ctrlBlk->sel2);
982 ctrlBlk->sel2 = XtMalloc(strlen(sel) + 1);
983 strcpy(ctrlBlk->sel2, sel);
987 XtFree(sel);
988 setupScrollLists(STYLE, *ctrlBlk);
989 if ((ctrlBlk->sel1 != NULL) && (ctrlBlk->sel2 != NULL) &&
990 (ctrlBlk->sel3 != NULL))
991 choiceMade(ctrlBlk);
992 else
994 int n;
995 XmString str;
996 Arg args[2];
998 n = 0;
999 str = XmStringCreate("", XmSTRING_DEFAULT_CHARSET);
1000 XtSetArg(args[n], XmNlabelString, str); n++;
1001 XtSetValues(ctrlBlk->dispLabel, args, n);
1002 XmTextSetString(ctrlBlk->fontNameField, "");
1003 XmStringFree(str);
1008 static void sizeAction(Widget widget, xfselControlBlkType *ctrlBlk,
1009 XmListCallbackStruct *call_data)
1011 char *sel;
1013 XmStringGetLtoR(call_data->item, XmSTRING_DEFAULT_CHARSET, &sel);
1015 if (ctrlBlk->sel3 == NULL)
1017 ctrlBlk->sel3 = XtMalloc(strlen(sel) + 1);
1018 strcpy(ctrlBlk->sel3, sel);
1020 else
1022 if (strcmp(ctrlBlk->sel3, sel) == 0)
1023 { /* unselecting current selection */
1024 XtFree(ctrlBlk->sel3);
1025 ctrlBlk->sel3 = NULL;
1026 XmListDeselectItem(widget, call_data->item);
1028 else
1030 XtFree(ctrlBlk->sel3);
1031 ctrlBlk->sel3 = XtMalloc(strlen(sel) + 1);
1032 strcpy(ctrlBlk->sel3, sel);
1036 XtFree(sel);
1037 setupScrollLists(SIZE, *ctrlBlk);
1038 if ((ctrlBlk->sel1 != NULL) && (ctrlBlk->sel2 != NULL) &&
1039 (ctrlBlk->sel3 != NULL))
1040 choiceMade(ctrlBlk);
1041 else
1043 int n;
1044 XmString str;
1045 Arg args[2];
1047 n = 0;
1048 str = XmStringCreate("", XmSTRING_DEFAULT_CHARSET);
1049 XtSetArg(args[n], XmNlabelString, str); n++;
1050 XtSetValues(ctrlBlk->dispLabel, args, n);
1051 XmTextSetString(ctrlBlk->fontNameField, "");
1052 XmStringFree(str);
1056 /* function called when all three choices have been made; sets up font
1057 name and displays sample font */
1059 static void choiceMade(xfselControlBlkType *ctrlBlk)
1061 int i;
1063 if (ctrlBlk->fontName != NULL)
1064 XtFree(ctrlBlk->fontName);
1065 ctrlBlk->fontName = NULL;
1067 for (i = 0; i < ctrlBlk->numFonts; i++)
1069 if ((fontMatch(ctrlBlk, ctrlBlk->fontData[i])) &&
1070 (styleMatch(ctrlBlk, ctrlBlk->fontData[i])) &&
1071 (sizeMatch (ctrlBlk, ctrlBlk->fontData[i])))
1073 ctrlBlk->fontName = XtMalloc(
1074 strlen(ctrlBlk->fontData[i]) + 1);
1075 strcpy(ctrlBlk->fontName, ctrlBlk->fontData[i]);
1076 break;
1080 if (ctrlBlk->fontName != NULL)
1082 XmTextSetString(ctrlBlk->fontNameField, ctrlBlk->fontName);
1083 dispSample(ctrlBlk);
1085 else
1086 DialogF (DF_ERR, ctrlBlk->form, 1, "Invalid Font Specification",
1087 "Dismiss");
1091 /* loads selected font and displays sample text in that font */
1093 static void dispSample(xfselControlBlkType *ctrlBlk)
1095 Arg args[2];
1096 int n;
1097 XFontStruct *font;
1098 XmFontList fontList;
1099 Display *display;
1100 XmString dispStr;
1102 display = XtDisplay(ctrlBlk->form);
1103 font = XLoadQueryFont(display, ctrlBlk->fontName);
1104 fontList = XmFontListCreate(font, XmSTRING_DEFAULT_CHARSET);
1106 n = 0;
1107 dispStr = XmStringCreate(
1108 "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789",
1109 XmSTRING_DEFAULT_CHARSET);
1110 XtSetArg(args[n], XmNlabelString, dispStr); n++;
1111 XtSetArg(args[n], XmNfontList, fontList); n++;
1113 XtSetValues(ctrlBlk->dispLabel, args, n);
1114 XmStringFree(dispStr);
1116 if (ctrlBlk->oldFont != NULL)
1118 XFreeFont(display, ctrlBlk->oldFont);
1119 XmFontListFree(ctrlBlk->oldFontList);
1121 ctrlBlk->oldFont = font;
1122 ctrlBlk->oldFontList = fontList;
1126 static void cancelAction(Widget widget, xfselControlBlkType *ctrlBlk,
1127 XmListCallbackStruct *call_data)
1129 if (ctrlBlk->sel1 != NULL)
1130 XtFree(ctrlBlk->sel1);
1131 if (ctrlBlk->sel2 != NULL)
1132 XtFree(ctrlBlk->sel2);
1133 if (ctrlBlk->sel3 != NULL)
1134 XtFree(ctrlBlk->sel3);
1135 if (ctrlBlk->fontName != NULL)
1136 XtFree(ctrlBlk->fontName);
1138 ctrlBlk->fontName = NULL;
1139 XFreeFontNames(ctrlBlk->fontData);
1141 ctrlBlk->exitFlag = TRUE;
1145 static void okAction(Widget widget, xfselControlBlkType *ctrlBlk,
1146 XmPushButtonCallbackStruct *call_data)
1148 char *fontPattern;
1149 char **fontName;
1150 int i;
1152 fontPattern = XmTextGetString(ctrlBlk->fontNameField);
1153 fontName = XListFonts(XtDisplay(ctrlBlk->form), fontPattern, 1, &i);
1154 XtFree(fontPattern);
1156 if (i != 1)
1158 DialogF (DF_ERR, ctrlBlk->okButton, 1,
1159 "Invalid Font Specification", "Dismiss");
1160 XFreeFontNames(fontName);
1162 else
1164 if (ctrlBlk->fontName != NULL)
1165 XtFree(ctrlBlk->fontName);
1166 ctrlBlk->fontName = XtMalloc(strlen(fontName[0]) + 1);
1167 strcpy(ctrlBlk->fontName, fontName[0]);
1169 if (ctrlBlk->sel1 != NULL)
1170 XtFree(ctrlBlk->sel1);
1171 if (ctrlBlk->sel2 != NULL)
1172 XtFree(ctrlBlk->sel2);
1173 if (ctrlBlk->sel3 != NULL)
1174 XtFree(ctrlBlk->sel3);
1176 XFreeFontNames(fontName);
1177 XFreeFontNames(ctrlBlk->fontData);
1179 ctrlBlk->exitFlag = TRUE;
1184 /* if current font is passed as an argument then this function is
1185 invoked and sets up initial entries */
1187 static void startupFont(xfselControlBlkType *ctrlBlk, char *font)
1189 int i;
1190 char **fontName;
1191 char part[TEMP_BUF_SIZE];
1192 XmString str;
1194 fontName = XListFonts(XtDisplay(ctrlBlk->form), font, 1, &i);
1196 if (i == 0)
1197 { /* invalid font passed in at startup */
1198 XFreeFontNames(fontName);
1199 return;
1202 ctrlBlk->fontName = XtMalloc(strlen(fontName[0]) + 1);
1203 strcpy(ctrlBlk->fontName, fontName[0]);
1205 getFontPart(fontName[0], part);
1206 XFreeFontNames(fontName);
1207 str = XmStringCreate(part, XmSTRING_DEFAULT_CHARSET);
1208 XmListSetBottomItem(ctrlBlk->fontList, str);
1209 XmListSelectItem(ctrlBlk->fontList, str, TRUE);
1210 XmListSelectItem(ctrlBlk->fontList, str, TRUE);
1211 XmStringFree(str);
1213 dispSample(ctrlBlk);
1214 XmTextSetString(ctrlBlk->fontNameField, ctrlBlk->fontName);
1218 /* hacked code to move initial input focus to first scroll list and at the
1219 same time have the OK button as the default button */
1221 static void setFocus(Widget w, xfselControlBlkType *ctrlBlk, XEvent *event,
1222 Boolean *continueToDispatch)
1224 int n;
1225 Arg args[2];
1227 *continueToDispatch = TRUE;
1229 n = 0;
1230 XtSetArg(args[n], XmNdefaultButton, ctrlBlk->okButton); n++;
1231 XtSetValues(ctrlBlk->form, args, n);
1235 /* finds the name of the biggest font less than the given limit
1236 MAX_DISPLAY_SIZE used to set up the initial height of the display widget
1239 static void FindBigFont(xfselControlBlkType *ctrlBlk, char *bigFont)
1241 int i, maxSize, ind = -1, size;
1242 char sizeStr[10];
1244 for (i = 0, maxSize = 0; i < ctrlBlk->numFonts; i++)
1246 getStringComponent(ctrlBlk->fontData[i], 7, sizeStr);
1247 size = atoi(sizeStr);
1248 if ((size > maxSize) && (size < MAX_DISPLAY_SIZE))
1250 ind = i;
1251 maxSize = size;
1254 if (ind >= 0) {
1255 strcpy(bigFont, ctrlBlk->fontData[ind]);
1257 else {
1258 bigFont[0] = 0;