… | |
… | |
482 | |
482 | |
483 | x += fwidth; |
483 | x += fwidth; |
484 | } |
484 | } |
485 | } |
485 | } |
486 | |
486 | |
|
|
487 | struct rxvt_font_meta : rxvt_font { |
|
|
488 | struct rxvt_fontset *fs; |
|
|
489 | |
|
|
490 | rxvt_font_meta (rxvt_fontset *fs) |
|
|
491 | : rxvt_font () |
|
|
492 | { |
|
|
493 | this->fs = fs; |
|
|
494 | } |
|
|
495 | |
|
|
496 | rxvt_fontprop properties () |
|
|
497 | { |
|
|
498 | rxvt_fontprop p; |
|
|
499 | |
|
|
500 | p.width = p.height = 1; |
|
|
501 | p.ascent = rxvt_fontprop::unset; |
|
|
502 | p.weight = rxvt_fontprop::medium; |
|
|
503 | p.slant = rxvt_fontprop::roman; |
|
|
504 | |
|
|
505 | return p; |
|
|
506 | } |
|
|
507 | |
|
|
508 | bool load (const rxvt_fontprop &prop, bool force_prop) |
|
|
509 | { |
|
|
510 | width = 1; height = 1; |
|
|
511 | ascent = 1; descent = 0; |
|
|
512 | |
|
|
513 | set_name (strdup ("built-in meta font")); |
|
|
514 | |
|
|
515 | return true; |
|
|
516 | } |
|
|
517 | |
|
|
518 | bool has_char (unicode_t unicode, const rxvt_fontprop *prop, bool &careful) const |
|
|
519 | { |
|
|
520 | return false; |
|
|
521 | } |
|
|
522 | |
|
|
523 | void draw (rxvt_drawable &d, int x, int y, |
|
|
524 | const text_t *text, int len, |
|
|
525 | int fg, int bg) |
|
|
526 | { |
|
|
527 | while (len--) |
|
|
528 | { |
|
|
529 | int fid = fs->find_font_idx (*text); |
|
|
530 | (*fs)[fid]->draw (d, x, y, text, 1, fg, bg); |
|
|
531 | ++text; |
|
|
532 | x += term->fwidth; |
|
|
533 | } |
|
|
534 | } |
|
|
535 | }; |
|
|
536 | |
487 | ///////////////////////////////////////////////////////////////////////////// |
537 | ///////////////////////////////////////////////////////////////////////////// |
488 | |
538 | |
489 | struct rxvt_font_x11 : rxvt_font { |
539 | struct rxvt_font_x11 : rxvt_font { |
490 | rxvt_font_x11 () { f = 0; } |
540 | rxvt_font_x11 () { f = 0; } |
491 | |
541 | |
… | |
… | |
499 | |
549 | |
500 | void draw (rxvt_drawable &d, int x, int y, |
550 | void draw (rxvt_drawable &d, int x, int y, |
501 | const text_t *text, int len, |
551 | const text_t *text, int len, |
502 | int fg, int bg); |
552 | int fg, int bg); |
503 | |
553 | |
504 | bool slow; // wether this is a proportional font or has other funny characteristics |
554 | bool slow; // whether this is a proportional font or has other funny characteristics |
505 | XFontStruct *f; |
555 | XFontStruct *f; |
506 | bool enc2b, encm; |
556 | bool enc2b, encm; |
507 | |
557 | |
508 | char *get_property (XFontStruct *f, Atom property, const char *repl) const; |
558 | 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); |
559 | bool set_properties (rxvt_fontprop &p, int height, const char *weight, const char *slant, int avgwidth); |
… | |
… | |
915 | uint32_t ch = FROM_UNICODE (cs, unicode); |
965 | uint32_t ch = FROM_UNICODE (cs, unicode); |
916 | |
966 | |
917 | if (ch == NOCHAR) |
967 | if (ch == NOCHAR) |
918 | return false; |
968 | return false; |
919 | |
969 | |
920 | /* check wether the character exists in _this_ font. horrible. */ |
970 | /* check whether the character exists in _this_ font. horrible. */ |
921 | XCharStruct *xcs; |
971 | XCharStruct *xcs; |
922 | |
972 | |
923 | if (encm) |
973 | if (encm) |
924 | { |
974 | { |
925 | unsigned char byte1 = ch >> 8; |
975 | unsigned char byte1 = ch >> 8; |
… | |
… | |
955 | return false; |
1005 | return false; |
956 | |
1006 | |
957 | if (!prop || prop->width == rxvt_fontprop::unset) |
1007 | if (!prop || prop->width == rxvt_fontprop::unset) |
958 | return true; |
1008 | return true; |
959 | |
1009 | |
960 | // check wether character overlaps previous/next character |
1010 | // check whether character overlaps previous/next character |
961 | int w = xcs->rbearing - xcs->lbearing; |
1011 | int w = xcs->rbearing - xcs->lbearing; |
962 | int wcw = max (WCWIDTH (unicode), 1); |
1012 | int wcw = max (WCWIDTH (unicode), 1); |
963 | |
1013 | |
964 | careful = xcs->lbearing < 0 || xcs->rbearing > prop->width * wcw; |
1014 | careful = xcs->lbearing < 0 || xcs->rbearing > prop->width * wcw; |
965 | |
1015 | |
… | |
… | |
1586 | |
1636 | |
1587 | return -1; |
1637 | return -1; |
1588 | } |
1638 | } |
1589 | |
1639 | |
1590 | int |
1640 | int |
1591 | rxvt_fontset::find_font (unicode_t unicode) |
1641 | rxvt_fontset::find_font_idx (unicode_t unicode) |
1592 | { |
1642 | { |
1593 | if (unicode >= 1<<20) |
1643 | if (unicode >= 1<<20) |
1594 | return 0; |
1644 | return 0; |
1595 | |
1645 | |
1596 | unicode_t hi = unicode >> 8; |
1646 | unicode_t hi = unicode >> 8; |
… | |
… | |
1622 | goto next_font; |
1672 | goto next_font; |
1623 | |
1673 | |
1624 | bool careful; |
1674 | bool careful; |
1625 | if (f->has_char (unicode, &prop, careful)) |
1675 | if (f->has_char (unicode, &prop, careful)) |
1626 | { |
1676 | { |
1627 | if (careful) |
1677 | i = (i << 1) | careful; |
1628 | i |= 128; |
|
|
1629 | |
1678 | |
1630 | goto found; |
1679 | goto found; |
1631 | } |
1680 | } |
1632 | |
1681 | |
1633 | next_font: |
1682 | next_font: |
… | |
… | |
1675 | FcPatternDestroy (match); |
1724 | FcPatternDestroy (match); |
1676 | |
1725 | |
1677 | if (find_font (font) < 0) |
1726 | if (find_font (font) < 0) |
1678 | { |
1727 | { |
1679 | char fontname[4096]; |
1728 | char fontname[4096]; |
1680 | sprintf (fontname, "xft:%-.4090s", font); |
1729 | snprintf (fontname, sizeof (fontname), "xft:%s", font); |
1681 | |
1730 | |
1682 | fonts.push_back (new_font (fontname, CS_UNICODE)); |
1731 | fonts.push_back (new_font (fontname, CS_UNICODE)); |
1683 | } |
1732 | } |
1684 | |
1733 | |
1685 | free (font); |
1734 | free (font); |
… | |
… | |
1709 | } |
1758 | } |
1710 | |
1759 | |
1711 | return i; |
1760 | return i; |
1712 | } |
1761 | } |
1713 | |
1762 | |
|
|
1763 | int |
|
|
1764 | rxvt_fontset::find_font (unicode_t unicode) |
|
|
1765 | { |
|
|
1766 | return min<int> ((fontCount << 1) | 1, find_font_idx (unicode)); |
|
|
1767 | } |
1714 | |
1768 | |
1715 | |
|
|