… | |
… | |
61 | # if XFT |
61 | # if XFT |
62 | // prefer xft for complex scripts |
62 | // prefer xft for complex scripts |
63 | { CS_UNICODE, "xft:Kochi Gothic:antialias=false" }, |
63 | { CS_UNICODE, "xft:Kochi Gothic:antialias=false" }, |
64 | # endif |
64 | # endif |
65 | { CS_JIS0201_1976_0, "-*-mincho-*-r-*--*-*-*-*-c-*-jisx0201*-0" }, |
65 | { CS_JIS0201_1976_0, "-*-mincho-*-r-*--*-*-*-*-c-*-jisx0201*-0" }, |
66 | { CS_JIS0208_1983_0, "-*-mincho-*-r-*--*-*-*-*-c-*-jisx0208*-0" }, |
66 | { CS_JIS0208_1990_0, "-*-mincho-*-r-*--*-*-*-*-c-*-jisx0208*-0" }, |
67 | { CS_JIS0212_1990_0, "-*-mincho-*-r-*--*-*-*-*-c-*-jisx0212*-0" }, |
67 | { CS_JIS0212_1990_0, "-*-mincho-*-r-*--*-*-*-*-c-*-jisx0212*-0" }, |
68 | #endif |
68 | #endif |
69 | |
69 | |
70 | #if ENCODING_CN || ENCODING_CN_EXT |
70 | #if ENCODING_CN || ENCODING_CN_EXT |
71 | # if XFT |
71 | # if XFT |
72 | { CS_BIG5_EXT, "xft:AR PL Mingti2L Big5" }, |
72 | { CS_BIG5_EXT, "xft:AR PL Mingti2L Big5" }, |
73 | { CS_BIG5_EXT, "xft:AR PL KaitiM Big5" }, |
73 | { CS_BIG5_EXT, "xft:AR PL KaitiM Big5" }, |
74 | { CS_GB2312_1980_0, "xft:AR PL KaitiM GB" }, |
74 | { CS_GB2312_1980_0, "xft:AR PL KaitiM GB" }, |
75 | { CS_GB2312_1980_0, "xft:AR PL SungtiL GB" }, |
75 | { CS_GB2312_1980_0, "xft:AR PL SungtiL GB" }, |
76 | # endif |
76 | # endif |
77 | { CS_BIG5_EXT, "-*-*-*-*-*-*-*-*-*-*-c-*-big5*-0" }, |
77 | { CS_BIG5, "-*-*-*-*-*-*-*-*-*-*-c-*-big5-0" }, |
|
|
78 | { CS_BIG5_PLUS, "-*-*-*-*-*-*-*-*-*-*-c-*-big5p-0" }, |
|
|
79 | { CS_BIG5_EXT, "-*-*-*-*-*-*-*-*-*-*-c-*-big5.eten-0" }, |
78 | { CS_CNS11643_1992_1, "-*-*-*-*-*-*-*-*-*-*-c-*-gb2312*-0" }, |
80 | { CS_CNS11643_1992_1, "-*-*-*-*-*-*-*-*-*-*-c-*-gb2312*-0" }, |
79 | { CS_CNS11643_1992_1, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-1" }, |
81 | { CS_CNS11643_1992_1, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-1" }, |
80 | { CS_CNS11643_1992_2, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-2" }, |
82 | { CS_CNS11643_1992_2, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-2" }, |
81 | { CS_CNS11643_1992_3, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-3" }, |
83 | { CS_CNS11643_1992_3, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-3" }, |
82 | { CS_CNS11643_1992_4, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-4" }, |
84 | { CS_CNS11643_1992_4, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-4" }, |
… | |
… | |
94 | { CS_UNICODE, "xft:FreeMono" }, |
96 | { CS_UNICODE, "xft:FreeMono" }, |
95 | { CS_UNICODE, "-*-unifont-*-*-*-*-*-*-*-*-c-*-iso10646-1" }, |
97 | { CS_UNICODE, "-*-unifont-*-*-*-*-*-*-*-*-c-*-iso10646-1" }, |
96 | { CS_UNICODE, "-*-*-*-r-*-*-*-*-*-*-c-*-iso10646-1" }, |
98 | { CS_UNICODE, "-*-*-*-r-*-*-*-*-*-*-c-*-iso10646-1" }, |
97 | { CS_UNICODE, "-*-*-*-r-*-*-*-*-*-*-m-*-iso10646-1" }, |
99 | { CS_UNICODE, "-*-*-*-r-*-*-*-*-*-*-m-*-iso10646-1" }, |
98 | |
100 | |
|
|
101 | #if UNICODE_3 && XFT |
|
|
102 | { CS_UNICODE, "xft:Code2001" }, // contains many plane-1 characters |
|
|
103 | #endif |
|
|
104 | |
99 | { CS_UNKNOWN, 0 } |
105 | { CS_UNKNOWN, 0 } |
100 | }; |
106 | }; |
101 | |
107 | |
102 | ///////////////////////////////////////////////////////////////////////////// |
108 | ///////////////////////////////////////////////////////////////////////////// |
103 | |
109 | |
… | |
… | |
262 | bool load (const rxvt_fontprop &prop) |
268 | bool load (const rxvt_fontprop &prop) |
263 | { |
269 | { |
264 | width = 1; height = 1; |
270 | width = 1; height = 1; |
265 | ascent = 1; descent = 0; |
271 | ascent = 1; descent = 0; |
266 | |
272 | |
|
|
273 | set_name ("built-in pseudofont"); |
|
|
274 | |
267 | return true; |
275 | return true; |
268 | } |
276 | } |
269 | |
277 | |
270 | bool has_codepoint (uint32_t unicode) |
278 | bool has_codepoint (unicode_t unicode) |
271 | { |
279 | { |
272 | if (unicode <= 0x001f) |
280 | if (unicode <= 0x001f) |
273 | return true; |
281 | return true; |
|
|
282 | |
274 | if (unicode >= 0x0080 && unicode <= 0x009f) |
283 | if (unicode >= 0x0080 && unicode <= 0x009f) |
275 | return true; |
284 | return true; |
276 | |
285 | |
277 | if (unicode >= 0x2500 && unicode <= 0x257f |
286 | if (unicode >= 0x2500 && unicode <= 0x257f |
278 | && linedraw_cmds[unicode - 0x2500]) |
287 | && linedraw_cmds[unicode - 0x2500]) |
|
|
288 | return true; |
|
|
289 | |
|
|
290 | if (IS_COMPOSE (unicode)) |
279 | return true; |
291 | return true; |
280 | |
292 | |
281 | switch (unicode) |
293 | switch (unicode) |
282 | { |
294 | { |
283 | case ZERO_WIDTH_CHAR: |
295 | case ZERO_WIDTH_CHAR: |
… | |
… | |
301 | |
313 | |
302 | XSetForeground (d.display->display, GC, r->PixColors[fg]); |
314 | XSetForeground (d.display->display, GC, r->PixColors[fg]); |
303 | |
315 | |
304 | while (len--) |
316 | while (len--) |
305 | { |
317 | { |
|
|
318 | #if ENABLE_COMBINING |
|
|
319 | compose_char *cc; |
|
|
320 | #endif |
306 | text_t t = *text++; |
321 | text_t t = *text++; |
307 | |
322 | |
308 | // is it in our linedrawing table? |
323 | // is it in our linedrawing table? |
309 | if (t >= 0x2500 & t <= 0x2580 && linedraw_cmds[t - 0x2500]) |
324 | if (t >= 0x2500 & t <= 0x2580 && linedraw_cmds[t - 0x2500]) |
310 | { |
325 | { |
311 | const char *p = linedraw_cmds[t - 0x2500]; |
326 | const char *p = linedraw_cmds[t - 0x2500]; |
312 | |
327 | |
313 | int x0 = x, x1 = x + r->TermWin.fwidth / 2, x2 = x + r->TermWin.fwidth - 1; |
328 | int x0 = x, x1 = x + (r->TermWin.fwidth - 1) / 2, x2 = x + r->TermWin.fwidth - 1; |
314 | int y0 = y, y1 = y + r->TermWin.fheight / 2, y2 = y + r->TermWin.fheight - 1; |
329 | int y0 = y, y1 = y + (r->TermWin.fheight - 1) / 2, y2 = y + r->TermWin.fheight - 1; |
315 | |
330 | |
316 | XGCValues gcv; |
331 | XGCValues gcv; |
317 | |
332 | |
318 | while (*p) |
333 | while (*p) |
319 | { |
334 | { |
… | |
… | |
339 | } |
354 | } |
340 | |
355 | |
341 | gcv.line_width = 0; |
356 | gcv.line_width = 0; |
342 | XChangeGC (d.display->display, GC, GCLineWidth, &gcv); |
357 | XChangeGC (d.display->display, GC, GCLineWidth, &gcv); |
343 | } |
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 |
344 | else |
375 | else |
345 | switch (t) |
376 | switch (t) |
346 | { |
377 | { |
347 | case ZERO_WIDTH_CHAR: |
378 | case ZERO_WIDTH_CHAR: |
348 | break; |
379 | break; |
… | |
… | |
373 | |
404 | |
374 | rxvt_fontprop properties (); |
405 | rxvt_fontprop properties (); |
375 | |
406 | |
376 | bool load (const rxvt_fontprop &prop); |
407 | bool load (const rxvt_fontprop &prop); |
377 | |
408 | |
378 | bool has_codepoint (uint32_t unicode); |
409 | bool has_codepoint (unicode_t unicode); |
379 | |
410 | |
380 | void draw (rxvt_drawable &d, int x, int y, |
411 | void draw (rxvt_drawable &d, int x, int y, |
381 | const text_t *text, int len, |
412 | const text_t *text, int len, |
382 | int fg, int bg); |
413 | int fg, int bg); |
383 | |
414 | |
… | |
… | |
440 | |
471 | |
441 | bool |
472 | bool |
442 | rxvt_font_x11::set_properties (rxvt_fontprop &p, const char *name) |
473 | rxvt_font_x11::set_properties (rxvt_fontprop &p, const char *name) |
443 | { |
474 | { |
444 | int slashes = 0; |
475 | int slashes = 0; |
445 | const char *comp[12]; |
476 | const char *comp[13]; |
446 | |
477 | |
447 | for (const char *c = name; *c; c++) |
478 | for (const char *c = name; *c; c++) |
448 | if (*c == '-') |
479 | if (*c == '-') |
449 | { |
480 | { |
450 | comp[slashes++] = c + 1; |
481 | comp[slashes++] = c + 1; |
… | |
… | |
630 | f = 0; |
661 | f = 0; |
631 | } |
662 | } |
632 | } |
663 | } |
633 | |
664 | |
634 | bool |
665 | bool |
635 | rxvt_font_x11::has_codepoint (uint32_t unicode) |
666 | rxvt_font_x11::has_codepoint (unicode_t unicode) |
636 | { |
667 | { |
637 | uint32_t ch = FROM_UNICODE (cs, unicode); |
668 | uint32_t ch = FROM_UNICODE (cs, unicode); |
638 | |
669 | |
639 | if (ch == NOCHAR) |
670 | if (ch == NOCHAR) |
640 | return false; |
671 | return false; |
… | |
… | |
782 | |
813 | |
783 | void draw (rxvt_drawable &d, int x, int y, |
814 | void draw (rxvt_drawable &d, int x, int y, |
784 | const text_t *text, int len, |
815 | const text_t *text, int len, |
785 | int fg, int bg); |
816 | int fg, int bg); |
786 | |
817 | |
787 | bool has_codepoint (uint32_t unicode); |
818 | bool has_codepoint (unicode_t unicode); |
788 | |
819 | |
789 | protected: |
820 | protected: |
790 | XftFont *f; |
821 | XftFont *f; |
791 | }; |
822 | }; |
792 | |
823 | |
… | |
… | |
905 | |
936 | |
906 | return true; |
937 | return true; |
907 | } |
938 | } |
908 | |
939 | |
909 | bool |
940 | bool |
910 | rxvt_font_xft::has_codepoint (uint32_t unicode) |
941 | rxvt_font_xft::has_codepoint (unicode_t unicode) |
911 | { |
942 | { |
912 | return XftCharExists (DISPLAY, f, unicode); |
943 | return XftCharExists (DISPLAY, f, unicode); |
913 | } |
944 | } |
914 | |
945 | |
915 | void |
946 | void |
… | |
… | |
1011 | f = new rxvt_font_x11; |
1042 | f = new rxvt_font_x11; |
1012 | } |
1043 | } |
1013 | else |
1044 | else |
1014 | f = new rxvt_font_x11; |
1045 | f = new rxvt_font_x11; |
1015 | |
1046 | |
|
|
1047 | f->fs = this; |
1016 | f->set_term (r); |
1048 | f->set_term (r); |
1017 | f->set_name (strdup (name)); |
1049 | f->set_name (strdup (name)); |
1018 | |
1050 | |
1019 | f->cs = cs; |
1051 | f->cs = cs; |
1020 | f->loaded = false; |
1052 | f->loaded = false; |
… | |
… | |
1117 | |
1149 | |
1118 | return true; |
1150 | return true; |
1119 | } |
1151 | } |
1120 | |
1152 | |
1121 | int |
1153 | int |
1122 | rxvt_fontset::find_font (uint32_t unicode) |
1154 | rxvt_fontset::find_font (unicode_t unicode) |
1123 | { |
1155 | { |
1124 | for (unsigned int i = 0; i < fonts.size (); i++) |
1156 | for (unsigned int i = 0; i < fonts.size (); i++) |
1125 | { |
1157 | { |
1126 | rxvt_font *f = fonts[i]; |
1158 | rxvt_font *f = fonts[i]; |
1127 | |
1159 | |