… | |
… | |
270 | p.slant = rxvt_fontprop::roman; |
270 | p.slant = rxvt_fontprop::roman; |
271 | |
271 | |
272 | return p; |
272 | return p; |
273 | } |
273 | } |
274 | |
274 | |
275 | bool load (const rxvt_fontprop &prop) |
275 | bool load (const rxvt_fontprop &prop, bool force_prop) |
276 | { |
276 | { |
277 | width = 1; height = 1; |
277 | width = 1; height = 1; |
278 | ascent = 1; descent = 0; |
278 | ascent = 1; descent = 0; |
279 | |
279 | |
280 | set_name (strdup ("built-in support font")); |
280 | set_name (strdup ("built-in support font")); |
… | |
… | |
471 | |
471 | |
472 | void clear (); |
472 | void clear (); |
473 | |
473 | |
474 | rxvt_fontprop properties (); |
474 | rxvt_fontprop properties (); |
475 | |
475 | |
476 | bool load (const rxvt_fontprop &prop); |
476 | bool load (const rxvt_fontprop &prop, bool force_prop); |
477 | |
477 | |
478 | bool has_char (unicode_t unicode, const rxvt_fontprop *prop, bool &careful) const; |
478 | bool has_char (unicode_t unicode, const rxvt_fontprop *prop, bool &careful) const; |
479 | |
479 | |
480 | void draw (rxvt_drawable &d, int x, int y, |
480 | void draw (rxvt_drawable &d, int x, int y, |
481 | const text_t *text, int len, |
481 | const text_t *text, int len, |
482 | int fg, int bg); |
482 | int fg, int bg); |
483 | |
483 | |
484 | bool slow; // wether this is a proportional font or has other funny characteristics |
484 | bool slow; // wether this is a proportional font or has other funny characteristics |
485 | XFontStruct *f; |
485 | XFontStruct *f; |
486 | codeset cs; |
|
|
487 | bool enc2b, encm; |
486 | bool enc2b, encm; |
488 | |
487 | |
489 | char *get_property (XFontStruct *f, Atom property, const char *repl) const; |
488 | char *get_property (XFontStruct *f, Atom property, const char *repl) const; |
490 | bool set_properties (rxvt_fontprop &p, int height, const char *weight, const char *slant, int avgwidth); |
489 | bool set_properties (rxvt_fontprop &p, int height, const char *weight, const char *slant, int avgwidth); |
491 | bool set_properties (rxvt_fontprop &p, XFontStruct *f); |
490 | bool set_properties (rxvt_fontprop &p, XFontStruct *f); |
… | |
… | |
627 | return false; |
626 | return false; |
628 | } |
627 | } |
629 | } |
628 | } |
630 | |
629 | |
631 | bool |
630 | bool |
632 | rxvt_font_x11::load (const rxvt_fontprop &prop) |
631 | rxvt_font_x11::load (const rxvt_fontprop &prop, bool force_prop) |
633 | { |
632 | { |
634 | dTermDisplay; |
633 | dTermDisplay; |
635 | |
634 | |
636 | clear (); |
635 | clear (); |
637 | |
636 | |
638 | char field_str[64]; // enough for 128 bits |
637 | char field_str[64]; // enough for 128 bits |
639 | |
638 | |
640 | // first morph the font if required |
639 | // first morph the font if required |
641 | if (prop.weight != rxvt_fontprop::unset |
640 | if (force_prop) |
642 | || prop.slant != rxvt_fontprop::unset) |
|
|
643 | { |
641 | { |
644 | char fname[1024]; |
642 | char fname[1024]; |
645 | |
643 | |
646 | if (name[0] != '-') |
644 | if (name[0] != '-') |
647 | { |
645 | { |
… | |
… | |
1039 | |
1037 | |
1040 | void clear (); |
1038 | void clear (); |
1041 | |
1039 | |
1042 | rxvt_fontprop properties (); |
1040 | rxvt_fontprop properties (); |
1043 | |
1041 | |
1044 | bool load (const rxvt_fontprop &prop); |
1042 | bool load (const rxvt_fontprop &prop, bool force_prop); |
1045 | |
1043 | |
1046 | void draw (rxvt_drawable &d, int x, int y, |
1044 | void draw (rxvt_drawable &d, int x, int y, |
1047 | const text_t *text, int len, |
1045 | const text_t *text, int len, |
1048 | int fg, int bg); |
1046 | int fg, int bg); |
1049 | |
1047 | |
… | |
… | |
1082 | |
1080 | |
1083 | return p; |
1081 | return p; |
1084 | } |
1082 | } |
1085 | |
1083 | |
1086 | bool |
1084 | bool |
1087 | rxvt_font_xft::load (const rxvt_fontprop &prop) |
1085 | rxvt_font_xft::load (const rxvt_fontprop &prop, bool force_prop) |
1088 | { |
1086 | { |
1089 | dTermDisplay; |
1087 | dTermDisplay; |
1090 | |
1088 | |
1091 | clear (); |
1089 | clear (); |
1092 | |
1090 | |
… | |
… | |
1101 | && (FcPatternGet (p, FC_PIXEL_SIZE, 0, &v) != FcResultMatch |
1099 | && (FcPatternGet (p, FC_PIXEL_SIZE, 0, &v) != FcResultMatch |
1102 | && FcPatternGet (p, FC_SIZE, 0, &v) != FcResultMatch)) |
1100 | && FcPatternGet (p, FC_SIZE, 0, &v) != FcResultMatch)) |
1103 | FcPatternAddInteger (p, FC_PIXEL_SIZE, prop.height); |
1101 | FcPatternAddInteger (p, FC_PIXEL_SIZE, prop.height); |
1104 | |
1102 | |
1105 | if (prop.weight != rxvt_fontprop::unset |
1103 | if (prop.weight != rxvt_fontprop::unset |
1106 | && FcPatternGet (p, FC_WEIGHT, 0, &v) != FcResultMatch) |
1104 | && (force_prop || FcPatternGet (p, FC_WEIGHT, 0, &v) != FcResultMatch)) |
1107 | FcPatternAddInteger (p, FC_WEIGHT, prop.weight); |
1105 | FcPatternAddInteger (p, FC_WEIGHT, prop.weight); |
1108 | |
1106 | |
1109 | if (prop.slant != rxvt_fontprop::unset |
1107 | if (prop.slant != rxvt_fontprop::unset |
1110 | && FcPatternGet (p, FC_SLANT, 0, &v) != FcResultMatch) |
1108 | && (force_prop || FcPatternGet (p, FC_SLANT, 0, &v) != FcResultMatch)) |
1111 | FcPatternAddInteger (p, FC_SLANT, prop.slant); |
1109 | FcPatternAddInteger (p, FC_SLANT, prop.slant); |
1112 | |
1110 | |
1113 | #if 0 // clipping unfortunately destroys our precious double-width-characters |
1111 | #if 0 // clipping unfortunately destroys our precious double-width-characters |
1114 | // clip width, we can't do better, or can we? |
1112 | // clip width, we can't do better, or can we? |
1115 | if (FcPatternGet (p, FC_CHAR_WIDTH, 0, &v) != FcResultMatch) |
1113 | if (FcPatternGet (p, FC_CHAR_WIDTH, 0, &v) != FcResultMatch) |
… | |
… | |
1385 | void |
1383 | void |
1386 | rxvt_fontset::clear () |
1384 | rxvt_fontset::clear () |
1387 | { |
1385 | { |
1388 | prop.width = prop.height = prop.ascent = prop.weight = prop.slant |
1386 | prop.width = prop.height = prop.ascent = prop.weight = prop.slant |
1389 | = rxvt_fontprop::unset; |
1387 | = rxvt_fontprop::unset; |
|
|
1388 | force_prop = false; |
1390 | |
1389 | |
1391 | for (rxvt_font **i = fonts.begin (); i != fonts.end (); i++) |
1390 | for (rxvt_font **i = fonts.begin (); i != fonts.end (); i++) |
1392 | FONT_UNREF (*i); |
1391 | FONT_UNREF (*i); |
1393 | |
1392 | |
1394 | for (pagemap **p = fmap.begin (); p != fmap.end (); p++) |
1393 | for (pagemap **p = fmap.begin (); p != fmap.end (); p++) |
… | |
… | |
1506 | if (fonts[i]->loaded) |
1505 | if (fonts[i]->loaded) |
1507 | return true; |
1506 | return true; |
1508 | |
1507 | |
1509 | fonts[i]->loaded = true; |
1508 | fonts[i]->loaded = true; |
1510 | |
1509 | |
1511 | if (!fonts[i]->load (prop)) |
1510 | if (!fonts[i]->load (prop, force_prop)) |
1512 | { |
1511 | { |
1513 | fonts[i]->cs = CS_UNKNOWN; |
1512 | fonts[i]->cs = CS_UNKNOWN; |
1514 | return false; |
1513 | return false; |
1515 | } |
1514 | } |
1516 | |
1515 | |