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.103 by root, Sun Aug 27 10:10:25 2006 UTC vs.
Revision 1.134 by root, Wed Jan 23 09:42:02 2008 UTC

19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 *---------------------------------------------------------------------*/ 20 *---------------------------------------------------------------------*/
21 21
22#include "../config.h" 22#include "../config.h"
23#include "rxvt.h" 23#include "rxvt.h"
24#include "rxvtlib.h"
25#include "rxvtutil.h" 24#include "rxvtutil.h"
26#include "rxvtfont.h" 25#include "rxvtfont.h"
27 26
28#include <cstdlib> 27#include <cstdlib>
29 28
43 const char *name; 42 const char *name;
44} fallback_fonts[] = { 43} fallback_fonts[] = {
45 { CS_ISO8859_1, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-1" }, 44 { CS_ISO8859_1, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-1" },
46 { CS_ISO8859_15, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-15" }, 45 { CS_ISO8859_15, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-15" },
47 { CS_ISO8859_15, "-*-*-*-r-*--*-*-*-*-c-*-fcd8859-15" }, 46 { CS_ISO8859_15, "-*-*-*-r-*--*-*-*-*-c-*-fcd8859-15" },
48 47
49#if ENCODING_EU 48#if ENCODING_EU
50 // cyrillic 49 // cyrillic
51 { CS_KOI8_R, "-*-*-*-r-*--*-*-*-*-c-*-koi8-r" }, 50 { CS_KOI8_R, "-*-*-*-r-*--*-*-*-*-c-*-koi8-r" },
52 { CS_KOI8_U, "-*-*-*-r-*--*-*-*-*-c-*-koi8-u" }, 51 { CS_KOI8_U, "-*-*-*-r-*--*-*-*-*-c-*-koi8-u" },
53 52
54 { CS_ISO8859_2, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-2" }, 53 { CS_ISO8859_2, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-2" },
55 { CS_ISO8859_3, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-3" }, 54 { CS_ISO8859_3, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-3" },
56 { CS_ISO8859_4, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-4" }, 55 { CS_ISO8859_4, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-4" },
57 { CS_ISO8859_5, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-5" }, 56 { CS_ISO8859_5, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-5" },
58 { CS_ISO8859_6, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-6" }, 57 { CS_ISO8859_6, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-6" },
65 { CS_ISO8859_14, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-14" }, 64 { CS_ISO8859_14, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-14" },
66 { CS_ISO8859_16, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-16" }, 65 { CS_ISO8859_16, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-16" },
67 66
68# if XFT 67# if XFT
69 { CS_KOI8_U, "xft::lang=ru" }, 68 { CS_KOI8_U, "xft::lang=ru" },
70 69
71 { CS_ISO8859_5, "xft::lang=ru" }, 70 { CS_ISO8859_5, "xft::lang=ru" },
72 { CS_ISO8859_6, "xft::lang=ar" }, 71 { CS_ISO8859_6, "xft::lang=ar" },
73 { CS_ISO8859_7, "xft::lang=el" }, 72 { CS_ISO8859_7, "xft::lang=el" },
74 { CS_ISO8859_8, "xft::lang=he" }, 73 { CS_ISO8859_8, "xft::lang=he" },
75 { CS_ISO8859_9, "xft::lang=tr" }, 74 { CS_ISO8859_9, "xft::lang=tr" },
231void 230void
232rxvt_font::clear_rect (rxvt_drawable &d, int x, int y, int w, int h, int color) const 231rxvt_font::clear_rect (rxvt_drawable &d, int x, int y, int w, int h, int color) const
233{ 232{
234 dTermDisplay; 233 dTermDisplay;
235 dTermGC; 234 dTermGC;
236 235
237 if (color < 0 || color == Color_bg) 236 if (color == Color_bg || color == Color_transparent)
238 XClearArea (disp, d, x, y, w, h, false); 237 XClearArea (disp, d, x, y, w, h, false);
239 else 238 else if (color >= 0)
240 { 239 {
241#if XFT 240#if XFT
241 bool done = false;
242
243# ifdef HAVE_BG_PIXMAP
244 if (term->bgPixmap.pixmap && color >= 0 && !term->pix_colors[color].is_opaque ())
245 {
246 Picture dst = XftDrawPicture (d);
247
248 if (dst != 0)
249 {
250 XClearArea (disp, d, x, y, w, h, false);
251 Picture solid_color_pict = XftDrawSrcPicture (d, &term->pix_colors[color].c);
252 XRenderComposite (disp, PictOpOver, solid_color_pict, None, dst, 0, 0, 0, 0, x, y, w, h);
253 done = true;
254 }
255 }
256# endif
257 if (!done)
242 XftDrawRect (d, &term->pix_colors[color].c, x, y, w, h); 258 XftDrawRect (d, &term->pix_colors[color].c, x, y, w, h);
259
243#else 260#else
244 XSetForeground (disp, gc, term->pix_colors[color]); 261 XSetForeground (disp, gc, term->pix_colors[color]);
245 XFillRectangle (disp, d, gc, x, y, w, h); 262 XFillRectangle (disp, d, gc, x, y, w, h);
246#endif 263#endif
247 } 264 }
248} 265}
249 266
250///////////////////////////////////////////////////////////////////////////// 267/////////////////////////////////////////////////////////////////////////////
251
252#include "table/linedraw.h"
253 268
254struct rxvt_font_default : rxvt_font { 269struct rxvt_font_default : rxvt_font {
255 struct rxvt_fontset *fs; 270 struct rxvt_fontset *fs;
256 271
257 rxvt_font_default (rxvt_fontset *fs) 272 rxvt_font_default (rxvt_fontset *fs)
293 return false; 308 return false;
294 309
295 if (unicode <= 0x009f) 310 if (unicode <= 0x009f)
296 return true; 311 return true;
297 312
313#ifdef BUILTIN_GLYPHS
298 if (unicode >= 0x2500 && unicode <= 0x259f && 314 if (unicode >= 0x2500 && unicode <= 0x259f &&
299 !term->option (Opt_skipBuiltinGlyphs)) 315 !term->option (Opt_skipBuiltinGlyphs))
300 return true; 316 return true;
317#endif
301 318
302 if (IS_COMPOSE (unicode)) 319 if (IS_COMPOSE (unicode))
303 return true; 320 return true;
304 321
305 switch (unicode) 322 switch (unicode)
341 ; 358 ;
342 359
343 int width = text - tp; 360 int width = text - tp;
344 int fwidth = term->fwidth * width; 361 int fwidth = term->fwidth * width;
345 362
363#ifdef BUILTIN_GLYPHS
346 if (0x2500 <= t && t <= 0x259f) 364 if (0x2500 <= t && t <= 0x259f)
347 { 365 {
366# include "table/linedraw.h"
348 uint16_t offs = linedraw_offs[t - 0x2500]; 367 uint16_t offs = linedraw_offs[t - 0x2500];
349 uint32_t *a = linedraw_command + (offs >> 4); 368 uint32_t *a = linedraw_command + (offs >> 4);
350 uint32_t *b = a + (offs & 15); 369 uint32_t *b = a + (offs & 15);
351 370
352 int W = fwidth; 371 int W = fwidth;
390 409
391 case 1: // rectangle, possibly stippled 410 case 1: // rectangle, possibly stippled
392 if (a) 411 if (a)
393 { 412 {
394 static char bm[] = { 0,0 , 3,1 , 1,2 , 1,0 }; 413 static char bm[] = { 0,0 , 3,1 , 1,2 , 1,0 };
395 414
396 gcv.fill_style = FillStippled; 415 gcv.fill_style = FillStippled;
397 gcv.stipple = XCreateBitmapFromData (disp, d, bm + a * 2, 2, 2); 416 gcv.stipple = XCreateBitmapFromData (disp, d, bm + a * 2, 2, 2);
398 gcv.ts_x_origin = x; 417 gcv.ts_x_origin = x;
399 gcv.ts_y_origin = y; 418 gcv.ts_y_origin = y;
400 419
419 (a - 1) * 90*64, (b - 1) * 90*64); 438 (a - 1) * 90*64, (b - 1) * 90*64);
420 break; 439 break;
421 } 440 }
422 } 441 }
423 } 442 }
443#else
444 if (0)
445 ;
446#endif
424#if ENABLE_COMBINING 447#if ENABLE_COMBINING
425 else if (IS_COMPOSE (t) && (cc = rxvt_composite[t])) 448 else if (IS_COMPOSE (t) && (cc = rxvt_composite[t]))
426 { 449 {
427 min_it (width, 2); // we only support wcwidth up to 2 450 min_it (width, 2); // we only support wcwidth up to 2
428 451
441 *chrs = cc->c2; 464 *chrs = cc->c2;
442 rxvt_font *f2 = (f1->has_char (cc->c2, 0, careful) && !careful) 465 rxvt_font *f2 = (f1->has_char (cc->c2, 0, careful) && !careful)
443 ? f1 466 ? f1
444 : (*fs)[fs->find_font (cc->c2)]; 467 : (*fs)[fs->find_font (cc->c2)];
445 468
446 f2->draw (d, x, y, chrs, width, fg, -1); 469 f2->draw (d, x, y, chrs, width, fg, Color_none);
447 } 470 }
448 } 471 }
449#endif 472#endif
450 else 473 else
451 switch (t) 474 switch (t)
481 const text_t *text, int len, 504 const text_t *text, int len,
482 int fg, int bg); 505 int fg, int bg);
483 506
484 bool slow; // wether this is a proportional font or has other funny characteristics 507 bool slow; // wether this is a proportional font or has other funny characteristics
485 XFontStruct *f; 508 XFontStruct *f;
486 codeset cs;
487 bool enc2b, encm; 509 bool enc2b, encm;
488 510
489 char *get_property (XFontStruct *f, Atom property, const char *repl) const; 511 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); 512 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); 513 bool set_properties (rxvt_fontprop &p, XFontStruct *f);
498 unsigned long value; 520 unsigned long value;
499 521
500 if (XGetFontProperty (f, property, &value)) 522 if (XGetFontProperty (f, property, &value))
501 return XGetAtomName (term->dpy, value); 523 return XGetAtomName (term->dpy, value);
502 else 524 else
503 return rxvt_strdup (repl); 525 return repl ? strdup (repl) : 0;
504} 526}
505 527
506rxvt_fontprop 528rxvt_fontprop
507rxvt_font_x11::properties () 529rxvt_font_x11::properties ()
508{ 530{
590 return false; 612 return false;
591} 613}
592 614
593// fix the size of scalable fonts 615// fix the size of scalable fonts
594static bool 616static bool
595replace_field (char *buf, const char *name, int index, const char old, const char *replace) 617replace_field (char **ptr, const char *name, int index, const char old, const char *replace)
596{ 618{
597 int slashes = 0; 619 int slashes = 0;
598 const char *field, *end; 620 const char *field, *end;
599 621
600 for (const char *c = name; *c; c++) 622 for (const char *c = name; *c; c++)
610 break; 632 break;
611 } 633 }
612 634
613 if (slashes >= 13 && (!old || *field == old)) 635 if (slashes >= 13 && (!old || *field == old))
614 { 636 {
615 // TODO: check for overflow in font-name 637 size_t len = field - name;
616 strncpy (buf, name, field - name); 638 *ptr = (char *)malloc (len + strlen (replace) + strlen (end) + 1);
617 buf += field - name; 639 memcpy (*ptr, name, len);
618 strcpy (buf, replace); 640 strcpy (*ptr + len, replace);
619 strcat (buf, end); 641 strcat (*ptr, end);
620 642
621 return true; 643 return true;
622 } 644 }
623 else 645 else
624 { 646 {
625 strcpy (buf, name); 647 *ptr = strdup (name);
626 648
627 return false; 649 return false;
628 } 650 }
629} 651}
630 652
638 char field_str[64]; // enough for 128 bits 660 char field_str[64]; // enough for 128 bits
639 661
640 // first morph the font if required 662 // first morph the font if required
641 if (force_prop) 663 if (force_prop)
642 { 664 {
643 char fname[1024]; 665 char *fname;
644 666
645 if (name[0] != '-') 667 if (name[0] != '-')
646 { 668 {
647 f = XLoadQueryFont (disp, name); 669 f = XLoadQueryFont (disp, name);
648 670
660 f = 0; 682 f = 0;
661 } 683 }
662 684
663 if (prop.weight != rxvt_fontprop::unset) 685 if (prop.weight != rxvt_fontprop::unset)
664 { 686 {
665 replace_field (fname, name, 2, 0, 687 replace_field (&fname, name, 2, 0,
666 prop.weight < rxvt_fontprop::bold 688 prop.weight < rxvt_fontprop::bold
667 ? "medium" : "bold"); 689 ? "medium" : "bold");
668 set_name (strdup (fname)); 690 set_name (fname);
669 } 691 }
670 692
671 if (prop.slant != rxvt_fontprop::unset) 693 if (prop.slant != rxvt_fontprop::unset)
672 { 694 {
673 replace_field (fname, name, 3, 0, 695 replace_field (&fname, name, 3, 0,
674 prop.slant < rxvt_fontprop::italic 696 prop.slant < rxvt_fontprop::italic
675 ? "r" : "i"); // TODO: handle "o"blique, too 697 ? "r" : "i"); // TODO: handle "o"blique, too
676 set_name (strdup (fname)); 698 set_name (fname);
677 } 699 }
678 } 700 }
679 701
680 sprintf (field_str, "%d", prop.height == rxvt_fontprop::unset 702 sprintf (field_str, "%d", prop.height == rxvt_fontprop::unset
681 ? 0 : prop.height); 703 ? 0 : prop.height);
706 font_weight *fonts = new font_weight[count]; 728 font_weight *fonts = new font_weight[count];
707 729
708 for (int i = 0; i < count; i++) 730 for (int i = 0; i < count; i++)
709 { 731 {
710 rxvt_fontprop p; 732 rxvt_fontprop p;
711 char fname[1024]; 733 char *fname;
712 734
713 int diff = 0; 735 int diff = 0;
714 736
715 if (replace_field (fname, list[i], 6, '0', field_str)) 737 if (replace_field (&fname, list[i], 6, '0', field_str))
716 diff += 10; // slightly penalize scalable fonts 738 diff += 10; // slightly penalize scalable fonts
739 else
740 {
741 free (fname);
717 else if (replace_field (fname, list[i], 11, '0', "0")) 742 if (replace_field (&fname, list[i], 11, '0', "0"))
718 diff += 300; // more heavily penalize what looks like scaled bitmap fonts 743 diff += 300; // more heavily penalize what looks like scaled bitmap fonts
744 }
719 745
720 if (!set_properties (p, fname)) 746 if (!set_properties (p, fname))
721 continue; 747 continue;
722 748
723 if (prop.height != rxvt_fontprop::unset 749 if (prop.height != rxvt_fontprop::unset
727 if (prop.height != rxvt_fontprop::unset) diff += (prop.height - p.height) * 128; 753 if (prop.height != rxvt_fontprop::unset) diff += (prop.height - p.height) * 128;
728 if (prop.weight != rxvt_fontprop::unset) diff += abs (prop.weight - p.weight); 754 if (prop.weight != rxvt_fontprop::unset) diff += abs (prop.weight - p.weight);
729 if (prop.slant != rxvt_fontprop::unset) diff += abs (prop.slant - p.slant); 755 if (prop.slant != rxvt_fontprop::unset) diff += abs (prop.slant - p.slant);
730 //if (prop.width != rxvt_fontprop::unset) diff += abs (prop.width - p.width); 756 //if (prop.width != rxvt_fontprop::unset) diff += abs (prop.width - p.width);
731 757
732 fonts[i].name = strdup (fname); 758 fonts[i].name = fname;
733 fonts[i].diff = diff; 759 fonts[i].diff = diff;
734 } 760 }
735 761
736 XFreeFontNames (list); 762 XFreeFontNames (list);
737 763
814 int N = f->max_char_or_byte2 - f->min_char_or_byte2; 840 int N = f->max_char_or_byte2 - f->min_char_or_byte2;
815 841
816 if (encm) 842 if (encm)
817 N += (f->max_byte1 - f->min_byte1) 843 N += (f->max_byte1 - f->min_byte1)
818 * (f->max_char_or_byte2 - f->min_char_or_byte2 + 1); 844 * (f->max_char_or_byte2 - f->min_char_or_byte2 + 1);
819 845
820 while (N) 846 while (N)
821 { 847 {
822 if (f->per_char[N].width > width) 848 if (f->per_char[N].width > width)
823 width = f->per_char[N].width; 849 width = f->per_char[N].width;
824 850
976 else 1002 else
977 { 1003 {
978 clear_rect (d, x, y, term->fwidth * len, term->fheight, bg); 1004 clear_rect (d, x, y, term->fwidth * len, term->fheight, bg);
979 1005
980 XChangeGC (disp, gc, GCForeground | GCFont, &v); 1006 XChangeGC (disp, gc, GCForeground | GCFont, &v);
981 1007
982 if (slow) 1008 if (slow)
983 { 1009 {
984 do 1010 do
985 { 1011 {
986 if (xc->byte1 || xc->byte2) 1012 if (xc->byte1 || xc->byte2)
1008 else 1034 else
1009 { 1035 {
1010 clear_rect (d, x, y, term->fwidth * len, term->fheight, bg); 1036 clear_rect (d, x, y, term->fwidth * len, term->fheight, bg);
1011 1037
1012 XChangeGC (disp, gc, GCForeground | GCFont, &v); 1038 XChangeGC (disp, gc, GCForeground | GCFont, &v);
1013 1039
1014 if (slow) 1040 if (slow)
1015 { 1041 {
1016 do 1042 do
1017 { 1043 {
1018 if (*xc) 1044 if (*xc)
1044 1070
1045 void draw (rxvt_drawable &d, int x, int y, 1071 void draw (rxvt_drawable &d, int x, int y,
1046 const text_t *text, int len, 1072 const text_t *text, int len,
1047 int fg, int bg); 1073 int fg, int bg);
1048 1074
1049 bool has_char (unicode_t unicode, const rxvt_fontprop *prop, bool &carefull) const; 1075 bool has_char (unicode_t unicode, const rxvt_fontprop *prop, bool &careful) const;
1050 1076
1051protected: 1077protected:
1052 XftFont *f; 1078 XftFont *f;
1053}; 1079};
1054 1080
1273 dTermGC; 1299 dTermGC;
1274 1300
1275 int w = term->fwidth * len; 1301 int w = term->fwidth * len;
1276 int h = term->fheight; 1302 int h = term->fheight;
1277 1303
1278 bool buffered = bg >= 0 // we don't use a transparent bg 1304 /*
1305 * Maybe make buffering into a resource flag? Compile time option doesn't seems like a
1306 * good idea from the perspective of packaging for wide variety of user configs.
1307 */
1308 bool buffered = bg >= Color_transparent;
1279#ifndef FORCE_UNBUFFERED_XFT 1309#ifdef FORCE_UNBUFFERED_XFT
1280# if defined(XPM_BACKGROUND) || defined(TRANSPARENT) 1310 buffered = false;
1281 || !term->am_transparent // we aren't transparent
1282 || term->am_pixmap_trans // we have a pixmap
1283# endif 1311#endif
1284#endif
1285 ;
1286 1312
1287 // cut trailing spaces 1313 // cut trailing spaces
1288 while (len && text [len - 1] == ' ') 1314 while (len && text [len - 1] == ' ')
1289 len--; 1315 len--;
1290 1316
1296 int cwidth = term->fwidth; 1322 int cwidth = term->fwidth;
1297 FcChar32 fc = *text++; len--; 1323 FcChar32 fc = *text++; len--;
1298 1324
1299 while (len && *text == NOCHAR) 1325 while (len && *text == NOCHAR)
1300 text++, len--, cwidth += term->fwidth; 1326 text++, len--, cwidth += term->fwidth;
1301 1327
1302 if (fc != ' ') // skip spaces 1328 if (fc != ' ') // skip spaces
1303 { 1329 {
1304 FT_UInt glyph = XftCharIndex (disp, f, fc); 1330 FT_UInt glyph = XftCharIndex (disp, f, fc);
1305 XftGlyphExtents (disp, f, &glyph, 1, &extents); 1331 XftGlyphExtents (disp, f, &glyph, 1, &extents);
1306 1332
1319 1345
1320 if (buffered) 1346 if (buffered)
1321 { 1347 {
1322 if (ep != enc) 1348 if (ep != enc)
1323 { 1349 {
1350 bool back_rendered = false;
1324 rxvt_drawable &d2 = d.screen->scratch_drawable (w, h); 1351 rxvt_drawable &d2 = d.screen->scratch_drawable (w, h);
1325 1352
1326 if (0) 1353#ifdef HAVE_BG_PIXMAP
1327 ; 1354
1328#ifdef TRANSPARENT
1329 else if (bg < 0 && term->am_pixmap_trans)
1330 XCopyArea (disp, term->pixmap, d2, gc,
1331 x + term->window_vt_x, y + term->window_vt_y,
1332 w, h, 0, 0);
1333#endif
1334#ifdef XPM_BACKGROUND
1335 else if (bg < 0 && term->bgPixmap.pixmap) 1355 if (term->bgPixmap.pixmap
1356 && !(bg >= 0 && term->pix_colors[bg].is_opaque ()))
1336 { 1357 {
1358 Picture dst = XftDrawPicture (d2);
1359
1360 int src_x = x, src_y = y;
1361
1362 if (term->bgPixmap.is_parentOrigin ())
1363 {
1364 src_x += term->window_vt_x;
1365 src_y += term->window_vt_y;
1366 }
1367
1368 if (term->bgPixmap.pmap_width >= src_x+w
1369 && term->bgPixmap.pmap_height >= src_y+h)
1370 {
1371 XCopyArea (disp, term->bgPixmap.pixmap, d2, gc,
1372 src_x, src_y, w, h, 0, 0);
1373 }
1374 else
1375 {
1337 XGCValues gcv; 1376 XGCValues gcv;
1338 1377
1339 gcv.fill_style = FillTiled; 1378 gcv.fill_style = FillTiled;
1340 gcv.tile = term->pixmap; 1379 gcv.tile = term->bgPixmap.pixmap;
1341 gcv.ts_x_origin = -x; 1380 gcv.ts_x_origin = -src_x;
1342 gcv.ts_y_origin = -y; 1381 gcv.ts_y_origin = -src_y;
1343 1382
1344 GC gc2 = XCreateGC (disp, d2, 1383 XChangeGC (disp, gc,
1345 GCTile | GCTileStipXOrigin | GCTileStipYOrigin | GCFillStyle, 1384 GCTile | GCTileStipXOrigin | GCTileStipYOrigin | GCFillStyle,
1346 &gcv); 1385 &gcv);
1347 1386
1348 XFillRectangle (disp, d2, gc2, 0, 0, w, h); 1387 XFillRectangle (disp, d2, gc, 0, 0, w, h);
1349 1388
1350 XFreeGC (disp, gc2); 1389 gcv.fill_style = FillSolid;
1390 XChangeGC (disp, gc, GCFillStyle, &gcv);
1391 }
1392
1393 if (bg >= 0 && dst) // colour must be (and is) non-opaque here
1394 {
1395 Picture solid_color_pict = XftDrawSrcPicture (d2, &term->pix_colors[bg].c);
1396 XRenderComposite (disp, PictOpOver, solid_color_pict, None, dst, 0, 0, 0, 0, 0, 0, w, h);
1397 }
1398
1399 back_rendered = true;
1351 } 1400 }
1352#endif 1401#endif
1353 else 1402
1403 if (!back_rendered)
1354 XftDrawRect (d2, &term->pix_colors[bg].c, 0, 0, w, h); 1404 XftDrawRect (d2, &term->pix_colors[bg < 0 ? Color_bg : bg].c, 0, 0, w, h);
1355 1405
1356 XftDrawGlyphSpec (d2, &term->pix_colors[fg].c, f, enc, ep - enc); 1406 XftDrawGlyphSpec (d2, &term->pix_colors[fg].c, f, enc, ep - enc);
1357 XCopyArea (disp, d2, d, gc, 0, 0, w, h, x, y); 1407 XCopyArea (disp, d2, d, gc, 0, 0, w, h, x, y);
1358 } 1408 }
1359 else 1409 else
1403 1453
1404rxvt_font * 1454rxvt_font *
1405rxvt_fontset::new_font (const char *name, codeset cs) 1455rxvt_fontset::new_font (const char *name, codeset cs)
1406{ 1456{
1407 rxvt_font *f; 1457 rxvt_font *f;
1408 1458
1409 if (!name || !*name) 1459 if (!name || !*name)
1410 { 1460 {
1411 name = ""; 1461 name = "";
1412 f = new rxvt_font_default (this); 1462 f = new rxvt_font_default (this);
1413 } 1463 }
1481 if (!end) 1531 if (!end)
1482 end = desc + strlen (desc); 1532 end = desc + strlen (desc);
1483 1533
1484 if (end - desc < 511) 1534 if (end - desc < 511)
1485 { 1535 {
1486 strncpy (buf, desc, end - desc); 1536 memcpy (buf, desc, end - desc);
1487 buf[end - desc] = 0; 1537 buf[end - desc] = 0;
1488 1538
1489 fonts.push_back (new_font (buf, cs)); 1539 fonts.push_back (new_font (buf, cs));
1490 } 1540 }
1491 else 1541 else
1632 if (find_font (font) < 0) 1682 if (find_font (font) < 0)
1633 { 1683 {
1634 char fontname[4096]; 1684 char fontname[4096];
1635 sprintf (fontname, "xft:%-.4090s", font); 1685 sprintf (fontname, "xft:%-.4090s", font);
1636 1686
1637 fonts.push_back (new_font (fontname, CS_UNICODE)); 1687 fonts.push_back (new_font (fontname, CS_UNICODE));
1638 } 1688 }
1639 1689
1640 free (font); 1690 free (font);
1641 } 1691 }
1642#endif 1692#endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines