aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenichi Handa2007-08-22 12:34:29 +0000
committerKenichi Handa2007-08-22 12:34:29 +0000
commitc78c16592410bbbcfbcd9fa8e7947cfd9b6643f6 (patch)
tree6c9d66ad8f291d6e76b7fa0f2b801afd173f6d1e
parent42216a6b65dabb543156bc5e52cbf89d8ce96cb9 (diff)
downloademacs-c78c16592410bbbcfbcd9fa8e7947cfd9b6643f6.tar.gz
emacs-c78c16592410bbbcfbcd9fa8e7947cfd9b6643f6.zip
(xftfont_draw): If s->font_info != s->face->font_info,
create a temporal XftDraw object.
-rw-r--r--src/xftfont.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/xftfont.c b/src/xftfont.c
index af03cc43ecb..4c7582ed041 100644
--- a/src/xftfont.c
+++ b/src/xftfont.c
@@ -490,28 +490,39 @@ xftfont_draw (s, from, to, x, y, with_background)
490{ 490{
491 FRAME_PTR f = s->f; 491 FRAME_PTR f = s->f;
492 struct face *face = s->face; 492 struct face *face = s->face;
493 struct xftfont_info *xftfont_info = (struct xftfont_info *) face->font_info; 493 struct xftfont_info *xftfont_info = (struct xftfont_info *) s->font_info;
494 struct xftface_info *xftface_info = (struct xftface_info *) face->extra; 494 struct xftface_info *xftface_info = NULL;
495 XftDraw *xft_draw = NULL;
495 FT_UInt *code; 496 FT_UInt *code;
496 XftColor fg, bg; 497 XftColor fg, bg;
497 XRectangle r; 498 XRectangle r;
498 int len = to - from; 499 int len = to - from;
499 int i; 500 int i;
500 501
502 if (s->font_info == face->font_info)
503 {
504 xftface_info = (struct xftface_info *) face->extra;
505 xft_draw = xftface_info->xft_draw;
506 }
501 xftfont_get_colors (f, face, s->gc, xftface_info, 507 xftfont_get_colors (f, face, s->gc, xftface_info,
502 &fg, with_background ? &bg : NULL); 508 &fg, with_background ? &bg : NULL);
503 BLOCK_INPUT; 509 BLOCK_INPUT;
510 if (! xft_draw)
511 xft_draw = XftDrawCreate (FRAME_X_DISPLAY (f),
512 FRAME_X_WINDOW (f),
513 FRAME_X_VISUAL (f),
514 FRAME_X_COLORMAP (f));
504 if (s->clip_width) 515 if (s->clip_width)
505 { 516 {
506 r.x = s->clip_x, r.width = s->clip_width; 517 r.x = s->clip_x, r.width = s->clip_width;
507 r.y = s->clip_y, r.height = s->clip_height; 518 r.y = s->clip_y, r.height = s->clip_height;
508 XftDrawSetClipRectangles (xftface_info->xft_draw, 0, 0, &r, 1); 519 XftDrawSetClipRectangles (xft_draw, 0, 0, &r, 1);
509 } 520 }
510 if (with_background) 521 if (with_background)
511 { 522 {
512 struct font *font = (struct font *) face->font_info; 523 struct font *font = (struct font *) face->font_info;
513 524
514 XftDrawRect (xftface_info->xft_draw, &bg, 525 XftDrawRect (xft_draw, &bg,
515 x, y - face->font->ascent, s->width, font->font.height); 526 x, y - face->font->ascent, s->width, font->font.height);
516 } 527 }
517 code = alloca (sizeof (FT_UInt) * len); 528 code = alloca (sizeof (FT_UInt) * len);
@@ -519,10 +530,12 @@ xftfont_draw (s, from, to, x, y, with_background)
519 code[i] = ((XCHAR2B_BYTE1 (s->char2b + from + i) << 8) 530 code[i] = ((XCHAR2B_BYTE1 (s->char2b + from + i) << 8)
520 | XCHAR2B_BYTE2 (s->char2b + from + i)); 531 | XCHAR2B_BYTE2 (s->char2b + from + i));
521 532
522 XftDrawGlyphs (xftface_info->xft_draw, &fg, xftfont_info->xftfont, 533 XftDrawGlyphs (xft_draw, &fg, xftfont_info->xftfont,
523 x, y, code, len); 534 x, y, code, len);
524 if (s->clip_width) 535 if (s->clip_width)
525 XftDrawSetClip (xftface_info->xft_draw, NULL); 536 XftDrawSetClip (xft_draw, NULL);
537 if (s->font_info != face->font_info)
538 XftDrawDestroy (xft_draw);
526 UNBLOCK_INPUT; 539 UNBLOCK_INPUT;
527 540
528 return len; 541 return len;