… | |
… | |
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 | return true; |
242 | return true; |
240 | |
243 | |
… | |
… | |
408 | |
411 | |
409 | XFontStruct *f; |
412 | XFontStruct *f; |
410 | codeset cs; |
413 | codeset cs; |
411 | bool enc2b, encm; |
414 | bool enc2b, encm; |
412 | |
415 | |
413 | 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; |
414 | 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); |
415 | bool set_properties (rxvt_fontprop &p, XFontStruct *f); |
418 | bool set_properties (rxvt_fontprop &p, XFontStruct *f); |
416 | bool set_properties (rxvt_fontprop &p, const char *name); |
419 | bool set_properties (rxvt_fontprop &p, const char *name); |
417 | }; |
420 | }; |
418 | |
421 | |
419 | const char * |
422 | char * |
420 | rxvt_font_x11::get_property (XFontStruct *f, const char *property, const char *repl) const |
423 | rxvt_font_x11::get_property (XFontStruct *f, const char *property, const char *repl) const |
421 | { |
424 | { |
422 | unsigned long value; |
425 | unsigned long value; |
423 | |
426 | |
424 | if (XGetFontProperty (f, XInternAtom (DISPLAY, property, 0), &value)) |
427 | if (XGetFontProperty (f, XInternAtom (DISPLAY, property, 0), &value)) |
425 | return XGetAtomName (DISPLAY, value); |
428 | return XGetAtomName (DISPLAY, value); |
426 | else |
429 | else |
427 | return repl; |
430 | return rxvt_strdup (repl); |
428 | } |
431 | } |
429 | |
432 | |
430 | rxvt_fontprop |
433 | rxvt_fontprop |
431 | rxvt_font_x11::properties () |
434 | rxvt_font_x11::properties () |
432 | { |
435 | { |
… | |
… | |
447 | } |
450 | } |
448 | |
451 | |
449 | bool |
452 | bool |
450 | rxvt_font_x11::set_properties (rxvt_fontprop &p, XFontStruct *f) |
453 | rxvt_font_x11::set_properties (rxvt_fontprop &p, XFontStruct *f) |
451 | { |
454 | { |
452 | const char *weight = get_property (f, "WEIGHT_NAME", "medium"); |
|
|
453 | const char *slant = get_property (f, "SLANT", "r"); |
|
|
454 | |
|
|
455 | unsigned long height; |
455 | unsigned long height; |
456 | if (!XGetFontProperty (f, XInternAtom (DISPLAY, "PIXEL_SIZE", 0), &height)) |
456 | if (!XGetFontProperty (f, XInternAtom (DISPLAY, "PIXEL_SIZE", 0), &height)) |
457 | return false; |
457 | return false; |
458 | |
458 | |
459 | unsigned long avgwidth; |
459 | unsigned long avgwidth; |
460 | if (!XGetFontProperty (f, XInternAtom (DISPLAY, "AVERAGE_WIDTH", 0), &avgwidth)) |
460 | if (!XGetFontProperty (f, XInternAtom (DISPLAY, "AVERAGE_WIDTH", 0), &avgwidth)) |
461 | avgwidth = 0; |
461 | avgwidth = 0; |
462 | |
462 | |
|
|
463 | char *weight = get_property (f, "WEIGHT_NAME", "medium"); |
|
|
464 | char *slant = get_property (f, "SLANT", "r"); |
|
|
465 | |
463 | 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; |
464 | } |
472 | } |
465 | |
473 | |
466 | bool |
474 | bool |
467 | rxvt_font_x11::set_properties (rxvt_fontprop &p, const char *name) |
475 | rxvt_font_x11::set_properties (rxvt_fontprop &p, const char *name) |
468 | { |
476 | { |
… | |
… | |
572 | f = XLoadQueryFont (DISPLAY, name); |
580 | f = XLoadQueryFont (DISPLAY, name); |
573 | |
581 | |
574 | if (!f) |
582 | if (!f) |
575 | return false; |
583 | return false; |
576 | |
584 | |
577 | const char *registry = get_property (f, "CHARSET_REGISTRY", 0); |
585 | char *registry = get_property (f, "CHARSET_REGISTRY", 0); |
578 | const char *encoding = get_property (f, "CHARSET_ENCODING", 0); |
586 | char *encoding = get_property (f, "CHARSET_ENCODING", 0); |
579 | |
587 | |
580 | if (registry && encoding) |
588 | if (registry && encoding) |
581 | { |
589 | { |
582 | char charset[64]; |
590 | char charset[64]; |
583 | snprintf (charset, 64, "%s-%s", registry, encoding); |
591 | snprintf (charset, 64, "%s-%s", registry, encoding); |
… | |
… | |
596 | if (*charset++ == '-' && !--count) |
604 | if (*charset++ == '-' && !--count) |
597 | break; |
605 | break; |
598 | |
606 | |
599 | cs = codeset_from_name (charset); |
607 | cs = codeset_from_name (charset); |
600 | } |
608 | } |
|
|
609 | |
|
|
610 | free (registry); |
|
|
611 | free (encoding); |
601 | |
612 | |
602 | if (cs == CS_UNICODE) |
613 | if (cs == CS_UNICODE) |
603 | 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 |
604 | |
615 | |
605 | encm = f->min_byte1 != 0 || f->max_byte1 != 0; |
616 | encm = f->min_byte1 != 0 || f->max_byte1 != 0; |
… | |
… | |
1145 | } |
1156 | } |
1146 | |
1157 | |
1147 | int |
1158 | int |
1148 | rxvt_fontset::find_font (unicode_t unicode) |
1159 | rxvt_fontset::find_font (unicode_t unicode) |
1149 | { |
1160 | { |
1150 | 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++) |
1151 | { |
1164 | { |
1152 | rxvt_font *f = fonts[i]; |
1165 | rxvt_font *f = fonts[i]; |
1153 | |
1166 | |
1154 | if (!f->loaded) |
1167 | if (!f->loaded) |
1155 | { |
1168 | { |