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.22 by pcg, Sat Feb 21 22:14:00 2004 UTC vs.
Revision 1.38 by pcg, Fri Mar 5 21:26:01 2004 UTC

24#include "defaultfont.h" 24#include "defaultfont.h"
25 25
26#include <cstdlib> 26#include <cstdlib>
27 27
28#define DISPLAY r->display->display 28#define DISPLAY r->display->display
29#define DRAWABLE r->TermWin.vt
30#define GC r->TermWin.gc 29#define GC r->TermWin.gc
31 30
32const struct rxvt_fallback_font { 31const struct rxvt_fallback_font {
33 codeset cs; 32 codeset cs;
34 const char *name; 33 const char *name;
73 { CS_BIG5_EXT, "xft:AR PL Mingti2L Big5" }, 72 { CS_BIG5_EXT, "xft:AR PL Mingti2L Big5" },
74 { CS_BIG5_EXT, "xft:AR PL KaitiM Big5" }, 73 { CS_BIG5_EXT, "xft:AR PL KaitiM Big5" },
75 { CS_GB2312_1980_0, "xft:AR PL KaitiM GB" }, 74 { CS_GB2312_1980_0, "xft:AR PL KaitiM GB" },
76 { CS_GB2312_1980_0, "xft:AR PL SungtiL GB" }, 75 { CS_GB2312_1980_0, "xft:AR PL SungtiL GB" },
77# endif 76# endif
77 { CS_BIG5, "-*-*-*-*-*-*-*-*-*-*-c-*-big5-0" },
78 { CS_BIG5_PLUS, "-*-*-*-*-*-*-*-*-*-*-c-*-big5p-0" },
79 { CS_BIG5_EXT, "-*-*-*-*-*-*-*-*-*-*-c-*-big5.eten-0" },
78 { CS_CNS11643_1992_1, "-*-*-*-*-*-*-*-*-*-*-c-*-gb2312*-0" }, 80 { CS_CNS11643_1992_1, "-*-*-*-*-*-*-*-*-*-*-c-*-gb2312*-0" },
79 { CS_CNS11643_1992_1, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-1" }, 81 { CS_CNS11643_1992_1, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-1" },
80 { CS_CNS11643_1992_2, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-2" }, 82 { CS_CNS11643_1992_2, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-2" },
81 { CS_CNS11643_1992_3, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-3" }, 83 { CS_CNS11643_1992_3, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-3" },
82 { CS_CNS11643_1992_4, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-4" }, 84 { CS_CNS11643_1992_4, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-4" },
83 { CS_CNS11643_1992_5, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-5" }, 85 { CS_CNS11643_1992_5, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-5" },
84 { CS_CNS11643_1992_6, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-6" }, 86 { CS_CNS11643_1992_6, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-6" },
85 { CS_CNS11643_1992_7, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-7" }, 87 { CS_CNS11643_1992_7, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-7" },
86 { CS_CNS11643_1992_F, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-f" }, 88 { CS_CNS11643_1992_F, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-f" },
87#endif 89#endif
88 90
89#if XFT 91#if XFT
90 { CS_UNICODE, "xft:Andale Mono" }, 92 { CS_UNICODE, "xft:Andale Mono" },
91 { CS_UNICODE, "xft:Arial Unicode MS" }, 93 { CS_UNICODE, "xft:Arial Unicode MS" },
94 { CS_UNICODE, "xft:FreeMono" }, 96 { CS_UNICODE, "xft:FreeMono" },
95 { CS_UNICODE, "-*-unifont-*-*-*-*-*-*-*-*-c-*-iso10646-1" }, 97 { CS_UNICODE, "-*-unifont-*-*-*-*-*-*-*-*-c-*-iso10646-1" },
96 { CS_UNICODE, "-*-*-*-r-*-*-*-*-*-*-c-*-iso10646-1" }, 98 { CS_UNICODE, "-*-*-*-r-*-*-*-*-*-*-c-*-iso10646-1" },
97 { CS_UNICODE, "-*-*-*-r-*-*-*-*-*-*-m-*-iso10646-1" }, 99 { CS_UNICODE, "-*-*-*-r-*-*-*-*-*-*-m-*-iso10646-1" },
98 100
101#if UNICODE_3 && XFT
102 { CS_UNICODE, "xft:Code2001" }, // contains many plane-1 characters
103#endif
104
99 { CS_UNKNOWN, 0 } 105 { CS_UNKNOWN, 0 }
100}; 106};
107
108/////////////////////////////////////////////////////////////////////////////
109
110#if XFT
111rxvt_drawable::~rxvt_drawable ()
112{
113 if (xftdrawable)
114 XftDrawDestroy (xftdrawable);
115}
116
117rxvt_drawable::operator XftDraw *()
118{
119 if (!xftdrawable)
120 xftdrawable = XftDrawCreate (display->display, drawable, display->visual, display->cmap);
121
122 return xftdrawable;
123}
124#endif
101 125
102///////////////////////////////////////////////////////////////////////////// 126/////////////////////////////////////////////////////////////////////////////
103 127
104static void *enc_buf; 128static void *enc_buf;
105static uint32_t enc_len; 129static uint32_t enc_len;
161} 185}
162 186
163///////////////////////////////////////////////////////////////////////////// 187/////////////////////////////////////////////////////////////////////////////
164 188
165void 189void
166rxvt_font::clear_rect (int x, int y, int w, int h, int color) 190rxvt_font::clear_rect (rxvt_drawable &d, int x, int y, int w, int h, int color)
167{ 191{
168 if (color == Color_bg) 192 if (color == Color_bg)
169 XClearArea (DISPLAY, DRAWABLE, x, y, w, h, FALSE); 193 XClearArea (d.display->display, d, x, y, w, h, FALSE);
170 else if (color >= 0) 194 else if (color >= 0)
171 { 195 {
196#if XFT
197 XftDrawRect (d, &r->PixColors[color].c, x, y, w, h);
198#else
172 XSetForeground (DISPLAY, GC, r->PixColors[color]); 199 XSetForeground (d.display->display, GC, r->PixColors[color]);
173 XFillRectangle (DISPLAY, DRAWABLE, GC, x, y, w, h); 200 XFillRectangle (d.display->display, d, GC, x, y, w, h);
201#endif
174 } 202 }
175} 203}
176 204
177static const char *linedraw_cmds[128] = { 205static const char *linedraw_cmds[128] = {
178 "1hH", "2hH", "1vV", "2vV", 206 "1hH", "2hH", "1vV", "2vV",
240 bool load (const rxvt_fontprop &prop) 268 bool load (const rxvt_fontprop &prop)
241 { 269 {
242 width = 1; height = 1; 270 width = 1; height = 1;
243 ascent = 1; descent = 0; 271 ascent = 1; descent = 0;
244 272
273 set_name ("built-in pseudofont");
274
245 return true; 275 return true;
246 } 276 }
247 277
248 bool has_codepoint (uint32_t unicode) 278 bool has_codepoint (uint32_t unicode)
249 { 279 {
250 if (unicode <= 0x001f) 280 if (unicode <= 0x001f)
251 return true; 281 return true;
282
252 if (unicode >= 0x0080 && unicode <= 0x009f) 283 if (unicode >= 0x0080 && unicode <= 0x009f)
253 return true; 284 return true;
254 285
255 if (unicode >= 0x2500 && unicode <= 0x257f 286 if (unicode >= 0x2500 && unicode <= 0x257f
256 && linedraw_cmds[unicode - 0x2500]) 287 && linedraw_cmds[unicode - 0x2500])
288 return true;
289
290 if (IS_COMPOSE (unicode))
257 return true; 291 return true;
258 292
259 switch (unicode) 293 switch (unicode)
260 { 294 {
261 case ZERO_WIDTH_CHAR: 295 case ZERO_WIDTH_CHAR:
263 } 297 }
264 298
265 return false; 299 return false;
266 } 300 }
267 301
268 void draw (int x, int y, 302 void draw (rxvt_drawable &d, int x, int y,
269 const text_t *text, int len, 303 const text_t *text, int len,
270 int fg, int bg); 304 int fg, int bg);
271}; 305};
272 306
273void 307void
274rxvt_font_default::draw (int x, int y, 308rxvt_font_default::draw (rxvt_drawable &d, int x, int y,
275 const text_t *text, int len, 309 const text_t *text, int len,
276 int fg, int bg) 310 int fg, int bg)
277{ 311{
278 clear_rect (x, y, r->TermWin.fwidth * len, r->TermWin.fheight, bg); 312 clear_rect (d, x, y, r->TermWin.fwidth * len, r->TermWin.fheight, bg);
279 313
280 XSetForeground (DISPLAY, GC, r->PixColors[fg]); 314 XSetForeground (d.display->display, GC, r->PixColors[fg]);
281 315
282 while (len--) 316 while (len--)
283 { 317 {
318 compose_char *cc;
284 text_t t = *text++; 319 text_t t = *text++;
285 320
321 // is it in our linedrawing table?
286 if (t >= 0x2500 & t <= 0x2580 && linedraw_cmds[t - 0x2500]) 322 if (t >= 0x2500 & t <= 0x2580 && linedraw_cmds[t - 0x2500])
287 { 323 {
288 const char *p = linedraw_cmds[t - 0x2500]; 324 const char *p = linedraw_cmds[t - 0x2500];
289 325
290 int x0 = x, x1 = x + r->TermWin.fwidth / 2, x2 = x + r->TermWin.fwidth ; 326 int x0 = x, x1 = x + (r->TermWin.fwidth - 1) / 2, x2 = x + r->TermWin.fwidth - 1;
291 int y0 = y, y1 = y + r->TermWin.fheight / 2, y2 = y + r->TermWin.fheight; 327 int y0 = y, y1 = y + (r->TermWin.fheight - 1) / 2, y2 = y + r->TermWin.fheight - 1;
292 328
293 XGCValues gcv; 329 XGCValues gcv;
294 330
295 while (*p) 331 while (*p)
296 { 332 {
297 switch (*p++) 333 switch (*p++)
298 { 334 {
299 case '1': 335 case '1':
300 gcv.line_width = 0; 336 gcv.line_width = 0;
301 XChangeGC (DISPLAY, GC, GCLineWidth, &gcv); 337 XChangeGC (d.display->display, GC, GCLineWidth, &gcv);
302 break; 338 break;
303 339
304 case '2': 340 case '2':
305 gcv.line_width = 2; 341 gcv.line_width = 2;
306 XChangeGC (DISPLAY, GC, GCLineWidth, &gcv); 342 XChangeGC (d.display->display, GC, GCLineWidth, &gcv);
307 break; 343 break;
308 344
309 case 'h': XDrawLine (DISPLAY, DRAWABLE, GC, x0, y1, x1, y1); break; 345 case 'h': XDrawLine (d.display->display, d, GC, x0, y1, x1, y1); break;
310 case 'H': XDrawLine (DISPLAY, DRAWABLE, GC, x1, y1, x2, y1); break; 346 case 'H': XDrawLine (d.display->display, d, GC, x1, y1, x2, y1); break;
311 case 'v': XDrawLine (DISPLAY, DRAWABLE, GC, x1, y0, x1, y1); break; 347 case 'v': XDrawLine (d.display->display, d, GC, x1, y0, x1, y1); break;
312 case 'V': XDrawLine (DISPLAY, DRAWABLE, GC, x1, y1, x1, y2); break; 348 case 'V': XDrawLine (d.display->display, d, GC, x1, y1, x1, y2); break;
313 case 'a': XDrawLine (DISPLAY, DRAWABLE, GC, x0, y2, x2, y0); break; 349 case 'a': XDrawLine (d.display->display, d, GC, x0, y2, x2, y0); break;
314 case 'b': XDrawLine (DISPLAY, DRAWABLE, GC, x0, y0, x2, y2); break; 350 case 'b': XDrawLine (d.display->display, d, GC, x0, y0, x2, y2); break;
315 } 351 }
316 } 352 }
317 353
318 gcv.line_width = 0; 354 gcv.line_width = 0;
319 XChangeGC (DISPLAY, GC, GCLineWidth, &gcv); 355 XChangeGC (d.display->display, GC, GCLineWidth, &gcv);
356 }
357 else if (IS_COMPOSE (t) && (cc = rxvt_composite[t]))
358 {
359 rxvt_font *f1 = (*fs)[fs->find_font (cc->c1)];
360 f1->draw (d, x, y, &(t = cc->c1), 1, fg, bg);
361 if (cc->c2 != NOCHAR)
362 {
363 // prefer font of first character, for no good reasons
364 rxvt_font *f2 = f1->has_codepoint (cc->c2)
365 ? f1
366 : (*fs)[fs->find_font (cc->c2)];
367
368 f2->draw (d, x, y, &(t = cc->c2), 1, fg, -1);
369 }
320 } 370 }
321 else 371 else
322 switch (*text++) 372 switch (t)
323 { 373 {
324 case NOCHAR:
325 case ZERO_WIDTH_CHAR: 374 case ZERO_WIDTH_CHAR:
326 break; 375 break;
327 default: 376 default:
328 XDrawRectangle (DISPLAY, DRAWABLE, GC, x + 2, y + 2, r->TermWin.fwidth - 5, r->TermWin.fheight - 5); 377 int w = 0;
378 while (len > 0 && *text == NOCHAR)
379 {
380 ++text;
381 --len;
382 w += r->TermWin.fwidth;
383 }
384
385 XDrawRectangle (d.display->display, d, GC, x + 2, y + 2,
386 w + r->TermWin.fwidth - 5, r->TermWin.fheight - 5);
387 x += w;
329 } 388 }
330 389
331 x += r->TermWin.fwidth; 390 x += r->TermWin.fwidth;
332 } 391 }
333} 392}
343 402
344 bool load (const rxvt_fontprop &prop); 403 bool load (const rxvt_fontprop &prop);
345 404
346 bool has_codepoint (uint32_t unicode); 405 bool has_codepoint (uint32_t unicode);
347 406
348 void draw (int x, int y, 407 void draw (rxvt_drawable &d, int x, int y,
349 const text_t *text, int len, 408 const text_t *text, int len,
350 int fg, int bg); 409 int fg, int bg);
351 410
352 XFontStruct *f; 411 XFontStruct *f;
353 codeset cs; 412 codeset cs;
408 467
409bool 468bool
410rxvt_font_x11::set_properties (rxvt_fontprop &p, const char *name) 469rxvt_font_x11::set_properties (rxvt_fontprop &p, const char *name)
411{ 470{
412 int slashes = 0; 471 int slashes = 0;
413 const char *comp[12]; 472 const char *comp[13];
414 473
415 for (const char *c = name; *c; c++) 474 for (const char *c = name; *c; c++)
416 if (*c == '-') 475 if (*c == '-')
417 { 476 {
418 comp[slashes++] = c + 1; 477 comp[slashes++] = c + 1;
644 703
645 return true; 704 return true;
646} 705}
647 706
648void 707void
649rxvt_font_x11::draw (int x, int y, 708rxvt_font_x11::draw (rxvt_drawable &d, int x, int y,
650 const text_t *text, int len, 709 const text_t *text, int len,
651 int fg, int bg) 710 int fg, int bg)
652{ 711{
653 // this looks like a mess /. 712 // this looks like a mess /.
654 // and it is a mess /. 713 // and it is a mess /.
670 { 729 {
671 const XChar2b *xc = enc_xchar2b (text, len, cs, slow); 730 const XChar2b *xc = enc_xchar2b (text, len, cs, slow);
672 731
673 if (bg == Color_bg && !slow) 732 if (bg == Color_bg && !slow)
674 { 733 {
675 XChangeGC (DISPLAY, GC, GCForeground | GCBackground | GCFont, &v); 734 XChangeGC (d.display->display, GC, GCForeground | GCBackground | GCFont, &v);
676 XDrawImageString16 (DISPLAY, DRAWABLE, GC, x, y + base, xc, len); 735 XDrawImageString16 (d.display->display, d, GC, x, y + base, xc, len);
677 } 736 }
678 else 737 else
679 { 738 {
680 clear_rect (x, y, r->TermWin.fwidth * len, r->TermWin.fheight, bg); 739 clear_rect (d, x, y, r->TermWin.fwidth * len, r->TermWin.fheight, bg);
681 740
682 XChangeGC (DISPLAY, GC, GCForeground | GCFont, &v); 741 XChangeGC (d.display->display, GC, GCForeground | GCFont, &v);
683 742
684 if (slow) 743 if (slow)
685 { 744 {
686 do 745 do
687 { 746 {
688 if (xc->byte1 || xc->byte2) 747 if (xc->byte1 || xc->byte2)
689 XDrawString16 (DISPLAY, DRAWABLE, GC, x, y + base, xc, 1); 748 XDrawString16 (d.display->display, d, GC, x, y + base, xc, 1);
690 749
691 x += r->TermWin.fwidth; 750 x += r->TermWin.fwidth;
692 xc++; len--; 751 xc++; len--;
693 } 752 }
694 while (len); 753 while (len);
695 } 754 }
696 else 755 else
697 XDrawString16 (DISPLAY, DRAWABLE, GC, x, y + base, xc, len); 756 XDrawString16 (d.display->display, d, GC, x, y + base, xc, len);
698 } 757 }
699 } 758 }
700 else 759 else
701 { 760 {
702 const char *xc = enc_char (text, len, cs, slow); 761 const char *xc = enc_char (text, len, cs, slow);
703 762
704 if (bg == Color_bg && !slow) 763 if (bg == Color_bg && !slow)
705 { 764 {
706 XChangeGC (DISPLAY, GC, GCForeground | GCBackground | GCFont, &v); 765 XChangeGC (d.display->display, GC, GCForeground | GCBackground | GCFont, &v);
707 XDrawImageString (DISPLAY, DRAWABLE, GC, x, y + base, xc, len); 766 XDrawImageString (d.display->display, d, GC, x, y + base, xc, len);
708 } 767 }
709 else 768 else
710 { 769 {
711 clear_rect (x, y, r->TermWin.fwidth * len, r->TermWin.fheight, bg); 770 clear_rect (d, x, y, r->TermWin.fwidth * len, r->TermWin.fheight, bg);
712 771
713 XChangeGC (DISPLAY, GC, GCForeground | GCFont, &v); 772 XChangeGC (d.display->display, GC, GCForeground | GCFont, &v);
714 773
715 if (slow) 774 if (slow)
716 { 775 {
717 do 776 do
718 { 777 {
719 if (*xc) 778 if (*xc)
720 XDrawString (DISPLAY, DRAWABLE, GC, x, y + base, xc, 1); 779 XDrawString (d.display->display, d, GC, x, y + base, xc, 1);
721 780
722 x += r->TermWin.fwidth; 781 x += r->TermWin.fwidth;
723 xc++; len--; 782 xc++; len--;
724 } 783 }
725 while (len); 784 while (len);
726 } 785 }
727 else 786 else
728 XDrawString (DISPLAY, DRAWABLE, GC, x, y + base, xc, len); 787 XDrawString (d.display->display, d, GC, x, y + base, xc, len);
729 } 788 }
730 } 789 }
731} 790}
732 791
733///////////////////////////////////////////////////////////////////////////// 792/////////////////////////////////////////////////////////////////////////////
738//#define SWATHBITS (UNIBITS / 2 + 3) // minimum size for "full" tables 797//#define SWATHBITS (UNIBITS / 2 + 3) // minimum size for "full" tables
739#define SWATHBITS 8 798#define SWATHBITS 8
740#endif 799#endif
741 800
742struct rxvt_font_xft : rxvt_font { 801struct rxvt_font_xft : rxvt_font {
743 rxvt_font_xft () { f = 0; d = 0; } 802 rxvt_font_xft () { f = 0; }
744 803
745 void clear (); 804 void clear ();
746 805
747 rxvt_fontprop properties (); 806 rxvt_fontprop properties ();
748 807
749 bool load (const rxvt_fontprop &prop); 808 bool load (const rxvt_fontprop &prop);
750 809
751 void draw (int x, int y, 810 void draw (rxvt_drawable &d, int x, int y,
752 const text_t *text, int len, 811 const text_t *text, int len,
753 int fg, int bg); 812 int fg, int bg);
754 813
755 bool has_codepoint (uint32_t unicode); 814 bool has_codepoint (uint32_t unicode);
756 815
757protected: 816protected:
758 XftFont *f; 817 XftFont *f;
759 XftDraw *d;
760}; 818};
761 819
762void 820void
763rxvt_font_xft::clear () 821rxvt_font_xft::clear ()
764{ 822{
765 if (d)
766 {
767 XftDrawDestroy (d);
768 d = 0;
769 }
770
771 if (f) 823 if (f)
772 { 824 {
773 XftFontClose (DISPLAY, f); 825 XftFontClose (DISPLAY, f);
774 f = 0; 826 f = 0;
775 } 827 }
886{ 938{
887 return XftCharExists (DISPLAY, f, unicode); 939 return XftCharExists (DISPLAY, f, unicode);
888} 940}
889 941
890void 942void
891rxvt_font_xft::draw (int x, int y, 943rxvt_font_xft::draw (rxvt_drawable &d, int x, int y,
892 const text_t *text, int len, 944 const text_t *text, int len,
893 int fg, int bg) 945 int fg, int bg)
894{ 946{
895 d = XftDrawCreate (DISPLAY, DRAWABLE, r->display->visual, r->display->cmap);
896
897 if (bg >= 0 && bg != Color_bg)
898 XftDrawRect (d, &r->PixColors[bg].c, x, y, r->TermWin.fwidth * len, r->TermWin.fheight);
899 else
900 clear_rect (x, y, r->TermWin.fwidth * len, r->TermWin.fheight, bg); 947 clear_rect (d, x, y, r->TermWin.fwidth * len, r->TermWin.fheight, bg);
901 948
902 if (!slow && width == r->TermWin.fwidth && 0) 949 if (!slow && width == r->TermWin.fwidth && 0)
903 { 950 {
904 if (sizeof (text_t) == sizeof (FcChar16)) 951 if (sizeof (text_t) == sizeof (FcChar16))
905 XftDrawString16 (d, &r->PixColors[fg].c, f, x, y + r->TermWin.fbase, (const FcChar16 *)text, len); 952 XftDrawString16 (d, &r->PixColors[fg].c, f, x, y + r->TermWin.fbase, (const FcChar16 *)text, len);
917 fwidth *= 2; 964 fwidth *= 2;
918 965
919 XGlyphInfo extents; 966 XGlyphInfo extents;
920 if (sizeof (text_t) == sizeof (FcChar16)) 967 if (sizeof (text_t) == sizeof (FcChar16))
921 { 968 {
922 XftTextExtents16 (DISPLAY, f, (const FcChar16 *)text, 1, &extents); 969 XftTextExtents16 (d.display->display, f, (const FcChar16 *)text, 1, &extents);
923 XftDrawString16 (d, &r->PixColors[fg].c, f, x + extents.x + (fwidth - extents.width) / 2, 970 XftDrawString16 (d, &r->PixColors[fg].c, f, x + extents.x + (fwidth - extents.width) / 2,
924 y + r->TermWin.fbase, (const FcChar16 *)text, 1); 971 y + r->TermWin.fbase, (const FcChar16 *)text, 1);
925 } 972 }
926 else 973 else
927 { 974 {
928 XGlyphInfo extents; 975 XGlyphInfo extents;
929 XftTextExtents32 (DISPLAY, f, (const FcChar32 *)text, 1, &extents); 976 XftTextExtents32 (d.display->display, f, (const FcChar32 *)text, 1, &extents);
930 XftDrawString32 (d, &r->PixColors[fg].c, f, x + extents.x + (fwidth - extents.width) / 2, 977 XftDrawString32 (d, &r->PixColors[fg].c, f, x + extents.x + (fwidth - extents.width) / 2,
931 y + r->TermWin.fbase, (const FcChar32 *)text, 1); 978 y + r->TermWin.fbase, (const FcChar32 *)text, 1);
932 } 979 }
933 } 980 }
934 981
991 f = new rxvt_font_x11; 1038 f = new rxvt_font_x11;
992 } 1039 }
993 else 1040 else
994 f = new rxvt_font_x11; 1041 f = new rxvt_font_x11;
995 1042
1043 f->fs = this;
996 f->set_term (r); 1044 f->set_term (r);
997 f->set_name (strdup (name)); 1045 f->set_name (strdup (name));
998 1046
999 f->cs = cs; 1047 f->cs = cs;
1000 f->loaded = false; 1048 f->loaded = false;
1067 } 1115 }
1068 1116
1069 return true; 1117 return true;
1070} 1118}
1071 1119
1072void 1120bool
1073rxvt_fontset::populate (const char *desc) 1121rxvt_fontset::populate (const char *desc)
1074{ 1122{
1075 clear (); 1123 clear ();
1076 1124
1077 fonts.push_back (new_font (0, CS_UNICODE)); 1125 fonts.push_back (new_font (0, CS_UNICODE));
1089 add_fonts ("fixed"); 1137 add_fonts ("fixed");
1090 base_id = fonts.size () - 1; 1138 base_id = fonts.size () - 1;
1091 } 1139 }
1092 1140
1093 if ((int)fonts.size () <= base_id || !realize_font (base_id)) 1141 if ((int)fonts.size () <= base_id || !realize_font (base_id))
1094 { 1142 return false;
1095 fprintf (stderr, "unable to load a base font, please provide one using -fn fontname\n");
1096 exit (1);
1097 }
1098 1143
1099 base_prop = fonts[base_id]->properties (); 1144 base_prop = fonts[base_id]->properties ();
1145
1146 return true;
1100} 1147}
1101 1148
1102int 1149int
1103rxvt_fontset::find_font (uint32_t unicode) 1150rxvt_fontset::find_font (uint32_t unicode)
1104{ 1151{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines