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.98 by root, Mon Feb 20 22:42:00 2006 UTC vs.
Revision 1.125 by ayin, Sun Nov 25 11:23:18 2007 UTC

43 const char *name; 43 const char *name;
44} fallback_fonts[] = { 44} fallback_fonts[] = {
45 { CS_ISO8859_1, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-1" }, 45 { CS_ISO8859_1, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-1" },
46 { CS_ISO8859_15, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-15" }, 46 { CS_ISO8859_15, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-15" },
47 { CS_ISO8859_15, "-*-*-*-r-*--*-*-*-*-c-*-fcd8859-15" }, 47 { CS_ISO8859_15, "-*-*-*-r-*--*-*-*-*-c-*-fcd8859-15" },
48 48
49#if ENCODING_EU 49#if ENCODING_EU
50 // cyrillic 50 // cyrillic
51 { CS_KOI8_R, "-*-*-*-r-*--*-*-*-*-c-*-koi8-r" }, 51 { CS_KOI8_R, "-*-*-*-r-*--*-*-*-*-c-*-koi8-r" },
52 { CS_KOI8_U, "-*-*-*-r-*--*-*-*-*-c-*-koi8-u" }, 52 { CS_KOI8_U, "-*-*-*-r-*--*-*-*-*-c-*-koi8-u" },
53 53
54 { CS_ISO8859_2, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-2" }, 54 { CS_ISO8859_2, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-2" },
55 { CS_ISO8859_3, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-3" }, 55 { CS_ISO8859_3, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-3" },
56 { CS_ISO8859_4, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-4" }, 56 { CS_ISO8859_4, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-4" },
57 { CS_ISO8859_5, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-5" }, 57 { CS_ISO8859_5, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-5" },
58 { CS_ISO8859_6, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-6" }, 58 { CS_ISO8859_6, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-6" },
65 { CS_ISO8859_14, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-14" }, 65 { CS_ISO8859_14, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-14" },
66 { CS_ISO8859_16, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-16" }, 66 { CS_ISO8859_16, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-16" },
67 67
68# if XFT 68# if XFT
69 { CS_KOI8_U, "xft::lang=ru" }, 69 { CS_KOI8_U, "xft::lang=ru" },
70 70
71 { CS_ISO8859_5, "xft::lang=ru" }, 71 { CS_ISO8859_5, "xft::lang=ru" },
72 { CS_ISO8859_6, "xft::lang=ar" }, 72 { CS_ISO8859_6, "xft::lang=ar" },
73 { CS_ISO8859_7, "xft::lang=el" }, 73 { CS_ISO8859_7, "xft::lang=el" },
74 { CS_ISO8859_8, "xft::lang=he" }, 74 { CS_ISO8859_8, "xft::lang=he" },
75 { CS_ISO8859_9, "xft::lang=tr" }, 75 { CS_ISO8859_9, "xft::lang=tr" },
231void 231void
232rxvt_font::clear_rect (rxvt_drawable &d, int x, int y, int w, int h, int color) const 232rxvt_font::clear_rect (rxvt_drawable &d, int x, int y, int w, int h, int color) const
233{ 233{
234 dTermDisplay; 234 dTermDisplay;
235 dTermGC; 235 dTermGC;
236 236
237 if (color < 0 || color == Color_bg) 237 if (color == Color_bg || color == Color_transparent)
238 XClearArea (disp, d, x, y, w, h, false); 238 XClearArea (disp, d, x, y, w, h, false);
239 else 239 else if (color >= 0)
240 { 240 {
241#if XFT 241#if XFT
242 bool done = false;
243#ifdef HAVE_BG_PIXMAP
244 if (term->bgPixmap.pixmap && color >= 0 && term->pix_colors[color].c.color.alpha < 0x0ff00)
245 {
246 Picture dst = XftDrawPicture (d);
247 if (dst != 0)
248 {
249 XClearArea (disp, d, x, y, w, h, false);
250 Picture solid_color_pict = XftDrawSrcPicture (d, &term->pix_colors[color].c);
251 XRenderComposite (disp, PictOpOver, solid_color_pict, None, dst, 0, 0, 0, 0, x, y, w, h);
252 done = true;
253 }
254 }
255#endif
256 if (!done)
242 XftDrawRect (d, &term->pix_colors[color].c, x, y, w, h); 257 XftDrawRect (d, &term->pix_colors[color].c, x, y, w, h);
243#else 258#else
244 XSetForeground (disp, gc, term->pix_colors[color]); 259 XSetForeground (disp, gc, term->pix_colors[color]);
245 XFillRectangle (disp, d, gc, x, y, w, h); 260 XFillRectangle (disp, d, gc, x, y, w, h);
246#endif 261#endif
247 } 262 }
248} 263}
249 264
250///////////////////////////////////////////////////////////////////////////// 265/////////////////////////////////////////////////////////////////////////////
251
252#include "table/linedraw.h"
253 266
254struct rxvt_font_default : rxvt_font { 267struct rxvt_font_default : rxvt_font {
255 struct rxvt_fontset *fs; 268 struct rxvt_fontset *fs;
256 269
257 rxvt_font_default (rxvt_fontset *fs) 270 rxvt_font_default (rxvt_fontset *fs)
270 p.slant = rxvt_fontprop::roman; 283 p.slant = rxvt_fontprop::roman;
271 284
272 return p; 285 return p;
273 } 286 }
274 287
275 bool load (const rxvt_fontprop &prop) 288 bool load (const rxvt_fontprop &prop, bool force_prop)
276 { 289 {
277 width = 1; height = 1; 290 width = 1; height = 1;
278 ascent = 1; descent = 0; 291 ascent = 1; descent = 0;
279 292
280 set_name (strdup ("built-in support font")); 293 set_name (strdup ("built-in support font"));
293 return false; 306 return false;
294 307
295 if (unicode <= 0x009f) 308 if (unicode <= 0x009f)
296 return true; 309 return true;
297 310
311#ifdef BUILTIN_GLYPHS
298 if (unicode >= 0x2500 && unicode <= 0x259f && 312 if (unicode >= 0x2500 && unicode <= 0x259f &&
299 !term->option (Opt_skipBuiltinGlyphs)) 313 !term->option (Opt_skipBuiltinGlyphs))
300 return true; 314 return true;
315#endif
301 316
302 if (IS_COMPOSE (unicode)) 317 if (IS_COMPOSE (unicode))
303 return true; 318 return true;
304 319
305 switch (unicode) 320 switch (unicode)
341 ; 356 ;
342 357
343 int width = text - tp; 358 int width = text - tp;
344 int fwidth = term->fwidth * width; 359 int fwidth = term->fwidth * width;
345 360
361#ifdef BUILTIN_GLYPHS
346 if (0x2500 <= t && t <= 0x259f) 362 if (0x2500 <= t && t <= 0x259f)
347 { 363 {
364# include "table/linedraw.h"
348 uint16_t offs = linedraw_offs[t - 0x2500]; 365 uint16_t offs = linedraw_offs[t - 0x2500];
349 uint32_t *a = linedraw_command + (offs >> 4); 366 uint32_t *a = linedraw_command + (offs >> 4);
350 uint32_t *b = a + (offs & 15); 367 uint32_t *b = a + (offs & 15);
351 368
352 int W = fwidth; 369 int W = fwidth;
390 407
391 case 1: // rectangle, possibly stippled 408 case 1: // rectangle, possibly stippled
392 if (a) 409 if (a)
393 { 410 {
394 static char bm[] = { 0,0 , 3,1 , 1,2 , 1,0 }; 411 static char bm[] = { 0,0 , 3,1 , 1,2 , 1,0 };
395 412
396 gcv.fill_style = FillStippled; 413 gcv.fill_style = FillStippled;
397 gcv.stipple = XCreateBitmapFromData (disp, d, bm + a * 2, 2, 2); 414 gcv.stipple = XCreateBitmapFromData (disp, d, bm + a * 2, 2, 2);
398 gcv.ts_x_origin = x; 415 gcv.ts_x_origin = x;
399 gcv.ts_y_origin = y; 416 gcv.ts_y_origin = y;
400 417
419 (a - 1) * 90*64, (b - 1) * 90*64); 436 (a - 1) * 90*64, (b - 1) * 90*64);
420 break; 437 break;
421 } 438 }
422 } 439 }
423 } 440 }
441#else
442 if (0)
443 ;
444#endif
424#if ENABLE_COMBINING 445#if ENABLE_COMBINING
425 else if (IS_COMPOSE (t) && (cc = rxvt_composite[t])) 446 else if (IS_COMPOSE (t) && (cc = rxvt_composite[t]))
426 { 447 {
427 min_it (width, 2); // we only support wcwidth up to 2 448 min_it (width, 2); // we only support wcwidth up to 2
428 449
441 *chrs = cc->c2; 462 *chrs = cc->c2;
442 rxvt_font *f2 = (f1->has_char (cc->c2, 0, careful) && !careful) 463 rxvt_font *f2 = (f1->has_char (cc->c2, 0, careful) && !careful)
443 ? f1 464 ? f1
444 : (*fs)[fs->find_font (cc->c2)]; 465 : (*fs)[fs->find_font (cc->c2)];
445 466
446 f2->draw (d, x, y, chrs, width, fg, -1); 467 f2->draw (d, x, y, chrs, width, fg, Color_none);
447 } 468 }
448 } 469 }
449#endif 470#endif
450 else 471 else
451 switch (t) 472 switch (t)
471 492
472 void clear (); 493 void clear ();
473 494
474 rxvt_fontprop properties (); 495 rxvt_fontprop properties ();
475 496
476 bool load (const rxvt_fontprop &prop); 497 bool load (const rxvt_fontprop &prop, bool force_prop);
477 498
478 bool has_char (unicode_t unicode, const rxvt_fontprop *prop, bool &careful) const; 499 bool has_char (unicode_t unicode, const rxvt_fontprop *prop, bool &careful) const;
479 500
480 void draw (rxvt_drawable &d, int x, int y, 501 void draw (rxvt_drawable &d, int x, int y,
481 const text_t *text, int len, 502 const text_t *text, int len,
482 int fg, int bg); 503 int fg, int bg);
483 504
484 bool slow; // wether this is a proportional font or has other funny characteristics 505 bool slow; // wether this is a proportional font or has other funny characteristics
485 XFontStruct *f; 506 XFontStruct *f;
486 codeset cs;
487 bool enc2b, encm; 507 bool enc2b, encm;
488 508
489 char *get_property (XFontStruct *f, Atom property, const char *repl) const; 509 char *get_property (XFontStruct *f, Atom property, const char *repl) const;
490 bool set_properties (rxvt_fontprop &p, int height, const char *weight, const char *slant, int avgwidth); 510 bool set_properties (rxvt_fontprop &p, int height, const char *weight, const char *slant, int avgwidth);
491 bool set_properties (rxvt_fontprop &p, XFontStruct *f); 511 bool set_properties (rxvt_fontprop &p, XFontStruct *f);
498 unsigned long value; 518 unsigned long value;
499 519
500 if (XGetFontProperty (f, property, &value)) 520 if (XGetFontProperty (f, property, &value))
501 return XGetAtomName (term->dpy, value); 521 return XGetAtomName (term->dpy, value);
502 else 522 else
503 return rxvt_strdup (repl); 523 return repl ? strdup (repl) : 0;
504} 524}
505 525
506rxvt_fontprop 526rxvt_fontprop
507rxvt_font_x11::properties () 527rxvt_font_x11::properties ()
508{ 528{
590 return false; 610 return false;
591} 611}
592 612
593// fix the size of scalable fonts 613// fix the size of scalable fonts
594static bool 614static bool
595replace_field (char *buf, const char *name, int index, const char old, const char *replace) 615replace_field (char **ptr, const char *name, int index, const char old, const char *replace)
596{ 616{
597 int slashes = 0; 617 int slashes = 0;
598 const char *field, *end; 618 const char *field, *end;
599 619
600 for (const char *c = name; *c; c++) 620 for (const char *c = name; *c; c++)
610 break; 630 break;
611 } 631 }
612 632
613 if (slashes >= 13 && (!old || *field == old)) 633 if (slashes >= 13 && (!old || *field == old))
614 { 634 {
615 // TODO: check for overflow in font-name 635 size_t len = field - name;
636 *ptr = (char *)malloc (len + strlen (replace) + strlen (end) + 1);
616 strncpy (buf, name, field - name); 637 strncpy (*ptr, name, len);
617 buf += field - name;
618 strcpy (buf, replace); 638 strcpy (*ptr + len, replace);
619 strcat (buf, end); 639 strcat (*ptr, end);
620 640
621 return true; 641 return true;
622 } 642 }
623 else 643 else
624 { 644 {
625 strcpy (buf, name); 645 *ptr = strdup (name);
626 646
627 return false; 647 return false;
628 } 648 }
629} 649}
630 650
631bool 651bool
632rxvt_font_x11::load (const rxvt_fontprop &prop) 652rxvt_font_x11::load (const rxvt_fontprop &prop, bool force_prop)
633{ 653{
634 dTermDisplay; 654 dTermDisplay;
635 655
636 clear (); 656 clear ();
637 657
638 char field_str[64]; // enough for 128 bits 658 char field_str[64]; // enough for 128 bits
639 659
640 // first morph the font if required 660 // first morph the font if required
641 if (prop.weight != rxvt_fontprop::unset 661 if (force_prop)
642 || prop.slant != rxvt_fontprop::unset)
643 { 662 {
644 char fname[1024]; 663 char *fname;
645 664
646 if (name[0] != '-') 665 if (name[0] != '-')
647 { 666 {
648 f = XLoadQueryFont (disp, name); 667 f = XLoadQueryFont (disp, name);
649 668
661 f = 0; 680 f = 0;
662 } 681 }
663 682
664 if (prop.weight != rxvt_fontprop::unset) 683 if (prop.weight != rxvt_fontprop::unset)
665 { 684 {
666 replace_field (fname, name, 2, 0, 685 replace_field (&fname, name, 2, 0,
667 prop.weight < rxvt_fontprop::bold 686 prop.weight < rxvt_fontprop::bold
668 ? "medium" : "bold"); 687 ? "medium" : "bold");
669 set_name (strdup (fname)); 688 set_name (fname);
670 } 689 }
671 690
672 if (prop.slant != rxvt_fontprop::unset) 691 if (prop.slant != rxvt_fontprop::unset)
673 { 692 {
674 replace_field (fname, name, 3, 0, 693 replace_field (&fname, name, 3, 0,
675 prop.slant < rxvt_fontprop::italic 694 prop.slant < rxvt_fontprop::italic
676 ? "r" : "i"); // TODO: handle "o"blique, too 695 ? "r" : "i"); // TODO: handle "o"blique, too
677 set_name (strdup (fname)); 696 set_name (fname);
678 } 697 }
679 } 698 }
680 699
681 sprintf (field_str, "%d", prop.height == rxvt_fontprop::unset 700 sprintf (field_str, "%d", prop.height == rxvt_fontprop::unset
682 ? 0 : prop.height); 701 ? 0 : prop.height);
707 font_weight *fonts = new font_weight[count]; 726 font_weight *fonts = new font_weight[count];
708 727
709 for (int i = 0; i < count; i++) 728 for (int i = 0; i < count; i++)
710 { 729 {
711 rxvt_fontprop p; 730 rxvt_fontprop p;
712 char fname[1024]; 731 char *fname;
713 732
714 int diff = 0; 733 int diff = 0;
715 734
716 if (replace_field (fname, list[i], 6, '0', field_str)) 735 if (replace_field (&fname, list[i], 6, '0', field_str))
717 diff += 10; // slightly penalize scalable fonts 736 diff += 10; // slightly penalize scalable fonts
737 else
738 {
739 free (fname);
718 else if (replace_field (fname, list[i], 11, '0', "0")) 740 if (replace_field (&fname, list[i], 11, '0', "0"))
719 diff += 300; // more heavily penalize what looks like scaled bitmap fonts 741 diff += 300; // more heavily penalize what looks like scaled bitmap fonts
742 }
720 743
721 if (!set_properties (p, fname)) 744 if (!set_properties (p, fname))
722 continue; 745 continue;
723 746
724 if (prop.height != rxvt_fontprop::unset 747 if (prop.height != rxvt_fontprop::unset
728 if (prop.height != rxvt_fontprop::unset) diff += (prop.height - p.height) * 128; 751 if (prop.height != rxvt_fontprop::unset) diff += (prop.height - p.height) * 128;
729 if (prop.weight != rxvt_fontprop::unset) diff += abs (prop.weight - p.weight); 752 if (prop.weight != rxvt_fontprop::unset) diff += abs (prop.weight - p.weight);
730 if (prop.slant != rxvt_fontprop::unset) diff += abs (prop.slant - p.slant); 753 if (prop.slant != rxvt_fontprop::unset) diff += abs (prop.slant - p.slant);
731 //if (prop.width != rxvt_fontprop::unset) diff += abs (prop.width - p.width); 754 //if (prop.width != rxvt_fontprop::unset) diff += abs (prop.width - p.width);
732 755
733 fonts[i].name = strdup (fname); 756 fonts[i].name = fname;
734 fonts[i].diff = diff; 757 fonts[i].diff = diff;
735 } 758 }
736 759
737 XFreeFontNames (list); 760 XFreeFontNames (list);
738 761
815 int N = f->max_char_or_byte2 - f->min_char_or_byte2; 838 int N = f->max_char_or_byte2 - f->min_char_or_byte2;
816 839
817 if (encm) 840 if (encm)
818 N += (f->max_byte1 - f->min_byte1) 841 N += (f->max_byte1 - f->min_byte1)
819 * (f->max_char_or_byte2 - f->min_char_or_byte2 + 1); 842 * (f->max_char_or_byte2 - f->min_char_or_byte2 + 1);
820 843
821 while (N) 844 while (N)
822 { 845 {
823 if (f->per_char[N].width > width) 846 if (f->per_char[N].width > width)
824 width = f->per_char[N].width; 847 width = f->per_char[N].width;
825 848
977 else 1000 else
978 { 1001 {
979 clear_rect (d, x, y, term->fwidth * len, term->fheight, bg); 1002 clear_rect (d, x, y, term->fwidth * len, term->fheight, bg);
980 1003
981 XChangeGC (disp, gc, GCForeground | GCFont, &v); 1004 XChangeGC (disp, gc, GCForeground | GCFont, &v);
982 1005
983 if (slow) 1006 if (slow)
984 { 1007 {
985 do 1008 do
986 { 1009 {
987 if (xc->byte1 || xc->byte2) 1010 if (xc->byte1 || xc->byte2)
1009 else 1032 else
1010 { 1033 {
1011 clear_rect (d, x, y, term->fwidth * len, term->fheight, bg); 1034 clear_rect (d, x, y, term->fwidth * len, term->fheight, bg);
1012 1035
1013 XChangeGC (disp, gc, GCForeground | GCFont, &v); 1036 XChangeGC (disp, gc, GCForeground | GCFont, &v);
1014 1037
1015 if (slow) 1038 if (slow)
1016 { 1039 {
1017 do 1040 do
1018 { 1041 {
1019 if (*xc) 1042 if (*xc)
1039 1062
1040 void clear (); 1063 void clear ();
1041 1064
1042 rxvt_fontprop properties (); 1065 rxvt_fontprop properties ();
1043 1066
1044 bool load (const rxvt_fontprop &prop); 1067 bool load (const rxvt_fontprop &prop, bool force_prop);
1045 1068
1046 void draw (rxvt_drawable &d, int x, int y, 1069 void draw (rxvt_drawable &d, int x, int y,
1047 const text_t *text, int len, 1070 const text_t *text, int len,
1048 int fg, int bg); 1071 int fg, int bg);
1049 1072
1050 bool has_char (unicode_t unicode, const rxvt_fontprop *prop, bool &carefull) const; 1073 bool has_char (unicode_t unicode, const rxvt_fontprop *prop, bool &careful) const;
1051 1074
1052protected: 1075protected:
1053 XftFont *f; 1076 XftFont *f;
1054}; 1077};
1055 1078
1082 1105
1083 return p; 1106 return p;
1084} 1107}
1085 1108
1086bool 1109bool
1087rxvt_font_xft::load (const rxvt_fontprop &prop) 1110rxvt_font_xft::load (const rxvt_fontprop &prop, bool force_prop)
1088{ 1111{
1089 dTermDisplay; 1112 dTermDisplay;
1090 1113
1091 clear (); 1114 clear ();
1092 1115
1101 && (FcPatternGet (p, FC_PIXEL_SIZE, 0, &v) != FcResultMatch 1124 && (FcPatternGet (p, FC_PIXEL_SIZE, 0, &v) != FcResultMatch
1102 && FcPatternGet (p, FC_SIZE, 0, &v) != FcResultMatch)) 1125 && FcPatternGet (p, FC_SIZE, 0, &v) != FcResultMatch))
1103 FcPatternAddInteger (p, FC_PIXEL_SIZE, prop.height); 1126 FcPatternAddInteger (p, FC_PIXEL_SIZE, prop.height);
1104 1127
1105 if (prop.weight != rxvt_fontprop::unset 1128 if (prop.weight != rxvt_fontprop::unset
1106 && FcPatternGet (p, FC_WEIGHT, 0, &v) != FcResultMatch) 1129 && (force_prop || FcPatternGet (p, FC_WEIGHT, 0, &v) != FcResultMatch))
1107 FcPatternAddInteger (p, FC_WEIGHT, prop.weight); 1130 FcPatternAddInteger (p, FC_WEIGHT, prop.weight);
1108 1131
1109 if (prop.slant != rxvt_fontprop::unset 1132 if (prop.slant != rxvt_fontprop::unset
1110 && FcPatternGet (p, FC_SLANT, 0, &v) != FcResultMatch) 1133 && (force_prop || FcPatternGet (p, FC_SLANT, 0, &v) != FcResultMatch))
1111 FcPatternAddInteger (p, FC_SLANT, prop.slant); 1134 FcPatternAddInteger (p, FC_SLANT, prop.slant);
1112 1135
1113#if 0 // clipping unfortunately destroys our precious double-width-characters 1136#if 0 // clipping unfortunately destroys our precious double-width-characters
1114 // clip width, we can't do better, or can we? 1137 // clip width, we can't do better, or can we?
1115 if (FcPatternGet (p, FC_CHAR_WIDTH, 0, &v) != FcResultMatch) 1138 if (FcPatternGet (p, FC_CHAR_WIDTH, 0, &v) != FcResultMatch)
1274 dTermGC; 1297 dTermGC;
1275 1298
1276 int w = term->fwidth * len; 1299 int w = term->fwidth * len;
1277 int h = term->fheight; 1300 int h = term->fheight;
1278 1301
1302 /* TODO: this logic needs some more thinking, since we no longer do pseudo-transparency.
1303 * Maybe make buffering into a resource flag? Compile time option doesn't seems like a
1304 * good idea from the perspective of packaging for wide variety of user configs.
1305 */
1279 bool buffered = 0 1306 bool buffered = true
1280#if defined(XPM_BACKGROUND) || defined(TRANSPARENT) 1307#ifdef FORCE_UNBUFFERED_XFT
1281 || !term->am_transparent // we aren't transparent 1308 && bg >= 0
1282 || term->am_pixmap_trans // we have a pixmap
1283#endif 1309#endif
1284 || bg >= 0; // we don't use a transparent bg 1310 ;
1285
1286 // cut trailing spaces 1311 // cut trailing spaces
1287 while (len && text [len - 1] == ' ') 1312 while (len && text [len - 1] == ' ')
1288 len--; 1313 len--;
1289 1314
1290 int x_ = buffered ? 0 : x; 1315 int x_ = buffered ? 0 : x;
1295 int cwidth = term->fwidth; 1320 int cwidth = term->fwidth;
1296 FcChar32 fc = *text++; len--; 1321 FcChar32 fc = *text++; len--;
1297 1322
1298 while (len && *text == NOCHAR) 1323 while (len && *text == NOCHAR)
1299 text++, len--, cwidth += term->fwidth; 1324 text++, len--, cwidth += term->fwidth;
1300 1325
1301 if (fc != ' ') // skip spaces 1326 if (fc != ' ') // skip spaces
1302 { 1327 {
1303 FT_UInt glyph = XftCharIndex (disp, f, fc); 1328 FT_UInt glyph = XftCharIndex (disp, f, fc);
1304 XftGlyphExtents (disp, f, &glyph, 1, &extents); 1329 XftGlyphExtents (disp, f, &glyph, 1, &extents);
1305 1330
1316 x_ += cwidth; 1341 x_ += cwidth;
1317 } 1342 }
1318 1343
1319 if (buffered) 1344 if (buffered)
1320 { 1345 {
1346 bool back_rendered = false;
1321 if (ep != enc) 1347 if (ep != enc)
1322 { 1348 {
1323 rxvt_drawable &d2 = d.screen->scratch_drawable (w, h); 1349 rxvt_drawable &d2 = d.screen->scratch_drawable (w, h);
1324 1350
1325#if defined(XPM_BACKGROUND) || defined(TRANSPARENT) 1351#ifdef HAVE_BG_PIXMAP
1326 if (bg < 0 && term->am_pixmap_trans)
1327 XCopyArea (disp, term->pixmap, d2, gc, x, y, w, h, 0, 0);
1328 else if (bg < 0 && term->bgPixmap.pixmap) 1352 if (term->bgPixmap.pixmap)
1329 { 1353 {
1354 Picture dst = 0;
1355
1356 if (bg >= 0 && term->pix_colors[bg].c.color.alpha < 0x0ff00)
1357 dst = XftDrawPicture (d2);
1358
1359 if (bg < 0 || dst != 0)
1360 {
1361 int src_x = x, src_y = y ;
1362
1363 if (term->bgPixmap.is_parentOrigin ())
1364 {
1365 src_x += term->window_vt_x;
1366 src_y += term->window_vt_y;
1367 }
1368
1369 if (term->bgPixmap.pmap_width >= src_x+w
1370 && term->bgPixmap.pmap_height >= src_y+h)
1371 {
1372 XCopyArea (disp, term->bgPixmap.pixmap, d2, gc,
1373 src_x, src_y, w, h, 0, 0);
1374 }
1375 else
1376 {
1330 XGCValues gcv; 1377 XGCValues gcv;
1331 1378
1332 gcv.fill_style = FillTiled; 1379 gcv.fill_style = FillTiled;
1333 gcv.tile = term->pixmap; 1380 gcv.tile = term->bgPixmap.pixmap;
1334 gcv.ts_x_origin = -x; 1381 gcv.ts_x_origin = -src_x;
1335 gcv.ts_y_origin = -y; 1382 gcv.ts_y_origin = -src_y;
1336 1383
1337 GC gc2 = XCreateGC (disp, d2, 1384 XChangeGC (disp, gc,
1338 GCTile | GCTileStipXOrigin | GCTileStipYOrigin | GCFillStyle, 1385 GCTile | GCTileStipXOrigin | GCTileStipYOrigin | GCFillStyle,
1339 &gcv); 1386 &gcv);
1340 1387
1341 XFillRectangle (disp, d2, gc2, 0, 0, w, h); 1388 XFillRectangle (disp, d2, gc, 0, 0, w, h);
1342 1389
1343 XFreeGC (disp, gc2); 1390 gcv.fill_style = FillSolid;
1391 XChangeGC (disp, gc, GCFillStyle, &gcv);
1392 }
1393
1394 if (bg >= 0)
1395 {
1396 Picture solid_color_pict = XftDrawSrcPicture (d2, &term->pix_colors[bg].c);
1397 XRenderComposite (disp, PictOpOver, solid_color_pict, None, dst, 0, 0, 0, 0, 0, 0, w, h);
1398 }
1399
1400 back_rendered = true;
1401 }
1344 } 1402 }
1345 else
1346#endif 1403#endif
1404
1405 if (bg >= 0 && !back_rendered)
1347 XftDrawRect (d2, &term->pix_colors[bg].c, 0, 0, w, h); 1406 XftDrawRect (d2, &term->pix_colors[bg].c, 0, 0, w, h);
1348 1407
1349 XftDrawGlyphSpec (d2, &term->pix_colors[fg].c, f, enc, ep - enc); 1408 XftDrawGlyphSpec (d2, &term->pix_colors[fg].c, f, enc, ep - enc);
1350 XCopyArea (disp, d2, d, gc, 0, 0, w, h, x, y); 1409 XCopyArea (disp, d2, d, gc, 0, 0, w, h, x, y);
1351 } 1410 }
1377void 1436void
1378rxvt_fontset::clear () 1437rxvt_fontset::clear ()
1379{ 1438{
1380 prop.width = prop.height = prop.ascent = prop.weight = prop.slant 1439 prop.width = prop.height = prop.ascent = prop.weight = prop.slant
1381 = rxvt_fontprop::unset; 1440 = rxvt_fontprop::unset;
1441 force_prop = false;
1382 1442
1383 for (rxvt_font **i = fonts.begin (); i != fonts.end (); i++) 1443 for (rxvt_font **i = fonts.begin (); i != fonts.end (); i++)
1384 FONT_UNREF (*i); 1444 FONT_UNREF (*i);
1385 1445
1386 for (pagemap **p = fmap.begin (); p != fmap.end (); p++) 1446 for (pagemap **p = fmap.begin (); p != fmap.end (); p++)
1395 1455
1396rxvt_font * 1456rxvt_font *
1397rxvt_fontset::new_font (const char *name, codeset cs) 1457rxvt_fontset::new_font (const char *name, codeset cs)
1398{ 1458{
1399 rxvt_font *f; 1459 rxvt_font *f;
1400 1460
1401 if (!name || !*name) 1461 if (!name || !*name)
1402 { 1462 {
1403 name = ""; 1463 name = "";
1404 f = new rxvt_font_default (this); 1464 f = new rxvt_font_default (this);
1405 } 1465 }
1498 if (fonts[i]->loaded) 1558 if (fonts[i]->loaded)
1499 return true; 1559 return true;
1500 1560
1501 fonts[i]->loaded = true; 1561 fonts[i]->loaded = true;
1502 1562
1503 if (!fonts[i]->load (prop)) 1563 if (!fonts[i]->load (prop, force_prop))
1504 { 1564 {
1505 fonts[i]->cs = CS_UNKNOWN; 1565 fonts[i]->cs = CS_UNKNOWN;
1506 return false; 1566 return false;
1507 } 1567 }
1508 1568
1624 if (find_font (font) < 0) 1684 if (find_font (font) < 0)
1625 { 1685 {
1626 char fontname[4096]; 1686 char fontname[4096];
1627 sprintf (fontname, "xft:%-.4090s", font); 1687 sprintf (fontname, "xft:%-.4090s", font);
1628 1688
1629 fonts.push_back (new_font (fontname, CS_UNICODE)); 1689 fonts.push_back (new_font (fontname, CS_UNICODE));
1630 } 1690 }
1631 1691
1632 free (font); 1692 free (font);
1633 } 1693 }
1634#endif 1694#endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines