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.46 by pcg, Tue Mar 16 05:55:51 2004 UTC vs.
Revision 1.49 by pcg, Mon Mar 22 15:15:04 2004 UTC

230 bool has_codepoint (unicode_t unicode) 230 bool has_codepoint (unicode_t unicode)
231 { 231 {
232 if (unicode <= 0x001f) 232 if (unicode <= 0x001f)
233 return true; 233 return true;
234 234
235 if (unicode >= 0x0080 && unicode <= 0x009f) 235 if (unicode <= 0x007f)
236 return false;
237
238 if (unicode <= 0x009f)
236 return true; 239 return true;
237 240
238 if (unicode >= 0x2500 && unicode <= 0x259f 241 if (unicode >= 0x2500 && unicode <= 0x259f)
239 && linedraw_offs[unicode - 0x2500] & 15)
240 return true; 242 return true;
241 243
242 if (IS_COMPOSE (unicode)) 244 if (IS_COMPOSE (unicode))
243 return true; 245 return true;
244 246
270#if ENABLE_COMBINING 272#if ENABLE_COMBINING
271 compose_char *cc; 273 compose_char *cc;
272#endif 274#endif
273 text_t t = *text++; 275 text_t t = *text++;
274 276
275 int W = r->TermWin.fwidth , w = (W - 1) / 2;
276 int H = r->TermWin.fheight, h = (H - 1) / 2;
277 int x0 = x, x1 = x + w, x2 = x + r->TermWin.fwidth ;
278 int y0 = y, y1 = y + h, y2 = y + r->TermWin.fheight;
279
280 if (0x2500 <= t && t <= 0x259f 277 if (0x2500 <= t && t <= 0x259f)
281 && linedraw_offs[t - 0x2500] & 15)
282 { 278 {
283 uint16_t offs = linedraw_offs[t - 0x2500]; 279 uint16_t offs = linedraw_offs[t - 0x2500];
284 uint32_t *a = linedraw_command + (offs >> 4); 280 uint32_t *a = linedraw_command + (offs >> 4);
285 uint32_t *b = a + (offs & 15); 281 uint32_t *b = a + (offs & 15);
282
283 int W = r->TermWin.fwidth;
284 int H = r->TermWin.fheight;
286 285
287 int x_[16]; 286 int x_[16];
288 int y_[16]; 287 int y_[16];
289 288
290 for (int i = 0; i <= 8; i++) 289 for (int i = 0; i <= 8; i++)
333 XChangeGC (d.display->display, TGC, 332 XChangeGC (d.display->display, TGC,
334 GCFillStyle | GCStipple | GCTileStipXOrigin | GCTileStipYOrigin, 333 GCFillStyle | GCStipple | GCTileStipXOrigin | GCTileStipYOrigin,
335 &gcv); 334 &gcv);
336 } 335 }
337 336
338
339 XFillRectangle (d.display->display, d, TGC, x1, y1, x2 - x1 + 1, y2 - y1 + 1); 337 XFillRectangle (d.display->display, d, TGC, x1, y1, x2 - x1 + 1, y2 - y1 + 1);
340 338
341 if (a) 339 if (a)
342 { 340 {
343 XFreePixmap (d.display->display, gcv.stipple); 341 XFreePixmap (d.display->display, gcv.stipple);
344 gcv.stipple = 0; 342 gcv.stipple = 0;
345 gcv.fill_style = FillSolid; 343 gcv.fill_style = FillSolid;
346 XChangeGC (d.display->display, TGC, GCFillStyle, &gcv); 344 XChangeGC (d.display->display, TGC, GCFillStyle, &gcv);
347 } 345 }
348
349 break; 346 break;
350 case 2: // arc 347 case 2: // arc
351 XDrawArc (d.display->display, d, TGC, 348 XDrawArc (d.display->display, d, TGC,
352 x1 - W/2, y1 - H/2, W-1, H-1, 349 x1 - W/2, y1 - H/2, W-1, H-1,
353 (a - 1) * 90*64, (b - 1) * 90*64); 350 (a - 1) * 90*64, (b - 1) * 90*64);
414 411
415 XFontStruct *f; 412 XFontStruct *f;
416 codeset cs; 413 codeset cs;
417 bool enc2b, encm; 414 bool enc2b, encm;
418 415
419 const char *get_property (XFontStruct *f, const char *property, const char *repl) const; 416 char *get_property (XFontStruct *f, const char *property, const char *repl) const;
420 bool set_properties (rxvt_fontprop &p, int height, const char *weight, const char *slant, int avgwidth); 417 bool set_properties (rxvt_fontprop &p, int height, const char *weight, const char *slant, int avgwidth);
421 bool set_properties (rxvt_fontprop &p, XFontStruct *f); 418 bool set_properties (rxvt_fontprop &p, XFontStruct *f);
422 bool set_properties (rxvt_fontprop &p, const char *name); 419 bool set_properties (rxvt_fontprop &p, const char *name);
423}; 420};
424 421
425const char * 422char *
426rxvt_font_x11::get_property (XFontStruct *f, const char *property, const char *repl) const 423rxvt_font_x11::get_property (XFontStruct *f, const char *property, const char *repl) const
427{ 424{
428 unsigned long value; 425 unsigned long value;
429 426
430 if (XGetFontProperty (f, XInternAtom (DISPLAY, property, 0), &value)) 427 if (XGetFontProperty (f, XInternAtom (DISPLAY, property, 0), &value))
431 return XGetAtomName (DISPLAY, value); 428 return XGetAtomName (DISPLAY, value);
432 else 429 else
433 return repl; 430 return rxvt_strdup (repl);
434} 431}
435 432
436rxvt_fontprop 433rxvt_fontprop
437rxvt_font_x11::properties () 434rxvt_font_x11::properties ()
438{ 435{
453} 450}
454 451
455bool 452bool
456rxvt_font_x11::set_properties (rxvt_fontprop &p, XFontStruct *f) 453rxvt_font_x11::set_properties (rxvt_fontprop &p, XFontStruct *f)
457{ 454{
458 const char *weight = get_property (f, "WEIGHT_NAME", "medium");
459 const char *slant = get_property (f, "SLANT", "r");
460
461 unsigned long height; 455 unsigned long height;
462 if (!XGetFontProperty (f, XInternAtom (DISPLAY, "PIXEL_SIZE", 0), &height)) 456 if (!XGetFontProperty (f, XInternAtom (DISPLAY, "PIXEL_SIZE", 0), &height))
463 return false; 457 return false;
464 458
465 unsigned long avgwidth; 459 unsigned long avgwidth;
466 if (!XGetFontProperty (f, XInternAtom (DISPLAY, "AVERAGE_WIDTH", 0), &avgwidth)) 460 if (!XGetFontProperty (f, XInternAtom (DISPLAY, "AVERAGE_WIDTH", 0), &avgwidth))
467 avgwidth = 0; 461 avgwidth = 0;
468 462
463 char *weight = get_property (f, "WEIGHT_NAME", "medium");
464 char *slant = get_property (f, "SLANT", "r");
465
469 return set_properties (p, height, weight, slant, avgwidth); 466 set_properties (p, height, weight, slant, avgwidth);
467
468 free (weight);
469 free (slant);
470
471 return true;
470} 472}
471 473
472bool 474bool
473rxvt_font_x11::set_properties (rxvt_fontprop &p, const char *name) 475rxvt_font_x11::set_properties (rxvt_fontprop &p, const char *name)
474{ 476{
578 f = XLoadQueryFont (DISPLAY, name); 580 f = XLoadQueryFont (DISPLAY, name);
579 581
580 if (!f) 582 if (!f)
581 return false; 583 return false;
582 584
583 const char *registry = get_property (f, "CHARSET_REGISTRY", 0); 585 char *registry = get_property (f, "CHARSET_REGISTRY", 0);
584 const char *encoding = get_property (f, "CHARSET_ENCODING", 0); 586 char *encoding = get_property (f, "CHARSET_ENCODING", 0);
585 587
586 if (registry && encoding) 588 if (registry && encoding)
587 { 589 {
588 char charset[64]; 590 char charset[64];
589 snprintf (charset, 64, "%s-%s", registry, encoding); 591 snprintf (charset, 64, "%s-%s", registry, encoding);
602 if (*charset++ == '-' && !--count) 604 if (*charset++ == '-' && !--count)
603 break; 605 break;
604 606
605 cs = codeset_from_name (charset); 607 cs = codeset_from_name (charset);
606 } 608 }
609
610 free (registry);
611 free (encoding);
607 612
608 if (cs == CS_UNICODE) 613 if (cs == CS_UNICODE)
609 cs = CS_UNICODE_16; // X11 can have a max. of 65536 chars per font 614 cs = CS_UNICODE_16; // X11 can have a max. of 65536 chars per font
610 615
611 encm = f->min_byte1 != 0 || f->max_byte1 != 0; 616 encm = f->min_byte1 != 0 || f->max_byte1 != 0;
1151} 1156}
1152 1157
1153int 1158int
1154rxvt_fontset::find_font (unicode_t unicode) 1159rxvt_fontset::find_font (unicode_t unicode)
1155{ 1160{
1156 for (unsigned int i = 0; i < fonts.size (); i++) 1161 for (unsigned int i = !!(0x20 <= unicode && unicode <= 0x7f); // skip pseudo-font for ascii
1162 i < fonts.size ();
1163 i++)
1157 { 1164 {
1158 rxvt_font *f = fonts[i]; 1165 rxvt_font *f = fonts[i];
1159 1166
1160 if (!f->loaded) 1167 if (!f->loaded)
1161 { 1168 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines