… | |
… | |
268 | bool load (const rxvt_fontprop &prop) |
268 | bool load (const rxvt_fontprop &prop) |
269 | { |
269 | { |
270 | width = 1; height = 1; |
270 | width = 1; height = 1; |
271 | ascent = 1; descent = 0; |
271 | ascent = 1; descent = 0; |
272 | |
272 | |
|
|
273 | set_name ("built-in pseudofont"); |
|
|
274 | |
273 | return true; |
275 | return true; |
274 | } |
276 | } |
275 | |
277 | |
276 | bool has_codepoint (uint32_t unicode) |
278 | bool has_codepoint (unicode_t unicode) |
277 | { |
279 | { |
278 | if (unicode <= 0x001f) |
280 | if (unicode <= 0x001f) |
279 | return true; |
281 | return true; |
|
|
282 | |
280 | if (unicode >= 0x0080 && unicode <= 0x009f) |
283 | if (unicode >= 0x0080 && unicode <= 0x009f) |
281 | return true; |
284 | return true; |
282 | |
285 | |
283 | if (unicode >= 0x2500 && unicode <= 0x257f |
286 | if (unicode >= 0x2500 && unicode <= 0x257f |
284 | && linedraw_cmds[unicode - 0x2500]) |
287 | && linedraw_cmds[unicode - 0x2500]) |
|
|
288 | return true; |
|
|
289 | |
|
|
290 | if (IS_COMPOSE (unicode)) |
285 | return true; |
291 | return true; |
286 | |
292 | |
287 | switch (unicode) |
293 | switch (unicode) |
288 | { |
294 | { |
289 | case ZERO_WIDTH_CHAR: |
295 | case ZERO_WIDTH_CHAR: |
… | |
… | |
307 | |
313 | |
308 | XSetForeground (d.display->display, GC, r->PixColors[fg]); |
314 | XSetForeground (d.display->display, GC, r->PixColors[fg]); |
309 | |
315 | |
310 | while (len--) |
316 | while (len--) |
311 | { |
317 | { |
|
|
318 | #if ENABLE_COMBINING |
|
|
319 | compose_char *cc; |
|
|
320 | #endif |
312 | text_t t = *text++; |
321 | text_t t = *text++; |
313 | |
322 | |
314 | // is it in our linedrawing table? |
323 | // is it in our linedrawing table? |
315 | if (t >= 0x2500 & t <= 0x2580 && linedraw_cmds[t - 0x2500]) |
324 | if (t >= 0x2500 & t <= 0x2580 && linedraw_cmds[t - 0x2500]) |
316 | { |
325 | { |
… | |
… | |
345 | } |
354 | } |
346 | |
355 | |
347 | gcv.line_width = 0; |
356 | gcv.line_width = 0; |
348 | XChangeGC (d.display->display, GC, GCLineWidth, &gcv); |
357 | XChangeGC (d.display->display, GC, GCLineWidth, &gcv); |
349 | } |
358 | } |
|
|
359 | #if ENABLE_COMBINING |
|
|
360 | else if (IS_COMPOSE (t) && (cc = rxvt_composite[t])) |
|
|
361 | { |
|
|
362 | rxvt_font *f1 = (*fs)[fs->find_font (cc->c1)]; |
|
|
363 | f1->draw (d, x, y, &(t = cc->c1), 1, fg, bg); |
|
|
364 | if (cc->c2 != NOCHAR) |
|
|
365 | { |
|
|
366 | // prefer font of first character, for no good reasons |
|
|
367 | rxvt_font *f2 = f1->has_codepoint (cc->c2) |
|
|
368 | ? f1 |
|
|
369 | : (*fs)[fs->find_font (cc->c2)]; |
|
|
370 | |
|
|
371 | f2->draw (d, x, y, &(t = cc->c2), 1, fg, -1); |
|
|
372 | } |
|
|
373 | } |
|
|
374 | #endif |
350 | else |
375 | else |
351 | switch (t) |
376 | switch (t) |
352 | { |
377 | { |
353 | case ZERO_WIDTH_CHAR: |
378 | case ZERO_WIDTH_CHAR: |
354 | break; |
379 | break; |
… | |
… | |
379 | |
404 | |
380 | rxvt_fontprop properties (); |
405 | rxvt_fontprop properties (); |
381 | |
406 | |
382 | bool load (const rxvt_fontprop &prop); |
407 | bool load (const rxvt_fontprop &prop); |
383 | |
408 | |
384 | bool has_codepoint (uint32_t unicode); |
409 | bool has_codepoint (unicode_t unicode); |
385 | |
410 | |
386 | void draw (rxvt_drawable &d, int x, int y, |
411 | void draw (rxvt_drawable &d, int x, int y, |
387 | const text_t *text, int len, |
412 | const text_t *text, int len, |
388 | int fg, int bg); |
413 | int fg, int bg); |
389 | |
414 | |
… | |
… | |
636 | f = 0; |
661 | f = 0; |
637 | } |
662 | } |
638 | } |
663 | } |
639 | |
664 | |
640 | bool |
665 | bool |
641 | rxvt_font_x11::has_codepoint (uint32_t unicode) |
666 | rxvt_font_x11::has_codepoint (unicode_t unicode) |
642 | { |
667 | { |
643 | uint32_t ch = FROM_UNICODE (cs, unicode); |
668 | uint32_t ch = FROM_UNICODE (cs, unicode); |
644 | |
669 | |
645 | if (ch == NOCHAR) |
670 | if (ch == NOCHAR) |
646 | return false; |
671 | return false; |
… | |
… | |
788 | |
813 | |
789 | void draw (rxvt_drawable &d, int x, int y, |
814 | void draw (rxvt_drawable &d, int x, int y, |
790 | const text_t *text, int len, |
815 | const text_t *text, int len, |
791 | int fg, int bg); |
816 | int fg, int bg); |
792 | |
817 | |
793 | bool has_codepoint (uint32_t unicode); |
818 | bool has_codepoint (unicode_t unicode); |
794 | |
819 | |
795 | protected: |
820 | protected: |
796 | XftFont *f; |
821 | XftFont *f; |
797 | }; |
822 | }; |
798 | |
823 | |
… | |
… | |
911 | |
936 | |
912 | return true; |
937 | return true; |
913 | } |
938 | } |
914 | |
939 | |
915 | bool |
940 | bool |
916 | rxvt_font_xft::has_codepoint (uint32_t unicode) |
941 | rxvt_font_xft::has_codepoint (unicode_t unicode) |
917 | { |
942 | { |
918 | return XftCharExists (DISPLAY, f, unicode); |
943 | return XftCharExists (DISPLAY, f, unicode); |
919 | } |
944 | } |
920 | |
945 | |
921 | void |
946 | void |
… | |
… | |
1017 | f = new rxvt_font_x11; |
1042 | f = new rxvt_font_x11; |
1018 | } |
1043 | } |
1019 | else |
1044 | else |
1020 | f = new rxvt_font_x11; |
1045 | f = new rxvt_font_x11; |
1021 | |
1046 | |
|
|
1047 | f->fs = this; |
1022 | f->set_term (r); |
1048 | f->set_term (r); |
1023 | f->set_name (strdup (name)); |
1049 | f->set_name (strdup (name)); |
1024 | |
1050 | |
1025 | f->cs = cs; |
1051 | f->cs = cs; |
1026 | f->loaded = false; |
1052 | f->loaded = false; |
… | |
… | |
1097 | |
1123 | |
1098 | bool |
1124 | bool |
1099 | rxvt_fontset::populate (const char *desc) |
1125 | rxvt_fontset::populate (const char *desc) |
1100 | { |
1126 | { |
1101 | clear (); |
1127 | clear (); |
1102 | printf ("P(%s)\n",desc); |
|
|
1103 | |
1128 | |
1104 | fonts.push_back (new_font (0, CS_UNICODE)); |
1129 | fonts.push_back (new_font (0, CS_UNICODE)); |
1105 | realize_font (0); |
1130 | realize_font (0); |
1106 | |
1131 | |
1107 | add_fonts (desc); |
1132 | add_fonts (desc); |
… | |
… | |
1124 | |
1149 | |
1125 | return true; |
1150 | return true; |
1126 | } |
1151 | } |
1127 | |
1152 | |
1128 | int |
1153 | int |
1129 | rxvt_fontset::find_font (uint32_t unicode) |
1154 | rxvt_fontset::find_font (unicode_t unicode) |
1130 | { |
1155 | { |
1131 | for (unsigned int i = 0; i < fonts.size (); i++) |
1156 | for (unsigned int i = 0; i < fonts.size (); i++) |
1132 | { |
1157 | { |
1133 | rxvt_font *f = fonts[i]; |
1158 | rxvt_font *f = fonts[i]; |
1134 | |
1159 | |