From 8d2b58fbbc371ca80f89c7d557e6f3137de9eaa2 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 27 Aug 2006 10:10:25 +0000 Subject: [PATCH] *** empty log message *** --- Changes | 2 ++ src/main.C | 11 +++++++---- src/rxvtfont.C | 20 ++++++++++---------- src/rxvtfont.h | 5 +++-- 4 files changed, 22 insertions(+), 16 deletions(-) diff --git a/Changes b/Changes index b67c4bf5..5a36d62b 100644 --- a/Changes +++ b/Changes @@ -22,6 +22,8 @@ WISH: kick out xpm.C, replace by pixbuf DUMB: support tex fonts 8.0 + - specified fonts were incorrectly morphed to bold/italic according to the + basefont, even if explicitly specified (tracked down by tpope). - fixed urxvt::strwidth to calculate width in the same way as screen.C. - fix a crash caused by passing negative widths to overlay functions. - give proper diagnostic when RXVT_SOCKET is too long instead of diff --git a/src/main.C b/src/main.C index 5156a8b2..699c6187 100644 --- a/src/main.C +++ b/src/main.C @@ -834,17 +834,20 @@ rxvt_term::set_fonts () rxvt_fontprop prop2 = prop; if (res) - prop2.weight = prop2.slant = rxvt_fontprop::unset; + { + fs->populate (res); + fs->set_prop (prop2, false); + } else { - res = fontset[0]->fontdesc; + fs->populate (fontset[0]->fontdesc); if (SET_STYLE (0, style) & RS_Bold) prop2.weight = rxvt_fontprop::bold; if (SET_STYLE (0, style) & RS_Italic) prop2.slant = rxvt_fontprop::italic; + + fs->set_prop (prop2, true); } - fs->populate (res); - fs->set_prop (prop2, true); } #else fontset[style] = fontset[0]; diff --git a/src/rxvtfont.C b/src/rxvtfont.C index e59f0ad0..56a35ed1 100644 --- a/src/rxvtfont.C +++ b/src/rxvtfont.C @@ -272,7 +272,7 @@ struct rxvt_font_default : rxvt_font { return p; } - bool load (const rxvt_fontprop &prop) + bool load (const rxvt_fontprop &prop, bool force_prop) { width = 1; height = 1; ascent = 1; descent = 0; @@ -473,7 +473,7 @@ struct rxvt_font_x11 : rxvt_font { rxvt_fontprop properties (); - bool load (const rxvt_fontprop &prop); + bool load (const rxvt_fontprop &prop, bool force_prop); bool has_char (unicode_t unicode, const rxvt_fontprop *prop, bool &careful) const; @@ -629,7 +629,7 @@ replace_field (char *buf, const char *name, int index, const char old, const cha } bool -rxvt_font_x11::load (const rxvt_fontprop &prop) +rxvt_font_x11::load (const rxvt_fontprop &prop, bool force_prop) { dTermDisplay; @@ -638,8 +638,7 @@ rxvt_font_x11::load (const rxvt_fontprop &prop) char field_str[64]; // enough for 128 bits // first morph the font if required - if (prop.weight != rxvt_fontprop::unset - || prop.slant != rxvt_fontprop::unset) + if (force_prop) { char fname[1024]; @@ -1041,7 +1040,7 @@ struct rxvt_font_xft : rxvt_font { rxvt_fontprop properties (); - bool load (const rxvt_fontprop &prop); + bool load (const rxvt_fontprop &prop, bool force_prop); void draw (rxvt_drawable &d, int x, int y, const text_t *text, int len, @@ -1084,7 +1083,7 @@ rxvt_font_xft::properties () } bool -rxvt_font_xft::load (const rxvt_fontprop &prop) +rxvt_font_xft::load (const rxvt_fontprop &prop, bool force_prop) { dTermDisplay; @@ -1103,11 +1102,11 @@ rxvt_font_xft::load (const rxvt_fontprop &prop) FcPatternAddInteger (p, FC_PIXEL_SIZE, prop.height); if (prop.weight != rxvt_fontprop::unset - && FcPatternGet (p, FC_WEIGHT, 0, &v) != FcResultMatch) + && (force_prop || FcPatternGet (p, FC_WEIGHT, 0, &v) != FcResultMatch)) FcPatternAddInteger (p, FC_WEIGHT, prop.weight); if (prop.slant != rxvt_fontprop::unset - && FcPatternGet (p, FC_SLANT, 0, &v) != FcResultMatch) + && (force_prop || FcPatternGet (p, FC_SLANT, 0, &v) != FcResultMatch)) FcPatternAddInteger (p, FC_SLANT, prop.slant); #if 0 // clipping unfortunately destroys our precious double-width-characters @@ -1387,6 +1386,7 @@ rxvt_fontset::clear () { prop.width = prop.height = prop.ascent = prop.weight = prop.slant = rxvt_fontprop::unset; + force_prop = false; for (rxvt_font **i = fonts.begin (); i != fonts.end (); i++) FONT_UNREF (*i); @@ -1508,7 +1508,7 @@ rxvt_fontset::realize_font (int i) fonts[i]->loaded = true; - if (!fonts[i]->load (prop)) + if (!fonts[i]->load (prop, force_prop)) { fonts[i]->cs = CS_UNKNOWN; return false; diff --git a/src/rxvtfont.h b/src/rxvtfont.h index a70ead45..62fb2e2a 100644 --- a/src/rxvtfont.h +++ b/src/rxvtfont.h @@ -62,7 +62,7 @@ struct rxvt_font { virtual rxvt_fontprop properties () = 0; - virtual bool load (const rxvt_fontprop &morph) = 0; + virtual bool load (const rxvt_fontprop &morph, bool force_prop) = 0; virtual bool has_char (uint32_t unicode, const rxvt_fontprop *prop, bool &careful) const = 0; virtual void draw (rxvt_drawable &d, @@ -82,7 +82,7 @@ struct rxvt_fontset { ~rxvt_fontset (); bool populate (const char *desc); - void set_prop (const rxvt_fontprop &prop) { this->prop = prop; } + void set_prop (const rxvt_fontprop &prop, bool force_prop) { this->prop = prop; this->force_prop = force_prop; } int find_font (uint32_t unicode); int find_font (const char *name) const; bool realize_font (int i); @@ -96,6 +96,7 @@ struct rxvt_fontset { private: rxvt_term *term; rxvt_fontprop prop; + bool force_prop; simplevec fonts; const rxvt_fallback_font *fallback; -- 2.34.1