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.8 by pcg, Thu Dec 18 04:27:36 2003 UTC vs.
Revision 1.10 by pcg, Wed Dec 24 09:07:01 2003 UTC

59 59
60 // japanese 60 // japanese
61#if ENCODING_JP || ENCODING_JP_EXT 61#if ENCODING_JP || ENCODING_JP_EXT
62# if XFT 62# if XFT
63 // prefer xft for complex scripts 63 // prefer xft for complex scripts
64 { CS_UNICODE, "xft:Kochi Gothic:antialias=false" }, 64 { CS_UNICODE, "xft:Kochi Gothic:antialias=false" },
65# endif 65# endif
66 { CS_JIS0201_1976_0, "-*-mincho-*-r-*--*-*-*-*-c-*-jisx0201*-0" }, 66 { CS_JIS0201_1976_0, "-*-mincho-*-r-*--*-*-*-*-c-*-jisx0201*-0" },
67 { CS_JIS0208_1983_0, "-*-mincho-*-r-*--*-*-*-*-c-*-jisx0208*-0" }, 67 { CS_JIS0208_1983_0, "-*-mincho-*-r-*--*-*-*-*-c-*-jisx0208*-0" },
68 { CS_JIS0212_1990_0, "-*-mincho-*-r-*--*-*-*-*-c-*-jisx0212*-0" }, 68 { CS_JIS0212_1990_0, "-*-mincho-*-r-*--*-*-*-*-c-*-jisx0212*-0" },
69#endif 69#endif
70 70
71#if ENCODING_CN || ENCODING_CN_EXT 71#if ENCODING_CN || ENCODING_CN_EXT
72# if XFT 72# if XFT
73 { CS_BIG5_EXT, "xft:AR PL Mingti2L Big5" }, 73 { CS_BIG5_EXT, "xft:AR PL Mingti2L Big5" },
74 { CS_BIG5_EXT, "xft:AR PL KaitiM Big5" }, 74 { CS_BIG5_EXT, "xft:AR PL KaitiM Big5" },
75 { CS_GB2312_1980_0, "xft:AR PL KaitiM GB" }, 75 { CS_GB2312_1980_0, "xft:AR PL KaitiM GB" },
76 { CS_GB2312_1980_0, "xft:AR PL SungtiL GB" }, 76 { CS_GB2312_1980_0, "xft:AR PL SungtiL GB" },
77# endif 77# endif
78 { CS_CNS11643_1992_1, "-*-*-*-r-*-*-*-*-*-*-c-*-cns11643.1992-1" }, 78 { CS_CNS11643_1992_1, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643.1992-1" },
79 { CS_CNS11643_1992_2, "-*-*-*-r-*-*-*-*-*-*-c-*-cns11643.1992-2" }, 79 { CS_CNS11643_1992_2, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643.1992-2" },
80 { CS_CNS11643_1992_3, "-*-*-*-r-*-*-*-*-*-*-c-*-cns11643.1992-3" }, 80 { CS_CNS11643_1992_3, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643.1992-3" },
81 { CS_CNS11643_1992_4, "-*-*-*-r-*-*-*-*-*-*-c-*-cns11643.1992-4" }, 81 { CS_CNS11643_1992_4, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643.1992-4" },
82 { CS_CNS11643_1992_5, "-*-*-*-r-*-*-*-*-*-*-c-*-cns11643.1992-5" }, 82 { CS_CNS11643_1992_5, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643.1992-5" },
83 { CS_CNS11643_1992_6, "-*-*-*-r-*-*-*-*-*-*-c-*-cns11643.1992-6" }, 83 { CS_CNS11643_1992_6, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643.1992-6" },
84 { CS_CNS11643_1992_7, "-*-*-*-r-*-*-*-*-*-*-c-*-cns11643.1992-7" }, 84 { CS_CNS11643_1992_7, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643.1992-7" },
85 { CS_CNS11643_1992_F, "-*-*-*-r-*-*-*-*-*-*-c-*-cns11643.1992-f" }, 85 { CS_CNS11643_1992_F, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643.1992-f" },
86#endif 86#endif
87 87
88#if XFT 88#if XFT
89 { CS_UNICODE, "xft:Andale Mono" }, 89 { CS_UNICODE, "xft:Andale Mono" },
90 { CS_UNICODE, "xft:Arial Unicode MS" }, 90 { CS_UNICODE, "xft:Arial Unicode MS" },
91#endif 91#endif
92 { CS_UNICODE, "-*-lucidatypewriter-*-r-*-*-*-*-*-*-m-*-iso10646-1" }, 92 { CS_UNICODE, "-*-lucidatypewriter-*-*-*-*-*-*-*-*-m-*-iso10646-1" },
93 { CS_UNICODE, "xft:FreeMono" },
94 { CS_UNICODE, "-*-unifont-*-*-*-*-*-*-*-*-c-*-iso10646-1" },
95 { CS_UNICODE, "-*-*-*-r-*-*-*-*-*-*-c-*-iso10646-1" },
93 { CS_UNICODE, "-*-*-*-r-*-*-*-*-*-*-m-*-iso10646-1" }, 96 { CS_UNICODE, "-*-*-*-r-*-*-*-*-*-*-m-*-iso10646-1" },
94 { CS_UNICODE, "-*-*-*-r-*-*-*-*-*-*-m-*-iso10646-1" },
95 { CS_UNICODE, "-*-*-*-r-*-*-*-*-*-*-m-*-iso10646-1" },
96 97
97 { CS_UNKNOWN, 0 } 98 { CS_UNKNOWN, 0 }
98}; 99};
99 100
100///////////////////////////////////////////////////////////////////////////// 101/////////////////////////////////////////////////////////////////////////////
226struct rxvt_font_default : rxvt_font { 227struct rxvt_font_default : rxvt_font {
227 rxvt_fontprop properties () 228 rxvt_fontprop properties ()
228 { 229 {
229 rxvt_fontprop p; 230 rxvt_fontprop p;
230 231
231 p.height = 1; 232 p.width = p.height = 1;
232 p.weight = rxvt_fontprop::medium; 233 p.weight = rxvt_fontprop::medium;
233 p.slant = rxvt_fontprop::roman; 234 p.slant = rxvt_fontprop::roman;
234 235
235 return p; 236 return p;
236 } 237 }
378 rxvt_fontprop p; 379 rxvt_fontprop p;
379 380
380 const char *weight = get_property (f, "WEIGHT_NAME", "medium"); 381 const char *weight = get_property (f, "WEIGHT_NAME", "medium");
381 const char *slant = get_property (f, "SLANT", "r"); 382 const char *slant = get_property (f, "SLANT", "r");
382 383
384 unsigned long avgwidth;
385 p.width = XGetFontProperty (f, XInternAtom (DISPLAY, "AVERAGE_WIDTH", 0), &avgwidth)
386 ? avgwidth / 10
387 : (height + 1) / 2;
383 p.height = height; 388 p.height = height;
384 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;
385 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;
386 391
387 return p; 392 return p;
419 best = f; 424 best = f;
420 bestdiff = diff; 425 bestdiff = diff;
421 } 426 }
422 } 427 }
423 } 428 }
429
430 if (!best)
431 return false;
424 432
425 set_name (strdup (list[best - info])); 433 set_name (strdup (list[best - info]));
426 434
427 XFreeFontInfo (list, info, count); 435 XFreeFontInfo (list, info, count);
428 436
654//#define SWATHBITS (UNIBITS / 2 + 3) // minimum size for "full" tables 662//#define SWATHBITS (UNIBITS / 2 + 3) // minimum size for "full" tables
655#define SWATHBITS 8 663#define SWATHBITS 8
656#endif 664#endif
657 665
658struct rxvt_font_xft : rxvt_font { 666struct rxvt_font_xft : rxvt_font {
659#if 0
660 enum {
661 SWATHCOUNT = 1 << (21 - UNIBITS),
662 SWATHSIZE = 1 << (SWATHBITS - 5)
663 };
664 typedef uint32_t swath[SWATHSIZE];
665
666 swath *cvr[SWATHCOUNT];
667#endif
668
669#if 0
670 void gen_coverage_swath (unsigned int page);
671
672 bool has_char (uint32_t ch)
673 {
674 unsigned int page = ch >> SWATHBITS;
675 unsigned int idx = ch & ((1 << SWATHBITS) - 1);
676
677 if (page >= SWATHCOUNT)
678 return false;
679
680 if (!cvr[page]) gen_coverage_swath (page);
681
682 return cvr[page][idx >> 5] & (1 << (idx & 31));
683 }
684#endif
685 rxvt_font_xft () { f = 0; d = 0; } 667 rxvt_font_xft () { f = 0; d = 0; }
686 668
687 void clear (); 669 void clear ();
688 670
689 rxvt_fontprop properties (); 671 rxvt_fontprop properties ();
697 bool has_codepoint (uint32_t unicode); 679 bool has_codepoint (uint32_t unicode);
698 680
699protected: 681protected:
700 XftFont *f; 682 XftFont *f;
701 XftDraw *d; 683 XftDraw *d;
702
703#if 0
704 virtual void populate_coverage_swath (uint32_t lo, uint32_t hi) = 0;
705 void set_swath (uint32_t ch)
706 {
707 cvr[ch >> SWATHBITS] |= 1 << (ch & ((1 << SWATHBITS) - 1));
708 }
709#endif
710}; 684};
711 685
712void 686void
713rxvt_font_xft::clear () 687rxvt_font_xft::clear ()
714{ 688{
721 if (d) 695 if (d)
722 { 696 {
723 XftDrawDestroy (d); 697 XftDrawDestroy (d);
724 d = 0; 698 d = 0;
725 } 699 }
726
727#if 0
728 for (int i = 0; i < SWATHCOUNT; i++)
729 delete cvr[i];
730#endif
731} 700}
732 701
733rxvt_fontprop 702rxvt_fontprop
734rxvt_font_xft::properties () 703rxvt_font_xft::properties ()
735{ 704{
736 rxvt_fontprop p; 705 rxvt_fontprop p;
737 706
738 FT_Face face = XftLockFace (f); 707 FT_Face face = XftLockFace (f);
739 708
740 p.height = height; 709 p.width = width; p.height = height;
741 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;
742 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;
743 712
744 XftUnlockFace (f); 713 XftUnlockFace (f);
745 714
767 FcPatternAddInteger (p, FC_WEIGHT, prop.weight); 736 FcPatternAddInteger (p, FC_WEIGHT, prop.weight);
768 737
769 if (FcPatternGet (p, FC_SLANT, 0, &v) != FcResultMatch) 738 if (FcPatternGet (p, FC_SLANT, 0, &v) != FcResultMatch)
770 FcPatternAddInteger (p, FC_SLANT, prop.slant); 739 FcPatternAddInteger (p, FC_SLANT, prop.slant);
771 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
772 //FcPatternAddBool (p, FC_MINSPACE, 1); 745 //FcPatternAddBool (p, FC_MINSPACE, 1);
773 746
774 XftResult result; 747 XftResult result;
775 FcPattern *match = XftFontMatch (DISPLAY, DefaultScreen (DISPLAY), p, &result); 748 FcPattern *match = XftFontMatch (DISPLAY, DefaultScreen (DISPLAY), p, &result);
776 749
827 800
828 XftUnlockFace (f); 801 XftUnlockFace (f);
829 802
830 return true; 803 return true;
831} 804}
832
833#if 0
834void rxvt_font::gen_coverage_swath (unsigned int page)
835{
836 cvr[page] = new swath;
837
838 for (int i = 0; i < SWATHSIZE; i++)
839 cvr[page][i] = 0;
840
841 populate_coverage_swath (cvr[page], page << SWATHBITS, ((page + 1) << SWATHBITS) - 1);
842}
843#endif
844 805
845bool 806bool
846rxvt_font_xft::has_codepoint (uint32_t unicode) 807rxvt_font_xft::has_codepoint (uint32_t unicode)
847{ 808{
848 return XftCharExists (DISPLAY, f, unicode); 809 return XftCharExists (DISPLAY, f, unicode);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines