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.153 by sf-exg, Sat Jan 30 20:43:57 2010 UTC vs.
Revision 1.160 by sf-exg, Wed Mar 31 21:52:05 2010 UTC

482 482
483 x += fwidth; 483 x += fwidth;
484 } 484 }
485} 485}
486 486
487struct 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
489struct rxvt_font_x11 : rxvt_font { 539struct 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
1590int 1640int
1591rxvt_fontset::find_font (unicode_t unicode) 1641rxvt_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;
1675 FcPatternDestroy (match); 1725 FcPatternDestroy (match);
1676 1726
1677 if (find_font (font) < 0) 1727 if (find_font (font) < 0)
1678 { 1728 {
1679 char fontname[4096]; 1729 char fontname[4096];
1680 sprintf (fontname, "xft:%-.4090s", font); 1730 snprintf (fontname, sizeof (fontname), "xft:%s", font);
1681 1731
1682 fonts.push_back (new_font (fontname, CS_UNICODE)); 1732 fonts.push_back (new_font (fontname, CS_UNICODE));
1683 } 1733 }
1684 1734
1685 free (font); 1735 free (font);
1709 } 1759 }
1710 1760
1711 return i; 1761 return i;
1712} 1762}
1713 1763
1764int
1765rxvt_fontset::find_font (unicode_t unicode)
1766{
1767 int id = find_font_idx (unicode);
1714 1768
1715 1769 return min<int> (fontCount, id & 127) | (id & 128 ? Careful : 0);
1770}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines