… | |
… | |
103 | |
103 | |
104 | static void *enc_buf; |
104 | static void *enc_buf; |
105 | static uint32_t enc_len; |
105 | static uint32_t enc_len; |
106 | |
106 | |
107 | static inline void * |
107 | static inline void * |
108 | get_enc_buf (int len) |
108 | get_enc_buf (uint32_t len) |
109 | { |
109 | { |
110 | if (len > enc_len) |
110 | if (len > enc_len) |
111 | { |
111 | { |
112 | free (enc_buf); |
112 | free (enc_buf); |
113 | enc_buf = malloc (len); |
113 | enc_buf = malloc (len); |
… | |
… | |
115 | |
115 | |
116 | return enc_buf; |
116 | return enc_buf; |
117 | } |
117 | } |
118 | |
118 | |
119 | static const char * |
119 | static const char * |
120 | enc_char (const text_t *text, int len, codeset cs, bool &zero) |
120 | enc_char (const text_t *text, uint32_t len, codeset cs, bool &zero) |
121 | { |
121 | { |
122 | uint8_t *buf = (uint8_t *)get_enc_buf (len); |
122 | uint8_t *buf = (uint8_t *)get_enc_buf (len); |
123 | |
123 | |
124 | while (len--) |
124 | while (len--) |
125 | { |
125 | { |
… | |
… | |
136 | |
136 | |
137 | return (const char *)enc_buf; |
137 | return (const char *)enc_buf; |
138 | } |
138 | } |
139 | |
139 | |
140 | static const XChar2b * |
140 | static const XChar2b * |
141 | enc_xchar2b (const text_t *text, int len, codeset cs, bool &zero) |
141 | enc_xchar2b (const text_t *text, uint32_t len, codeset cs, bool &zero) |
142 | { |
142 | { |
143 | XChar2b *buf = (XChar2b *)get_enc_buf (len * sizeof (XChar2b)); |
143 | XChar2b *buf = (XChar2b *)get_enc_buf (len * sizeof (XChar2b)); |
144 | |
144 | |
145 | while (len--) |
145 | while (len--) |
146 | { |
146 | { |
… | |
… | |
515 | f = XLoadQueryFont (DISPLAY, name); |
515 | f = XLoadQueryFont (DISPLAY, name); |
516 | |
516 | |
517 | if (!f) |
517 | if (!f) |
518 | return false; |
518 | return false; |
519 | |
519 | |
520 | unsigned long value; |
|
|
521 | |
|
|
522 | const char *registry = get_property (f, "CHARSET_REGISTRY", 0); |
520 | const char *registry = get_property (f, "CHARSET_REGISTRY", 0); |
523 | const char *encoding = get_property (f, "CHARSET_ENCODING", 0); |
521 | const char *encoding = get_property (f, "CHARSET_ENCODING", 0); |
524 | |
522 | |
525 | if (registry && encoding) |
523 | if (registry && encoding) |
526 | { |
524 | { |
… | |
… | |
612 | /* check wether the character exists in _this_ font. horrible. */ |
610 | /* check wether the character exists in _this_ font. horrible. */ |
613 | XCharStruct *xcs; |
611 | XCharStruct *xcs; |
614 | |
612 | |
615 | if (encm) |
613 | if (encm) |
616 | { |
614 | { |
617 | int byte1 = ch >> 8; |
615 | unsigned char byte1 = ch >> 8; |
618 | int byte2 = ch & 255; |
616 | unsigned char byte2 = ch & 255; |
619 | |
617 | |
620 | if (byte1 < f->min_byte1 || byte1 > f->max_byte1 |
618 | if (byte1 < f->min_byte1 || byte1 > f->max_byte1 |
621 | || byte2 < f->min_char_or_byte2 || byte2 > f->max_char_or_byte2) |
619 | || byte2 < f->min_char_or_byte2 || byte2 > f->max_char_or_byte2) |
622 | return false; |
620 | return false; |
623 | |
621 | |
… | |
… | |
893 | rxvt_font_xft::draw (int x, int y, |
891 | rxvt_font_xft::draw (int x, int y, |
894 | const text_t *text, int len, |
892 | const text_t *text, int len, |
895 | int fg, int bg) |
893 | int fg, int bg) |
896 | { |
894 | { |
897 | if (!d) |
895 | if (!d) |
898 | { |
|
|
899 | dR; |
|
|
900 | d = XftDrawCreate (DISPLAY, DRAWABLE, XVISUAL, XCMAP); |
896 | d = XftDrawCreate (DISPLAY, DRAWABLE, r->Xvisual, r->Xcmap); |
901 | } |
|
|
902 | |
897 | |
903 | if (bg >= 0 && bg != Color_bg) |
898 | if (bg >= 0 && bg != Color_bg) |
904 | XftDrawRect (d, &r->PixColors[bg].c, x, y, r->TermWin.fwidth * len, r->TermWin.fheight); |
899 | XftDrawRect (d, &r->PixColors[bg].c, x, y, r->TermWin.fwidth * len, r->TermWin.fheight); |
905 | else |
900 | else |
906 | clear_rect (x, y, r->TermWin.fwidth * len, r->TermWin.fheight, bg); |
901 | clear_rect (x, y, r->TermWin.fwidth * len, r->TermWin.fheight, bg); |
… | |
… | |
947 | #endif |
942 | #endif |
948 | |
943 | |
949 | ///////////////////////////////////////////////////////////////////////////// |
944 | ///////////////////////////////////////////////////////////////////////////// |
950 | |
945 | |
951 | rxvt_fontset::rxvt_fontset (rxvt_t r) |
946 | rxvt_fontset::rxvt_fontset (rxvt_t r) |
952 | #ifdef EXPLICIT_CONTEXT |
|
|
953 | : r(r) |
947 | : r(r) |
954 | #endif |
|
|
955 | { |
948 | { |
956 | clear (); |
949 | clear (); |
957 | } |
950 | } |
958 | |
951 | |
959 | rxvt_fontset::~rxvt_fontset () |
952 | rxvt_fontset::~rxvt_fontset () |
… | |
… | |
1026 | |
1019 | |
1027 | if (*desc == '[') |
1020 | if (*desc == '[') |
1028 | { |
1021 | { |
1029 | fprintf (stderr, "extra font parameters not yet supported, skipping.\n"); |
1022 | fprintf (stderr, "extra font parameters not yet supported, skipping.\n"); |
1030 | |
1023 | |
1031 | const char *extra = desc++; |
1024 | //const char *extra = desc++; // not yet used |
1032 | |
1025 | |
1033 | desc = strchr (desc, ']'); |
1026 | desc = strchr (desc, ']'); |
1034 | |
1027 | |
1035 | if (!desc) |
1028 | if (!desc) |
1036 | { |
1029 | { |
… | |
… | |
1089 | |
1082 | |
1090 | if (!base_id) |
1083 | if (!base_id) |
1091 | base_id = 1; |
1084 | base_id = 1; |
1092 | |
1085 | |
1093 | // we currently need a base-font, no matter what |
1086 | // we currently need a base-font, no matter what |
1094 | if (fonts.size () <= base_id || !realize_font (base_id)) |
1087 | if ((int)fonts.size () <= base_id || !realize_font (base_id)) |
1095 | { |
1088 | { |
1096 | puts ("unable to load specified font(s), falling back to 'fixed'\n"); |
1089 | puts ("unable to load specified font(s), falling back to 'fixed'\n"); |
1097 | add_fonts ("fixed"); |
1090 | add_fonts ("fixed"); |
1098 | base_id = fonts.size () - 1; |
1091 | base_id = fonts.size () - 1; |
1099 | } |
1092 | } |
1100 | |
1093 | |
1101 | if (fonts.size () <= base_id || !realize_font (base_id)) |
1094 | if ((int)fonts.size () <= base_id || !realize_font (base_id)) |
1102 | { |
1095 | { |
1103 | fprintf (stderr, "unable to load a base font, please provide one using -fn fontname\n"); |
1096 | fprintf (stderr, "unable to load a base font, please provide one using -fn fontname\n"); |
1104 | exit (1); |
1097 | exit (1); |
1105 | } |
1098 | } |
1106 | |
1099 | |
… | |
… | |
1108 | } |
1101 | } |
1109 | |
1102 | |
1110 | int |
1103 | int |
1111 | rxvt_fontset::find_font (uint32_t unicode) |
1104 | rxvt_fontset::find_font (uint32_t unicode) |
1112 | { |
1105 | { |
1113 | for (int i = 0; i < fonts.size (); i++) |
1106 | for (unsigned int i = 0; i < fonts.size (); i++) |
1114 | { |
1107 | { |
1115 | rxvt_font *f = fonts[i]; |
1108 | rxvt_font *f = fonts[i]; |
1116 | |
1109 | |
1117 | if (!f->loaded) |
1110 | if (!f->loaded) |
1118 | { |
1111 | { |