
Example F-5. The fonts.c program (continued)
void
change_font(item, value, event)
Panel_item item;
Event *event;
{
static int family, style, scale;
char buf[128];
Frame frame;
char *family_name;
char *style_name;
int scale_value;
Xv_Font font;
frame = (Frame)xv_get(xv_get(item, PANEL_PARENT_PANEL), XV_OWNER);
family_name = (char *)xv_get(family_item, PANEL_CHOICE_STRING,
xv_get(family_item, PANEL_VALUE));
style_name = (char *)xv_get(style_item, PANEL_CHOICE_STRING,
xv_get(style_item, PANEL_VALUE));
scale_value = (int) xv_get(scale_item, PANEL_VALUE);
xv_set(frame, FRAME_BUSY, TRUE, NULL);
font = (Xv_Font)xv_find(frame, FONT,
FONT_FAMILY, family_name,
FONT_STYLE, style_name,
/* scale_value happens to coincide with Window_rescale_state */
FONT_SCALE, scale_value,
/*
* If run on a server that cannot rescale fonts, only font
* sizes that exist should be passed
*/
FONT_SIZES_FOR_SCALE, 12, 14, 16, 22,
NULL);
xv_set(frame, FRAME_BUSY, FALSE, NULL);
if (!font) {
if (item == family_item) {
sprintf(buf, "cannot load ’%s’", family_name);
xv_set(family_item, PANEL_VALUE, family, NULL);
} else if (item == style_item) {
sprintf(buf, "cannot load ’%s’", style_name);
xv_set(style_item, PANEL_VALUE, style, NULL);
} else {
sprintf(buf, "Not available in %s scale.",
xv_get(scale_item, PANEL_CHOICE_STRING, scale));
xv_set(scale_item, PANEL_VALUE, scale, NULL);
}
xv_set(frame, FRAME_RIGHT_FOOTER, buf, NULL);
return;
}
if (item == family_ite