ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/defaultfont.C
(Generate patch)

Comparing rxvt-unicode/src/defaultfont.C (file contents):
Revision 1.3 by pcg, Thu Nov 27 20:09:00 2003 UTC vs.
Revision 1.6 by pcg, Wed Dec 17 22:29:03 2003 UTC

270 270
271 if (t >= 0x2500 & t <= 0x2580 && linedraw_cmds[t - 0x2500]) 271 if (t >= 0x2500 & t <= 0x2580 && linedraw_cmds[t - 0x2500])
272 { 272 {
273 const char *p = linedraw_cmds[t - 0x2500]; 273 const char *p = linedraw_cmds[t - 0x2500];
274 274
275 int x0 = x, x1 = x + (r->TermWin.fwidth - 1) / 2, x2 = x + r->TermWin.fwidth - 1; 275 int x0 = x, x1 = x + r->TermWin.fwidth / 2, x2 = x + r->TermWin.fwidth ;
276 int y0 = y, y1 = y + (r->TermWin.fheight - 1) / 2, y2 = y + r->TermWin.fheight - 1; 276 int y0 = y, y1 = y + r->TermWin.fheight / 2, y2 = y + r->TermWin.fheight;
277 277
278 XGCValues gcv; 278 XGCValues gcv;
279
280 gcv.cap_style = CapButt;
281 XChangeGC (DISPLAY, GC, GCCapStyle, &gcv);
282 279
283 while (*p) 280 while (*p)
284 { 281 {
285 switch (*p++) 282 switch (*p++)
286 { 283 {
356bool 353bool
357rxvt_font_x11::load (int maxheight) 354rxvt_font_x11::load (int maxheight)
358{ 355{
359 clear (); 356 clear ();
360 357
358 char **list;
359 int count;
360 XFontStruct *info;
361 list = XListFontsWithInfo (DISPLAY, name, 128, &count, &info);
362
363 if (!list)
364 return false;
365
366 XFontStruct *best = 0;
367 for (int i = 0; i < count; i++)
368 {
369 XFontStruct *f = info + i;
370 if (f->ascent + f->descent <= maxheight) // weed out too large fonts
371 if (!best // compare against best found so far
372 || best->ascent + best->descent < f->ascent + f->descent)
373 best = f;
374 }
375
376 set_name (strdup (list[best - info]));
377
378 XFreeFontInfo (list, info, count);
379
361 f = XLoadQueryFont (DISPLAY, name); 380 f = XLoadQueryFont (DISPLAY, name);
362 381
363 if (!f) 382 if (!f)
364 return false; 383 return false;
365 384
894rxvt_fontset::realize_font (int i) 913rxvt_fontset::realize_font (int i)
895{ 914{
896 if (fonts[i]->loaded) 915 if (fonts[i]->loaded)
897 return true; 916 return true;
898 917
918 fonts[i]->loaded = true;
919
899 if (fonts[i]->load (height)) 920 if (!fonts[i]->load (height))
900 return fonts[i]->loaded = true; 921 {
901 922 fonts[i]->cs = CS_UNKNOWN;
902 delete fonts[i];
903 fonts.erase (fonts.begin () + i);
904
905 return false; 923 return false;
924 }
925
926 return true;
906} 927}
907 928
908void 929void
909rxvt_fontset::populate (const char *desc) 930rxvt_fontset::populate (const char *desc)
910{ 931{
947 { 968 {
948 if (FROM_UNICODE (f->cs, unicode) == NOCHAR) 969 if (FROM_UNICODE (f->cs, unicode) == NOCHAR)
949 goto next_font; 970 goto next_font;
950 971
951 if (!realize_font (i)) 972 if (!realize_font (i))
952 {
953 --i;
954 goto next_font; 973 goto next_font;
955 } 974 }
956 975
957 //printf ("added font %s for %04lx\n", f->name, unicode);
958 }
959
960 if (f->has_codepoint (unicode)) 976 if (f->cs != CS_UNKNOWN && f->has_codepoint (unicode))
961 return i; 977 return i;
962 978
963 next_font: 979 next_font:
964 if (i == fonts.size () - 1 && fallback->name) 980 if (i == fonts.size () - 1 && fallback->name)
965 { 981 {
966 fonts.push_back (new_font (fallback->name, fallback->cs)); 982 fonts.push_back (new_font (fallback->name, fallback->cs));
967 fallback++; 983 fallback++;
984 i = 0;
968 } 985 }
969 } 986 }
970 987
971 return 0; /* we must return SOME font */ 988 return 0; /* we must return SOME font */
972} 989}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines