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.161 by root, Wed Mar 31 22:22:32 2010 UTC vs.
Revision 1.163 by root, Wed Mar 31 23:01:51 2010 UTC

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
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;
1683 if (i == fonts.size () - 1) 1706 if (i == fonts.size () - 1)
1684 { 1707 {
1685 if (fallback->name) 1708 if (fallback->name)
1686 { 1709 {
1687 // search through the fallback list 1710 // search through the fallback list
1688 fonts.push_back (new_font (fallback->name, fallback->cs)); 1711 push_font (new_font (fallback->name, fallback->cs));
1689 fallback++; 1712 fallback++;
1690 } 1713 }
1691 else 1714 else
1692 { 1715 {
1693 // try to find a new font. 1716 // try to find a new font.
1726 if (find_font (font) < 0) 1749 if (find_font (font) < 0)
1727 { 1750 {
1728 char fontname[4096]; 1751 char fontname[4096];
1729 snprintf (fontname, sizeof (fontname), "xft:%s", font); 1752 snprintf (fontname, sizeof (fontname), "xft:%s", font);
1730 1753
1731 fonts.push_back (new_font (fontname, CS_UNICODE)); 1754 push_font (new_font (fontname, CS_UNICODE));
1732 } 1755 }
1733 1756
1734 free (font); 1757 free (font);
1735 } 1758 }
1736#endif 1759#endif
1758 } 1781 }
1759 1782
1760 return i; 1783 return i;
1761} 1784}
1762 1785
1763int
1764rxvt_fontset::find_font (unicode_t unicode)
1765{
1766 return min<int> ((fontCount << 1) | 1, find_font_idx (unicode));
1767}
1768

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines