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.42 by pcg, Mon Mar 15 06:13:35 2004 UTC

61# if XFT 61# if XFT
62 // prefer xft for complex scripts 62 // prefer xft for complex scripts
63 { CS_UNICODE, "xft:Kochi Gothic:antialias=false" }, 63 { CS_UNICODE, "xft:Kochi Gothic:antialias=false" },
64# endif 64# endif
65 { CS_JIS0201_1976_0, "-*-mincho-*-r-*--*-*-*-*-c-*-jisx0201*-0" }, 65 { CS_JIS0201_1976_0, "-*-mincho-*-r-*--*-*-*-*-c-*-jisx0201*-0" },
66 { CS_JIS0208_1983_0, "-*-mincho-*-r-*--*-*-*-*-c-*-jisx0208*-0" }, 66 { CS_JIS0208_1990_0, "-*-mincho-*-r-*--*-*-*-*-c-*-jisx0208*-0" },
67 { CS_JIS0212_1990_0, "-*-mincho-*-r-*--*-*-*-*-c-*-jisx0212*-0" }, 67 { CS_JIS0212_1990_0, "-*-mincho-*-r-*--*-*-*-*-c-*-jisx0212*-0" },
68#endif 68#endif
69 69
70#if ENCODING_CN || ENCODING_CN_EXT 70#if ENCODING_CN || ENCODING_CN_EXT
71# if XFT 71# if XFT
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;
192#endif 201#endif
193 } 202 }
194} 203}
195 204
196static const char *linedraw_cmds[128] = { 205static const char *linedraw_cmds[128] = {
197 "1hH", "2hH", "1vV", "2vV", 206 "1-", "2-", "1|", "2|",
198 0, 0, 0, 0, 207 0, 0, 0, 0,
199 0, 0, 0, 0, 208 0, 0, 0, 0,
200 "1HV", "2H1V", "1H2V", "2HV", 209 "1HV", "2H1V", "1H2V", "2HV",
201 210
202 // 2510 211 // 2510
203 "1hV", "2h1V", "1h2V", "2hV", 212 "1hV", "2h1V", "1h2V", "2hV",
204 "1Hv", "2H1v", "1H2v", "2Hv", 213 "1Hv", "2H1v", "1H2v", "2Hv",
205 "1hv", "2h1v", "1h2v", "2hv", 214 "1hv", "2h1v", "1h2v", "2hv",
206 "1HvV", "2H1vV", "1HV2v", "1Hv2V", 215 "1H|", "2H1|", "1HV2v", "1Hv2V",
207 216
208 // 2520 217 // 2520
209 "1H2vV", "2Hv1V", "2HV1v", "2HvV", 218 "1H2|", "2Hv1V", "2HV1v", "2H|",
210 "1hvV", "2h1vV", "1hV2v", "1hv2V", 219 "1h|", "2h1|", "1hV2v", "1hv2V",
211 "1h2vV", "2hv1V", "1v2hV", "2hvV", 220 "1h2|", "2hv1V", "1v2hV", "2h|",
212 "1hHV", "2h1HV", "2H1hV", "2hH1V", 221 "1-V", "2h1HV", "2H1hV", "2-1V",
213 222
214 // 2530 223 // 2530
215 "1hH2V", "2hV1H", "1h2HV", "2hHV", 224 "1-2V", "2hV1H", "1h2HV", "2-V",
216 "1hHv", "1vH2h", "1hv2H", "1v2hH", 225 "1-v", "1vH2h", "1hv2H", "1v2-",
217 "1hH2v", "1H2hv", "1h2Hv", "2hHv", 226 "1-2v", "1H2hv", "1h2Hv", "2-v",
218 "1hHvV", "1vVH2h", "1hvV2H", "1vV2hH", 227 "1-|", "1|H2h", "1h|2H", "1|2-",
219 228
220 // 2540 229 // 2540
221 "1hHV2v", "1hHv2V", "1hH2vV", "1HV2hv", 230 "1-V2v", "1-v2V", "1-2|", "1HV2hv",
222 "1hV2Hv", "1Hv2hV", "1hv2HV", "1V2hHv", 231 "1hV2Hv", "1Hv2hV", "1hv2HV", "1V2-v",
223 "1v2hHV", "1H2hvV", "1h2HvV", "2hHvV", 232 "1v2-V", "1H2h|", "1h2H|", "2-|",
224 0, 0, 0, 0, 233 0, 0, 0, 0,
225 234
226 // 2550 235 // 2550
227 0, 0, 0, 0, 236 0, 0, 0, 0,
228 0, 0, 0, 0, 237 0, 0, 0, 0,
231 240
232 // 2560 241 // 2560
233 0, 0, 0, 0, 242 0, 0, 0, 0,
234 0, 0, 0, 0, 243 0, 0, 0, 0,
235 0, 0, 0, 0, 244 0, 0, 0, 0,
236 0, 0, 0, 0, 245 0, "A", "B", "C",
237 246
238 // 2570 247 // 2570
239 0, "1a", "1b", "1ab", 248 "D", "1/", "1\\", "1/\\",
240 "1h", "1v", "1H", "1V", 249 "1h", "1v", "1H", "1V",
241 "2h", "2v", "2H", "2V", 250 "2h", "2v", "2H", "2V",
242 "1h2H", "1v2V", "1H2h", "1V2v" 251 "1h2H", "1v2V", "1H2h", "1V2v"
243 252
244 // to be done 253 // to be done
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 W = r->TermWin.fwidth , w = (W - 1) / 2;
310 int y0 = y, y1 = y + r->TermWin.fheight / 2, y2 = y + r->TermWin.fheight - 1; 329 int H = r->TermWin.fheight, h = (H - 1) / 2;
330 int x0 = x, x1 = x + w, x2 = x + r->TermWin.fwidth ;
331 int y0 = y, y1 = y + h, y2 = y + r->TermWin.fheight;
311 332
312 XGCValues gcv; 333 XGCValues gcv;
334
335 gcv.cap_style = CapNotLast;
336 XChangeGC (d.display->display, GC, GCCapStyle, &gcv);
313 337
314 while (*p) 338 while (*p)
315 { 339 {
316 switch (*p++) 340 switch (*p++)
317 { 341 {
319 gcv.line_width = 0; 343 gcv.line_width = 0;
320 XChangeGC (d.display->display, GC, GCLineWidth, &gcv); 344 XChangeGC (d.display->display, GC, GCLineWidth, &gcv);
321 break; 345 break;
322 346
323 case '2': 347 case '2':
324 gcv.line_width = 2; 348 gcv.line_width = 3;
325 XChangeGC (d.display->display, GC, GCLineWidth, &gcv); 349 XChangeGC (d.display->display, GC, GCLineWidth, &gcv);
326 break; 350 break;
327 351
328 case 'h': XDrawLine (d.display->display, d, GC, x0, y1, x1, y1); break; 352 case 'h': XDrawLine (d.display->display, d, GC, x0, y1, x1+1, y1 ); break;
329 case 'H': XDrawLine (d.display->display, d, GC, x1, y1, x2, y1); break; 353 case 'H': XDrawLine (d.display->display, d, GC, x2, y1, x1-1, y1 ); break;
354 case '-': XDrawLine (d.display->display, d, GC, x0, y1, x2 , y1 ); break;
330 case 'v': XDrawLine (d.display->display, d, GC, x1, y0, x1, y1); break; 355 case 'v': XDrawLine (d.display->display, d, GC, x1, y0, x1 , y1+1); break;
356 case 'V': XDrawLine (d.display->display, d, GC, x1, y2, x1 , y1-1); break;
331 case 'V': XDrawLine (d.display->display, d, GC, x1, y1, x1, y2); break; 357 case '|': XDrawLine (d.display->display, d, GC, x1, y0, x1 , y2 ); break;
358
332 case 'a': XDrawLine (d.display->display, d, GC, x0, y2, x2, y0); break; 359 case '/' : XDrawLine (d.display->display, d, GC, x0, y2, x2 , y0 ); break;
333 case 'b': XDrawLine (d.display->display, d, GC, x0, y0, x2, y2); break; 360 case '\\': XDrawLine (d.display->display, d, GC, x0, y0, x2 , y2 ); break;
361
362 case 'A': XDrawArc (d.display->display, d, GC, x1 , y1 , W-1, H-1, 90*64, 90*64); break;
363 case 'B': XDrawArc (d.display->display, d, GC, x1-W+1, y1 , W-1, H-1, 0*64, 90*64); break;
364 case 'C': XDrawArc (d.display->display, d, GC, x1-W+1, y1-H+1, W-1, H-1, 0*64, -90*64); break;
365 case 'D': XDrawArc (d.display->display, d, GC, x1 , y1-H+1, W-1, H-1, -90*64, -90*64); break;
334 } 366 }
335 } 367 }
336 368
337 gcv.line_width = 0; 369 gcv.line_width = 0;
338 XChangeGC (d.display->display, GC, GCLineWidth, &gcv); 370 XChangeGC (d.display->display, GC, GCLineWidth, &gcv);
339 } 371 }
372
373#if ENABLE_COMBINING
374 else if (IS_COMPOSE (t) && (cc = rxvt_composite[t]))
375 {
376 rxvt_font *f1 = (*fs)[fs->find_font (cc->c1)];
377 f1->draw (d, x, y, &(t = cc->c1), 1, fg, bg);
378 if (cc->c2 != NOCHAR)
379 {
380 // prefer font of first character, for no good reasons
381 rxvt_font *f2 = f1->has_codepoint (cc->c2)
382 ? f1
383 : (*fs)[fs->find_font (cc->c2)];
384
385 f2->draw (d, x, y, &(t = cc->c2), 1, fg, -1);
386 }
387 }
388#endif
340 else 389 else
341 switch (*text++) 390 switch (t)
342 { 391 {
343 case NOCHAR:
344 case ZERO_WIDTH_CHAR: 392 case ZERO_WIDTH_CHAR:
345 break; 393 break;
346 default: 394 default:
347 XDrawRectangle (d.display->display, d, GC, x + 2, y + 2, r->TermWin.fwidth - 5, r->TermWin.fheight - 5); 395 int w = 0;
396 while (len > 0 && *text == NOCHAR)
397 {
398 ++text;
399 --len;
400 w += r->TermWin.fwidth;
401 }
402
403 XDrawRectangle (d.display->display, d, GC, x + 2, y + 2,
404 w + r->TermWin.fwidth - 5, r->TermWin.fheight - 5);
405 x += w;
348 } 406 }
349 407
350 x += r->TermWin.fwidth; 408 x += r->TermWin.fwidth;
351 } 409 }
352} 410}
360 418
361 rxvt_fontprop properties (); 419 rxvt_fontprop properties ();
362 420
363 bool load (const rxvt_fontprop &prop); 421 bool load (const rxvt_fontprop &prop);
364 422
365 bool has_codepoint (uint32_t unicode); 423 bool has_codepoint (unicode_t unicode);
366 424
367 void draw (rxvt_drawable &d, int x, int y, 425 void draw (rxvt_drawable &d, int x, int y,
368 const text_t *text, int len, 426 const text_t *text, int len,
369 int fg, int bg); 427 int fg, int bg);
370 428
427 485
428bool 486bool
429rxvt_font_x11::set_properties (rxvt_fontprop &p, const char *name) 487rxvt_font_x11::set_properties (rxvt_fontprop &p, const char *name)
430{ 488{
431 int slashes = 0; 489 int slashes = 0;
432 const char *comp[12]; 490 const char *comp[13];
433 491
434 for (const char *c = name; *c; c++) 492 for (const char *c = name; *c; c++)
435 if (*c == '-') 493 if (*c == '-')
436 { 494 {
437 comp[slashes++] = c + 1; 495 comp[slashes++] = c + 1;
617 f = 0; 675 f = 0;
618 } 676 }
619} 677}
620 678
621bool 679bool
622rxvt_font_x11::has_codepoint (uint32_t unicode) 680rxvt_font_x11::has_codepoint (unicode_t unicode)
623{ 681{
624 uint32_t ch = FROM_UNICODE (cs, unicode); 682 uint32_t ch = FROM_UNICODE (cs, unicode);
625 683
626 if (ch == NOCHAR) 684 if (ch == NOCHAR)
627 return false; 685 return false;
769 827
770 void draw (rxvt_drawable &d, int x, int y, 828 void draw (rxvt_drawable &d, int x, int y,
771 const text_t *text, int len, 829 const text_t *text, int len,
772 int fg, int bg); 830 int fg, int bg);
773 831
774 bool has_codepoint (uint32_t unicode); 832 bool has_codepoint (unicode_t unicode);
775 833
776protected: 834protected:
777 XftFont *f; 835 XftFont *f;
778}; 836};
779 837
892 950
893 return true; 951 return true;
894} 952}
895 953
896bool 954bool
897rxvt_font_xft::has_codepoint (uint32_t unicode) 955rxvt_font_xft::has_codepoint (unicode_t unicode)
898{ 956{
899 return XftCharExists (DISPLAY, f, unicode); 957 return XftCharExists (DISPLAY, f, unicode);
900} 958}
901 959
902void 960void
998 f = new rxvt_font_x11; 1056 f = new rxvt_font_x11;
999 } 1057 }
1000 else 1058 else
1001 f = new rxvt_font_x11; 1059 f = new rxvt_font_x11;
1002 1060
1061 f->fs = this;
1003 f->set_term (r); 1062 f->set_term (r);
1004 f->set_name (strdup (name)); 1063 f->set_name (strdup (name));
1005 1064
1006 f->cs = cs; 1065 f->cs = cs;
1007 f->loaded = false; 1066 f->loaded = false;
1104 1163
1105 return true; 1164 return true;
1106} 1165}
1107 1166
1108int 1167int
1109rxvt_fontset::find_font (uint32_t unicode) 1168rxvt_fontset::find_font (unicode_t unicode)
1110{ 1169{
1111 for (unsigned int i = 0; i < fonts.size (); i++) 1170 for (unsigned int i = 0; i < fonts.size (); i++)
1112 { 1171 {
1113 rxvt_font *f = fonts[i]; 1172 rxvt_font *f = fonts[i];
1114 1173

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines