*** empty log message ***
authorroot <root>
Mon, 30 Jan 2006 04:27:17 +0000 (04:27 +0000)
committerroot <root>
Mon, 30 Jan 2006 04:27:17 +0000 (04:27 +0000)
Changes
src/command.C
src/rxvt.h
src/rxvtfont.C
src/rxvtfont.h
src/screen.C

diff --git a/Changes b/Changes
index 1dd22f1097670d4dd2b586377a064095899c6e63..b489557de628ff9fb446f2456b7a8fa7eca3aea6 100644 (file)
--- 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.
index d4838d54d64f1aa2f917a1d1335931cd2c6cb65c..0382beb45abcc74ea75bb46740ccf7c2c1e10020 100644 (file)
@@ -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);
 
index 7156ff66edad2573fecbd07f82afec73792a4e78..cef60304947465385b9d9a3ab2f6bfecca9c6b71 100644 (file)
@@ -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
index 42d6f6af21177d6d9c4931c6ab13c075a1acd86f..67f4cbe286904dbe84626bb68aab8419b830bd83 100644 (file)
 #include "rxvtfont.h"
 
 #include <cstdlib>
-#include <wchar.h>
+
 #include <inttypes.h>
 
 #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++;
         }
 
index 4cb7def1607cf924b6aa13677871ef54965e5417..6eb296f1f0a36539157539498fb1a2101491dc19 100644 (file)
@@ -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 () { };
index a57b25e37c7b727bd1ca85c5ff9d4e6adef0c01b..2db4dd8fd04845de27e02e990579513b22c85aa0 100644 (file)
@@ -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;