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.29 by pcg, Wed Mar 3 20:15:18 2004 UTC vs.
Revision 1.40 by pcg, Mon Mar 15 00:08:11 2004 UTC

96 { CS_UNICODE, "xft:FreeMono" }, 96 { CS_UNICODE, "xft:FreeMono" },
97 { CS_UNICODE, "-*-unifont-*-*-*-*-*-*-*-*-c-*-iso10646-1" }, 97 { CS_UNICODE, "-*-unifont-*-*-*-*-*-*-*-*-c-*-iso10646-1" },
98 { CS_UNICODE, "-*-*-*-r-*-*-*-*-*-*-c-*-iso10646-1" }, 98 { CS_UNICODE, "-*-*-*-r-*-*-*-*-*-*-c-*-iso10646-1" },
99 { CS_UNICODE, "-*-*-*-r-*-*-*-*-*-*-m-*-iso10646-1" }, 99 { CS_UNICODE, "-*-*-*-r-*-*-*-*-*-*-m-*-iso10646-1" },
100 100
101#if UNICODE_3 && XFT
102 { CS_UNICODE, "xft:Code2001" }, // contains many plane-1 characters
103#endif
104
101 { CS_UNKNOWN, 0 } 105 { CS_UNKNOWN, 0 }
102}; 106};
103 107
104///////////////////////////////////////////////////////////////////////////// 108/////////////////////////////////////////////////////////////////////////////
105 109
264 bool load (const rxvt_fontprop &prop) 268 bool load (const rxvt_fontprop &prop)
265 { 269 {
266 width = 1; height = 1; 270 width = 1; height = 1;
267 ascent = 1; descent = 0; 271 ascent = 1; descent = 0;
268 272
273 set_name ("built-in pseudofont");
274
269 return true; 275 return true;
270 } 276 }
271 277
272 bool has_codepoint (uint32_t unicode) 278 bool has_codepoint (unicode_t unicode)
273 { 279 {
274 if (unicode <= 0x001f) 280 if (unicode <= 0x001f)
275 return true; 281 return true;
282
276 if (unicode >= 0x0080 && unicode <= 0x009f) 283 if (unicode >= 0x0080 && unicode <= 0x009f)
277 return true; 284 return true;
278 285
279 if (unicode >= 0x2500 && unicode <= 0x257f 286 if (unicode >= 0x2500 && unicode <= 0x257f
280 && linedraw_cmds[unicode - 0x2500]) 287 && linedraw_cmds[unicode - 0x2500])
288 return true;
289
290 if (IS_COMPOSE (unicode))
281 return true; 291 return true;
282 292
283 switch (unicode) 293 switch (unicode)
284 { 294 {
285 case ZERO_WIDTH_CHAR: 295 case ZERO_WIDTH_CHAR:
303 313
304 XSetForeground (d.display->display, GC, r->PixColors[fg]); 314 XSetForeground (d.display->display, GC, r->PixColors[fg]);
305 315
306 while (len--) 316 while (len--)
307 { 317 {
318#if ENABLE_COMBINING
319 compose_char *cc;
320#endif
308 text_t t = *text++; 321 text_t t = *text++;
309 322
310 // is it in our linedrawing table? 323 // is it in our linedrawing table?
311 if (t >= 0x2500 & t <= 0x2580 && linedraw_cmds[t - 0x2500]) 324 if (t >= 0x2500 & t <= 0x2580 && linedraw_cmds[t - 0x2500])
312 { 325 {
313 const char *p = linedraw_cmds[t - 0x2500]; 326 const char *p = linedraw_cmds[t - 0x2500];
314 327
315 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;
316 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;
317 330
318 XGCValues gcv; 331 XGCValues gcv;
319 332
320 while (*p) 333 while (*p)
321 { 334 {
341 } 354 }
342 355
343 gcv.line_width = 0; 356 gcv.line_width = 0;
344 XChangeGC (d.display->display, GC, GCLineWidth, &gcv); 357 XChangeGC (d.display->display, GC, GCLineWidth, &gcv);
345 } 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
346 else 375 else
347 switch (t) 376 switch (t)
348 { 377 {
349 case ZERO_WIDTH_CHAR: 378 case ZERO_WIDTH_CHAR:
350 break; 379 break;
375 404
376 rxvt_fontprop properties (); 405 rxvt_fontprop properties ();
377 406
378 bool load (const rxvt_fontprop &prop); 407 bool load (const rxvt_fontprop &prop);
379 408
380 bool has_codepoint (uint32_t unicode); 409 bool has_codepoint (unicode_t unicode);
381 410
382 void draw (rxvt_drawable &d, int x, int y, 411 void draw (rxvt_drawable &d, int x, int y,
383 const text_t *text, int len, 412 const text_t *text, int len,
384 int fg, int bg); 413 int fg, int bg);
385 414
632 f = 0; 661 f = 0;
633 } 662 }
634} 663}
635 664
636bool 665bool
637rxvt_font_x11::has_codepoint (uint32_t unicode) 666rxvt_font_x11::has_codepoint (unicode_t unicode)
638{ 667{
639 uint32_t ch = FROM_UNICODE (cs, unicode); 668 uint32_t ch = FROM_UNICODE (cs, unicode);
640 669
641 if (ch == NOCHAR) 670 if (ch == NOCHAR)
642 return false; 671 return false;
784 813
785 void draw (rxvt_drawable &d, int x, int y, 814 void draw (rxvt_drawable &d, int x, int y,
786 const text_t *text, int len, 815 const text_t *text, int len,
787 int fg, int bg); 816 int fg, int bg);
788 817
789 bool has_codepoint (uint32_t unicode); 818 bool has_codepoint (unicode_t unicode);
790 819
791protected: 820protected:
792 XftFont *f; 821 XftFont *f;
793}; 822};
794 823
907 936
908 return true; 937 return true;
909} 938}
910 939
911bool 940bool
912rxvt_font_xft::has_codepoint (uint32_t unicode) 941rxvt_font_xft::has_codepoint (unicode_t unicode)
913{ 942{
914 return XftCharExists (DISPLAY, f, unicode); 943 return XftCharExists (DISPLAY, f, unicode);
915} 944}
916 945
917void 946void
1013 f = new rxvt_font_x11; 1042 f = new rxvt_font_x11;
1014 } 1043 }
1015 else 1044 else
1016 f = new rxvt_font_x11; 1045 f = new rxvt_font_x11;
1017 1046
1047 f->fs = this;
1018 f->set_term (r); 1048 f->set_term (r);
1019 f->set_name (strdup (name)); 1049 f->set_name (strdup (name));
1020 1050
1021 f->cs = cs; 1051 f->cs = cs;
1022 f->loaded = false; 1052 f->loaded = false;
1119 1149
1120 return true; 1150 return true;
1121} 1151}
1122 1152
1123int 1153int
1124rxvt_fontset::find_font (uint32_t unicode) 1154rxvt_fontset::find_font (unicode_t unicode)
1125{ 1155{
1126 for (unsigned int i = 0; i < fonts.size (); i++) 1156 for (unsigned int i = 0; i < fonts.size (); i++)
1127 { 1157 {
1128 rxvt_font *f = fonts[i]; 1158 rxvt_font *f = fonts[i];
1129 1159

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines