void setCgsFont(XtermWidget xw, VTwin *cgsWin, CgsEnum cgsId, XTermFonts * font) { CgsCache *me; if ((me = myCache(xw, cgsWin, cgsId)) != 0) { if (!HaveFont(font)) { if (cgsId != gcNorm) (void) getCgsGC(xw, cgsWin, gcNorm); #ifndef NO_ACTIVE_ICON if (cgsWin == &(TScreenOf(xw)->iconVwin)) font = &(TScreenOf(xw)->fnt_icon); else #endif font = &(TScreenOf(xw)->fnts[fNorm]); } if (HaveFont(font) && okFont(font->fs)) { TRACE2(("setCgsFont next: %s for %s slot %p, gc %#x\n", traceFont(font), traceCgsEnum(cgsId), me, (unsigned) THIS(gc))); TRACE2(("...next font was %s\n", traceFont(NEXT(font)))); NEXT(font) = font; me->mask |= GCFont; } else { /* EMPTY */ TRACE2(("...NOT updated font for %s\n", traceCgsEnum(cgsId))); } } }
/* * Lookup/cache a GC for the double-size character display. We save up to * NUM_CHRSET values. */ GC xterm_DoubleGC(XtermWidget xw, unsigned chrset, unsigned attr_flags, unsigned draw_flags, GC old_gc, int *inxp) { TScreen *screen = TScreenOf(xw); VTwin *cgsWin = WhichVWin(screen); char *name; GC result = 0; if ((name = xtermSpecialFont(screen, attr_flags, draw_flags, chrset)) != 0) { CgsEnum cgsId = WhichCgsId(attr_flags); Boolean found = False; XTermFonts *data = 0; int n; if ((n = xterm_Double_index(xw, chrset, attr_flags)) >= 0) { data = &(screen->double_fonts[n]); if (data->fn != 0) { if (!strcmp(data->fn, name) && data->fs != 0) { found = True; free(name); } else { discard_font(xw, n); } } } if (!found) { XTermFonts temp; TRACE(("xterm_DoubleGC %s %d: %s\n", (attr_flags & BOLD) ? "BOLD" : "NORM", n, name)); memset(&temp, 0, sizeof(temp)); temp.fn = name; temp.chrset = chrset; temp.flags = (attr_flags & BOLD); if (!xtermOpenFont(xw, name, &temp, fwAlways, False)) { /* Retry with * in resolutions */ char *nname = xtermSpecialFont(screen, attr_flags, draw_flags | NORESOLUTION, chrset); if (nname != 0) { found = (Boolean) xtermOpenFont(xw, nname, &temp, fwAlways, False); free(nname); } } else { found = True; } free(name); if (found) { n = 0; data = pushback_font(xw, &temp); } TRACE(("-> %s\n", found ? "OK" : "FAIL")); } if (found) { setCgsCSet(xw, cgsWin, cgsId, chrset); setCgsFont(xw, cgsWin, cgsId, data); setCgsFore(xw, cgsWin, cgsId, getCgsFore(xw, cgsWin, old_gc)); setCgsBack(xw, cgsWin, cgsId, getCgsBack(xw, cgsWin, old_gc)); result = getCgsGC(xw, cgsWin, cgsId); *inxp = n; } else if (attr_flags & BOLD) { UIntClr(attr_flags, BOLD); result = xterm_DoubleGC(xw, chrset, attr_flags, draw_flags, old_gc, inxp); } } return result; }