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.210 by root, Fri Jun 18 22:11:09 2021 UTC vs.
Revision 1.211 by root, Fri Jun 18 22:12:30 2021 UTC

1382void 1382void
1383rxvt_font_xft::draw (rxvt_drawable &d, int x, int y, 1383rxvt_font_xft::draw (rxvt_drawable &d, int x, int y,
1384 const text_t *text, int len, 1384 const text_t *text, int len,
1385 int fg, int bg) 1385 int fg, int bg)
1386{ 1386{
1387 //XftGlyphSpec *enc = rxvt_temp_buf<XftGlyphSpec> (len);//D 1387 XftGlyphSpec *enc = rxvt_temp_buf<XftGlyphSpec> (len);
1388 //XftGlyphSpec *ep = enc;//D 1388 XftGlyphSpec *ep = enc;
1389 static vector<XftGlyphSpec> enc; enc.resize (0); // static to avoid malloc, still slow
1390 1389
1391 dTermDisplay; 1390 dTermDisplay;
1392 dTermGC; 1391 dTermGC;
1393 1392
1394 int w = term->fwidth * len; 1393 int w = term->fwidth * len;
1438 1437
1439 FT_UInt glyph = XftCharIndex (disp, f, chr); 1438 FT_UInt glyph = XftCharIndex (disp, f, chr);
1440 XGlyphInfo extents; 1439 XGlyphInfo extents;
1441 XftGlyphExtents (disp, f, &glyph, 1, &extents); 1440 XftGlyphExtents (disp, f, &glyph, 1, &extents);
1442 1441
1443 XftGlyphSpec ep;
1444 ep.glyph = glyph; 1442 ep->glyph = glyph;
1445 ep.x = x_; 1443 ep->x = x_;
1446 ep.y = y_ + ascent; 1444 ep->y = y_ + ascent;
1447 1445
1448 // the xft font cell might differ from the terminal font cell, 1446 // the xft font cell might differ from the terminal font cell,
1449 // in which we use the average between the two 1447 // in which we use the average between the two
1450 ep.x += cwidth - extents.xOff >> 1; 1448 ep->x += cwidth - extents.xOff >> 1;
1451 1449
1452 // xft/freetype represent combining characters as characters with zero 1450 // xft/freetype represent combining characters as characters with zero
1453 // width rendered over the previous character with some fonts, while 1451 // width rendered over the previous character with some fonts, while
1454 // in other fonts, they are considered normal characters, while yet 1452 // in other fonts, they are considered normal characters, while yet
1455 // in other fonts, they are shifted all over the place. 1453 // in other fonts, they are shifted all over the place.
1456 // we handle the first two cases by keying off on xOff being 0 1454 // we handle the first two cases by keying off on xOff being 0
1457 // for zero-width chars. normally, we would add extents.xOff 1455 // for zero-width chars. normally, we would add extents.xOff
1458 // of the base chaarcter here, but we don't have that, so we use cwidth. 1456 // of the base chaarcter here, but we don't have that, so we use cwidth.
1459 ep.x += extents.xOff ? 0 : cwidth; 1457 ep->x += extents.xOff ? 0 : cwidth;
1460 1458
1461 enc.push_back (ep); 1459 ++ep;
1462 } 1460 }
1463 1461
1464 x_ += cwidth; 1462 x_ += cwidth;
1465 } 1463 }
1466 1464
1467 if (buffered) 1465 if (buffered)
1468 { 1466 {
1469 if (!enc.empty ()) 1467 if (ep != enc)
1470 { 1468 {
1471 rxvt_drawable &d2 = d.screen->scratch_drawable (w, h); 1469 rxvt_drawable &d2 = d.screen->scratch_drawable (w, h);
1472 1470
1473#ifdef HAVE_IMG 1471#ifdef HAVE_IMG
1474 Picture dst = 0; // the only assignment is done conditionally in the following if condition 1472 Picture dst = 0; // the only assignment is done conditionally in the following if condition
1520 } 1518 }
1521 else 1519 else
1522#endif 1520#endif
1523 XftDrawRect (d2, &term->pix_colors[bg >= 0 ? bg : Color_bg].c, 0, 0, w, h); 1521 XftDrawRect (d2, &term->pix_colors[bg >= 0 ? bg : Color_bg].c, 0, 0, w, h);
1524 1522
1525 XftDrawGlyphSpec (d2, &term->pix_colors[fg].c, f, &enc[0], enc.size ()); 1523 XftDrawGlyphSpec (d2, &term->pix_colors[fg].c, f, enc, ep - enc);
1526 XCopyArea (disp, d2, d, gc, 0, 0, w, h, x, y); 1524 XCopyArea (disp, d2, d, gc, 0, 0, w, h, x, y);
1527 } 1525 }
1528 else 1526 else
1529 clear_rect (d, x, y, w, h, bg); 1527 clear_rect (d, x, y, w, h, bg);
1530 } 1528 }
1531 else 1529 else
1532 { 1530 {
1533 clear_rect (d, x, y, w, h, bg); 1531 clear_rect (d, x, y, w, h, bg);
1534 XftDrawGlyphSpec (d, &term->pix_colors[fg].c, f, &enc[0], enc.size ()); 1532 XftDrawGlyphSpec (d, &term->pix_colors[fg].c, f, enc, ep - enc);
1535 } 1533 }
1536} 1534}
1537 1535
1538#endif 1536#endif
1539 1537

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines