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.168 by sf-exg, Tue Dec 14 08:01:51 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
159 '0', '1', '8', 'a', 'd', 'x', 'm', 'y', 'g', 'W', 'X', '\'', '_', 159 '0', '1', '8', 'a', 'd', 'x', 'm', 'y', 'g', 'W', 'X', '\'', '_',
160 0x00cd, 0x00d5, 0x0114, 0x0177, 0x0643, // ÍÕĔŷﻙ 160 0x00cd, 0x00d5, 0x0114, 0x0177, 0x0643, // ÍÕĔŷﻙ
161 0x304c, 0x672c, // が本 161 0x304c, 0x672c, // が本
162}; 162};
163 163
164#define NUM_EXTENT_TEST_CHARS (sizeof (extent_test_chars) / sizeof (extent_test_chars[0]))
165
166#define dTermDisplay Display *disp = term->dpy 164#define dTermDisplay Display *disp = term->dpy
167#define dTermGC GC gc = term->gc 165#define dTermGC GC gc = term->gc
168 166
169///////////////////////////////////////////////////////////////////////////// 167/////////////////////////////////////////////////////////////////////////////
170 168
243 { 241 {
244#if XFT 242#if XFT
245 Picture dst; 243 Picture dst;
246 244
247# ifdef HAVE_BG_PIXMAP 245# ifdef HAVE_BG_PIXMAP
248 if (term->bgPixmap.pixmap 246 if (term->bg_pixmap
249 && !term->pix_colors[color].is_opaque () 247 && !term->pix_colors[color].is_opaque ()
250 && ((dst = XftDrawPicture (d)))) 248 && ((dst = XftDrawPicture (d))))
251 { 249 {
252 XClearArea (disp, d, x, y, w, h, false); 250 XClearArea (disp, d, x, y, w, h, false);
253 251
526 524
527 void draw (rxvt_drawable &d, int x, int y, 525 void draw (rxvt_drawable &d, int x, int y,
528 const text_t *text, int len, 526 const text_t *text, int len,
529 int fg, int bg) 527 int fg, int bg)
530 { 528 {
531 while (len--) 529 while (len)
532 { 530 {
533 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++;
534 (*fs)[fid]->draw (d, x, y, text, 1, fg, bg); 535 (*fs)[fid]->draw (d, x, y, text, w, fg, bg);
535 ++text; 536 text += w;
537 len -= w;
536 x += term->fwidth; 538 x += term->fwidth * w;
537 } 539 }
538 } 540 }
539}; 541};
540 542
541///////////////////////////////////////////////////////////////////////////// 543/////////////////////////////////////////////////////////////////////////////
720 f = XLoadQueryFont (disp, name); 722 f = XLoadQueryFont (disp, name);
721 723
722 if (!f) 724 if (!f)
723 return false; 725 return false;
724 726
725 char *new_name = get_property (f, XA_FONT, name); 727 char *new_name = get_property (f, XA_FONT, 0);
726 728
727 if (new_name) 729 if (new_name)
728 set_name (new_name); 730 set_name (new_name);
729 else 731 else
730 rxvt_warn ("font '%s' has no FONT property, continuing without.", name); 732 rxvt_warn ("font '%s' has no FONT property, continuing without.\n", name);
731 733
732 XFreeFont (disp, f); 734 XFreeFont (disp, f);
733 f = 0; 735 f = 0;
734 } 736 }
735 737
792 free (fname); 794 free (fname);
793 if (replace_field (&fname, list[i], 11, '0', "0")) 795 if (replace_field (&fname, list[i], 11, '0', "0"))
794 diff += 300; // more heavily penalize what looks like scaled bitmap fonts 796 diff += 300; // more heavily penalize what looks like scaled bitmap fonts
795 } 797 }
796 798
797 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);
798 continue; 805 continue;
799 806 }
800 if (prop.height != rxvt_fontprop::unset
801 && p.height > prop.height) // weed out too large fonts
802 continue;
803 807
804 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;
805 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);
806 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);
807 //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);
864 free (registry); 868 free (registry);
865 free (encoding); 869 free (encoding);
866 870
867 if (cs == CS_UNKNOWN) 871 if (cs == CS_UNKNOWN)
868 { 872 {
869 const char *charset = get_property (f, XA_FONT, 0); 873 char *value = get_property (f, XA_FONT, 0);
874 const char *charset = value;
870 875
871 if (!charset) 876 if (!charset)
872 charset = name; 877 charset = name;
873 878
874 int count = 13; 879 int count = 13;
877 break; 882 break;
878 883
879 cs = codeset_from_name (charset); 884 cs = codeset_from_name (charset);
880 if (cs == CS_UNKNOWN) 885 if (cs == CS_UNKNOWN)
881 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);
882 } 889 }
883 890
884 if (cs == CS_UNKNOWN) 891 if (cs == CS_UNKNOWN)
885 { 892 {
886 clear (); 893 clear ();
918 } 925 }
919#endif 926#endif
920 927
921 width = 1; 928 width = 1;
922 929
923 for (uint16_t *t = extent_test_chars + NUM_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; )
924 { 931 {
925 if (FROM_UNICODE (cs, *t) == NOCHAR) 932 if (FROM_UNICODE (cs, *t) == NOCHAR)
926 continue; 933 continue;
927 934
928 // ignore characters we wouldn't use anyways 935 // ignore characters we wouldn't use anyways
964} 971}
965 972
966bool 973bool
967rxvt_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
968{ 975{
976 careful = false;
977
969 uint32_t ch = FROM_UNICODE (cs, unicode); 978 uint32_t ch = FROM_UNICODE (cs, unicode);
970 979
971 if (ch == NOCHAR) 980 if (ch == NOCHAR)
972 return false; 981 return false;
973 982
1215 int ftheight = 0; 1224 int ftheight = 0;
1216 bool success = true; 1225 bool success = true;
1217 1226
1218 for (;;) 1227 for (;;)
1219 { 1228 {
1229 p = FcPatternDuplicate (match);
1220 f = XftFontOpenPattern (disp, FcPatternDuplicate (match)); 1230 f = XftFontOpenPattern (disp, p);
1221 1231
1222 if (!f) 1232 if (!f)
1223 { 1233 {
1234 FcPatternDestroy (p);
1224 success = false; 1235 success = false;
1225 break; 1236 break;
1226 } 1237 }
1227 1238
1228 FT_Face face = XftLockFace (f); 1239 FT_Face face = XftLockFace (f);
1236 1247
1237 XftUnlockFace (f); 1248 XftUnlockFace (f);
1238 1249
1239 int glheight = height; 1250 int glheight = height;
1240 1251
1241 for (uint16_t *t = extent_test_chars + NUM_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; )
1242 { 1253 {
1243 FcChar16 ch = *t; 1254 FcChar16 ch = *t;
1244 1255
1245 if (cs != CS_UNICODE 1256 if (cs != CS_UNICODE
1246 && ch > 0x100 1257 && ch > 0x100
1401 rxvt_drawable &d2 = d.screen->scratch_drawable (w, h); 1412 rxvt_drawable &d2 = d.screen->scratch_drawable (w, h);
1402 1413
1403#ifdef HAVE_BG_PIXMAP 1414#ifdef HAVE_BG_PIXMAP
1404 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
1405 1416
1406 if (term->bgPixmap.pixmap 1417 if (term->bg_pixmap
1407 && (bg == Color_transparent || bg == Color_bg 1418 && (bg == Color_transparent || bg == Color_bg
1408 || (bg >= 0 && !term->pix_colors[bg].is_opaque () && ((dst = XftDrawPicture (d2)))))) 1419 || (bg >= 0 && !term->pix_colors[bg].is_opaque () && ((dst = XftDrawPicture (d2))))))
1409 { 1420 {
1410 int src_x = x, src_y = y; 1421 int src_x = x, src_y = y;
1411 1422
1412 if (term->bgPixmap.flags & bgPixmap_t::isTransparent) 1423 if (term->bg_flags & rxvt_term::BG_IS_TRANSPARENT)
1413 { 1424 {
1414 src_x += term->window_vt_x; 1425 src_x += term->window_vt_x;
1415 src_y += term->window_vt_y; 1426 src_y += term->window_vt_y;
1416 } 1427 }
1417 1428
1418 if (term->bgPixmap.pmap_width >= src_x + w 1429 if (term->bg_pmap_width >= src_x + w
1419 && term->bgPixmap.pmap_height >= src_y + h) 1430 && term->bg_pmap_height >= src_y + h)
1420 { 1431 {
1421 XCopyArea (disp, term->bgPixmap.pixmap, d2, gc, 1432 XCopyArea (disp, term->bg_pixmap, d2, gc,
1422 src_x, src_y, w, h, 0, 0); 1433 src_x, src_y, w, h, 0, 0);
1423 } 1434 }
1424 else 1435 else
1425 { 1436 {
1426 XGCValues gcv; 1437 XGCValues gcv;
1427 1438
1428 gcv.fill_style = FillTiled; 1439 gcv.fill_style = FillTiled;
1429 gcv.tile = term->bgPixmap.pixmap; 1440 gcv.tile = term->bg_pixmap;
1430 gcv.ts_x_origin = -src_x; 1441 gcv.ts_x_origin = -src_x;
1431 gcv.ts_y_origin = -src_y; 1442 gcv.ts_y_origin = -src_y;
1432 1443
1433 XChangeGC (disp, gc, 1444 XChangeGC (disp, gc,
1434 GCTile | GCTileStipXOrigin | GCTileStipYOrigin | GCFillStyle, 1445 GCTile | GCTileStipXOrigin | GCTileStipYOrigin | GCFillStyle,
1609 buf[end - desc] = 0; 1620 buf[end - desc] = 0;
1610 1621
1611 push_font (new_font (buf, cs)); 1622 push_font (new_font (buf, cs));
1612 } 1623 }
1613 else 1624 else
1614 rxvt_warn ("fontset element too long (>511 bytes), ignored."); 1625 rxvt_warn ("fontset element too long (>511 bytes), ignored.\n");
1615 1626
1616 desc = end + 1; 1627 desc = end + 1;
1617 } 1628 }
1618 while (*end); 1629 while (*end);
1619 } 1630 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines