--- rxvt-unicode/src/defaultfont.C 2004/02/27 02:52:51 1.26 +++ rxvt-unicode/src/defaultfont.C 2004/03/15 06:13:35 1.42 @@ -63,7 +63,7 @@ { CS_UNICODE, "xft:Kochi Gothic:antialias=false" }, # endif { CS_JIS0201_1976_0, "-*-mincho-*-r-*--*-*-*-*-c-*-jisx0201*-0" }, - { CS_JIS0208_1983_0, "-*-mincho-*-r-*--*-*-*-*-c-*-jisx0208*-0" }, + { CS_JIS0208_1990_0, "-*-mincho-*-r-*--*-*-*-*-c-*-jisx0208*-0" }, { CS_JIS0212_1990_0, "-*-mincho-*-r-*--*-*-*-*-c-*-jisx0212*-0" }, #endif @@ -74,15 +74,18 @@ { CS_GB2312_1980_0, "xft:AR PL KaitiM GB" }, { CS_GB2312_1980_0, "xft:AR PL SungtiL GB" }, # endif - { CS_CNS11643_1992_1, "-*-*-*-*-*-*-*-*-*-*-c-*-gb2312*-0" }, - { CS_CNS11643_1992_1, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-1" }, - { CS_CNS11643_1992_2, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-2" }, - { CS_CNS11643_1992_3, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-3" }, - { CS_CNS11643_1992_4, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-4" }, - { CS_CNS11643_1992_5, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-5" }, - { CS_CNS11643_1992_6, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-6" }, - { CS_CNS11643_1992_7, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-7" }, - { CS_CNS11643_1992_F, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-f" }, + { CS_BIG5, "-*-*-*-*-*-*-*-*-*-*-c-*-big5-0" }, + { CS_BIG5_PLUS, "-*-*-*-*-*-*-*-*-*-*-c-*-big5p-0" }, + { CS_BIG5_EXT, "-*-*-*-*-*-*-*-*-*-*-c-*-big5.eten-0" }, + { CS_CNS11643_1992_1, "-*-*-*-*-*-*-*-*-*-*-c-*-gb2312*-0" }, + { CS_CNS11643_1992_1, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-1" }, + { CS_CNS11643_1992_2, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-2" }, + { CS_CNS11643_1992_3, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-3" }, + { CS_CNS11643_1992_4, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-4" }, + { CS_CNS11643_1992_5, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-5" }, + { CS_CNS11643_1992_6, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-6" }, + { CS_CNS11643_1992_7, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-7" }, + { CS_CNS11643_1992_F, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-f" }, #endif #if XFT @@ -95,6 +98,10 @@ { CS_UNICODE, "-*-*-*-r-*-*-*-*-*-*-c-*-iso10646-1" }, { CS_UNICODE, "-*-*-*-r-*-*-*-*-*-*-m-*-iso10646-1" }, +#if UNICODE_3 && XFT + { CS_UNICODE, "xft:Code2001" }, // contains many plane-1 characters +#endif + { CS_UNKNOWN, 0 } }; @@ -196,7 +203,7 @@ } static const char *linedraw_cmds[128] = { - "1hH", "2hH", "1vV", "2vV", + "1-", "2-", "1|", "2|", 0, 0, 0, 0, 0, 0, 0, 0, "1HV", "2H1V", "1H2V", "2HV", @@ -205,24 +212,24 @@ "1hV", "2h1V", "1h2V", "2hV", "1Hv", "2H1v", "1H2v", "2Hv", "1hv", "2h1v", "1h2v", "2hv", - "1HvV", "2H1vV", "1HV2v", "1Hv2V", + "1H|", "2H1|", "1HV2v", "1Hv2V", // 2520 - "1H2vV", "2Hv1V", "2HV1v", "2HvV", - "1hvV", "2h1vV", "1hV2v", "1hv2V", - "1h2vV", "2hv1V", "1v2hV", "2hvV", - "1hHV", "2h1HV", "2H1hV", "2hH1V", + "1H2|", "2Hv1V", "2HV1v", "2H|", + "1h|", "2h1|", "1hV2v", "1hv2V", + "1h2|", "2hv1V", "1v2hV", "2h|", + "1-V", "2h1HV", "2H1hV", "2-1V", // 2530 - "1hH2V", "2hV1H", "1h2HV", "2hHV", - "1hHv", "1vH2h", "1hv2H", "1v2hH", - "1hH2v", "1H2hv", "1h2Hv", "2hHv", - "1hHvV", "1vVH2h", "1hvV2H", "1vV2hH", + "1-2V", "2hV1H", "1h2HV", "2-V", + "1-v", "1vH2h", "1hv2H", "1v2-", + "1-2v", "1H2hv", "1h2Hv", "2-v", + "1-|", "1|H2h", "1h|2H", "1|2-", // 2540 - "1hHV2v", "1hHv2V", "1hH2vV", "1HV2hv", - "1hV2Hv", "1Hv2hV", "1hv2HV", "1V2hHv", - "1v2hHV", "1H2hvV", "1h2HvV", "2hHvV", + "1-V2v", "1-v2V", "1-2|", "1HV2hv", + "1hV2Hv", "1Hv2hV", "1hv2HV", "1V2-v", + "1v2-V", "1H2h|", "1h2H|", "2-|", 0, 0, 0, 0, // 2550 @@ -235,10 +242,10 @@ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, + 0, "A", "B", "C", // 2570 - 0, "1a", "1b", "1ab", + "D", "1/", "1\\", "1/\\", "1h", "1v", "1H", "1V", "2h", "2v", "2H", "2V", "1h2H", "1v2V", "1H2h", "1V2v" @@ -263,13 +270,16 @@ width = 1; height = 1; ascent = 1; descent = 0; + set_name ("built-in pseudofont"); + return true; } - bool has_codepoint (uint32_t unicode) + bool has_codepoint (unicode_t unicode) { if (unicode <= 0x001f) return true; + if (unicode >= 0x0080 && unicode <= 0x009f) return true; @@ -277,6 +287,9 @@ && linedraw_cmds[unicode - 0x2500]) return true; + if (IS_COMPOSE (unicode)) + return true; + switch (unicode) { case ZERO_WIDTH_CHAR: @@ -302,17 +315,26 @@ while (len--) { +#if ENABLE_COMBINING + compose_char *cc; +#endif text_t t = *text++; + // is it in our linedrawing table? if (t >= 0x2500 & t <= 0x2580 && linedraw_cmds[t - 0x2500]) { const char *p = linedraw_cmds[t - 0x2500]; - int x0 = x, x1 = x + r->TermWin.fwidth / 2, x2 = x + r->TermWin.fwidth - 1; - int y0 = y, y1 = y + r->TermWin.fheight / 2, y2 = y + r->TermWin.fheight - 1; + int W = r->TermWin.fwidth , w = (W - 1) / 2; + int H = r->TermWin.fheight, h = (H - 1) / 2; + int x0 = x, x1 = x + w, x2 = x + r->TermWin.fwidth ; + int y0 = y, y1 = y + h, y2 = y + r->TermWin.fheight; XGCValues gcv; + gcv.cap_style = CapNotLast; + XChangeGC (d.display->display, GC, GCCapStyle, &gcv); + while (*p) { switch (*p++) @@ -323,30 +345,64 @@ break; case '2': - gcv.line_width = 2; + gcv.line_width = 3; XChangeGC (d.display->display, GC, GCLineWidth, &gcv); break; - case 'h': XDrawLine (d.display->display, d, GC, x0, y1, x1, y1); break; - case 'H': XDrawLine (d.display->display, d, GC, x1, y1, x2, y1); break; - case 'v': XDrawLine (d.display->display, d, GC, x1, y0, x1, y1); break; - case 'V': XDrawLine (d.display->display, d, GC, x1, y1, x1, y2); break; - case 'a': XDrawLine (d.display->display, d, GC, x0, y2, x2, y0); break; - case 'b': XDrawLine (d.display->display, d, GC, x0, y0, x2, y2); break; + case 'h': XDrawLine (d.display->display, d, GC, x0, y1, x1+1, y1 ); break; + case 'H': XDrawLine (d.display->display, d, GC, x2, y1, x1-1, y1 ); break; + case '-': XDrawLine (d.display->display, d, GC, x0, y1, x2 , y1 ); break; + case 'v': XDrawLine (d.display->display, d, GC, x1, y0, x1 , y1+1); break; + case 'V': XDrawLine (d.display->display, d, GC, x1, y2, x1 , y1-1); break; + case '|': XDrawLine (d.display->display, d, GC, x1, y0, x1 , y2 ); break; + + case '/' : XDrawLine (d.display->display, d, GC, x0, y2, x2 , y0 ); break; + case '\\': XDrawLine (d.display->display, d, GC, x0, y0, x2 , y2 ); break; + + case 'A': XDrawArc (d.display->display, d, GC, x1 , y1 , W-1, H-1, 90*64, 90*64); break; + case 'B': XDrawArc (d.display->display, d, GC, x1-W+1, y1 , W-1, H-1, 0*64, 90*64); break; + case 'C': XDrawArc (d.display->display, d, GC, x1-W+1, y1-H+1, W-1, H-1, 0*64, -90*64); break; + case 'D': XDrawArc (d.display->display, d, GC, x1 , y1-H+1, W-1, H-1, -90*64, -90*64); break; } } gcv.line_width = 0; XChangeGC (d.display->display, GC, GCLineWidth, &gcv); } + +#if ENABLE_COMBINING + else if (IS_COMPOSE (t) && (cc = rxvt_composite[t])) + { + rxvt_font *f1 = (*fs)[fs->find_font (cc->c1)]; + f1->draw (d, x, y, &(t = cc->c1), 1, fg, bg); + if (cc->c2 != NOCHAR) + { + // prefer font of first character, for no good reasons + rxvt_font *f2 = f1->has_codepoint (cc->c2) + ? f1 + : (*fs)[fs->find_font (cc->c2)]; + + f2->draw (d, x, y, &(t = cc->c2), 1, fg, -1); + } + } +#endif else - switch (*text++) + switch (t) { - case NOCHAR: case ZERO_WIDTH_CHAR: break; default: - XDrawRectangle (d.display->display, d, GC, x + 2, y + 2, r->TermWin.fwidth - 5, r->TermWin.fheight - 5); + int w = 0; + while (len > 0 && *text == NOCHAR) + { + ++text; + --len; + w += r->TermWin.fwidth; + } + + XDrawRectangle (d.display->display, d, GC, x + 2, y + 2, + w + r->TermWin.fwidth - 5, r->TermWin.fheight - 5); + x += w; } x += r->TermWin.fwidth; @@ -364,7 +420,7 @@ bool load (const rxvt_fontprop &prop); - bool has_codepoint (uint32_t unicode); + bool has_codepoint (unicode_t unicode); void draw (rxvt_drawable &d, int x, int y, const text_t *text, int len, @@ -431,7 +487,7 @@ rxvt_font_x11::set_properties (rxvt_fontprop &p, const char *name) { int slashes = 0; - const char *comp[12]; + const char *comp[13]; for (const char *c = name; *c; c++) if (*c == '-') @@ -621,7 +677,7 @@ } bool -rxvt_font_x11::has_codepoint (uint32_t unicode) +rxvt_font_x11::has_codepoint (unicode_t unicode) { uint32_t ch = FROM_UNICODE (cs, unicode); @@ -773,7 +829,7 @@ const text_t *text, int len, int fg, int bg); - bool has_codepoint (uint32_t unicode); + bool has_codepoint (unicode_t unicode); protected: XftFont *f; @@ -896,7 +952,7 @@ } bool -rxvt_font_xft::has_codepoint (uint32_t unicode) +rxvt_font_xft::has_codepoint (unicode_t unicode) { return XftCharExists (DISPLAY, f, unicode); } @@ -1002,6 +1058,7 @@ else f = new rxvt_font_x11; + f->fs = this; f->set_term (r); f->set_name (strdup (name)); @@ -1108,7 +1165,7 @@ } int -rxvt_fontset::find_font (uint32_t unicode) +rxvt_fontset::find_font (unicode_t unicode) { for (unsigned int i = 0; i < fonts.size (); i++) {