From c323f0339e844121cd4af6a5a6d5789989e4f9b4 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 30 Jan 2006 04:27:17 +0000 Subject: [PATCH] *** empty log message *** --- Changes | 12 +++++++ src/command.C | 9 +++++- src/rxvt.h | 3 ++ src/rxvtfont.C | 85 +++++++++++++++++++++++++++++--------------------- src/rxvtfont.h | 2 +- src/screen.C | 7 ++--- 6 files changed, 77 insertions(+), 41 deletions(-) diff --git a/Changes b/Changes index 1dd22f10..b489557d 100644 --- a/Changes +++ b/Changes @@ -23,6 +23,18 @@ DUMB: support tex fonts transparent. Long Live Xft! - do not include X11/Intrinsic.h anymore, directly use Xlib/Xutil/Xresource directly. + - further improve the careful mode detection, and font width + detection: + - fully double-wide fonts will now be correctly treated, + - overlap detection was improved. + - detect totally broken fonts (usually synthesized by xft). + - careful mode forced refresh sometimes clashed with blinking, + causing unnecessary screen redraws. + - better handling of XFT combining characters. + - enable antialiasing for some replacement fonts, as they + might get used for other encodings which really need it, later. + - remove spacing=100 from all default fonts, as this creates totally + weird spacing (5 times normal) with xft. - replace named colours by xorg's rgb.txt equivalents, to reduce round trip time on startup, and short-cut allocation of rgb:rr/gg/bb. diff --git a/src/command.C b/src/command.C index d4838d54..0382beb4 100644 --- a/src/command.C +++ b/src/command.C @@ -229,9 +229,16 @@ rxvt_term::iso14755_51 (unicode_t ch, rend_t r, int x, int y) ch = 0xfffd; # endif scr_overlay_set (11, y, ch, r); - scr_overlay_set (12, y, NOCHAR, r); + + if (WCWIDTH (ch) >= 2) + scr_overlay_set (12, y, NOCHAR, r); } +// { +// char buf[4+4+3+1]; +// snprintf (buf, sizeof (buf), "(%.4d|%.4d)", x, y); +// scr_overlay_set (0, 0, buf); +// } scr_overlay_set (0, len , attr); scr_overlay_set (0, len + 1, fname); diff --git a/src/rxvt.h b/src/rxvt.h index 7156ff66..cef60304 100644 --- a/src/rxvt.h +++ b/src/rxvt.h @@ -434,6 +434,9 @@ enum { #define RS_RVid 0x00020000UL // reverse video #define RS_Uline 0x00040000UL // underline +// toggle this to force redraw, must be != RS_Careful +#define RS_redraw 0x01000000UL + // 5 custom bits for extensions #define RS_customCount 32 #define RS_customMask 0x00f80000UL diff --git a/src/rxvtfont.C b/src/rxvtfont.C index 42d6f6af..67f4cbe2 100644 --- a/src/rxvtfont.C +++ b/src/rxvtfont.C @@ -26,17 +26,17 @@ #include "rxvtfont.h" #include -#include + #include #define MAX_OVERLAP_ROMAN (8 + 2) // max. character width in 8ths of the base width #define MAX_OVERLAP_ITALIC (8 + 3) // max. overlap for italic fonts -#define OVERLAP_OK(w,prop) (w) > ( \ - prop->slant >= rxvt_fontprop::italic \ - ? (prop->width * MAX_OVERLAP_ITALIC + 7) >> 3 \ - : (prop->width * MAX_OVERLAP_ROMAN + 7) >> 3 \ - ) +#define OVERLAP_OK(w,wcw,prop) ((w) <= ( \ + (prop)->slant >= rxvt_fontprop::italic \ + ? ((prop)->width * (wcw) * MAX_OVERLAP_ITALIC + 7) >> 3 \ + : ((prop)->width * (wcw) * MAX_OVERLAP_ROMAN + 7) >> 3 \ + )) const struct rxvt_fallback_font { codeset cs; @@ -66,15 +66,15 @@ const struct rxvt_fallback_font { { CS_ISO8859_16, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-16" }, # if XFT - { CS_KOI8_U, "xft::spacing=100:lang=ru:antialias=false" }, - - { CS_ISO8859_5, "xft::spacing=100:lang=ru:antialias=false" }, - { CS_ISO8859_6, "xft::spacing=100:lang=ar:antialias=false" }, - { CS_ISO8859_7, "xft::spacing=100:lang=el:antialias=false" }, - { CS_ISO8859_8, "xft::spacing=100:lang=he:antialias=false" }, - { CS_ISO8859_9, "xft::spacing=100:lang=tr:antialias=false" }, - { CS_ISO8859_10, "xft::spacing=100:lang=se:antialias=false" }, - { CS_ISO8859_11, "xft::spacing=100:lang=th:antialias=false" }, + { CS_KOI8_U, "xft::lang=ru" }, + + { CS_ISO8859_5, "xft::lang=ru" }, + { CS_ISO8859_6, "xft::lang=ar" }, + { CS_ISO8859_7, "xft::lang=el" }, + { CS_ISO8859_8, "xft::lang=he" }, + { CS_ISO8859_9, "xft::lang=tr" }, + { CS_ISO8859_10, "xft::lang=se" }, + { CS_ISO8859_11, "xft::lang=th" }, # endif #endif @@ -85,7 +85,7 @@ const struct rxvt_fallback_font { { CS_JIS0208_1990_0, "xft:Kochi Gothic:antialias=false" }, { CS_JIS0208_1990_0, "xft:Sazanami Mincho:antialias=false" }, { CS_JIS0208_1990_0, "xft:Mincho:antialias=false" }, - { CS_JIS0208_1990_0, "xft::lang=ja:spacing=100:antialias=false" }, + { CS_JIS0208_1990_0, "xft::lang=ja:antialias=false" }, # endif { CS_JIS0201_1976_0, "-*-mincho-*-r-*--*-*-*-*-c-*-jisx0201*-0" }, { CS_JIS0208_1990_0, "-*-mincho-*-r-*--*-*-*-*-c-*-jisx0208*-0" }, @@ -99,12 +99,12 @@ const struct rxvt_fallback_font { # if XFT { CS_GBK_0, "xft:AR PL KaitiM GB" }, { CS_GBK_0, "xft:AR PL SungtiL GB" }, - { CS_GBK_0, "xft::spacing=100:lang=zh" }, + { CS_GBK_0, "xft::lang=zh" }, { CS_BIG5_EXT, "xft:AR PL Mingti2L Big5" }, { CS_BIG5_EXT, "xft:AR PL KaitiM Big5" }, { CS_GB2312_1980_0, "xft:AR PL KaitiM GB" }, { CS_GB2312_1980_0, "xft:AR PL SungtiL GB" }, - { CS_GB2312_1980_0, "xft::spacing=100:lang=zh" }, + { CS_GB2312_1980_0, "xft::lang=zh" }, # endif { CS_GBK_0, "-*-*-*-*-*-*-*-*-*-*-c-*-gbk*-0" }, { CS_BIG5, "-*-*-*-*-*-*-*-*-*-*-c-*-big5-0" }, @@ -127,7 +127,7 @@ const struct rxvt_fallback_font { { CS_KSC5601_1987_0, "-*-*-*-*-*-*-*-*-*-*-c-*-ksc5601*" }, # if XFT { CS_KSC5601_1987_0, "xft:Baekmuk Gulim:antialias=false" }, - { CS_KSC5601_1987_0, "xft::spacing=100:lang=ko:antialias=false" }, + { CS_KSC5601_1987_0, "xft::lang=ko:antialias=false" }, # endif #endif @@ -230,6 +230,11 @@ enc_xchar2b (const text_t *text, uint32_t len, codeset cs, bool &zero) ///////////////////////////////////////////////////////////////////////////// +rxvt_font::rxvt_font () +: name(0), width(rxvt_fontprop::unset), height(rxvt_fontprop::unset) +{ +} + void rxvt_font::set_name (char *name) { @@ -259,6 +264,8 @@ rxvt_font::clear_rect (rxvt_drawable &d, int x, int y, int w, int h, int color) } } +///////////////////////////////////////////////////////////////////////////// + #include "table/linedraw.h" struct rxvt_font_default : rxvt_font { @@ -434,8 +441,9 @@ rxvt_font_default::draw (rxvt_drawable &d, int x, int y, #if ENABLE_COMBINING else if (IS_COMPOSE (t) && (cc = rxvt_composite[t])) { + min_it (width, 2); // we only support wcwidth up to 2 + text_t chrs[2]; - width = min (2, width); chrs [1] = NOCHAR; *chrs = cc->c1; @@ -523,7 +531,9 @@ rxvt_font_x11::properties () bool rxvt_font_x11::set_properties (rxvt_fontprop &p, int height, const char *weight, const char *slant, int avgwidth) { - p.width = avgwidth ? (avgwidth + 1) / 10 : (height + 1) / 2; + p.width = width != rxvt_fontprop::unset ? width + : avgwidth ? (avgwidth + 1) / 10 + : (height + 1) / 2; p.height = height; p.ascent = rxvt_fontprop::unset; p.weight = *weight == 'B' || *weight == 'b' ? rxvt_fontprop::bold : rxvt_fontprop::medium; @@ -813,9 +823,7 @@ rxvt_font_x11::load (const rxvt_fontprop &prop) slow = false; #if 1 // only used for slow detection, TODO optimize - if (f->min_bounds.width == f->max_bounds.width) - width = f->min_bounds.width; - else if (f->per_char == NULL) + if (f->min_bounds.width == f->max_bounds.width || !f->per_char) width = f->max_bounds.width; else { @@ -841,9 +849,7 @@ rxvt_font_x11::load (const rxvt_fontprop &prop) for (uint16_t *t = extent_test_chars + NUM_EXTENT_TEST_CHARS; t-- > extent_test_chars; ) { - if (cs != CS_UNICODE - && *t > 0x100 - && FROM_UNICODE (cs, *t) == NOCHAR) + if (FROM_UNICODE (cs, *t) == NOCHAR) continue; // ignore characters we wouldn't use anyways @@ -859,7 +865,7 @@ rxvt_font_x11::load (const rxvt_fontprop &prop) int wcw = WCWIDTH (*t); if (wcw > 0) g.width = (g.width + wcw - 1) / wcw; - if (width < g.width) width = g.width; + if (width < g.width) width = g.width; } if (cs == CS_UNKNOWN) @@ -939,13 +945,13 @@ rxvt_font_x11::has_char (unicode_t unicode, const rxvt_fontprop *prop, bool &car if (!prop || prop->width == rxvt_fontprop::unset) return true; - // check character against base font bounding box + // check wether character overlaps previous/next character int w = xcs->rbearing - xcs->lbearing; int wcw = WCWIDTH (unicode); - if (wcw > 0) w = (w + wcw - 1) / wcw; - careful = w > prop->width; - if (careful && OVERLAP_OK (w, prop)) + careful = xcs->lbearing < 0 || xcs->rbearing > prop->width * wcw; + + if (careful && !OVERLAP_OK (w, wcw, prop)) return false; return true; @@ -1258,10 +1264,14 @@ rxvt_font_xft::has_char (unicode_t unicode, const rxvt_fontprop *prop, bool &car int w = g.width - g.x; int wcw = WCWIDTH (unicode); - if (wcw > 0) w = (w + wcw - 1) / wcw; - careful = w > prop->width; - if (careful && OVERLAP_OK (w, prop)) + careful = g.x > 0 || w > prop->width * wcw; + + if (careful && !OVERLAP_OK (w, wcw, prop)) + return false; + + // this weeds out _totally_ broken fonts, or glyphs + if (!OVERLAP_OK (g.xOff, wcw, prop)) return false; return true; @@ -1298,9 +1308,14 @@ rxvt_font_xft::draw (rxvt_drawable &d, int x, int y, FT_UInt glyph = XftCharIndex (disp, f, fc); XftGlyphExtents (disp, f, &glyph, 1, &extents); + ep->glyph = glyph; ep->x = x + (cwidth - extents.xOff >> 1); ep->y = y + ascent; + + if (extents.xOff == 0) + ep->x = x + cwidth; + ep++; } diff --git a/src/rxvtfont.h b/src/rxvtfont.h index 4cb7def1..6eb296f1 100644 --- a/src/rxvtfont.h +++ b/src/rxvtfont.h @@ -76,7 +76,7 @@ struct rxvt_font { void set_name (char *name); - rxvt_font () { name = 0; } + rxvt_font (); virtual ~rxvt_font () { free (name); }; virtual void clear () { }; diff --git a/src/screen.C b/src/screen.C index a57b25e3..2db4dd8f 100644 --- a/src/screen.C +++ b/src/screen.C @@ -1756,10 +1756,9 @@ rxvt_term::scr_refresh_rend (rend_t mask, rend_t value) NOTHROW for (int i = 0; i < nrow; i++) { - int col = 0; rend_t *drp = drawn_buf[i].r; - for (; col < ncol; col++, drp++) + for (int col = 0; col < ncol; col++, drp++) if ((*drp & mask) == value) { found = true; @@ -2260,11 +2259,11 @@ rxvt_term::scr_refresh () NOTHROW // force redraw after "careful" characters to avoid pixel droppings for (int i = 0; srp[col + i] & RS_Careful && col + i < ncol - 1; i++) - drp[col + i + 1] = ~srp[col + i + 1]; + drp[col + i + 1] = srp[col + i + 1] ^ RS_redraw; // force redraw before "careful" characters to avoid pixel droppings for (int i = 0; srp[text - stp - i] & RS_Careful && text - i > stp; i++) - drp[text - stp - i - 1] = ~srp[text - stp - i - 1]; + drp[text - stp - i - 1] = srp[text - stp - i - 1] ^ RS_redraw; #endif bool invert = rend & RS_RVid; -- 2.34.1