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.26 by pcg, Fri Feb 27 02:52:51 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
261 bool load (const rxvt_fontprop &prop) 268 bool load (const rxvt_fontprop &prop)
262 { 269 {
263 width = 1; height = 1; 270 width = 1; height = 1;
264 ascent = 1; descent = 0; 271 ascent = 1; descent = 0;
265 272
273 set_name ("built-in pseudofont");
274
266 return true; 275 return true;
267 } 276 }
268 277
269 bool has_codepoint (uint32_t unicode) 278 bool has_codepoint (unicode_t unicode)
270 { 279 {
271 if (unicode <= 0x001f) 280 if (unicode <= 0x001f)
272 return true; 281 return true;
282
273 if (unicode >= 0x0080 && unicode <= 0x009f) 283 if (unicode >= 0x0080 && unicode <= 0x009f)
274 return true; 284 return true;
275 285
276 if (unicode >= 0x2500 && unicode <= 0x257f 286 if (unicode >= 0x2500 && unicode <= 0x257f
277 && linedraw_cmds[unicode - 0x2500]) 287 && linedraw_cmds[unicode - 0x2500])
288 return true;
289
290 if (IS_COMPOSE (unicode))
278 return true; 291 return true;
279 292
280 switch (unicode) 293 switch (unicode)
281 { 294 {
282 case ZERO_WIDTH_CHAR: 295 case ZERO_WIDTH_CHAR:
300 313
301 XSetForeground (d.display->display, GC, r->PixColors[fg]); 314 XSetForeground (d.display->display, GC, r->PixColors[fg]);
302 315
303 while (len--) 316 while (len--)
304 { 317 {
318#if ENABLE_COMBINING
319 compose_char *cc;
320#endif
305 text_t t = *text++; 321 text_t t = *text++;
306 322
323 // is it in our linedrawing table?
307 if (t >= 0x2500 & t <= 0x2580 && linedraw_cmds[t - 0x2500]) 324 if (t >= 0x2500 & t <= 0x2580 && linedraw_cmds[t - 0x2500])
308 { 325 {
309 const char *p = linedraw_cmds[t - 0x2500]; 326 const char *p = linedraw_cmds[t - 0x2500];
310 327
311 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;
312 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;
313 330
314 XGCValues gcv; 331 XGCValues gcv;
315 332
316 while (*p) 333 while (*p)
317 { 334 {
337 } 354 }
338 355
339 gcv.line_width = 0; 356 gcv.line_width = 0;
340 XChangeGC (d.display->display, GC, GCLineWidth, &gcv); 357 XChangeGC (d.display->display, GC, GCLineWidth, &gcv);
341 } 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
342 else 375 else
343 switch (*text++) 376 switch (t)
344 { 377 {
345 case NOCHAR:
346 case ZERO_WIDTH_CHAR: 378 case ZERO_WIDTH_CHAR:
347 break; 379 break;
348 default: 380 default:
349 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;
350 } 392 }
351 393
352 x += r->TermWin.fwidth; 394 x += r->TermWin.fwidth;
353 } 395 }
354} 396}
362 404
363 rxvt_fontprop properties (); 405 rxvt_fontprop properties ();
364 406
365 bool load (const rxvt_fontprop &prop); 407 bool load (const rxvt_fontprop &prop);
366 408
367 bool has_codepoint (uint32_t unicode); 409 bool has_codepoint (unicode_t unicode);
368 410
369 void draw (rxvt_drawable &d, int x, int y, 411 void draw (rxvt_drawable &d, int x, int y,
370 const text_t *text, int len, 412 const text_t *text, int len,
371 int fg, int bg); 413 int fg, int bg);
372 414
429 471
430bool 472bool
431rxvt_font_x11::set_properties (rxvt_fontprop &p, const char *name) 473rxvt_font_x11::set_properties (rxvt_fontprop &p, const char *name)
432{ 474{
433 int slashes = 0; 475 int slashes = 0;
434 const char *comp[12]; 476 const char *comp[13];
435 477
436 for (const char *c = name; *c; c++) 478 for (const char *c = name; *c; c++)
437 if (*c == '-') 479 if (*c == '-')
438 { 480 {
439 comp[slashes++] = c + 1; 481 comp[slashes++] = c + 1;
619 f = 0; 661 f = 0;
620 } 662 }
621} 663}
622 664
623bool 665bool
624rxvt_font_x11::has_codepoint (uint32_t unicode) 666rxvt_font_x11::has_codepoint (unicode_t unicode)
625{ 667{
626 uint32_t ch = FROM_UNICODE (cs, unicode); 668 uint32_t ch = FROM_UNICODE (cs, unicode);
627 669
628 if (ch == NOCHAR) 670 if (ch == NOCHAR)
629 return false; 671 return false;
771 813
772 void draw (rxvt_drawable &d, int x, int y, 814 void draw (rxvt_drawable &d, int x, int y,
773 const text_t *text, int len, 815 const text_t *text, int len,
774 int fg, int bg); 816 int fg, int bg);
775 817
776 bool has_codepoint (uint32_t unicode); 818 bool has_codepoint (unicode_t unicode);
777 819
778protected: 820protected:
779 XftFont *f; 821 XftFont *f;
780}; 822};
781 823
894 936
895 return true; 937 return true;
896} 938}
897 939
898bool 940bool
899rxvt_font_xft::has_codepoint (uint32_t unicode) 941rxvt_font_xft::has_codepoint (unicode_t unicode)
900{ 942{
901 return XftCharExists (DISPLAY, f, unicode); 943 return XftCharExists (DISPLAY, f, unicode);
902} 944}
903 945
904void 946void
1000 f = new rxvt_font_x11; 1042 f = new rxvt_font_x11;
1001 } 1043 }
1002 else 1044 else
1003 f = new rxvt_font_x11; 1045 f = new rxvt_font_x11;
1004 1046
1047 f->fs = this;
1005 f->set_term (r); 1048 f->set_term (r);
1006 f->set_name (strdup (name)); 1049 f->set_name (strdup (name));
1007 1050
1008 f->cs = cs; 1051 f->cs = cs;
1009 f->loaded = false; 1052 f->loaded = false;
1106 1149
1107 return true; 1150 return true;
1108} 1151}
1109 1152
1110int 1153int
1111rxvt_fontset::find_font (uint32_t unicode) 1154rxvt_fontset::find_font (unicode_t unicode)
1112{ 1155{
1113 for (unsigned int i = 0; i < fonts.size (); i++) 1156 for (unsigned int i = 0; i < fonts.size (); i++)
1114 { 1157 {
1115 rxvt_font *f = fonts[i]; 1158 rxvt_font *f = fonts[i];
1116 1159

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines