ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/defaultfont.C
(Generate patch)

Comparing rxvt-unicode/src/defaultfont.C (file contents):
Revision 1.25 by pcg, Tue Feb 24 23:58:12 2004 UTC vs.
Revision 1.40 by pcg, Mon Mar 15 00:08:11 2004 UTC

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, "-*-*-*-*-*-*-*-*-*-*-c-*-big5-0" },
78 { CS_BIG5_PLUS, "-*-*-*-*-*-*-*-*-*-*-c-*-big5p-0" },
79 { CS_BIG5_EXT, "-*-*-*-*-*-*-*-*-*-*-c-*-big5.eten-0" },
77 { CS_CNS11643_1992_1, "-*-*-*-*-*-*-*-*-*-*-c-*-gb2312*-0" }, 80 { CS_CNS11643_1992_1, "-*-*-*-*-*-*-*-*-*-*-c-*-gb2312*-0" },
78 { CS_CNS11643_1992_1, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-1" }, 81 { CS_CNS11643_1992_1, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-1" },
79 { CS_CNS11643_1992_2, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-2" }, 82 { CS_CNS11643_1992_2, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-2" },
80 { CS_CNS11643_1992_3, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-3" }, 83 { CS_CNS11643_1992_3, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-3" },
81 { CS_CNS11643_1992_4, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-4" }, 84 { CS_CNS11643_1992_4, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-4" },
82 { CS_CNS11643_1992_5, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-5" }, 85 { CS_CNS11643_1992_5, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-5" },
83 { CS_CNS11643_1992_6, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-6" }, 86 { CS_CNS11643_1992_6, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-6" },
84 { CS_CNS11643_1992_7, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-7" }, 87 { CS_CNS11643_1992_7, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-7" },
85 { CS_CNS11643_1992_F, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-f" }, 88 { CS_CNS11643_1992_F, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-f" },
86#endif 89#endif
87 90
88#if XFT 91#if XFT
89 { CS_UNICODE, "xft:Andale Mono" }, 92 { CS_UNICODE, "xft:Andale Mono" },
90 { CS_UNICODE, "xft:Arial Unicode MS" }, 93 { CS_UNICODE, "xft:Arial Unicode MS" },
93 { CS_UNICODE, "xft:FreeMono" }, 96 { CS_UNICODE, "xft:FreeMono" },
94 { CS_UNICODE, "-*-unifont-*-*-*-*-*-*-*-*-c-*-iso10646-1" }, 97 { CS_UNICODE, "-*-unifont-*-*-*-*-*-*-*-*-c-*-iso10646-1" },
95 { CS_UNICODE, "-*-*-*-r-*-*-*-*-*-*-c-*-iso10646-1" }, 98 { CS_UNICODE, "-*-*-*-r-*-*-*-*-*-*-c-*-iso10646-1" },
96 { CS_UNICODE, "-*-*-*-r-*-*-*-*-*-*-m-*-iso10646-1" }, 99 { CS_UNICODE, "-*-*-*-r-*-*-*-*-*-*-m-*-iso10646-1" },
97 100
101#if UNICODE_3 && XFT
102 { CS_UNICODE, "xft:Code2001" }, // contains many plane-1 characters
103#endif
104
98 { CS_UNKNOWN, 0 } 105 { CS_UNKNOWN, 0 }
99}; 106};
100 107
101///////////////////////////////////////////////////////////////////////////// 108/////////////////////////////////////////////////////////////////////////////
102 109
110#if XFT
103rxvt_drawable::~rxvt_drawable () 111rxvt_drawable::~rxvt_drawable ()
104{ 112{
105 if (xftdrawable) 113 if (xftdrawable)
106 XftDrawDestroy (xftdrawable); 114 XftDrawDestroy (xftdrawable);
107} 115}
111 if (!xftdrawable) 119 if (!xftdrawable)
112 xftdrawable = XftDrawCreate (display->display, drawable, display->visual, display->cmap); 120 xftdrawable = XftDrawCreate (display->display, drawable, display->visual, display->cmap);
113 121
114 return xftdrawable; 122 return xftdrawable;
115} 123}
124#endif
116 125
117///////////////////////////////////////////////////////////////////////////// 126/////////////////////////////////////////////////////////////////////////////
118 127
119static void *enc_buf; 128static void *enc_buf;
120static uint32_t enc_len; 129static uint32_t enc_len;
259 bool load (const rxvt_fontprop &prop) 268 bool load (const rxvt_fontprop &prop)
260 { 269 {
261 width = 1; height = 1; 270 width = 1; height = 1;
262 ascent = 1; descent = 0; 271 ascent = 1; descent = 0;
263 272
273 set_name ("built-in pseudofont");
274
264 return true; 275 return true;
265 } 276 }
266 277
267 bool has_codepoint (uint32_t unicode) 278 bool has_codepoint (unicode_t unicode)
268 { 279 {
269 if (unicode <= 0x001f) 280 if (unicode <= 0x001f)
270 return true; 281 return true;
282
271 if (unicode >= 0x0080 && unicode <= 0x009f) 283 if (unicode >= 0x0080 && unicode <= 0x009f)
272 return true; 284 return true;
273 285
274 if (unicode >= 0x2500 && unicode <= 0x257f 286 if (unicode >= 0x2500 && unicode <= 0x257f
275 && linedraw_cmds[unicode - 0x2500]) 287 && linedraw_cmds[unicode - 0x2500])
288 return true;
289
290 if (IS_COMPOSE (unicode))
276 return true; 291 return true;
277 292
278 switch (unicode) 293 switch (unicode)
279 { 294 {
280 case ZERO_WIDTH_CHAR: 295 case ZERO_WIDTH_CHAR:
298 313
299 XSetForeground (d.display->display, GC, r->PixColors[fg]); 314 XSetForeground (d.display->display, GC, r->PixColors[fg]);
300 315
301 while (len--) 316 while (len--)
302 { 317 {
318#if ENABLE_COMBINING
319 compose_char *cc;
320#endif
303 text_t t = *text++; 321 text_t t = *text++;
304 322
323 // is it in our linedrawing table?
305 if (t >= 0x2500 & t <= 0x2580 && linedraw_cmds[t - 0x2500]) 324 if (t >= 0x2500 & t <= 0x2580 && linedraw_cmds[t - 0x2500])
306 { 325 {
307 const char *p = linedraw_cmds[t - 0x2500]; 326 const char *p = linedraw_cmds[t - 0x2500];
308 327
309 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;
310 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;
311 330
312 XGCValues gcv; 331 XGCValues gcv;
313 332
314 while (*p) 333 while (*p)
315 { 334 {
335 } 354 }
336 355
337 gcv.line_width = 0; 356 gcv.line_width = 0;
338 XChangeGC (d.display->display, GC, GCLineWidth, &gcv); 357 XChangeGC (d.display->display, GC, GCLineWidth, &gcv);
339 } 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
340 else 375 else
341 switch (*text++) 376 switch (t)
342 { 377 {
343 case NOCHAR:
344 case ZERO_WIDTH_CHAR: 378 case ZERO_WIDTH_CHAR:
345 break; 379 break;
346 default: 380 default:
347 XDrawRectangle (d.display->display, d, GC, x + 2, y + 2, r->TermWin.fwidth - 5, r->TermWin.fheight - 5); 381 int w = 0;
382 while (len > 0 && *text == NOCHAR)
383 {
384 ++text;
385 --len;
386 w += r->TermWin.fwidth;
387 }
388
389 XDrawRectangle (d.display->display, d, GC, x + 2, y + 2,
390 w + r->TermWin.fwidth - 5, r->TermWin.fheight - 5);
391 x += w;
348 } 392 }
349 393
350 x += r->TermWin.fwidth; 394 x += r->TermWin.fwidth;
351 } 395 }
352} 396}
360 404
361 rxvt_fontprop properties (); 405 rxvt_fontprop properties ();
362 406
363 bool load (const rxvt_fontprop &prop); 407 bool load (const rxvt_fontprop &prop);
364 408
365 bool has_codepoint (uint32_t unicode); 409 bool has_codepoint (unicode_t unicode);
366 410
367 void draw (rxvt_drawable &d, int x, int y, 411 void draw (rxvt_drawable &d, int x, int y,
368 const text_t *text, int len, 412 const text_t *text, int len,
369 int fg, int bg); 413 int fg, int bg);
370 414
427 471
428bool 472bool
429rxvt_font_x11::set_properties (rxvt_fontprop &p, const char *name) 473rxvt_font_x11::set_properties (rxvt_fontprop &p, const char *name)
430{ 474{
431 int slashes = 0; 475 int slashes = 0;
432 const char *comp[12]; 476 const char *comp[13];
433 477
434 for (const char *c = name; *c; c++) 478 for (const char *c = name; *c; c++)
435 if (*c == '-') 479 if (*c == '-')
436 { 480 {
437 comp[slashes++] = c + 1; 481 comp[slashes++] = c + 1;
617 f = 0; 661 f = 0;
618 } 662 }
619} 663}
620 664
621bool 665bool
622rxvt_font_x11::has_codepoint (uint32_t unicode) 666rxvt_font_x11::has_codepoint (unicode_t unicode)
623{ 667{
624 uint32_t ch = FROM_UNICODE (cs, unicode); 668 uint32_t ch = FROM_UNICODE (cs, unicode);
625 669
626 if (ch == NOCHAR) 670 if (ch == NOCHAR)
627 return false; 671 return false;
769 813
770 void draw (rxvt_drawable &d, int x, int y, 814 void draw (rxvt_drawable &d, int x, int y,
771 const text_t *text, int len, 815 const text_t *text, int len,
772 int fg, int bg); 816 int fg, int bg);
773 817
774 bool has_codepoint (uint32_t unicode); 818 bool has_codepoint (unicode_t unicode);
775 819
776protected: 820protected:
777 XftFont *f; 821 XftFont *f;
778}; 822};
779 823
892 936
893 return true; 937 return true;
894} 938}
895 939
896bool 940bool
897rxvt_font_xft::has_codepoint (uint32_t unicode) 941rxvt_font_xft::has_codepoint (unicode_t unicode)
898{ 942{
899 return XftCharExists (DISPLAY, f, unicode); 943 return XftCharExists (DISPLAY, f, unicode);
900} 944}
901 945
902void 946void
998 f = new rxvt_font_x11; 1042 f = new rxvt_font_x11;
999 } 1043 }
1000 else 1044 else
1001 f = new rxvt_font_x11; 1045 f = new rxvt_font_x11;
1002 1046
1047 f->fs = this;
1003 f->set_term (r); 1048 f->set_term (r);
1004 f->set_name (strdup (name)); 1049 f->set_name (strdup (name));
1005 1050
1006 f->cs = cs; 1051 f->cs = cs;
1007 f->loaded = false; 1052 f->loaded = false;
1104 1149
1105 return true; 1150 return true;
1106} 1151}
1107 1152
1108int 1153int
1109rxvt_fontset::find_font (uint32_t unicode) 1154rxvt_fontset::find_font (unicode_t unicode)
1110{ 1155{
1111 for (unsigned int i = 0; i < fonts.size (); i++) 1156 for (unsigned int i = 0; i < fonts.size (); i++)
1112 { 1157 {
1113 rxvt_font *f = fonts[i]; 1158 rxvt_font *f = fonts[i];
1114 1159

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines