changeset 95791:82a0e6885715

* xterm.c (x_underline_minimum_display_offset): New var. (x_draw_glyph_string): Use it. (syms_of_xterm): Declare it. * cus-start.el (x-underline-minimum-display-offset): Give it a type.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Tue, 10 Jun 2008 20:01:54 +0000
parents a486132d892c
children 953225ddde83
files lisp/ChangeLog lisp/cus-start.el src/ChangeLog src/xterm.c
diffstat 4 files changed, 32 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Tue Jun 10 20:01:06 2008 +0000
+++ b/lisp/ChangeLog	Tue Jun 10 20:01:54 2008 +0000
@@ -1,3 +1,7 @@
+2008-06-10  David De La Harpe Golden  <david@harpegolden.net>  (tiny change)
+
+	* cus-start.el (x-underline-minimum-display-offset): Give it a type.
+
 2008-06-10  Chong Yidong  <cyd@stupidchicken.com>
 
 	* mouse.el (mouse-select-font): New function.
--- a/lisp/cus-start.el	Tue Jun 10 20:01:06 2008 +0000
+++ b/lisp/cus-start.el	Tue Jun 10 20:01:54 2008 +0000
@@ -348,6 +348,7 @@
 	     ;; xterm.c
 	     (x-use-underline-position-properties display boolean "22.1")
 	     (x-underline-at-descent-line display boolean "22.1")
+	     (x-underline-minimum-display-offset display integer "23.1")
 	     (x-stretch-cursor display boolean "21.1")))
       this symbol group type standard version native-p
       ;; This function turns a value
--- a/src/ChangeLog	Tue Jun 10 20:01:06 2008 +0000
+++ b/src/ChangeLog	Tue Jun 10 20:01:54 2008 +0000
@@ -1,3 +1,9 @@
+2008-06-10  David De La Harpe Golden  <david@harpegolden.net>  (tiny change)
+
+	* xterm.c (x_underline_minimum_display_offset): New var.
+	(x_draw_glyph_string): Use it.
+	(syms_of_xterm): Declare it.
+
 2008-06-10  Chong Yidong  <cyd@stupidchicken.com>
 
 	* font.c (font_parse_fcname): Accept GTK-style font names too.
--- a/src/xterm.c	Tue Jun 10 20:01:06 2008 +0000
+++ b/src/xterm.c	Tue Jun 10 20:01:54 2008 +0000
@@ -183,6 +183,12 @@
 
 int x_underline_at_descent_line;
 
+/* Require underline to be at least this many screen pixels below baseline
+   This to avoid underline "merging" with the base of letters at small
+   font sizes, particularly when x_use_underline_position_properties is on. */
+
+int x_underline_minimum_display_offset;
+
 /* This is a chain of structures for all the X displays currently in
    use.  */
 
@@ -2744,6 +2750,8 @@
 		  else if (s->font)
 		    position = (s->font->descent + 1) / 2;
 		}
+	      if (x_underline_minimum_display_offset)
+		position = max (position, eabs (x_underline_minimum_display_offset));
 	    }
 	  /* Check the sanity of thickness and position.  We should
 	     avoid drawing underline out of the current line area.  */
@@ -10781,7 +10789,9 @@
      doc: /* *Non-nil means make use of UNDERLINE_POSITION font properties.
 A value of nil means ignore them.  If you encounter fonts with bogus
 UNDERLINE_POSITION font properties, for example 7x13 on XFree prior
-to 4.1, set this to nil.  */);
+to 4.1, set this to nil.  Variable `x-underline-minimum-display-offset' may
+be used to override the font's UNDERLINE_POSITION for small font display
+sizes.  */);
   x_use_underline_position_properties = 1;
 
   DEFVAR_BOOL ("x-underline-at-descent-line",
@@ -10792,6 +10802,16 @@
 baseline level.  The default value is nil.  */);
   x_underline_at_descent_line = 0;
 
+  DEFVAR_INT ("x-underline-minimum-display-offset",
+	       &x_underline_minimum_display_offset,
+     doc: /* *When > 0, underline is drawn at least that many screen pixels below baseline.
+This can improve legibility of underlined text at small font sizes,
+particularly when using variable `x-use-underline-position-properties'
+with fonts that specify an UNDERLINE_POSITION relatively close to the
+baseline.  The default value is 0. */);
+  x_underline_minimum_display_offset = 0;
+
+
   DEFVAR_BOOL ("x-mouse-click-focus-ignore-position",
 	       &x_mouse_click_focus_ignore_position,
     doc: /* Non-nil means that a mouse click to focus a frame does not move point.