ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/defaultfont.C
(Generate patch)

Comparing rxvt-unicode/src/defaultfont.C (file contents):
Revision 1.9 by pcg, Wed Dec 24 06:26:52 2003 UTC vs.
Revision 1.10 by pcg, Wed Dec 24 09:07:01 2003 UTC

227struct rxvt_font_default : rxvt_font { 227struct rxvt_font_default : rxvt_font {
228 rxvt_fontprop properties () 228 rxvt_fontprop properties ()
229 { 229 {
230 rxvt_fontprop p; 230 rxvt_fontprop p;
231 231
232 p.height = 1; 232 p.width = p.height = 1;
233 p.weight = rxvt_fontprop::medium; 233 p.weight = rxvt_fontprop::medium;
234 p.slant = rxvt_fontprop::roman; 234 p.slant = rxvt_fontprop::roman;
235 235
236 return p; 236 return p;
237 } 237 }
379 rxvt_fontprop p; 379 rxvt_fontprop p;
380 380
381 const char *weight = get_property (f, "WEIGHT_NAME", "medium"); 381 const char *weight = get_property (f, "WEIGHT_NAME", "medium");
382 const char *slant = get_property (f, "SLANT", "r"); 382 const char *slant = get_property (f, "SLANT", "r");
383 383
384 unsigned long avgwidth;
385 p.width = XGetFontProperty (f, XInternAtom (DISPLAY, "AVERAGE_WIDTH", 0), &avgwidth)
386 ? avgwidth / 10
387 : (height + 1) / 2;
384 p.height = height; 388 p.height = height;
385 p.weight = *weight == 'B' || *weight == 'b' ? rxvt_fontprop::bold : rxvt_fontprop::medium; 389 p.weight = *weight == 'B' || *weight == 'b' ? rxvt_fontprop::bold : rxvt_fontprop::medium;
386 p.slant = *slant == 'r' || *slant == 'R' ? rxvt_fontprop::roman : rxvt_fontprop::italic; 390 p.slant = *slant == 'r' || *slant == 'R' ? rxvt_fontprop::roman : rxvt_fontprop::italic;
387 391
388 return p; 392 return p;
658//#define SWATHBITS (UNIBITS / 2 + 3) // minimum size for "full" tables 662//#define SWATHBITS (UNIBITS / 2 + 3) // minimum size for "full" tables
659#define SWATHBITS 8 663#define SWATHBITS 8
660#endif 664#endif
661 665
662struct rxvt_font_xft : rxvt_font { 666struct rxvt_font_xft : rxvt_font {
663#if 0
664 enum {
665 SWATHCOUNT = 1 << (21 - UNIBITS),
666 SWATHSIZE = 1 << (SWATHBITS - 5)
667 };
668 typedef uint32_t swath[SWATHSIZE];
669
670 swath *cvr[SWATHCOUNT];
671#endif
672
673#if 0
674 void gen_coverage_swath (unsigned int page);
675
676 bool has_char (uint32_t ch)
677 {
678 unsigned int page = ch >> SWATHBITS;
679 unsigned int idx = ch & ((1 << SWATHBITS) - 1);
680
681 if (page >= SWATHCOUNT)
682 return false;
683
684 if (!cvr[page]) gen_coverage_swath (page);
685
686 return cvr[page][idx >> 5] & (1 << (idx & 31));
687 }
688#endif
689 rxvt_font_xft () { f = 0; d = 0; } 667 rxvt_font_xft () { f = 0; d = 0; }
690 668
691 void clear (); 669 void clear ();
692 670
693 rxvt_fontprop properties (); 671 rxvt_fontprop properties ();
701 bool has_codepoint (uint32_t unicode); 679 bool has_codepoint (uint32_t unicode);
702 680
703protected: 681protected:
704 XftFont *f; 682 XftFont *f;
705 XftDraw *d; 683 XftDraw *d;
706
707#if 0
708 virtual void populate_coverage_swath (uint32_t lo, uint32_t hi) = 0;
709 void set_swath (uint32_t ch)
710 {
711 cvr[ch >> SWATHBITS] |= 1 << (ch & ((1 << SWATHBITS) - 1));
712 }
713#endif
714}; 684};
715 685
716void 686void
717rxvt_font_xft::clear () 687rxvt_font_xft::clear ()
718{ 688{
725 if (d) 695 if (d)
726 { 696 {
727 XftDrawDestroy (d); 697 XftDrawDestroy (d);
728 d = 0; 698 d = 0;
729 } 699 }
730
731#if 0
732 for (int i = 0; i < SWATHCOUNT; i++)
733 delete cvr[i];
734#endif
735} 700}
736 701
737rxvt_fontprop 702rxvt_fontprop
738rxvt_font_xft::properties () 703rxvt_font_xft::properties ()
739{ 704{
740 rxvt_fontprop p; 705 rxvt_fontprop p;
741 706
742 FT_Face face = XftLockFace (f); 707 FT_Face face = XftLockFace (f);
743 708
744 p.height = height; 709 p.width = width; p.height = height;
745 p.weight = face->style_flags & FT_STYLE_FLAG_BOLD ? rxvt_fontprop::bold : rxvt_fontprop::medium; 710 p.weight = face->style_flags & FT_STYLE_FLAG_BOLD ? rxvt_fontprop::bold : rxvt_fontprop::medium;
746 p.slant = face->style_flags & FT_STYLE_FLAG_ITALIC ? rxvt_fontprop::italic : rxvt_fontprop::roman; 711 p.slant = face->style_flags & FT_STYLE_FLAG_ITALIC ? rxvt_fontprop::italic : rxvt_fontprop::roman;
747 712
748 XftUnlockFace (f); 713 XftUnlockFace (f);
749 714
771 FcPatternAddInteger (p, FC_WEIGHT, prop.weight); 736 FcPatternAddInteger (p, FC_WEIGHT, prop.weight);
772 737
773 if (FcPatternGet (p, FC_SLANT, 0, &v) != FcResultMatch) 738 if (FcPatternGet (p, FC_SLANT, 0, &v) != FcResultMatch)
774 FcPatternAddInteger (p, FC_SLANT, prop.slant); 739 FcPatternAddInteger (p, FC_SLANT, prop.slant);
775 740
741 // clip width, we can't do better, or can we?
742 if (FcPatternGet (p, FC_CHAR_WIDTH, 0, &v) != FcResultMatch)
743 FcPatternAddInteger (p, FC_CHAR_WIDTH, prop.width);
744
776 //FcPatternAddBool (p, FC_MINSPACE, 1); 745 //FcPatternAddBool (p, FC_MINSPACE, 1);
777 746
778 XftResult result; 747 XftResult result;
779 FcPattern *match = XftFontMatch (DISPLAY, DefaultScreen (DISPLAY), p, &result); 748 FcPattern *match = XftFontMatch (DISPLAY, DefaultScreen (DISPLAY), p, &result);
780 749
831 800
832 XftUnlockFace (f); 801 XftUnlockFace (f);
833 802
834 return true; 803 return true;
835} 804}
836
837#if 0
838void rxvt_font::gen_coverage_swath (unsigned int page)
839{
840 cvr[page] = new swath;
841
842 for (int i = 0; i < SWATHSIZE; i++)
843 cvr[page][i] = 0;
844
845 populate_coverage_swath (cvr[page], page << SWATHBITS, ((page + 1) << SWATHBITS) - 1);
846}
847#endif
848 805
849bool 806bool
850rxvt_font_xft::has_codepoint (uint32_t unicode) 807rxvt_font_xft::has_codepoint (uint32_t unicode)
851{ 808{
852 return XftCharExists (DISPLAY, f, unicode); 809 return XftCharExists (DISPLAY, f, unicode);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines