… | |
… | |
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->get (cc->c1); |
453 | rxvt_font *f1 = (*fs)[fs->find_font (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->get (cc->c2); |
464 | : (*fs)[fs->find_font (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 |
… | |
… | |
499 | |
499 | |
500 | void draw (rxvt_drawable &d, int x, int y, |
500 | void draw (rxvt_drawable &d, int x, int y, |
501 | const text_t *text, int len, |
501 | const text_t *text, int len, |
502 | int fg, int bg); |
502 | int fg, int bg); |
503 | |
503 | |
504 | bool slow; // wether this is a proportional font or has other funny characteristics |
504 | bool slow; // whether this is a proportional font or has other funny characteristics |
505 | XFontStruct *f; |
505 | XFontStruct *f; |
506 | bool enc2b, encm; |
506 | bool enc2b, encm; |
507 | |
507 | |
508 | char *get_property (XFontStruct *f, Atom property, const char *repl) const; |
508 | char *get_property (XFontStruct *f, Atom property, const char *repl) const; |
509 | bool set_properties (rxvt_fontprop &p, int height, const char *weight, const char *slant, int avgwidth); |
509 | bool set_properties (rxvt_fontprop &p, int height, const char *weight, const char *slant, int avgwidth); |
… | |
… | |
915 | uint32_t ch = FROM_UNICODE (cs, unicode); |
915 | uint32_t ch = FROM_UNICODE (cs, unicode); |
916 | |
916 | |
917 | if (ch == NOCHAR) |
917 | if (ch == NOCHAR) |
918 | return false; |
918 | return false; |
919 | |
919 | |
920 | /* check wether the character exists in _this_ font. horrible. */ |
920 | /* check whether the character exists in _this_ font. horrible. */ |
921 | XCharStruct *xcs; |
921 | XCharStruct *xcs; |
922 | |
922 | |
923 | if (encm) |
923 | if (encm) |
924 | { |
924 | { |
925 | unsigned char byte1 = ch >> 8; |
925 | unsigned char byte1 = ch >> 8; |
… | |
… | |
955 | return false; |
955 | return false; |
956 | |
956 | |
957 | if (!prop || prop->width == rxvt_fontprop::unset) |
957 | if (!prop || prop->width == rxvt_fontprop::unset) |
958 | return true; |
958 | return true; |
959 | |
959 | |
960 | // check wether character overlaps previous/next character |
960 | // check whether character overlaps previous/next character |
961 | int w = xcs->rbearing - xcs->lbearing; |
961 | int w = xcs->rbearing - xcs->lbearing; |
962 | int wcw = max (WCWIDTH (unicode), 1); |
962 | int wcw = max (WCWIDTH (unicode), 1); |
963 | |
963 | |
964 | careful = xcs->lbearing < 0 || xcs->rbearing > prop->width * wcw; |
964 | careful = xcs->lbearing < 0 || xcs->rbearing > prop->width * wcw; |
965 | |
965 | |
… | |
… | |
1586 | |
1586 | |
1587 | return -1; |
1587 | return -1; |
1588 | } |
1588 | } |
1589 | |
1589 | |
1590 | int |
1590 | int |
1591 | rxvt_fontset::find_font_idx (unicode_t unicode, bool &careful) |
1591 | rxvt_fontset::find_font (unicode_t unicode) |
1592 | { |
1592 | { |
1593 | if (unicode >= 1<<20) |
1593 | if (unicode >= 1<<20) |
1594 | return 0; |
1594 | return 0; |
1595 | |
1595 | |
1596 | unicode_t hi = unicode >> 8; |
1596 | unicode_t hi = unicode >> 8; |
1597 | |
1597 | |
1598 | if (hi < fmap.size () && fmap[hi]) |
1598 | if (hi < fmap.size () |
1599 | { |
1599 | && fmap[hi] |
|
|
1600 | && (*fmap[hi])[unicode & 0xff] != 0xff) |
1600 | unsigned char m = (*fmap[hi])[unicode & 0xff]; |
1601 | return (*fmap[hi])[unicode & 0xff]; |
1601 | |
|
|
1602 | if (m != 0xff) |
|
|
1603 | { |
|
|
1604 | careful = m & 128; |
|
|
1605 | return m & 127; |
|
|
1606 | } |
|
|
1607 | } |
|
|
1608 | |
1602 | |
1609 | unsigned int i; |
1603 | unsigned int i; |
1610 | |
1604 | |
1611 | for (i = 0; i < fonts.size (); i++) |
1605 | for (i = 0; i < fonts.size (); i++) |
1612 | { |
1606 | { |
… | |
… | |
1625 | } |
1619 | } |
1626 | |
1620 | |
1627 | if (f->cs == CS_UNKNOWN) |
1621 | if (f->cs == CS_UNKNOWN) |
1628 | goto next_font; |
1622 | goto next_font; |
1629 | |
1623 | |
|
|
1624 | bool careful; |
1630 | if (f->has_char (unicode, &prop, careful)) |
1625 | if (f->has_char (unicode, &prop, careful)) |
|
|
1626 | { |
|
|
1627 | if (careful) |
|
|
1628 | i |= 128; |
|
|
1629 | |
1631 | goto found; |
1630 | goto found; |
|
|
1631 | } |
1632 | |
1632 | |
1633 | next_font: |
1633 | next_font: |
1634 | if (i == fonts.size () - 1) |
1634 | if (i == fonts.size () - 1) |
1635 | { |
1635 | { |
1636 | if (fallback->name) |
1636 | if (fallback->name) |
… | |
… | |
1689 | } |
1689 | } |
1690 | } |
1690 | } |
1691 | |
1691 | |
1692 | /* we must return SOME font */ |
1692 | /* we must return SOME font */ |
1693 | i = 0; |
1693 | i = 0; |
1694 | careful = false; |
|
|
1695 | |
1694 | |
1696 | found: |
1695 | found: |
1697 | // found a font, cache it |
1696 | // found a font, cache it |
1698 | if (i < 255) |
1697 | if (i < 255) |
1699 | { |
1698 | { |
… | |
… | |
1704 | { |
1703 | { |
1705 | fmap[hi] = (pagemap *)new pagemap; |
1704 | fmap[hi] = (pagemap *)new pagemap; |
1706 | memset (fmap[hi], 0xff, sizeof (pagemap)); |
1705 | memset (fmap[hi], 0xff, sizeof (pagemap)); |
1707 | } |
1706 | } |
1708 | |
1707 | |
1709 | (*fmap[hi])[unicode & 0xff] = i | (careful ? 128 : 0); |
1708 | (*fmap[hi])[unicode & 0xff] = i; |
1710 | } |
1709 | } |
1711 | |
1710 | |
1712 | return i; |
1711 | return i; |
1713 | } |
1712 | } |
1714 | |
1713 | |
1715 | int |
|
|
1716 | rxvt_fontset::find_font (unicode_t unicode) |
|
|
1717 | { |
|
|
1718 | bool careful; |
|
|
1719 | int id = find_font_idx (unicode, careful); |
|
|
1720 | |
|
|
1721 | return min<int> (fontCount, id) | (careful ? Careful : 0); |
|
|
1722 | } |
|
|
1723 | |
|
|