… | |
… | |
493 | bool slow; // wether this is a proportional font or has other funny characteristics |
493 | bool slow; // wether this is a proportional font or has other funny characteristics |
494 | XFontStruct *f; |
494 | XFontStruct *f; |
495 | codeset cs; |
495 | codeset cs; |
496 | bool enc2b, encm; |
496 | bool enc2b, encm; |
497 | |
497 | |
498 | char *get_property (XFontStruct *f, const char *property, const char *repl) const; |
498 | char *get_property (XFontStruct *f, Atom property, const char *repl) const; |
499 | bool set_properties (rxvt_fontprop &p, int height, const char *weight, const char *slant, int avgwidth); |
499 | bool set_properties (rxvt_fontprop &p, int height, const char *weight, const char *slant, int avgwidth); |
500 | bool set_properties (rxvt_fontprop &p, XFontStruct *f); |
500 | bool set_properties (rxvt_fontprop &p, XFontStruct *f); |
501 | bool set_properties (rxvt_fontprop &p, const char *name); |
501 | bool set_properties (rxvt_fontprop &p, const char *name); |
502 | }; |
502 | }; |
503 | |
503 | |
504 | char * |
504 | char * |
505 | rxvt_font_x11::get_property (XFontStruct *f, const char *property, const char *repl) const |
505 | rxvt_font_x11::get_property (XFontStruct *f, Atom property, const char *repl) const |
506 | { |
506 | { |
507 | unsigned long value; |
507 | unsigned long value; |
508 | |
508 | |
509 | if (XGetFontProperty (f, XInternAtom (term->xdisp, property, 0), &value)) |
509 | if (XGetFontProperty (f, property, &value)) |
510 | return XGetAtomName (term->xdisp, value); |
510 | return XGetAtomName (term->xdisp, value); |
511 | else |
511 | else |
512 | return rxvt_strdup (repl); |
512 | return rxvt_strdup (repl); |
513 | } |
513 | } |
514 | |
514 | |
… | |
… | |
543 | #else |
543 | #else |
544 | height = f->ascent + f->descent; |
544 | height = f->ascent + f->descent; |
545 | #endif |
545 | #endif |
546 | |
546 | |
547 | unsigned long avgwidth; |
547 | unsigned long avgwidth; |
548 | if (!XGetFontProperty (f, XInternAtom (term->xdisp, "AVERAGE_WIDTH", 0), &avgwidth)) |
548 | if (!XGetFontProperty (f, term->xa [XA_AVERAGE_WIDTH], &avgwidth)) |
549 | avgwidth = 0; |
549 | avgwidth = 0; |
550 | |
550 | |
551 | char *weight = get_property (f, "WEIGHT_NAME", "medium"); |
551 | char *weight = get_property (f, term->xa [XA_WEIGHT_NAME], "medium"); |
552 | char *slant = get_property (f, "SLANT", "r"); |
552 | char *slant = get_property (f, term->xa [XA_SLANT], "r"); |
553 | |
553 | |
554 | set_properties (p, height, weight, slant, avgwidth); |
554 | set_properties (p, height, weight, slant, avgwidth); |
555 | |
555 | |
556 | free (weight); |
556 | free (weight); |
557 | free (slant); |
557 | free (slant); |
… | |
… | |
655 | f = XLoadQueryFont (disp, name); |
655 | f = XLoadQueryFont (disp, name); |
656 | |
656 | |
657 | if (!f) |
657 | if (!f) |
658 | return false; |
658 | return false; |
659 | |
659 | |
660 | char *new_name = get_property (f, "FONT", name); |
660 | char *new_name = get_property (f, XA_FONT, name); |
661 | |
661 | |
662 | if (new_name) |
662 | if (new_name) |
663 | set_name (new_name); |
663 | set_name (new_name); |
664 | else |
664 | else |
665 | rxvt_warn ("font '%s' has no FONT property, continuing without.", name); |
665 | rxvt_warn ("font '%s' has no FONT property, continuing without.", name); |
… | |
… | |
774 | delete [] fonts; |
774 | delete [] fonts; |
775 | |
775 | |
776 | if (!f) |
776 | if (!f) |
777 | return false; |
777 | return false; |
778 | |
778 | |
779 | char *registry = get_property (f, "CHARSET_REGISTRY", 0); |
779 | char *registry = get_property (f, term->xa [XA_CHARSET_REGISTRY], 0); |
780 | char *encoding = get_property (f, "CHARSET_ENCODING", 0); |
780 | char *encoding = get_property (f, term->xa [XA_CHARSET_ENCODING], 0); |
781 | |
781 | |
782 | if (registry && encoding) |
782 | if (registry && encoding) |
783 | { |
783 | { |
784 | char charset[64]; |
784 | char charset[64]; |
785 | snprintf (charset, 64, "%s-%s", registry, encoding); |
785 | snprintf (charset, 64, "%s-%s", registry, encoding); |
786 | |
786 | |
787 | cs = codeset_from_name (charset); |
787 | cs = codeset_from_name (charset); |
788 | } |
788 | } |
789 | else |
789 | else |
790 | { |
790 | { |
791 | const char *charset = get_property (f, "FONT", 0); |
791 | const char *charset = get_property (f, XA_FONT, 0); |
792 | |
792 | |
793 | if (!charset) |
793 | if (!charset) |
794 | charset = name; |
794 | charset = name; |
795 | |
795 | |
796 | int count = 13; |
796 | int count = 13; |