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.160 by sf-exg, Wed Mar 31 21:52:05 2010 UTC vs.
Revision 1.166 by sf-exg, Fri Oct 22 18:03:10 2010 UTC

448 448
449 text_t chrs[2]; 449 text_t chrs[2];
450 chrs [1] = NOCHAR; 450 chrs [1] = NOCHAR;
451 451
452 *chrs = cc->c1; 452 *chrs = cc->c1;
453 rxvt_font *f1 = (*fs)[fs->find_font (cc->c1)]; 453 rxvt_font *f1 = (*fs)[fs->find_font_idx (cc->c1)];
454 f1->draw (d, x, y, chrs, width, fg, bg); 454 f1->draw (d, x, y, chrs, width, fg, bg);
455 455
456 if (cc->c2 != NOCHAR) 456 if (cc->c2 != NOCHAR)
457 { 457 {
458 bool careful; 458 bool careful;
459 459
460 // prefer font of first character, for no good reasons 460 // prefer font of first character, for no good reasons
461 *chrs = cc->c2; 461 *chrs = cc->c2;
462 rxvt_font *f2 = (f1->has_char (cc->c2, 0, careful) && !careful) 462 rxvt_font *f2 = (f1->has_char (cc->c2, 0, careful) && !careful)
463 ? f1 463 ? f1
464 : (*fs)[fs->find_font (cc->c2)]; 464 : (*fs)[fs->find_font_idx (cc->c2)];
465 465
466 f2->draw (d, x, y, chrs, width, fg, Color_none); 466 f2->draw (d, x, y, chrs, width, fg, Color_none);
467 } 467 }
468 } 468 }
469#endif 469#endif
482 482
483 x += fwidth; 483 x += fwidth;
484 } 484 }
485} 485}
486 486
487struct rxvt_font_meta : rxvt_font { 487struct rxvt_font_overflow : rxvt_font {
488 struct rxvt_fontset *fs; 488 struct rxvt_fontset *fs;
489 489
490 rxvt_font_meta (rxvt_fontset *fs) 490 rxvt_font_overflow (rxvt_fontset *fs)
491 : rxvt_font () 491 : rxvt_font ()
492 { 492 {
493 this->fs = fs; 493 this->fs = fs;
494 } 494 }
495 495
508 bool load (const rxvt_fontprop &prop, bool force_prop) 508 bool load (const rxvt_fontprop &prop, bool force_prop)
509 { 509 {
510 width = 1; height = 1; 510 width = 1; height = 1;
511 ascent = 1; descent = 0; 511 ascent = 1; descent = 0;
512 512
513 set_name (strdup ("built-in meta font")); 513 set_name (strdup ("built-in rendition overflow font"));
514 514
515 return true; 515 return true;
516 } 516 }
517 517
518 bool has_char (unicode_t unicode, const rxvt_fontprop *prop, bool &careful) const 518 bool has_char (unicode_t unicode, const rxvt_fontprop *prop, bool &careful) const
1403 && (bg == Color_transparent || bg == Color_bg 1403 && (bg == Color_transparent || bg == Color_bg
1404 || (bg >= 0 && !term->pix_colors[bg].is_opaque () && ((dst = XftDrawPicture (d2)))))) 1404 || (bg >= 0 && !term->pix_colors[bg].is_opaque () && ((dst = XftDrawPicture (d2))))))
1405 { 1405 {
1406 int src_x = x, src_y = y; 1406 int src_x = x, src_y = y;
1407 1407
1408 if (term->bgPixmap.is_parentOrigin ()) 1408 if (term->bgPixmap.flags & bgPixmap_t::isTransparent)
1409 { 1409 {
1410 src_x += term->window_vt_x; 1410 src_x += term->window_vt_x;
1411 src_y += term->window_vt_y; 1411 src_y += term->window_vt_y;
1412 } 1412 }
1413 1413
1482 prop.width = prop.height = prop.ascent = prop.weight = prop.slant 1482 prop.width = prop.height = prop.ascent = prop.weight = prop.slant
1483 = rxvt_fontprop::unset; 1483 = rxvt_fontprop::unset;
1484 force_prop = false; 1484 force_prop = false;
1485 1485
1486 for (rxvt_font **i = fonts.begin (); i != fonts.end (); i++) 1486 for (rxvt_font **i = fonts.begin (); i != fonts.end (); i++)
1487 FONT_UNREF (*i); 1487 (*i)->unref ();
1488 1488
1489 for (pagemap **p = fmap.begin (); p != fmap.end (); p++) 1489 for (pagemap **p = fmap.begin (); p != fmap.end (); p++)
1490 delete *p; 1490 delete *p;
1491 1491
1492 free (fontdesc); fontdesc = 0; 1492 free (fontdesc); fontdesc = 0;
1494 fonts.clear (); 1494 fonts.clear ();
1495 1495
1496 fallback = fallback_fonts; 1496 fallback = fallback_fonts;
1497} 1497}
1498 1498
1499void
1500rxvt_fontset::prepare_font (rxvt_font *font, codeset cs)
1501{
1502 font->set_term (term);
1503
1504 font->cs = cs;
1505 font->loaded = false;
1506}
1507
1499rxvt_font * 1508rxvt_font *
1500rxvt_fontset::new_font (const char *name, codeset cs) 1509rxvt_fontset::new_font (const char *name, codeset cs)
1501{ 1510{
1502 rxvt_font *f; 1511 rxvt_font *f;
1503 1512
1519 f = new rxvt_font_x11; 1528 f = new rxvt_font_x11;
1520 } 1529 }
1521 else 1530 else
1522 f = new rxvt_font_x11; 1531 f = new rxvt_font_x11;
1523 1532
1524 f->set_term (term);
1525 f->set_name (strdup (name)); 1533 f->set_name (strdup (name));
1526 1534 prepare_font (f, cs);
1527 f->cs = cs;
1528 f->loaded = false;
1529 1535
1530 return f; 1536 return f;
1531} 1537}
1532 1538
1533///////////////////////////////////////////////////////////////////////////// 1539/////////////////////////////////////////////////////////////////////////////
1540
1541void
1542rxvt_fontset::push_font (rxvt_font *font)
1543{
1544 // the fontCount index is reserved for the overflow font, it is only
1545 // necessary when we get fontCount or more fonts, as they cannot be
1546 // represented in the rendition.
1547 if (fonts.size () == fontCount)
1548 {
1549 rxvt_font *f = new rxvt_font_overflow (this);
1550
1551 prepare_font (f, CS_UNICODE);
1552 fonts.push_back (f);
1553 }
1554
1555 fonts.push_back (font);
1556}
1534 1557
1535void 1558void
1536rxvt_fontset::add_fonts (const char *desc) 1559rxvt_fontset::add_fonts (const char *desc)
1537{ 1560{
1538 if (desc) 1561 if (desc)
1579 if (end - desc < 511) 1602 if (end - desc < 511)
1580 { 1603 {
1581 memcpy (buf, desc, end - desc); 1604 memcpy (buf, desc, end - desc);
1582 buf[end - desc] = 0; 1605 buf[end - desc] = 0;
1583 1606
1584 fonts.push_back (new_font (buf, cs)); 1607 push_font (new_font (buf, cs));
1585 } 1608 }
1586 else 1609 else
1587 rxvt_warn ("fontset element too long (>511 bytes), ignored."); 1610 rxvt_warn ("fontset element too long (>511 bytes), ignored.");
1588 1611
1589 desc = end + 1; 1612 desc = end + 1;
1617{ 1640{
1618 clear (); 1641 clear ();
1619 1642
1620 fontdesc = strdup (desc); 1643 fontdesc = strdup (desc);
1621 1644
1622 fonts.push_back (new_font (0, CS_UNICODE)); 1645 push_font (new_font (0, CS_UNICODE));
1623 realize_font (0); 1646 realize_font (0);
1624 1647
1625 add_fonts (desc); 1648 add_fonts (desc);
1626 1649
1627 return true; 1650 return true;
1672 goto next_font; 1695 goto next_font;
1673 1696
1674 bool careful; 1697 bool careful;
1675 if (f->has_char (unicode, &prop, careful)) 1698 if (f->has_char (unicode, &prop, careful))
1676 { 1699 {
1677 if (careful) 1700 i = (i << 1) | careful;
1678 i |= 128;
1679 1701
1680 goto found; 1702 goto found;
1681 } 1703 }
1682 1704
1683 next_font: 1705 next_font:
1684 if (i == fonts.size () - 1) 1706 if (i == fonts.size () - 1)
1685 { 1707 {
1686 if (fallback->name) 1708 if (fallback->name)
1687 { 1709 {
1688 // search through the fallback list 1710 // search through the fallback list
1689 fonts.push_back (new_font (fallback->name, fallback->cs)); 1711 push_font (new_font (fallback->name, fallback->cs));
1690 fallback++; 1712 fallback++;
1691 } 1713 }
1692 else 1714 else
1693 { 1715 {
1694 // try to find a new font. 1716 // try to find a new font.
1727 if (find_font (font) < 0) 1749 if (find_font (font) < 0)
1728 { 1750 {
1729 char fontname[4096]; 1751 char fontname[4096];
1730 snprintf (fontname, sizeof (fontname), "xft:%s", font); 1752 snprintf (fontname, sizeof (fontname), "xft:%s", font);
1731 1753
1732 fonts.push_back (new_font (fontname, CS_UNICODE)); 1754 push_font (new_font (fontname, CS_UNICODE));
1733 } 1755 }
1734 1756
1735 free (font); 1757 free (font);
1736 } 1758 }
1737#endif 1759#endif
1759 } 1781 }
1760 1782
1761 return i; 1783 return i;
1762} 1784}
1763 1785
1764int
1765rxvt_fontset::find_font (unicode_t unicode)
1766{
1767 int id = find_font_idx (unicode);
1768
1769 return min<int> (fontCount, id & 127) | (id & 128 ? Careful : 0);
1770}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines