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

Comparing rxvt-unicode/src/rxvtfont.C (file contents):
Revision 1.151 by root, Sat Apr 4 13:58:55 2009 UTC vs.
Revision 1.159 by sf-exg, Wed Mar 31 13:14:50 2010 UTC

499 499
500 void draw (rxvt_drawable &d, int x, int y, 500 void draw (rxvt_drawable &d, int x, int y,
501 const text_t *text, int len, 501 const text_t *text, int len,
502 int fg, int bg); 502 int fg, int bg);
503 503
504 bool slow; // wether this is a proportional font or has other funny characteristics 504 bool slow; // whether this is a proportional font or has other funny characteristics
505 XFontStruct *f; 505 XFontStruct *f;
506 bool enc2b, encm; 506 bool enc2b, encm;
507 507
508 char *get_property (XFontStruct *f, Atom property, const char *repl) const; 508 char *get_property (XFontStruct *f, Atom property, const char *repl) const;
509 bool set_properties (rxvt_fontprop &p, int height, const char *weight, const char *slant, int avgwidth); 509 bool set_properties (rxvt_fontprop &p, int height, const char *weight, const char *slant, int avgwidth);
792 return false; 792 return false;
793 793
794 char *registry = get_property (f, term->xa [XA_CHARSET_REGISTRY], 0); 794 char *registry = get_property (f, term->xa [XA_CHARSET_REGISTRY], 0);
795 char *encoding = get_property (f, term->xa [XA_CHARSET_ENCODING], 0); 795 char *encoding = get_property (f, term->xa [XA_CHARSET_ENCODING], 0);
796 796
797 cs = CS_UNKNOWN;
798
797 if (registry && encoding) 799 if (registry && encoding)
798 { 800 {
799 char charset[64]; 801 char charset[64];
800 snprintf (charset, 64, "%s-%s", registry, encoding); 802 snprintf (charset, 64, "%s-%s", registry, encoding);
801 803
802 cs = codeset_from_name (charset); 804 cs = codeset_from_name (charset);
805
806 if (cs == CS_UNKNOWN)
807 rxvt_warn ("%s: cannot deduce encoding from registry/encoding properties \"%s\", ignoring font.\n", name, charset);
803 } 808 }
804 else 809
810 free (registry);
811 free (encoding);
812
813 if (cs == CS_UNKNOWN)
805 { 814 {
806 const char *charset = get_property (f, XA_FONT, 0); 815 const char *charset = get_property (f, XA_FONT, 0);
807 816
808 if (!charset) 817 if (!charset)
809 charset = name; 818 charset = name;
812 while (*charset) 821 while (*charset)
813 if (*charset++ == '-' && !--count) 822 if (*charset++ == '-' && !--count)
814 break; 823 break;
815 824
816 cs = codeset_from_name (charset); 825 cs = codeset_from_name (charset);
826 if (cs == CS_UNKNOWN)
827 rxvt_warn ("%s: cannot deduce encoding from font name property \"%s\", ignoring font.\n", name, charset);
828 }
829
830 if (cs == CS_UNKNOWN)
817 } 831 {
818 832 clear ();
819 free (registry); 833 return false;
820 free (encoding); 834 }
821 835
822 if (cs == CS_UNICODE) 836 if (cs == CS_UNICODE)
823 cs = CS_UNICODE_16; // X11 can have a max. of 65536 chars per font 837 cs = CS_UNICODE_16; // X11 can have a max. of 65536 chars per font
824 838
825 encm = f->min_byte1 != 0 || f->max_byte1 != 0; 839 encm = f->min_byte1 != 0 || f->max_byte1 != 0;
872 if (wcw > 0) g.width = (g.width + wcw - 1) / wcw; 886 if (wcw > 0) g.width = (g.width + wcw - 1) / wcw;
873 887
874 if (width < g.width) width = g.width; 888 if (width < g.width) width = g.width;
875 } 889 }
876 890
877 if (cs == CS_UNKNOWN) 891#if 0 // do it per-character
892 if (prop && width > prop->width)
878 { 893 {
879 fprintf (stderr, "unable to deduce codeset, ignoring font '%s'\n", name);
880
881 clear (); 894 clear ();
882 return false; 895 return false;
883 } 896 }
884
885#if 0 // do it per-character
886 if (prop && width > prop->width)
887 {
888 clear ();
889 return false;
890 }
891#endif 897#endif
892 898
893 return true; 899 return true;
894} 900}
895 901
909 uint32_t ch = FROM_UNICODE (cs, unicode); 915 uint32_t ch = FROM_UNICODE (cs, unicode);
910 916
911 if (ch == NOCHAR) 917 if (ch == NOCHAR)
912 return false; 918 return false;
913 919
914 /* check wether the character exists in _this_ font. horrible. */ 920 /* check whether the character exists in _this_ font. horrible. */
915 XCharStruct *xcs; 921 XCharStruct *xcs;
916 922
917 if (encm) 923 if (encm)
918 { 924 {
919 unsigned char byte1 = ch >> 8; 925 unsigned char byte1 = ch >> 8;
949 return false; 955 return false;
950 956
951 if (!prop || prop->width == rxvt_fontprop::unset) 957 if (!prop || prop->width == rxvt_fontprop::unset)
952 return true; 958 return true;
953 959
954 // check wether character overlaps previous/next character 960 // check whether character overlaps previous/next character
955 int w = xcs->rbearing - xcs->lbearing; 961 int w = xcs->rbearing - xcs->lbearing;
956 int wcw = max (WCWIDTH (unicode), 1); 962 int wcw = max (WCWIDTH (unicode), 1);
957 963
958 careful = xcs->lbearing < 0 || xcs->rbearing > prop->width * wcw; 964 careful = xcs->lbearing < 0 || xcs->rbearing > prop->width * wcw;
959 965
1287rxvt_font_xft::draw (rxvt_drawable &d, int x, int y, 1293rxvt_font_xft::draw (rxvt_drawable &d, int x, int y,
1288 const text_t *text, int len, 1294 const text_t *text, int len,
1289 int fg, int bg) 1295 int fg, int bg)
1290{ 1296{
1291 XGlyphInfo extents; 1297 XGlyphInfo extents;
1292 XftGlyphSpec *enc = (XftGlyphSpec *)rxvt_temp_buf (len * sizeof (XftGlyphSpec)); 1298 XftGlyphSpec *enc = rxvt_temp_buf<XftGlyphSpec> (len);
1293 XftGlyphSpec *ep = enc; 1299 XftGlyphSpec *ep = enc;
1294 1300
1295 dTermDisplay; 1301 dTermDisplay;
1296 dTermGC; 1302 dTermGC;
1297 1303
1669 FcPatternDestroy (match); 1675 FcPatternDestroy (match);
1670 1676
1671 if (find_font (font) < 0) 1677 if (find_font (font) < 0)
1672 { 1678 {
1673 char fontname[4096]; 1679 char fontname[4096];
1674 sprintf (fontname, "xft:%-.4090s", font); 1680 snprintf (fontname, sizeof (fontname), "xft:%s", font);
1675 1681
1676 fonts.push_back (new_font (fontname, CS_UNICODE)); 1682 fonts.push_back (new_font (fontname, CS_UNICODE));
1677 } 1683 }
1678 1684
1679 free (font); 1685 free (font);
1703 } 1709 }
1704 1710
1705 return i; 1711 return i;
1706} 1712}
1707 1713
1708
1709

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines