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.169 by sf-exg, Sat Dec 18 18:17:38 2010 UTC vs.
Revision 1.180 by sf-exg, Mon May 30 18:39:03 2011 UTC

1/*----------------------------------------------------------------------* 1/*----------------------------------------------------------------------*
2 * File: rxvtfont.C 2 * File: rxvtfont.C
3 *----------------------------------------------------------------------* 3 *----------------------------------------------------------------------*
4 * Copyright (c) 2003-2008 Marc Lehmann <pcg@goof.com> 4 * Copyright (c) 2003-2008 Marc Lehmann <schmorp@schmorp.de>
5 * - original version. 5 * - original version.
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or 9 * the Free Software Foundation; either version 2 of the License, or
241 { 241 {
242#if XFT 242#if XFT
243 Picture dst; 243 Picture dst;
244 244
245# ifdef HAVE_BG_PIXMAP 245# ifdef HAVE_BG_PIXMAP
246 if (term->bgPixmap.pixmap 246 if (term->bg_pixmap
247 && !term->pix_colors[color].is_opaque () 247 && !term->pix_colors[color].is_opaque ()
248 && ((dst = XftDrawPicture (d)))) 248 && ((dst = XftDrawPicture (d))))
249 { 249 {
250 XClearArea (disp, d, x, y, w, h, false); 250 XClearArea (disp, d, x, y, w, h, false);
251 251
524 524
525 void draw (rxvt_drawable &d, int x, int y, 525 void draw (rxvt_drawable &d, int x, int y,
526 const text_t *text, int len, 526 const text_t *text, int len,
527 int fg, int bg) 527 int fg, int bg)
528 { 528 {
529 while (len--) 529 while (len)
530 { 530 {
531 int fid = fs->find_font_idx (*text); 531 int fid = fs->find_font_idx (*text);
532 int w = 1;
533 while (w < len && text[w] == NOCHAR)
534 w++;
532 (*fs)[fid]->draw (d, x, y, text, 1, fg, bg); 535 (*fs)[fid]->draw (d, x, y, text, w, fg, bg);
533 ++text; 536 text += w;
537 len -= w;
534 x += term->fwidth; 538 x += term->fwidth * w;
535 } 539 }
536 } 540 }
537}; 541};
538 542
539///////////////////////////////////////////////////////////////////////////// 543/////////////////////////////////////////////////////////////////////////////
718 f = XLoadQueryFont (disp, name); 722 f = XLoadQueryFont (disp, name);
719 723
720 if (!f) 724 if (!f)
721 return false; 725 return false;
722 726
723 char *new_name = get_property (f, XA_FONT, name); 727 char *new_name = get_property (f, XA_FONT, 0);
724 728
725 if (new_name) 729 if (new_name)
726 set_name (new_name); 730 set_name (new_name);
727 else 731 else
728 rxvt_warn ("font '%s' has no FONT property, continuing without.", name); 732 rxvt_warn ("font '%s' has no FONT property, continuing without.\n", name);
729 733
730 XFreeFont (disp, f); 734 XFreeFont (disp, f);
731 f = 0; 735 f = 0;
732 } 736 }
733 737
790 free (fname); 794 free (fname);
791 if (replace_field (&fname, list[i], 11, '0', "0")) 795 if (replace_field (&fname, list[i], 11, '0', "0"))
792 diff += 300; // more heavily penalize what looks like scaled bitmap fonts 796 diff += 300; // more heavily penalize what looks like scaled bitmap fonts
793 } 797 }
794 798
795 if (!set_properties (p, fname)) 799 if (!set_properties (p, fname)
800 // also weed out too large fonts
801 || (prop.height != rxvt_fontprop::unset
802 && p.height > prop.height))
803 {
804 free (fname);
796 continue; 805 continue;
797 806 }
798 if (prop.height != rxvt_fontprop::unset
799 && p.height > prop.height) // weed out too large fonts
800 continue;
801 807
802 if (prop.height != rxvt_fontprop::unset) diff += (prop.height - p.height) * 128; 808 if (prop.height != rxvt_fontprop::unset) diff += (prop.height - p.height) * 128;
803 if (prop.weight != rxvt_fontprop::unset) diff += abs (prop.weight - p.weight); 809 if (prop.weight != rxvt_fontprop::unset) diff += abs (prop.weight - p.weight);
804 if (prop.slant != rxvt_fontprop::unset) diff += abs (prop.slant - p.slant); 810 if (prop.slant != rxvt_fontprop::unset) diff += abs (prop.slant - p.slant);
805 //if (prop.width != rxvt_fontprop::unset) diff += abs (prop.width - p.width); 811 //if (prop.width != rxvt_fontprop::unset) diff += abs (prop.width - p.width);
862 free (registry); 868 free (registry);
863 free (encoding); 869 free (encoding);
864 870
865 if (cs == CS_UNKNOWN) 871 if (cs == CS_UNKNOWN)
866 { 872 {
867 const char *charset = get_property (f, XA_FONT, 0); 873 char *value = get_property (f, XA_FONT, 0);
874 const char *charset = value;
868 875
869 if (!charset) 876 if (!charset)
870 charset = name; 877 charset = name;
871 878
872 int count = 13; 879 int count = 13;
875 break; 882 break;
876 883
877 cs = codeset_from_name (charset); 884 cs = codeset_from_name (charset);
878 if (cs == CS_UNKNOWN) 885 if (cs == CS_UNKNOWN)
879 rxvt_warn ("%s: cannot deduce encoding from font name property \"%s\", ignoring font.\n", name, charset); 886 rxvt_warn ("%s: cannot deduce encoding from font name property \"%s\", ignoring font.\n", name, charset);
887
888 free (value);
880 } 889 }
881 890
882 if (cs == CS_UNKNOWN) 891 if (cs == CS_UNKNOWN)
883 { 892 {
884 clear (); 893 clear ();
916 } 925 }
917#endif 926#endif
918 927
919 width = 1; 928 width = 1;
920 929
921 for (uint16_t *t = extent_test_chars + ARRAY_LENGTH(extent_test_chars); t-- > extent_test_chars; ) 930 for (uint16_t *t = extent_test_chars + ecb_array_length (extent_test_chars); t-- > extent_test_chars; )
922 { 931 {
923 if (FROM_UNICODE (cs, *t) == NOCHAR) 932 if (FROM_UNICODE (cs, *t) == NOCHAR)
924 continue; 933 continue;
925 934
926 // ignore characters we wouldn't use anyways 935 // ignore characters we wouldn't use anyways
962} 971}
963 972
964bool 973bool
965rxvt_font_x11::has_char (unicode_t unicode, const rxvt_fontprop *prop, bool &careful) const 974rxvt_font_x11::has_char (unicode_t unicode, const rxvt_fontprop *prop, bool &careful) const
966{ 975{
976 careful = false;
977
967 uint32_t ch = FROM_UNICODE (cs, unicode); 978 uint32_t ch = FROM_UNICODE (cs, unicode);
968 979
969 if (ch == NOCHAR) 980 if (ch == NOCHAR)
970 return false; 981 return false;
971 982
1213 int ftheight = 0; 1224 int ftheight = 0;
1214 bool success = true; 1225 bool success = true;
1215 1226
1216 for (;;) 1227 for (;;)
1217 { 1228 {
1229 p = FcPatternDuplicate (match);
1218 f = XftFontOpenPattern (disp, FcPatternDuplicate (match)); 1230 f = XftFontOpenPattern (disp, p);
1219 1231
1220 if (!f) 1232 if (!f)
1221 { 1233 {
1234 FcPatternDestroy (p);
1222 success = false; 1235 success = false;
1223 break; 1236 break;
1224 } 1237 }
1225 1238
1226 FT_Face face = XftLockFace (f); 1239 FT_Face face = XftLockFace (f);
1234 1247
1235 XftUnlockFace (f); 1248 XftUnlockFace (f);
1236 1249
1237 int glheight = height; 1250 int glheight = height;
1238 1251
1239 for (uint16_t *t = extent_test_chars + ARRAY_LENGTH(extent_test_chars); t-- > extent_test_chars; ) 1252 for (uint16_t *t = extent_test_chars + ecb_array_length (extent_test_chars); t-- > extent_test_chars; )
1240 { 1253 {
1241 FcChar16 ch = *t; 1254 FcChar16 ch = *t;
1242 1255
1243 if (cs != CS_UNICODE 1256 if (cs != CS_UNICODE
1244 && ch > 0x100 1257 && ch > 0x100
1399 rxvt_drawable &d2 = d.screen->scratch_drawable (w, h); 1412 rxvt_drawable &d2 = d.screen->scratch_drawable (w, h);
1400 1413
1401#ifdef HAVE_BG_PIXMAP 1414#ifdef HAVE_BG_PIXMAP
1402 Picture dst = 0; // the only assignment is done conditionally in the following if condition 1415 Picture dst = 0; // the only assignment is done conditionally in the following if condition
1403 1416
1404 if (term->bgPixmap.pixmap 1417 if (term->bg_pixmap
1405 && (bg == Color_transparent || bg == Color_bg 1418 && (bg == Color_transparent || bg == Color_bg
1406 || (bg >= 0 && !term->pix_colors[bg].is_opaque () && ((dst = XftDrawPicture (d2)))))) 1419 || (bg >= 0 && !term->pix_colors[bg].is_opaque () && ((dst = XftDrawPicture (d2))))))
1407 { 1420 {
1408 int src_x = x, src_y = y; 1421 int src_x = x, src_y = y;
1409 1422
1410 if (term->bgPixmap.flags & bgPixmap_t::isTransparent) 1423 if (term->bg_flags & rxvt_term::BG_IS_TRANSPARENT)
1411 { 1424 {
1412 src_x += term->window_vt_x; 1425 src_x += term->window_vt_x;
1413 src_y += term->window_vt_y; 1426 src_y += term->window_vt_y;
1414 } 1427 }
1415 1428
1416 if (term->bgPixmap.pmap_width >= src_x + w 1429 if (term->bg_pmap_width >= src_x + w
1417 && term->bgPixmap.pmap_height >= src_y + h) 1430 && term->bg_pmap_height >= src_y + h)
1418 { 1431 {
1419 XCopyArea (disp, term->bgPixmap.pixmap, d2, gc, 1432 XCopyArea (disp, term->bg_pixmap, d2, gc,
1420 src_x, src_y, w, h, 0, 0); 1433 src_x, src_y, w, h, 0, 0);
1421 } 1434 }
1422 else 1435 else
1423 { 1436 {
1424 XGCValues gcv; 1437 XGCValues gcv;
1425 1438
1426 gcv.fill_style = FillTiled; 1439 gcv.fill_style = FillTiled;
1427 gcv.tile = term->bgPixmap.pixmap; 1440 gcv.tile = term->bg_pixmap;
1428 gcv.ts_x_origin = -src_x; 1441 gcv.ts_x_origin = -src_x;
1429 gcv.ts_y_origin = -src_y; 1442 gcv.ts_y_origin = -src_y;
1430 1443
1431 XChangeGC (disp, gc, 1444 XChangeGC (disp, gc,
1432 GCTile | GCTileStipXOrigin | GCTileStipYOrigin | GCFillStyle, 1445 GCTile | GCTileStipXOrigin | GCTileStipYOrigin | GCFillStyle,
1607 buf[end - desc] = 0; 1620 buf[end - desc] = 0;
1608 1621
1609 push_font (new_font (buf, cs)); 1622 push_font (new_font (buf, cs));
1610 } 1623 }
1611 else 1624 else
1612 rxvt_warn ("fontset element too long (>511 bytes), ignored."); 1625 rxvt_warn ("fontset element too long (>511 bytes), ignored.\n");
1613 1626
1614 desc = end + 1; 1627 desc = end + 1;
1615 } 1628 }
1616 while (*end); 1629 while (*end);
1617 } 1630 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines