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 |
… | |
… | |
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 | |
32 | const struct rxvt_fallback_font { |
31 | const 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 | |
|
|
103 | #if XFT |
|
|
104 | rxvt_drawable::~rxvt_drawable () |
|
|
105 | { |
|
|
106 | if (xftdrawable) |
|
|
107 | XftDrawDestroy (xftdrawable); |
|
|
108 | } |
|
|
109 | |
|
|
110 | rxvt_drawable::operator XftDraw *() |
|
|
111 | { |
|
|
112 | if (!xftdrawable) |
|
|
113 | xftdrawable = XftDrawCreate (display->display, drawable, display->visual, display->cmap); |
|
|
114 | |
|
|
115 | return xftdrawable; |
|
|
116 | } |
|
|
117 | #endif |
|
|
118 | |
|
|
119 | ///////////////////////////////////////////////////////////////////////////// |
|
|
120 | |
104 | static void *enc_buf; |
121 | static void *enc_buf; |
105 | static uint32_t enc_len; |
122 | static uint32_t enc_len; |
106 | |
123 | |
107 | static inline void * |
124 | static inline void * |
108 | get_enc_buf (uint32_t len) |
125 | get_enc_buf (uint32_t len) |
… | |
… | |
161 | } |
178 | } |
162 | |
179 | |
163 | ///////////////////////////////////////////////////////////////////////////// |
180 | ///////////////////////////////////////////////////////////////////////////// |
164 | |
181 | |
165 | void |
182 | void |
166 | rxvt_font::clear_rect (int x, int y, int w, int h, int color) |
183 | rxvt_font::clear_rect (rxvt_drawable &d, int x, int y, int w, int h, int color) |
167 | { |
184 | { |
168 | if (color == Color_bg) |
185 | if (color == Color_bg) |
169 | XClearArea (DISPLAY, DRAWABLE, x, y, w, h, FALSE); |
186 | XClearArea (d.display->display, d, x, y, w, h, FALSE); |
170 | else if (color >= 0) |
187 | else if (color >= 0) |
171 | { |
188 | { |
|
|
189 | #if XFT |
|
|
190 | XftDrawRect (d, &r->PixColors[color].c, x, y, w, h); |
|
|
191 | #else |
172 | XSetForeground (DISPLAY, GC, r->PixColors[color]); |
192 | XSetForeground (d.display->display, GC, r->PixColors[color]); |
173 | XFillRectangle (DISPLAY, DRAWABLE, GC, x, y, w, h); |
193 | XFillRectangle (d.display->display, d, GC, x, y, w, h); |
|
|
194 | #endif |
174 | } |
195 | } |
175 | } |
196 | } |
176 | |
197 | |
177 | static const char *linedraw_cmds[128] = { |
198 | static const char *linedraw_cmds[128] = { |
178 | "1hH", "2hH", "1vV", "2vV", |
199 | "1hH", "2hH", "1vV", "2vV", |
… | |
… | |
263 | } |
284 | } |
264 | |
285 | |
265 | return false; |
286 | return false; |
266 | } |
287 | } |
267 | |
288 | |
268 | void draw (int x, int y, |
289 | void draw (rxvt_drawable &d, int x, int y, |
269 | const text_t *text, int len, |
290 | const text_t *text, int len, |
270 | int fg, int bg); |
291 | int fg, int bg); |
271 | }; |
292 | }; |
272 | |
293 | |
273 | void |
294 | void |
274 | rxvt_font_default::draw (int x, int y, |
295 | rxvt_font_default::draw (rxvt_drawable &d, int x, int y, |
275 | const text_t *text, int len, |
296 | const text_t *text, int len, |
276 | int fg, int bg) |
297 | int fg, int bg) |
277 | { |
298 | { |
278 | clear_rect (x, y, r->TermWin.fwidth * len, r->TermWin.fheight, bg); |
299 | clear_rect (d, x, y, r->TermWin.fwidth * len, r->TermWin.fheight, bg); |
279 | |
300 | |
280 | XSetForeground (DISPLAY, GC, r->PixColors[fg]); |
301 | XSetForeground (d.display->display, GC, r->PixColors[fg]); |
281 | |
302 | |
282 | while (len--) |
303 | while (len--) |
283 | { |
304 | { |
284 | text_t t = *text++; |
305 | text_t t = *text++; |
285 | |
306 | |
286 | if (t >= 0x2500 & t <= 0x2580 && linedraw_cmds[t - 0x2500]) |
307 | if (t >= 0x2500 & t <= 0x2580 && linedraw_cmds[t - 0x2500]) |
287 | { |
308 | { |
288 | const char *p = linedraw_cmds[t - 0x2500]; |
309 | const char *p = linedraw_cmds[t - 0x2500]; |
289 | |
310 | |
290 | int x0 = x, x1 = x + r->TermWin.fwidth / 2, x2 = x + r->TermWin.fwidth ; |
311 | 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; |
312 | int y0 = y, y1 = y + r->TermWin.fheight / 2, y2 = y + r->TermWin.fheight - 1; |
292 | |
313 | |
293 | XGCValues gcv; |
314 | XGCValues gcv; |
294 | |
315 | |
295 | while (*p) |
316 | while (*p) |
296 | { |
317 | { |
297 | switch (*p++) |
318 | switch (*p++) |
298 | { |
319 | { |
299 | case '1': |
320 | case '1': |
300 | gcv.line_width = 0; |
321 | gcv.line_width = 0; |
301 | XChangeGC (DISPLAY, GC, GCLineWidth, &gcv); |
322 | XChangeGC (d.display->display, GC, GCLineWidth, &gcv); |
302 | break; |
323 | break; |
303 | |
324 | |
304 | case '2': |
325 | case '2': |
305 | gcv.line_width = 2; |
326 | gcv.line_width = 2; |
306 | XChangeGC (DISPLAY, GC, GCLineWidth, &gcv); |
327 | XChangeGC (d.display->display, GC, GCLineWidth, &gcv); |
307 | break; |
328 | break; |
308 | |
329 | |
309 | case 'h': XDrawLine (DISPLAY, DRAWABLE, GC, x0, y1, x1, y1); break; |
330 | 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; |
331 | 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; |
332 | 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; |
333 | 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; |
334 | 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; |
335 | case 'b': XDrawLine (d.display->display, d, GC, x0, y0, x2, y2); break; |
315 | } |
336 | } |
316 | } |
337 | } |
317 | |
338 | |
318 | gcv.line_width = 0; |
339 | gcv.line_width = 0; |
319 | XChangeGC (DISPLAY, GC, GCLineWidth, &gcv); |
340 | XChangeGC (d.display->display, GC, GCLineWidth, &gcv); |
320 | } |
341 | } |
321 | else |
342 | else |
322 | switch (*text++) |
343 | switch (*text++) |
323 | { |
344 | { |
324 | case NOCHAR: |
345 | case NOCHAR: |
325 | case ZERO_WIDTH_CHAR: |
346 | case ZERO_WIDTH_CHAR: |
326 | break; |
347 | break; |
327 | default: |
348 | default: |
328 | XDrawRectangle (DISPLAY, DRAWABLE, GC, x + 2, y + 2, r->TermWin.fwidth - 5, r->TermWin.fheight - 5); |
349 | XDrawRectangle (d.display->display, d, GC, x + 2, y + 2, r->TermWin.fwidth - 5, r->TermWin.fheight - 5); |
329 | } |
350 | } |
330 | |
351 | |
331 | x += r->TermWin.fwidth; |
352 | x += r->TermWin.fwidth; |
332 | } |
353 | } |
333 | } |
354 | } |
… | |
… | |
343 | |
364 | |
344 | bool load (const rxvt_fontprop &prop); |
365 | bool load (const rxvt_fontprop &prop); |
345 | |
366 | |
346 | bool has_codepoint (uint32_t unicode); |
367 | bool has_codepoint (uint32_t unicode); |
347 | |
368 | |
348 | void draw (int x, int y, |
369 | void draw (rxvt_drawable &d, int x, int y, |
349 | const text_t *text, int len, |
370 | const text_t *text, int len, |
350 | int fg, int bg); |
371 | int fg, int bg); |
351 | |
372 | |
352 | XFontStruct *f; |
373 | XFontStruct *f; |
353 | codeset cs; |
374 | codeset cs; |
… | |
… | |
428 | |
449 | |
429 | XFontStruct *f = XLoadQueryFont (DISPLAY, name); |
450 | XFontStruct *f = XLoadQueryFont (DISPLAY, name); |
430 | |
451 | |
431 | if (f) |
452 | if (f) |
432 | { |
453 | { |
433 | // the font should really exists now. if not, we have a problem |
454 | // 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). |
455 | // (e.g. if the user did xset fp rehash just when we were searching fonts). |
435 | // in that case, just return garbage. |
456 | // in that case, just return garbage. |
436 | bool ret = set_properties (p, f); |
457 | bool ret = set_properties (p, f); |
437 | XFreeFont (DISPLAY, f); |
458 | XFreeFont (DISPLAY, f); |
438 | return ret; |
459 | return ret; |
… | |
… | |
644 | |
665 | |
645 | return true; |
666 | return true; |
646 | } |
667 | } |
647 | |
668 | |
648 | void |
669 | void |
649 | rxvt_font_x11::draw (int x, int y, |
670 | rxvt_font_x11::draw (rxvt_drawable &d, int x, int y, |
650 | const text_t *text, int len, |
671 | const text_t *text, int len, |
651 | int fg, int bg) |
672 | int fg, int bg) |
652 | { |
673 | { |
653 | // this looks like a mess /. |
674 | // this looks like a mess /. |
654 | // and it is a mess /. |
675 | // and it is a mess /. |
… | |
… | |
670 | { |
691 | { |
671 | const XChar2b *xc = enc_xchar2b (text, len, cs, slow); |
692 | const XChar2b *xc = enc_xchar2b (text, len, cs, slow); |
672 | |
693 | |
673 | if (bg == Color_bg && !slow) |
694 | if (bg == Color_bg && !slow) |
674 | { |
695 | { |
675 | XChangeGC (DISPLAY, GC, GCForeground | GCBackground | GCFont, &v); |
696 | XChangeGC (d.display->display, GC, GCForeground | GCBackground | GCFont, &v); |
676 | XDrawImageString16 (DISPLAY, DRAWABLE, GC, x, y + base, xc, len); |
697 | XDrawImageString16 (d.display->display, d, GC, x, y + base, xc, len); |
677 | } |
698 | } |
678 | else |
699 | else |
679 | { |
700 | { |
680 | clear_rect (x, y, r->TermWin.fwidth * len, r->TermWin.fheight, bg); |
701 | clear_rect (d, x, y, r->TermWin.fwidth * len, r->TermWin.fheight, bg); |
681 | |
702 | |
682 | XChangeGC (DISPLAY, GC, GCForeground | GCFont, &v); |
703 | XChangeGC (d.display->display, GC, GCForeground | GCFont, &v); |
683 | |
704 | |
684 | if (slow) |
705 | if (slow) |
685 | { |
706 | { |
686 | do |
707 | do |
687 | { |
708 | { |
688 | if (xc->byte1 || xc->byte2) |
709 | if (xc->byte1 || xc->byte2) |
689 | XDrawString16 (DISPLAY, DRAWABLE, GC, x, y + base, xc, 1); |
710 | XDrawString16 (d.display->display, d, GC, x, y + base, xc, 1); |
690 | |
711 | |
691 | x += r->TermWin.fwidth; |
712 | x += r->TermWin.fwidth; |
692 | xc++; len--; |
713 | xc++; len--; |
693 | } |
714 | } |
694 | while (len); |
715 | while (len); |
695 | } |
716 | } |
696 | else |
717 | else |
697 | XDrawString16 (DISPLAY, DRAWABLE, GC, x, y + base, xc, len); |
718 | XDrawString16 (d.display->display, d, GC, x, y + base, xc, len); |
698 | } |
719 | } |
699 | } |
720 | } |
700 | else |
721 | else |
701 | { |
722 | { |
702 | const char *xc = enc_char (text, len, cs, slow); |
723 | const char *xc = enc_char (text, len, cs, slow); |
703 | |
724 | |
704 | if (bg == Color_bg && !slow) |
725 | if (bg == Color_bg && !slow) |
705 | { |
726 | { |
706 | XChangeGC (DISPLAY, GC, GCForeground | GCBackground | GCFont, &v); |
727 | XChangeGC (d.display->display, GC, GCForeground | GCBackground | GCFont, &v); |
707 | XDrawImageString (DISPLAY, DRAWABLE, GC, x, y + base, xc, len); |
728 | XDrawImageString (d.display->display, d, GC, x, y + base, xc, len); |
708 | } |
729 | } |
709 | else |
730 | else |
710 | { |
731 | { |
711 | clear_rect (x, y, r->TermWin.fwidth * len, r->TermWin.fheight, bg); |
732 | clear_rect (d, x, y, r->TermWin.fwidth * len, r->TermWin.fheight, bg); |
712 | |
733 | |
713 | XChangeGC (DISPLAY, GC, GCForeground | GCFont, &v); |
734 | XChangeGC (d.display->display, GC, GCForeground | GCFont, &v); |
714 | |
735 | |
715 | if (slow) |
736 | if (slow) |
716 | { |
737 | { |
717 | do |
738 | do |
718 | { |
739 | { |
719 | if (*xc) |
740 | if (*xc) |
720 | XDrawString (DISPLAY, DRAWABLE, GC, x, y + base, xc, 1); |
741 | XDrawString (d.display->display, d, GC, x, y + base, xc, 1); |
721 | |
742 | |
722 | x += r->TermWin.fwidth; |
743 | x += r->TermWin.fwidth; |
723 | xc++; len--; |
744 | xc++; len--; |
724 | } |
745 | } |
725 | while (len); |
746 | while (len); |
726 | } |
747 | } |
727 | else |
748 | else |
728 | XDrawString (DISPLAY, DRAWABLE, GC, x, y + base, xc, len); |
749 | XDrawString (d.display->display, d, GC, x, y + base, xc, len); |
729 | } |
750 | } |
730 | } |
751 | } |
731 | } |
752 | } |
732 | |
753 | |
733 | ///////////////////////////////////////////////////////////////////////////// |
754 | ///////////////////////////////////////////////////////////////////////////// |
… | |
… | |
738 | //#define SWATHBITS (UNIBITS / 2 + 3) // minimum size for "full" tables |
759 | //#define SWATHBITS (UNIBITS / 2 + 3) // minimum size for "full" tables |
739 | #define SWATHBITS 8 |
760 | #define SWATHBITS 8 |
740 | #endif |
761 | #endif |
741 | |
762 | |
742 | struct rxvt_font_xft : rxvt_font { |
763 | struct rxvt_font_xft : rxvt_font { |
743 | rxvt_font_xft () { f = 0; d = 0; } |
764 | rxvt_font_xft () { f = 0; } |
744 | |
765 | |
745 | void clear (); |
766 | void clear (); |
746 | |
767 | |
747 | rxvt_fontprop properties (); |
768 | rxvt_fontprop properties (); |
748 | |
769 | |
749 | bool load (const rxvt_fontprop &prop); |
770 | bool load (const rxvt_fontprop &prop); |
750 | |
771 | |
751 | void draw (int x, int y, |
772 | void draw (rxvt_drawable &d, int x, int y, |
752 | const text_t *text, int len, |
773 | const text_t *text, int len, |
753 | int fg, int bg); |
774 | int fg, int bg); |
754 | |
775 | |
755 | bool has_codepoint (uint32_t unicode); |
776 | bool has_codepoint (uint32_t unicode); |
756 | |
777 | |
757 | protected: |
778 | protected: |
758 | XftFont *f; |
779 | XftFont *f; |
759 | XftDraw *d; |
|
|
760 | }; |
780 | }; |
761 | |
781 | |
762 | void |
782 | void |
763 | rxvt_font_xft::clear () |
783 | rxvt_font_xft::clear () |
764 | { |
784 | { |
765 | if (f) |
785 | if (f) |
766 | { |
786 | { |
767 | XftFontClose (DISPLAY, f); |
787 | XftFontClose (DISPLAY, f); |
768 | f = 0; |
788 | f = 0; |
769 | } |
|
|
770 | |
|
|
771 | if (d) |
|
|
772 | { |
|
|
773 | XftDrawDestroy (d); |
|
|
774 | d = 0; |
|
|
775 | } |
789 | } |
776 | } |
790 | } |
777 | |
791 | |
778 | rxvt_fontprop |
792 | rxvt_fontprop |
779 | rxvt_font_xft::properties () |
793 | rxvt_font_xft::properties () |
… | |
… | |
886 | { |
900 | { |
887 | return XftCharExists (DISPLAY, f, unicode); |
901 | return XftCharExists (DISPLAY, f, unicode); |
888 | } |
902 | } |
889 | |
903 | |
890 | void |
904 | void |
891 | rxvt_font_xft::draw (int x, int y, |
905 | rxvt_font_xft::draw (rxvt_drawable &d, int x, int y, |
892 | const text_t *text, int len, |
906 | const text_t *text, int len, |
893 | int fg, int bg) |
907 | int fg, int bg) |
894 | { |
908 | { |
895 | if (!d) |
|
|
896 | d = XftDrawCreate (DISPLAY, DRAWABLE, r->display->visual, r->display->cmap); |
|
|
897 | |
|
|
898 | if (bg >= 0 && bg != Color_bg) |
|
|
899 | XftDrawRect (d, &r->PixColors[bg].c, x, y, r->TermWin.fwidth * len, r->TermWin.fheight); |
|
|
900 | else |
|
|
901 | clear_rect (x, y, r->TermWin.fwidth * len, r->TermWin.fheight, bg); |
909 | clear_rect (d, x, y, r->TermWin.fwidth * len, r->TermWin.fheight, bg); |
902 | |
910 | |
903 | if (!slow && width == r->TermWin.fwidth && 0) |
911 | if (!slow && width == r->TermWin.fwidth && 0) |
904 | { |
912 | { |
905 | if (sizeof (text_t) == sizeof (FcChar16)) |
913 | if (sizeof (text_t) == sizeof (FcChar16)) |
906 | XftDrawString16 (d, &r->PixColors[fg].c, f, x, y + r->TermWin.fbase, (const FcChar16 *)text, len); |
914 | XftDrawString16 (d, &r->PixColors[fg].c, f, x, y + r->TermWin.fbase, (const FcChar16 *)text, len); |
… | |
… | |
918 | fwidth *= 2; |
926 | fwidth *= 2; |
919 | |
927 | |
920 | XGlyphInfo extents; |
928 | XGlyphInfo extents; |
921 | if (sizeof (text_t) == sizeof (FcChar16)) |
929 | if (sizeof (text_t) == sizeof (FcChar16)) |
922 | { |
930 | { |
923 | XftTextExtents16 (DISPLAY, f, (const FcChar16 *)text, 1, &extents); |
931 | XftTextExtents16 (d.display->display, f, (const FcChar16 *)text, 1, &extents); |
924 | XftDrawString16 (d, &r->PixColors[fg].c, f, x + extents.x + (fwidth - extents.width) / 2, |
932 | XftDrawString16 (d, &r->PixColors[fg].c, f, x + extents.x + (fwidth - extents.width) / 2, |
925 | y + r->TermWin.fbase, (const FcChar16 *)text, 1); |
933 | y + r->TermWin.fbase, (const FcChar16 *)text, 1); |
926 | } |
934 | } |
927 | else |
935 | else |
928 | { |
936 | { |
929 | XGlyphInfo extents; |
937 | XGlyphInfo extents; |
930 | XftTextExtents32 (DISPLAY, f, (const FcChar32 *)text, 1, &extents); |
938 | XftTextExtents32 (d.display->display, f, (const FcChar32 *)text, 1, &extents); |
931 | XftDrawString32 (d, &r->PixColors[fg].c, f, x + extents.x + (fwidth - extents.width) / 2, |
939 | XftDrawString32 (d, &r->PixColors[fg].c, f, x + extents.x + (fwidth - extents.width) / 2, |
932 | y + r->TermWin.fbase, (const FcChar32 *)text, 1); |
940 | y + r->TermWin.fbase, (const FcChar32 *)text, 1); |
933 | } |
941 | } |
934 | } |
942 | } |
935 | |
943 | |
… | |
… | |
942 | #endif |
950 | #endif |
943 | |
951 | |
944 | ///////////////////////////////////////////////////////////////////////////// |
952 | ///////////////////////////////////////////////////////////////////////////// |
945 | |
953 | |
946 | rxvt_fontset::rxvt_fontset (rxvt_t r) |
954 | rxvt_fontset::rxvt_fontset (rxvt_t r) |
947 | : r(r) |
955 | : r (r) |
948 | { |
956 | { |
949 | clear (); |
957 | clear (); |
950 | } |
958 | } |
951 | |
959 | |
952 | rxvt_fontset::~rxvt_fontset () |
960 | rxvt_fontset::~rxvt_fontset () |
… | |
… | |
955 | } |
963 | } |
956 | |
964 | |
957 | void |
965 | void |
958 | rxvt_fontset::clear () |
966 | rxvt_fontset::clear () |
959 | { |
967 | { |
960 | for (rxvt_font **i = fonts.begin (); i != fonts.end(); i++) |
968 | for (rxvt_font **i = fonts.begin (); i != fonts.end (); i++) |
961 | FONT_UNREF (*i); |
969 | FONT_UNREF (*i); |
962 | |
970 | |
963 | fonts.clear (); |
971 | fonts.clear (); |
964 | base_id = 0; |
972 | base_id = 0; |
965 | base_prop.height = 0x7fffffff; |
973 | base_prop.height = 0x7fffffff; |
… | |
… | |
1068 | } |
1076 | } |
1069 | |
1077 | |
1070 | return true; |
1078 | return true; |
1071 | } |
1079 | } |
1072 | |
1080 | |
1073 | void |
1081 | bool |
1074 | rxvt_fontset::populate (const char *desc) |
1082 | rxvt_fontset::populate (const char *desc) |
1075 | { |
1083 | { |
1076 | clear (); |
1084 | clear (); |
1077 | |
1085 | |
1078 | fonts.push_back (new_font (0, CS_UNICODE)); |
1086 | fonts.push_back (new_font (0, CS_UNICODE)); |
… | |
… | |
1084 | base_id = 1; |
1092 | base_id = 1; |
1085 | |
1093 | |
1086 | // we currently need a base-font, no matter what |
1094 | // we currently need a base-font, no matter what |
1087 | if ((int)fonts.size () <= base_id || !realize_font (base_id)) |
1095 | if ((int)fonts.size () <= base_id || !realize_font (base_id)) |
1088 | { |
1096 | { |
1089 | puts ("unable to load specified font(s), falling back to 'fixed'\n"); |
1097 | puts ("unable to load specified font (s), falling back to 'fixed'\n"); |
1090 | add_fonts ("fixed"); |
1098 | add_fonts ("fixed"); |
1091 | base_id = fonts.size () - 1; |
1099 | base_id = fonts.size () - 1; |
1092 | } |
1100 | } |
1093 | |
1101 | |
1094 | if ((int)fonts.size () <= base_id || !realize_font (base_id)) |
1102 | if ((int)fonts.size () <= base_id || !realize_font (base_id)) |
1095 | { |
1103 | return false; |
1096 | fprintf (stderr, "unable to load a base font, please provide one using -fn fontname\n"); |
|
|
1097 | exit (1); |
|
|
1098 | } |
|
|
1099 | |
1104 | |
1100 | base_prop = fonts[base_id]->properties (); |
1105 | base_prop = fonts[base_id]->properties (); |
|
|
1106 | |
|
|
1107 | return true; |
1101 | } |
1108 | } |
1102 | |
1109 | |
1103 | int |
1110 | int |
1104 | rxvt_fontset::find_font (uint32_t unicode) |
1111 | rxvt_fontset::find_font (uint32_t unicode) |
1105 | { |
1112 | { |