… | |
… | |
88 | { CS_JIS0201_1976_0, "-*-*-*-r-*--*-*-*-*-c-*-jisx0201*-0" }, |
88 | { CS_JIS0201_1976_0, "-*-*-*-r-*--*-*-*-*-c-*-jisx0201*-0" }, |
89 | { CS_JIS0208_1990_0, "-*-*-*-r-*--*-*-*-*-c-*-jisx0208*-0" }, |
89 | { CS_JIS0208_1990_0, "-*-*-*-r-*--*-*-*-*-c-*-jisx0208*-0" }, |
90 | { CS_JIS0212_1990_0, "-*-*-*-r-*--*-*-*-*-c-*-jisx0212*-0" }, |
90 | { CS_JIS0212_1990_0, "-*-*-*-r-*--*-*-*-*-c-*-jisx0212*-0" }, |
91 | #endif |
91 | #endif |
92 | |
92 | |
93 | #if ENCODING_CN || ENCODING_CN_EXT |
93 | #if ENCODING_ZH || ENCODING_ZH_EXT |
94 | # if XFT |
94 | # if XFT |
|
|
95 | { CS_GBK_0, "xft:AR PL KaitiM GB" }, |
|
|
96 | { CS_GBK_0, "xft:AR PL SungtiL GB" }, |
|
|
97 | { CS_GBK_0, "xft::spacing=100:lang=zh" }, |
95 | { CS_BIG5_EXT, "xft:AR PL Mingti2L Big5" }, |
98 | { CS_BIG5_EXT, "xft:AR PL Mingti2L Big5" }, |
96 | { CS_BIG5_EXT, "xft:AR PL KaitiM Big5" }, |
99 | { CS_BIG5_EXT, "xft:AR PL KaitiM Big5" }, |
97 | { CS_GB2312_1980_0, "xft:AR PL KaitiM GB" }, |
100 | { CS_GB2312_1980_0, "xft:AR PL KaitiM GB" }, |
98 | { CS_GB2312_1980_0, "xft:AR PL SungtiL GB" }, |
101 | { CS_GB2312_1980_0, "xft:AR PL SungtiL GB" }, |
99 | { CS_GB2312_1980_0, "xft::spacing=100:lang=zh" }, |
102 | { CS_GB2312_1980_0, "xft::spacing=100:lang=zh" }, |
100 | # endif |
103 | # endif |
|
|
104 | { CS_GBK_0, "-*-*-*-*-*-*-*-*-*-*-c-*-gbk*-0" }, |
101 | { CS_BIG5, "-*-*-*-*-*-*-*-*-*-*-c-*-big5-0" }, |
105 | { CS_BIG5, "-*-*-*-*-*-*-*-*-*-*-c-*-big5-0" }, |
102 | { CS_BIG5_PLUS, "-*-*-*-*-*-*-*-*-*-*-c-*-big5p-0" }, |
106 | { CS_BIG5_PLUS, "-*-*-*-*-*-*-*-*-*-*-c-*-big5p-0" }, |
103 | { CS_BIG5_EXT, "-*-*-*-*-*-*-*-*-*-*-c-*-big5.eten-0" }, |
107 | { CS_BIG5_EXT, "-*-*-*-*-*-*-*-*-*-*-c-*-big5.eten-0" }, |
|
|
108 | { CS_GB2312_1980_0, "-*-*-*-*-*-*-*-*-*-*-c-*-gb2312*-0" }, |
104 | { CS_CNS11643_1992_1, "-*-*-*-*-*-*-*-*-*-*-c-*-gb2312*-0" }, |
109 | { CS_CNS11643_1992_1, "-*-*-*-*-*-*-*-*-*-*-c-*-gb2312*-0" }, |
105 | { CS_CNS11643_1992_1, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-1" }, |
110 | { CS_CNS11643_1992_1, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-1" }, |
106 | { CS_CNS11643_1992_2, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-2" }, |
111 | { CS_CNS11643_1992_2, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-2" }, |
107 | { CS_CNS11643_1992_3, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-3" }, |
112 | { CS_CNS11643_1992_3, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-3" }, |
108 | { CS_CNS11643_1992_4, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-4" }, |
113 | { CS_CNS11643_1992_4, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-4" }, |
… | |
… | |
125 | { CS_UNICODE, "-*-lucidatypewriter-*-*-*-*-*-*-*-*-m-*-iso10646-1" }, |
130 | { CS_UNICODE, "-*-lucidatypewriter-*-*-*-*-*-*-*-*-m-*-iso10646-1" }, |
126 | { CS_UNICODE, "-*-unifont-*-*-*-*-*-*-*-*-c-*-iso10646-1" }, |
131 | { CS_UNICODE, "-*-unifont-*-*-*-*-*-*-*-*-c-*-iso10646-1" }, |
127 | { CS_UNICODE, "-*-*-*-r-*-*-*-*-*-*-c-*-iso10646-1" }, |
132 | { CS_UNICODE, "-*-*-*-r-*-*-*-*-*-*-c-*-iso10646-1" }, |
128 | { CS_UNICODE, "-*-*-*-r-*-*-*-*-*-*-m-*-iso10646-1" }, |
133 | { CS_UNICODE, "-*-*-*-r-*-*-*-*-*-*-m-*-iso10646-1" }, |
129 | #if XFT |
134 | #if XFT |
130 | { CS_UNICODE, "xft:Bitstream Vera Sans Mono:antialias=false"}, |
135 | { CS_UNICODE, "xft:Bitstream Vera Sans Mono:antialias=false:autohint=true"}, |
|
|
136 | { CS_UNICODE, "xft:Courier New:antialias=false:autohint=true" }, |
131 | { CS_UNICODE, "xft:Andale Mono:antialias=false" }, |
137 | { CS_UNICODE, "xft:Andale Mono:antialias=false" }, |
132 | { CS_UNICODE, "xft:Arial Unicode MS:antialias=false" }, |
138 | { CS_UNICODE, "xft:Arial Unicode MS:antialias=false" }, |
133 | { CS_UNICODE, "xft:Courier New:antialias=false" }, |
|
|
134 | |
139 | |
135 | // FreeMono is usually uglier than x fonts, so try last only. |
140 | // FreeMono is usually uglier than x fonts, so try last only. |
136 | { CS_UNICODE, "xft:FreeMono" }, |
141 | { CS_UNICODE, "xft:FreeMono:autohint=true" }, |
137 | #endif |
142 | #endif |
138 | |
143 | |
139 | { CS_UNKNOWN, 0 } |
144 | { CS_UNKNOWN, 0 } |
140 | }; |
145 | }; |
141 | |
146 | |
… | |
… | |
330 | { |
335 | { |
331 | clear_rect (d, x, y, r->TermWin.fwidth * len, r->TermWin.fheight, bg); |
336 | clear_rect (d, x, y, r->TermWin.fwidth * len, r->TermWin.fheight, bg); |
332 | |
337 | |
333 | XSetForeground (d.display->display, TGC, r->pix_colors[fg]); |
338 | XSetForeground (d.display->display, TGC, r->pix_colors[fg]); |
334 | |
339 | |
335 | while (len--) |
340 | while (len) |
336 | { |
341 | { |
337 | #if ENABLE_COMBINING |
342 | #if ENABLE_COMBINING |
338 | compose_char *cc; |
343 | compose_char *cc; |
339 | #endif |
344 | #endif |
|
|
345 | const text_t *tp = text; |
340 | text_t t = *text++; |
346 | text_t t = *tp; |
|
|
347 | |
|
|
348 | while (++text, --len && *text == NOCHAR) |
|
|
349 | ; |
|
|
350 | |
|
|
351 | int width = text - tp; |
|
|
352 | int fwidth = r->TermWin.fwidth * width; |
341 | |
353 | |
342 | if (0x2500 <= t && t <= 0x259f) |
354 | if (0x2500 <= t && t <= 0x259f) |
343 | { |
355 | { |
344 | uint16_t offs = linedraw_offs[t - 0x2500]; |
356 | uint16_t offs = linedraw_offs[t - 0x2500]; |
345 | uint32_t *a = linedraw_command + (offs >> 4); |
357 | uint32_t *a = linedraw_command + (offs >> 4); |
346 | uint32_t *b = a + (offs & 15); |
358 | uint32_t *b = a + (offs & 15); |
347 | |
359 | |
348 | int W = r->TermWin.fwidth; |
360 | int W = fwidth; |
349 | int H = r->TermWin.fheight; |
361 | int H = r->TermWin.fheight; |
350 | |
362 | |
351 | int x_[16]; |
363 | int x_[16]; |
352 | int y_[16]; |
364 | int y_[16]; |
353 | |
365 | |
… | |
… | |
418 | } |
430 | } |
419 | } |
431 | } |
420 | #if ENABLE_COMBINING |
432 | #if ENABLE_COMBINING |
421 | else if (IS_COMPOSE (t) && (cc = rxvt_composite[t])) |
433 | else if (IS_COMPOSE (t) && (cc = rxvt_composite[t])) |
422 | { |
434 | { |
|
|
435 | text_t chrs[2]; |
|
|
436 | width = min (2, width); |
|
|
437 | chrs [1] = NOCHAR; |
|
|
438 | |
|
|
439 | *chrs = cc->c1; |
423 | rxvt_font *f1 = (*fs)[fs->find_font (cc->c1)]; |
440 | rxvt_font *f1 = (*fs)[fs->find_font (cc->c1)]; |
424 | f1->draw (d, x, y, &(t = cc->c1), 1, fg, bg); |
441 | f1->draw (d, x, y, chrs, width, fg, bg); |
|
|
442 | |
425 | if (cc->c2 != NOCHAR) |
443 | if (cc->c2 != NOCHAR) |
426 | { |
444 | { |
|
|
445 | bool careful; |
|
|
446 | |
427 | // prefer font of first character, for no good reasons |
447 | // prefer font of first character, for no good reasons |
428 | bool careful; |
448 | *chrs = cc->c2; |
429 | rxvt_font *f2 = f1->has_char (cc->c2, 0, careful) |
449 | rxvt_font *f2 = (f1->has_char (cc->c2, 0, careful) && !careful) |
430 | ? f1 |
450 | ? f1 |
431 | : (*fs)[fs->find_font (cc->c2)]; |
451 | : (*fs)[fs->find_font (cc->c2)]; |
432 | |
452 | |
433 | f2->draw (d, x, y, &(t = cc->c2), 1, fg, -1); |
453 | f2->draw (d, x, y, chrs, width, fg, -1); |
434 | } |
454 | } |
435 | } |
455 | } |
436 | #endif |
456 | #endif |
437 | else |
457 | else |
438 | switch (t) |
458 | switch (t) |
… | |
… | |
441 | case ZERO_WIDTH_CHAR: |
461 | case ZERO_WIDTH_CHAR: |
442 | case NOCHAR: |
462 | case NOCHAR: |
443 | break; |
463 | break; |
444 | |
464 | |
445 | default: |
465 | default: |
446 | int w = 0; |
|
|
447 | while (len > 0 && *text == NOCHAR) |
|
|
448 | { |
|
|
449 | ++text; |
|
|
450 | --len; |
|
|
451 | w += r->TermWin.fwidth; |
|
|
452 | } |
|
|
453 | |
|
|
454 | XDrawRectangle (d.display->display, d, TGC, x + 2, y + 2, |
466 | XDrawRectangle (d.display->display, d, TGC, x + 2, y + 2, |
455 | w + r->TermWin.fwidth - 4, r->TermWin.fheight - 4); |
467 | fwidth - 4, r->TermWin.fheight - 4); |
456 | x += w; |
|
|
457 | } |
468 | } |
458 | |
469 | |
459 | x += r->TermWin.fwidth; |
470 | x += fwidth; |
460 | } |
471 | } |
461 | } |
472 | } |
462 | |
473 | |
463 | ///////////////////////////////////////////////////////////////////////////// |
474 | ///////////////////////////////////////////////////////////////////////////// |
464 | |
475 | |
… | |
… | |
678 | { |
689 | { |
679 | rxvt_fontprop p; |
690 | rxvt_fontprop p; |
680 | char fname[1024]; |
691 | char fname[1024]; |
681 | |
692 | |
682 | int diff = 0; |
693 | int diff = 0; |
683 | |
694 | |
684 | if (replace_field (fname, list[i], 6, '0', field_str)) |
695 | if (replace_field (fname, list[i], 6, '0', field_str)) |
685 | diff += 10; // slightly penalize scalable fonts |
696 | diff += 10; // slightly penalize scalable fonts |
686 | |
697 | |
687 | if (!set_properties (p, fname)) |
698 | if (!set_properties (p, fname)) |
688 | continue; |
699 | continue; |
… | |
… | |
1042 | return false; |
1053 | return false; |
1043 | |
1054 | |
1044 | FcValue v; |
1055 | FcValue v; |
1045 | |
1056 | |
1046 | if (prop.height != rxvt_fontprop::unset |
1057 | if (prop.height != rxvt_fontprop::unset |
1047 | && FcPatternGet (p, FC_PIXEL_SIZE, 0, &v) != FcResultMatch) |
1058 | || (FcPatternGet (p, FC_PIXEL_SIZE, 0, &v) != FcResultMatch |
|
|
1059 | && FcPatternGet (p, FC_SIZE, 0, &v) != FcResultMatch)) |
1048 | FcPatternAddInteger (p, FC_PIXEL_SIZE, prop.height); |
1060 | FcPatternAddInteger (p, FC_PIXEL_SIZE, prop.height); |
1049 | |
1061 | |
1050 | if (prop.weight != rxvt_fontprop::unset |
1062 | if (prop.weight != rxvt_fontprop::unset |
1051 | && FcPatternGet (p, FC_WEIGHT, 0, &v) != FcResultMatch) |
1063 | && FcPatternGet (p, FC_WEIGHT, 0, &v) != FcResultMatch) |
1052 | FcPatternAddInteger (p, FC_WEIGHT, prop.weight); |
1064 | FcPatternAddInteger (p, FC_WEIGHT, prop.weight); |
… | |
… | |
1264 | } |
1276 | } |
1265 | |
1277 | |
1266 | void |
1278 | void |
1267 | rxvt_fontset::clear () |
1279 | rxvt_fontset::clear () |
1268 | { |
1280 | { |
|
|
1281 | prop.width = prop.height = prop.weight = prop.slant |
|
|
1282 | = rxvt_fontprop::unset; |
|
|
1283 | |
1269 | for (rxvt_font **i = fonts.begin (); i != fonts.end (); i++) |
1284 | for (rxvt_font **i = fonts.begin (); i != fonts.end (); i++) |
1270 | FONT_UNREF (*i); |
1285 | FONT_UNREF (*i); |
1271 | |
1286 | |
1272 | for (pagemap **p = fmap.begin (); p != fmap.end (); p++) |
1287 | for (pagemap **p = fmap.begin (); p != fmap.end (); p++) |
1273 | delete *p; |
1288 | delete *p; |
… | |
… | |
1393 | |
1408 | |
1394 | return true; |
1409 | return true; |
1395 | } |
1410 | } |
1396 | |
1411 | |
1397 | bool |
1412 | bool |
1398 | rxvt_fontset::populate (const char *desc, const rxvt_fontprop &prop) |
1413 | rxvt_fontset::populate (const char *desc) |
1399 | { |
1414 | { |
1400 | clear (); |
1415 | clear (); |
1401 | |
1416 | |
1402 | fontdesc = strdup (desc); |
1417 | fontdesc = strdup (desc); |
1403 | |
1418 | |
1404 | fonts.push_back (new_font (0, CS_UNICODE)); |
1419 | fonts.push_back (new_font (0, CS_UNICODE)); |
1405 | realize_font (0); |
1420 | realize_font (0); |
1406 | |
|
|
1407 | this->prop = prop; |
|
|
1408 | |
1421 | |
1409 | add_fonts (desc); |
1422 | add_fonts (desc); |
1410 | |
1423 | |
1411 | return true; |
1424 | return true; |
1412 | } |
1425 | } |