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 |
… | |
… | |
428 | |
428 | |
429 | XFontStruct *f = XLoadQueryFont (DISPLAY, name); |
429 | XFontStruct *f = XLoadQueryFont (DISPLAY, name); |
430 | |
430 | |
431 | if (f) |
431 | if (f) |
432 | { |
432 | { |
433 | // the font should really exists now. if not, we have a problem |
433 | // 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). |
434 | // (e.g. if the user did xset fp rehash just when we were searching fonts). |
435 | // in that case, just return garbage. |
435 | // in that case, just return garbage. |
436 | bool ret = set_properties (p, f); |
436 | bool ret = set_properties (p, f); |
437 | XFreeFont (DISPLAY, f); |
437 | XFreeFont (DISPLAY, f); |
438 | return ret; |
438 | return ret; |
… | |
… | |
760 | }; |
760 | }; |
761 | |
761 | |
762 | void |
762 | void |
763 | rxvt_font_xft::clear () |
763 | rxvt_font_xft::clear () |
764 | { |
764 | { |
|
|
765 | if (d) |
|
|
766 | { |
|
|
767 | XftDrawDestroy (d); |
|
|
768 | d = 0; |
|
|
769 | } |
|
|
770 | |
765 | if (f) |
771 | if (f) |
766 | { |
772 | { |
767 | XftFontClose (DISPLAY, f); |
773 | XftFontClose (DISPLAY, f); |
768 | f = 0; |
774 | f = 0; |
769 | } |
|
|
770 | |
|
|
771 | if (d) |
|
|
772 | { |
|
|
773 | XftDrawDestroy (d); |
|
|
774 | d = 0; |
|
|
775 | } |
775 | } |
776 | } |
776 | } |
777 | |
777 | |
778 | rxvt_fontprop |
778 | rxvt_fontprop |
779 | rxvt_font_xft::properties () |
779 | rxvt_font_xft::properties () |
… | |
… | |
890 | void |
890 | void |
891 | rxvt_font_xft::draw (int x, int y, |
891 | rxvt_font_xft::draw (int x, int y, |
892 | const text_t *text, int len, |
892 | const text_t *text, int len, |
893 | int fg, int bg) |
893 | int fg, int bg) |
894 | { |
894 | { |
895 | if (!d) |
|
|
896 | d = XftDrawCreate (DISPLAY, DRAWABLE, r->display->visual, r->display->cmap); |
895 | d = XftDrawCreate (DISPLAY, DRAWABLE, r->display->visual, r->display->cmap); |
897 | |
896 | |
898 | if (bg >= 0 && bg != Color_bg) |
897 | if (bg >= 0 && bg != Color_bg) |
899 | XftDrawRect (d, &r->PixColors[bg].c, x, y, r->TermWin.fwidth * len, r->TermWin.fheight); |
898 | XftDrawRect (d, &r->PixColors[bg].c, x, y, r->TermWin.fwidth * len, r->TermWin.fheight); |
900 | else |
899 | else |
901 | clear_rect (x, y, r->TermWin.fwidth * len, r->TermWin.fheight, bg); |
900 | clear_rect (x, y, r->TermWin.fwidth * len, r->TermWin.fheight, bg); |
… | |
… | |
1068 | } |
1067 | } |
1069 | |
1068 | |
1070 | return true; |
1069 | return true; |
1071 | } |
1070 | } |
1072 | |
1071 | |
1073 | void |
1072 | bool |
1074 | rxvt_fontset::populate (const char *desc) |
1073 | rxvt_fontset::populate (const char *desc) |
1075 | { |
1074 | { |
1076 | clear (); |
1075 | clear (); |
1077 | |
1076 | |
1078 | fonts.push_back (new_font (0, CS_UNICODE)); |
1077 | fonts.push_back (new_font (0, CS_UNICODE)); |
… | |
… | |
1090 | add_fonts ("fixed"); |
1089 | add_fonts ("fixed"); |
1091 | base_id = fonts.size () - 1; |
1090 | base_id = fonts.size () - 1; |
1092 | } |
1091 | } |
1093 | |
1092 | |
1094 | if ((int)fonts.size () <= base_id || !realize_font (base_id)) |
1093 | if ((int)fonts.size () <= base_id || !realize_font (base_id)) |
1095 | { |
1094 | return false; |
1096 | fprintf (stderr, "unable to load a base font, please provide one using -fn fontname\n"); |
|
|
1097 | exit (1); |
|
|
1098 | } |
|
|
1099 | |
1095 | |
1100 | base_prop = fonts[base_id]->properties (); |
1096 | base_prop = fonts[base_id]->properties (); |
|
|
1097 | |
|
|
1098 | return true; |
1101 | } |
1099 | } |
1102 | |
1100 | |
1103 | int |
1101 | int |
1104 | rxvt_fontset::find_font (uint32_t unicode) |
1102 | rxvt_fontset::find_font (uint32_t unicode) |
1105 | { |
1103 | { |