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.16 by pcg, Sat Jan 31 00:20:21 2004 UTC vs.
Revision 1.20 by pcg, Fri Feb 20 22:27:23 2004 UTC

23#include "rxvt.h" 23#include "rxvt.h"
24#include "defaultfont.h" 24#include "defaultfont.h"
25 25
26#include <cstdlib> 26#include <cstdlib>
27 27
28#define DISPLAY r->Xdisplay 28#define DISPLAY r->display->display
29#define DRAWABLE r->TermWin.vt 29#define DRAWABLE r->TermWin.vt
30#define GC r->TermWin.gc 30#define GC r->TermWin.gc
31 31
32const struct rxvt_fallback_font { 32const struct rxvt_fallback_font {
33 codeset cs; 33 codeset cs;
428 428
429 XFontStruct *f = XLoadQueryFont (DISPLAY, name); 429 XFontStruct *f = XLoadQueryFont (DISPLAY, name);
430 430
431 if (f) 431 if (f)
432 { 432 {
433 // the font should really exists now. if not, we have a problem 433 // the font should really exist now. if not, we have a problem
434 // (e.g. if the user did xset fp rehash just when we were searching fonts). 434 // (e.g. if the user did xset fp rehash just when we were searching fonts).
435 // in that case, just return garbage. 435 // in that case, just return garbage.
436 bool ret = set_properties (p, f); 436 bool ret = set_properties (p, f);
437 XFreeFont (DISPLAY, f); 437 XFreeFont (DISPLAY, f);
438 return ret; 438 return ret;
760}; 760};
761 761
762void 762void
763rxvt_font_xft::clear () 763rxvt_font_xft::clear ()
764{ 764{
765 if (d)
766 {
767 XftDrawDestroy (d);
768 d = 0;
769 }
770
765 if (f) 771 if (f)
766 { 772 {
767 XftFontClose (DISPLAY, f); 773 XftFontClose (DISPLAY, f);
768 f = 0; 774 f = 0;
769 }
770
771 if (d)
772 {
773 XftDrawDestroy (d);
774 d = 0;
775 } 775 }
776} 776}
777 777
778rxvt_fontprop 778rxvt_fontprop
779rxvt_font_xft::properties () 779rxvt_font_xft::properties ()
876 FT_Set_Pixel_Sizes (face, 0, ftheight = prop.height); 876 FT_Set_Pixel_Sizes (face, 0, ftheight = prop.height);
877 } 877 }
878 878
879 XftUnlockFace (f); 879 XftUnlockFace (f);
880 880
881 d = XftDrawCreate (DISPLAY, DRAWABLE, r->display->visual, r->display->cmap);
882 if (!d)
883 return false;
884
881 return true; 885 return true;
882} 886}
883 887
884bool 888bool
885rxvt_font_xft::has_codepoint (uint32_t unicode) 889rxvt_font_xft::has_codepoint (uint32_t unicode)
890void 894void
891rxvt_font_xft::draw (int x, int y, 895rxvt_font_xft::draw (int x, int y,
892 const text_t *text, int len, 896 const text_t *text, int len,
893 int fg, int bg) 897 int fg, int bg)
894{ 898{
895 if (!d)
896 d = XftDrawCreate (DISPLAY, DRAWABLE, r->Xvisual, r->Xcmap);
897
898 if (bg >= 0 && bg != Color_bg) 899 if (bg >= 0 && bg != Color_bg)
899 XftDrawRect (d, &r->PixColors[bg].c, x, y, r->TermWin.fwidth * len, r->TermWin.fheight); 900 XftDrawRect (d, &r->PixColors[bg].c, x, y, r->TermWin.fwidth * len, r->TermWin.fheight);
900 else 901 else
901 clear_rect (x, y, r->TermWin.fwidth * len, r->TermWin.fheight, bg); 902 clear_rect (x, y, r->TermWin.fwidth * len, r->TermWin.fheight, bg);
902 903
942#endif 943#endif
943 944
944///////////////////////////////////////////////////////////////////////////// 945/////////////////////////////////////////////////////////////////////////////
945 946
946rxvt_fontset::rxvt_fontset (rxvt_t r) 947rxvt_fontset::rxvt_fontset (rxvt_t r)
947: r(r) 948: r (r)
948{ 949{
949 clear (); 950 clear ();
950} 951}
951 952
952rxvt_fontset::~rxvt_fontset () 953rxvt_fontset::~rxvt_fontset ()
955} 956}
956 957
957void 958void
958rxvt_fontset::clear () 959rxvt_fontset::clear ()
959{ 960{
960 for (rxvt_font **i = fonts.begin (); i != fonts.end(); i++) 961 for (rxvt_font **i = fonts.begin (); i != fonts.end (); i++)
961 FONT_UNREF (*i); 962 FONT_UNREF (*i);
962 963
963 fonts.clear (); 964 fonts.clear ();
964 base_id = 0; 965 base_id = 0;
965 base_prop.height = 0x7fffffff; 966 base_prop.height = 0x7fffffff;
1084 base_id = 1; 1085 base_id = 1;
1085 1086
1086 // we currently need a base-font, no matter what 1087 // we currently need a base-font, no matter what
1087 if ((int)fonts.size () <= base_id || !realize_font (base_id)) 1088 if ((int)fonts.size () <= base_id || !realize_font (base_id))
1088 { 1089 {
1089 puts ("unable to load specified font(s), falling back to 'fixed'\n"); 1090 puts ("unable to load specified font (s), falling back to 'fixed'\n");
1090 add_fonts ("fixed"); 1091 add_fonts ("fixed");
1091 base_id = fonts.size () - 1; 1092 base_id = fonts.size () - 1;
1092 } 1093 }
1093 1094
1094 if ((int)fonts.size () <= base_id || !realize_font (base_id)) 1095 if ((int)fonts.size () <= base_id || !realize_font (base_id))

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines