draw.c
changeset 7 49e2fc9fb94f
parent 5 e5018cae273f
child 26 e8f627998d6f
equal deleted inserted replaced
6:e0cefb3981c8 7:49e2fc9fb94f
   114 loadfont(Display *dpy, Fnt *font, const char *fontstr)
   114 loadfont(Display *dpy, Fnt *font, const char *fontstr)
   115 {
   115 {
   116 	char **missing, *def;
   116 	char **missing, *def;
   117 	int n;
   117 	int n;
   118 
   118 
   119 	missing = 0;
   119 	missing = NULL;
   120 	def = "?";
   120 	def = "?";
   121 	setlocale(LC_ALL, "");
   121 	setlocale(LC_ALL, "");
   122 	if(font->set)
   122 	if(font->set)
   123 		XFreeFontSet(dpy, font->set);
   123 		XFreeFontSet(dpy, font->set);
   124 	font->set = XCreateFontSet(dpy, fontstr, &missing, &n, &def);
   124 	font->set = XCreateFontSet(dpy, fontstr, &missing, &n, &def);
   126 		while(n--)
   126 		while(n--)
   127 			fprintf(stderr, "missing fontset: %s\n", missing[n]);
   127 			fprintf(stderr, "missing fontset: %s\n", missing[n]);
   128 		XFreeStringList(missing);
   128 		XFreeStringList(missing);
   129 		if(font->set) {
   129 		if(font->set) {
   130 			XFreeFontSet(dpy, font->set);
   130 			XFreeFontSet(dpy, font->set);
   131 			font->set = 0;
   131 			font->set = NULL;
   132 		}
   132 		}
   133 	}
   133 	}
   134 	if(font->set) {
   134 	if(font->set) {
   135 		XFontSetExtents *font_extents;
   135 		XFontSetExtents *font_extents;
   136 		XFontStruct **xfonts;
   136 		XFontStruct **xfonts;
   149 		}
   149 		}
   150 	}
   150 	}
   151 	else {
   151 	else {
   152 		if(font->xfont)
   152 		if(font->xfont)
   153 			XFreeFont(dpy, font->xfont);
   153 			XFreeFont(dpy, font->xfont);
   154 		font->xfont = 0;
   154 		font->xfont = NULL;
   155 		font->xfont = XLoadQueryFont(dpy, fontstr);
   155 		font->xfont = XLoadQueryFont(dpy, fontstr);
   156 		if (!font->xfont)
   156 		if (!font->xfont)
   157 			font->xfont = XLoadQueryFont(dpy, "fixed");
   157 			font->xfont = XLoadQueryFont(dpy, "fixed");
   158 		if (!font->xfont)
   158 		if (!font->xfont)
   159 			error("error, cannot load 'fixed' font\n");
   159 			error("error, cannot load 'fixed' font\n");