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.216 by root, Sat Jun 19 10:08:10 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;
1407 while (len) 1406 while (len)
1408 { 1407 {
1409 int cwidth = term->fwidth; 1408 int cwidth = term->fwidth;
1410 FcChar32 chr = *text++; len--; 1409 FcChar32 chr = *text++; len--;
1411 1410
1412 // handle non-bmp chars when text_t is 16 bit
1413 #if ENABLE_COMBINING && !UNICODE_3
1414 if (ecb_expect_false (IS_COMPOSE (chr)))
1415 if (compose_char *cc = rxvt_composite [chr])
1416 if (cc->c2 == NOCHAR)
1417 chr = cc->c1;
1418 #endif
1419
1420 while (len && *text == NOCHAR) 1411 while (len && *text == NOCHAR)
1421 text++, len--, cwidth += term->fwidth; 1412 text++, len--, cwidth += term->fwidth;
1422 1413
1423 if (chr != ' ') // skip spaces 1414 if (chr != ' ') // skip spaces
1424 { 1415 {
1416 // handle non-bmp chars when text_t is 16 bit
1417 #if ENABLE_COMBINING && !UNICODE_3
1418 if (ecb_expect_false (IS_COMPOSE (chr)))
1419 if (compose_char *cc = rxvt_composite [chr])
1420 if (cc->c2 == NOCHAR)
1421 chr = cc->c1;
1422 #endif
1423
1425 #if 0 1424 #if 0
1426 FT_UInt glyphs [decltype (exp)::max_size]; 1425 FT_UInt glyphs [decltype (exp)::max_size];
1427 1426
1428 for (int i = 0; i < nchrs; ++i) 1427 for (int i = 0; i < nchrs; ++i)
1429 glyphs [i] = XftCharIndex (disp, f, chrs [i]); 1428 glyphs [i] = XftCharIndex (disp, f, chrs [i]);
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 case we use the average between the two.
1450 ep.x += cwidth - extents.xOff >> 1; 1448 ep->x += extents.xOff ? cwidth - extents.xOff >> 1 : 0;
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 character 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
1735} 1733}
1736 1734
1737int 1735int
1738rxvt_fontset::find_font_idx (unicode_t unicode) 1736rxvt_fontset::find_font_idx (unicode_t unicode)
1739{ 1737{
1740 // this limits fmap size. it has to accomodate COMPOSE_HI when UNICODE_3 1738 // this limits fmap size. it has to accommodate COMPOSE_HI when UNICODE_3
1741 if (unicode > 0x1fffff) 1739 if (unicode > 0x1fffff)
1742 return 0; 1740 return 0;
1743 1741
1744 unicode_t hi = unicode >> 8; 1742 unicode_t hi = unicode >> 8;
1745 1743

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines