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.15 by pcg, Thu Jan 29 00:38:56 2004 UTC vs.
Revision 1.25 by pcg, Tue Feb 24 23:58:12 2004 UTC

1/*--------------------------------*-C-*---------------------------------*; 1/*--------------------------------*-C-*---------------------------------*;
2 * File: defaultfont.C 2 * File: defaultfont.C
3 *----------------------------------------------------------------------* 3 *----------------------------------------------------------------------*
4 * Copyright (c) 2003 Marc Lehmann rxvt@plan9.de> 4 * Copyright (c) 2003-2004 Marc Lehmann <pcg@goof.com>
5 * - original version. 5 * - original version.
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or 9 * the Free Software Foundation; either version 2 of the License, or
23#include "rxvt.h" 23#include "rxvt.h"
24#include "defaultfont.h" 24#include "defaultfont.h"
25 25
26#include <cstdlib> 26#include <cstdlib>
27 27
28#define DISPLAY r->Xdisplay 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;
99 { CS_UNKNOWN, 0 } 98 { CS_UNKNOWN, 0 }
100}; 99};
101 100
102///////////////////////////////////////////////////////////////////////////// 101/////////////////////////////////////////////////////////////////////////////
103 102
103rxvt_drawable::~rxvt_drawable ()
104{
105 if (xftdrawable)
106 XftDrawDestroy (xftdrawable);
107}
108
109rxvt_drawable::operator XftDraw *()
110{
111 if (!xftdrawable)
112 xftdrawable = XftDrawCreate (display->display, drawable, display->visual, display->cmap);
113
114 return xftdrawable;
115}
116
117/////////////////////////////////////////////////////////////////////////////
118
104static void *enc_buf; 119static void *enc_buf;
105static uint32_t enc_len; 120static uint32_t enc_len;
106 121
107static inline void * 122static inline void *
108get_enc_buf (int len) 123get_enc_buf (uint32_t len)
109{ 124{
110 if (len > enc_len) 125 if (len > enc_len)
111 { 126 {
112 free (enc_buf); 127 free (enc_buf);
113 enc_buf = malloc (len); 128 enc_buf = malloc (len);
115 130
116 return enc_buf; 131 return enc_buf;
117} 132}
118 133
119static const char * 134static const char *
120enc_char (const text_t *text, int len, codeset cs, bool &zero) 135enc_char (const text_t *text, uint32_t len, codeset cs, bool &zero)
121{ 136{
122 uint8_t *buf = (uint8_t *)get_enc_buf (len); 137 uint8_t *buf = (uint8_t *)get_enc_buf (len);
123 138
124 while (len--) 139 while (len--)
125 { 140 {
136 151
137 return (const char *)enc_buf; 152 return (const char *)enc_buf;
138} 153}
139 154
140static const XChar2b * 155static const XChar2b *
141enc_xchar2b (const text_t *text, int len, codeset cs, bool &zero) 156enc_xchar2b (const text_t *text, uint32_t len, codeset cs, bool &zero)
142{ 157{
143 XChar2b *buf = (XChar2b *)get_enc_buf (len * sizeof (XChar2b)); 158 XChar2b *buf = (XChar2b *)get_enc_buf (len * sizeof (XChar2b));
144 159
145 while (len--) 160 while (len--)
146 { 161 {
161} 176}
162 177
163///////////////////////////////////////////////////////////////////////////// 178/////////////////////////////////////////////////////////////////////////////
164 179
165void 180void
166rxvt_font::clear_rect (int x, int y, int w, int h, int color) 181rxvt_font::clear_rect (rxvt_drawable &d, int x, int y, int w, int h, int color)
167{ 182{
168 if (color == Color_bg) 183 if (color == Color_bg)
169 XClearArea (DISPLAY, DRAWABLE, x, y, w, h, FALSE); 184 XClearArea (d.display->display, d, x, y, w, h, FALSE);
170 else if (color >= 0) 185 else if (color >= 0)
171 { 186 {
187#if XFT
188 XftDrawRect (d, &r->PixColors[color].c, x, y, w, h);
189#else
172 XSetForeground (DISPLAY, GC, r->PixColors[color]); 190 XSetForeground (d.display->display, GC, r->PixColors[color]);
173 XFillRectangle (DISPLAY, DRAWABLE, GC, x, y, w, h); 191 XFillRectangle (d.display->display, d, GC, x, y, w, h);
192#endif
174 } 193 }
175} 194}
176 195
177static const char *linedraw_cmds[128] = { 196static const char *linedraw_cmds[128] = {
178 "1hH", "2hH", "1vV", "2vV", 197 "1hH", "2hH", "1vV", "2vV",
263 } 282 }
264 283
265 return false; 284 return false;
266 } 285 }
267 286
268 void draw (int x, int y, 287 void draw (rxvt_drawable &d, int x, int y,
269 const text_t *text, int len, 288 const text_t *text, int len,
270 int fg, int bg); 289 int fg, int bg);
271}; 290};
272 291
273void 292void
274rxvt_font_default::draw (int x, int y, 293rxvt_font_default::draw (rxvt_drawable &d, int x, int y,
275 const text_t *text, int len, 294 const text_t *text, int len,
276 int fg, int bg) 295 int fg, int bg)
277{ 296{
278 clear_rect (x, y, r->TermWin.fwidth * len, r->TermWin.fheight, bg); 297 clear_rect (d, x, y, r->TermWin.fwidth * len, r->TermWin.fheight, bg);
279 298
280 XSetForeground (DISPLAY, GC, r->PixColors[fg]); 299 XSetForeground (d.display->display, GC, r->PixColors[fg]);
281 300
282 while (len--) 301 while (len--)
283 { 302 {
284 text_t t = *text++; 303 text_t t = *text++;
285 304
286 if (t >= 0x2500 & t <= 0x2580 && linedraw_cmds[t - 0x2500]) 305 if (t >= 0x2500 & t <= 0x2580 && linedraw_cmds[t - 0x2500])
287 { 306 {
288 const char *p = linedraw_cmds[t - 0x2500]; 307 const char *p = linedraw_cmds[t - 0x2500];
289 308
290 int x0 = x, x1 = x + r->TermWin.fwidth / 2, x2 = x + r->TermWin.fwidth ; 309 int x0 = x, x1 = x + r->TermWin.fwidth / 2, x2 = x + r->TermWin.fwidth - 1;
291 int y0 = y, y1 = y + r->TermWin.fheight / 2, y2 = y + r->TermWin.fheight; 310 int y0 = y, y1 = y + r->TermWin.fheight / 2, y2 = y + r->TermWin.fheight - 1;
292 311
293 XGCValues gcv; 312 XGCValues gcv;
294 313
295 while (*p) 314 while (*p)
296 { 315 {
297 switch (*p++) 316 switch (*p++)
298 { 317 {
299 case '1': 318 case '1':
300 gcv.line_width = 0; 319 gcv.line_width = 0;
301 XChangeGC (DISPLAY, GC, GCLineWidth, &gcv); 320 XChangeGC (d.display->display, GC, GCLineWidth, &gcv);
302 break; 321 break;
303 322
304 case '2': 323 case '2':
305 gcv.line_width = 2; 324 gcv.line_width = 2;
306 XChangeGC (DISPLAY, GC, GCLineWidth, &gcv); 325 XChangeGC (d.display->display, GC, GCLineWidth, &gcv);
307 break; 326 break;
308 327
309 case 'h': XDrawLine (DISPLAY, DRAWABLE, GC, x0, y1, x1, y1); break; 328 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; 329 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; 330 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; 331 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; 332 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; 333 case 'b': XDrawLine (d.display->display, d, GC, x0, y0, x2, y2); break;
315 } 334 }
316 } 335 }
317 336
318 gcv.line_width = 0; 337 gcv.line_width = 0;
319 XChangeGC (DISPLAY, GC, GCLineWidth, &gcv); 338 XChangeGC (d.display->display, GC, GCLineWidth, &gcv);
320 } 339 }
321 else 340 else
322 switch (*text++) 341 switch (*text++)
323 { 342 {
324 case NOCHAR: 343 case NOCHAR:
325 case ZERO_WIDTH_CHAR: 344 case ZERO_WIDTH_CHAR:
326 break; 345 break;
327 default: 346 default:
328 XDrawRectangle (DISPLAY, DRAWABLE, GC, x + 2, y + 2, r->TermWin.fwidth - 5, r->TermWin.fheight - 5); 347 XDrawRectangle (d.display->display, d, GC, x + 2, y + 2, r->TermWin.fwidth - 5, r->TermWin.fheight - 5);
329 } 348 }
330 349
331 x += r->TermWin.fwidth; 350 x += r->TermWin.fwidth;
332 } 351 }
333} 352}
343 362
344 bool load (const rxvt_fontprop &prop); 363 bool load (const rxvt_fontprop &prop);
345 364
346 bool has_codepoint (uint32_t unicode); 365 bool has_codepoint (uint32_t unicode);
347 366
348 void draw (int x, int y, 367 void draw (rxvt_drawable &d, int x, int y,
349 const text_t *text, int len, 368 const text_t *text, int len,
350 int fg, int bg); 369 int fg, int bg);
351 370
352 XFontStruct *f; 371 XFontStruct *f;
353 codeset cs; 372 codeset cs;
428 447
429 XFontStruct *f = XLoadQueryFont (DISPLAY, name); 448 XFontStruct *f = XLoadQueryFont (DISPLAY, name);
430 449
431 if (f) 450 if (f)
432 { 451 {
433 // the font should really exists now. if not, we have a problem 452 // the font should really exist now. if not, we have a problem
434 // (e.g. if the user did xset fp rehash just when we were searching fonts). 453 // (e.g. if the user did xset fp rehash just when we were searching fonts).
435 // in that case, just return garbage. 454 // in that case, just return garbage.
436 bool ret = set_properties (p, f); 455 bool ret = set_properties (p, f);
437 XFreeFont (DISPLAY, f); 456 XFreeFont (DISPLAY, f);
438 return ret; 457 return ret;
515 f = XLoadQueryFont (DISPLAY, name); 534 f = XLoadQueryFont (DISPLAY, name);
516 535
517 if (!f) 536 if (!f)
518 return false; 537 return false;
519 538
520 unsigned long value;
521
522 const char *registry = get_property (f, "CHARSET_REGISTRY", 0); 539 const char *registry = get_property (f, "CHARSET_REGISTRY", 0);
523 const char *encoding = get_property (f, "CHARSET_ENCODING", 0); 540 const char *encoding = get_property (f, "CHARSET_ENCODING", 0);
524 541
525 if (registry && encoding) 542 if (registry && encoding)
526 { 543 {
612 /* check wether the character exists in _this_ font. horrible. */ 629 /* check wether the character exists in _this_ font. horrible. */
613 XCharStruct *xcs; 630 XCharStruct *xcs;
614 631
615 if (encm) 632 if (encm)
616 { 633 {
617 int byte1 = ch >> 8; 634 unsigned char byte1 = ch >> 8;
618 int byte2 = ch & 255; 635 unsigned char byte2 = ch & 255;
619 636
620 if (byte1 < f->min_byte1 || byte1 > f->max_byte1 637 if (byte1 < f->min_byte1 || byte1 > f->max_byte1
621 || byte2 < f->min_char_or_byte2 || byte2 > f->max_char_or_byte2) 638 || byte2 < f->min_char_or_byte2 || byte2 > f->max_char_or_byte2)
622 return false; 639 return false;
623 640
646 663
647 return true; 664 return true;
648} 665}
649 666
650void 667void
651rxvt_font_x11::draw (int x, int y, 668rxvt_font_x11::draw (rxvt_drawable &d, int x, int y,
652 const text_t *text, int len, 669 const text_t *text, int len,
653 int fg, int bg) 670 int fg, int bg)
654{ 671{
655 // this looks like a mess /. 672 // this looks like a mess /.
656 // and it is a mess /. 673 // and it is a mess /.
672 { 689 {
673 const XChar2b *xc = enc_xchar2b (text, len, cs, slow); 690 const XChar2b *xc = enc_xchar2b (text, len, cs, slow);
674 691
675 if (bg == Color_bg && !slow) 692 if (bg == Color_bg && !slow)
676 { 693 {
677 XChangeGC (DISPLAY, GC, GCForeground | GCBackground | GCFont, &v); 694 XChangeGC (d.display->display, GC, GCForeground | GCBackground | GCFont, &v);
678 XDrawImageString16 (DISPLAY, DRAWABLE, GC, x, y + base, xc, len); 695 XDrawImageString16 (d.display->display, d, GC, x, y + base, xc, len);
679 } 696 }
680 else 697 else
681 { 698 {
682 clear_rect (x, y, r->TermWin.fwidth * len, r->TermWin.fheight, bg); 699 clear_rect (d, x, y, r->TermWin.fwidth * len, r->TermWin.fheight, bg);
683 700
684 XChangeGC (DISPLAY, GC, GCForeground | GCFont, &v); 701 XChangeGC (d.display->display, GC, GCForeground | GCFont, &v);
685 702
686 if (slow) 703 if (slow)
687 { 704 {
688 do 705 do
689 { 706 {
690 if (xc->byte1 || xc->byte2) 707 if (xc->byte1 || xc->byte2)
691 XDrawString16 (DISPLAY, DRAWABLE, GC, x, y + base, xc, 1); 708 XDrawString16 (d.display->display, d, GC, x, y + base, xc, 1);
692 709
693 x += r->TermWin.fwidth; 710 x += r->TermWin.fwidth;
694 xc++; len--; 711 xc++; len--;
695 } 712 }
696 while (len); 713 while (len);
697 } 714 }
698 else 715 else
699 XDrawString16 (DISPLAY, DRAWABLE, GC, x, y + base, xc, len); 716 XDrawString16 (d.display->display, d, GC, x, y + base, xc, len);
700 } 717 }
701 } 718 }
702 else 719 else
703 { 720 {
704 const char *xc = enc_char (text, len, cs, slow); 721 const char *xc = enc_char (text, len, cs, slow);
705 722
706 if (bg == Color_bg && !slow) 723 if (bg == Color_bg && !slow)
707 { 724 {
708 XChangeGC (DISPLAY, GC, GCForeground | GCBackground | GCFont, &v); 725 XChangeGC (d.display->display, GC, GCForeground | GCBackground | GCFont, &v);
709 XDrawImageString (DISPLAY, DRAWABLE, GC, x, y + base, xc, len); 726 XDrawImageString (d.display->display, d, GC, x, y + base, xc, len);
710 } 727 }
711 else 728 else
712 { 729 {
713 clear_rect (x, y, r->TermWin.fwidth * len, r->TermWin.fheight, bg); 730 clear_rect (d, x, y, r->TermWin.fwidth * len, r->TermWin.fheight, bg);
714 731
715 XChangeGC (DISPLAY, GC, GCForeground | GCFont, &v); 732 XChangeGC (d.display->display, GC, GCForeground | GCFont, &v);
716 733
717 if (slow) 734 if (slow)
718 { 735 {
719 do 736 do
720 { 737 {
721 if (*xc) 738 if (*xc)
722 XDrawString (DISPLAY, DRAWABLE, GC, x, y + base, xc, 1); 739 XDrawString (d.display->display, d, GC, x, y + base, xc, 1);
723 740
724 x += r->TermWin.fwidth; 741 x += r->TermWin.fwidth;
725 xc++; len--; 742 xc++; len--;
726 } 743 }
727 while (len); 744 while (len);
728 } 745 }
729 else 746 else
730 XDrawString (DISPLAY, DRAWABLE, GC, x, y + base, xc, len); 747 XDrawString (d.display->display, d, GC, x, y + base, xc, len);
731 } 748 }
732 } 749 }
733} 750}
734 751
735///////////////////////////////////////////////////////////////////////////// 752/////////////////////////////////////////////////////////////////////////////
740//#define SWATHBITS (UNIBITS / 2 + 3) // minimum size for "full" tables 757//#define SWATHBITS (UNIBITS / 2 + 3) // minimum size for "full" tables
741#define SWATHBITS 8 758#define SWATHBITS 8
742#endif 759#endif
743 760
744struct rxvt_font_xft : rxvt_font { 761struct rxvt_font_xft : rxvt_font {
745 rxvt_font_xft () { f = 0; d = 0; } 762 rxvt_font_xft () { f = 0; }
746 763
747 void clear (); 764 void clear ();
748 765
749 rxvt_fontprop properties (); 766 rxvt_fontprop properties ();
750 767
751 bool load (const rxvt_fontprop &prop); 768 bool load (const rxvt_fontprop &prop);
752 769
753 void draw (int x, int y, 770 void draw (rxvt_drawable &d, int x, int y,
754 const text_t *text, int len, 771 const text_t *text, int len,
755 int fg, int bg); 772 int fg, int bg);
756 773
757 bool has_codepoint (uint32_t unicode); 774 bool has_codepoint (uint32_t unicode);
758 775
759protected: 776protected:
760 XftFont *f; 777 XftFont *f;
761 XftDraw *d;
762}; 778};
763 779
764void 780void
765rxvt_font_xft::clear () 781rxvt_font_xft::clear ()
766{ 782{
767 if (f) 783 if (f)
768 { 784 {
769 XftFontClose (DISPLAY, f); 785 XftFontClose (DISPLAY, f);
770 f = 0; 786 f = 0;
771 }
772
773 if (d)
774 {
775 XftDrawDestroy (d);
776 d = 0;
777 } 787 }
778} 788}
779 789
780rxvt_fontprop 790rxvt_fontprop
781rxvt_font_xft::properties () 791rxvt_font_xft::properties ()
888{ 898{
889 return XftCharExists (DISPLAY, f, unicode); 899 return XftCharExists (DISPLAY, f, unicode);
890} 900}
891 901
892void 902void
893rxvt_font_xft::draw (int x, int y, 903rxvt_font_xft::draw (rxvt_drawable &d, int x, int y,
894 const text_t *text, int len, 904 const text_t *text, int len,
895 int fg, int bg) 905 int fg, int bg)
896{ 906{
897 if (!d)
898 {
899 dR;
900 d = XftDrawCreate (DISPLAY, DRAWABLE, XVISUAL, XCMAP);
901 }
902
903 if (bg >= 0 && bg != Color_bg)
904 XftDrawRect (d, &r->PixColors[bg].c, x, y, r->TermWin.fwidth * len, r->TermWin.fheight);
905 else
906 clear_rect (x, y, r->TermWin.fwidth * len, r->TermWin.fheight, bg); 907 clear_rect (d, x, y, r->TermWin.fwidth * len, r->TermWin.fheight, bg);
907 908
908 if (!slow && width == r->TermWin.fwidth && 0) 909 if (!slow && width == r->TermWin.fwidth && 0)
909 { 910 {
910 if (sizeof (text_t) == sizeof (FcChar16)) 911 if (sizeof (text_t) == sizeof (FcChar16))
911 XftDrawString16 (d, &r->PixColors[fg].c, f, x, y + r->TermWin.fbase, (const FcChar16 *)text, len); 912 XftDrawString16 (d, &r->PixColors[fg].c, f, x, y + r->TermWin.fbase, (const FcChar16 *)text, len);
923 fwidth *= 2; 924 fwidth *= 2;
924 925
925 XGlyphInfo extents; 926 XGlyphInfo extents;
926 if (sizeof (text_t) == sizeof (FcChar16)) 927 if (sizeof (text_t) == sizeof (FcChar16))
927 { 928 {
928 XftTextExtents16 (DISPLAY, f, (const FcChar16 *)text, 1, &extents); 929 XftTextExtents16 (d.display->display, f, (const FcChar16 *)text, 1, &extents);
929 XftDrawString16 (d, &r->PixColors[fg].c, f, x + extents.x + (fwidth - extents.width) / 2, 930 XftDrawString16 (d, &r->PixColors[fg].c, f, x + extents.x + (fwidth - extents.width) / 2,
930 y + r->TermWin.fbase, (const FcChar16 *)text, 1); 931 y + r->TermWin.fbase, (const FcChar16 *)text, 1);
931 } 932 }
932 else 933 else
933 { 934 {
934 XGlyphInfo extents; 935 XGlyphInfo extents;
935 XftTextExtents32 (DISPLAY, f, (const FcChar32 *)text, 1, &extents); 936 XftTextExtents32 (d.display->display, f, (const FcChar32 *)text, 1, &extents);
936 XftDrawString32 (d, &r->PixColors[fg].c, f, x + extents.x + (fwidth - extents.width) / 2, 937 XftDrawString32 (d, &r->PixColors[fg].c, f, x + extents.x + (fwidth - extents.width) / 2,
937 y + r->TermWin.fbase, (const FcChar32 *)text, 1); 938 y + r->TermWin.fbase, (const FcChar32 *)text, 1);
938 } 939 }
939 } 940 }
940 941
947#endif 948#endif
948 949
949///////////////////////////////////////////////////////////////////////////// 950/////////////////////////////////////////////////////////////////////////////
950 951
951rxvt_fontset::rxvt_fontset (rxvt_t r) 952rxvt_fontset::rxvt_fontset (rxvt_t r)
952#ifdef EXPLICIT_CONTEXT
953: r(r) 953: r (r)
954#endif
955{ 954{
956 clear (); 955 clear ();
957} 956}
958 957
959rxvt_fontset::~rxvt_fontset () 958rxvt_fontset::~rxvt_fontset ()
962} 961}
963 962
964void 963void
965rxvt_fontset::clear () 964rxvt_fontset::clear ()
966{ 965{
967 for (rxvt_font **i = fonts.begin (); i != fonts.end(); i++) 966 for (rxvt_font **i = fonts.begin (); i != fonts.end (); i++)
968 FONT_UNREF (*i); 967 FONT_UNREF (*i);
969 968
970 fonts.clear (); 969 fonts.clear ();
971 base_id = 0; 970 base_id = 0;
972 base_prop.height = 0x7fffffff; 971 base_prop.height = 0x7fffffff;
1026 1025
1027 if (*desc == '[') 1026 if (*desc == '[')
1028 { 1027 {
1029 fprintf (stderr, "extra font parameters not yet supported, skipping.\n"); 1028 fprintf (stderr, "extra font parameters not yet supported, skipping.\n");
1030 1029
1031 const char *extra = desc++; 1030 //const char *extra = desc++; // not yet used
1032 1031
1033 desc = strchr (desc, ']'); 1032 desc = strchr (desc, ']');
1034 1033
1035 if (!desc) 1034 if (!desc)
1036 { 1035 {
1075 } 1074 }
1076 1075
1077 return true; 1076 return true;
1078} 1077}
1079 1078
1080void 1079bool
1081rxvt_fontset::populate (const char *desc) 1080rxvt_fontset::populate (const char *desc)
1082{ 1081{
1083 clear (); 1082 clear ();
1084 1083
1085 fonts.push_back (new_font (0, CS_UNICODE)); 1084 fonts.push_back (new_font (0, CS_UNICODE));
1089 1088
1090 if (!base_id) 1089 if (!base_id)
1091 base_id = 1; 1090 base_id = 1;
1092 1091
1093 // we currently need a base-font, no matter what 1092 // we currently need a base-font, no matter what
1094 if (fonts.size () <= base_id || !realize_font (base_id)) 1093 if ((int)fonts.size () <= base_id || !realize_font (base_id))
1095 { 1094 {
1096 puts ("unable to load specified font(s), falling back to 'fixed'\n"); 1095 puts ("unable to load specified font (s), falling back to 'fixed'\n");
1097 add_fonts ("fixed"); 1096 add_fonts ("fixed");
1098 base_id = fonts.size () - 1; 1097 base_id = fonts.size () - 1;
1099 } 1098 }
1100 1099
1101 if (fonts.size () <= base_id || !realize_font (base_id)) 1100 if ((int)fonts.size () <= base_id || !realize_font (base_id))
1102 { 1101 return false;
1103 fprintf (stderr, "unable to load a base font, please provide one using -fn fontname\n");
1104 exit (1);
1105 }
1106 1102
1107 base_prop = fonts[base_id]->properties (); 1103 base_prop = fonts[base_id]->properties ();
1104
1105 return true;
1108} 1106}
1109 1107
1110int 1108int
1111rxvt_fontset::find_font (uint32_t unicode) 1109rxvt_fontset::find_font (uint32_t unicode)
1112{ 1110{
1113 for (int i = 0; i < fonts.size (); i++) 1111 for (unsigned int i = 0; i < fonts.size (); i++)
1114 { 1112 {
1115 rxvt_font *f = fonts[i]; 1113 rxvt_font *f = fonts[i];
1116 1114
1117 if (!f->loaded) 1115 if (!f->loaded)
1118 { 1116 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines