diff options
author | Aaron Jensen <aaronjensen@gmail.com> | 2018-03-10 13:14:28 +0200 |
---|---|---|
committer | Eli Zaretskii <eliz@gnu.org> | 2018-03-10 13:14:28 +0200 |
commit | bbf53d99b57bd3d7fc0427d378df2efc6fa10e00 (patch) | |
tree | 0d3074b8c6ad4acff71383fa8be427a03a63d8df /src/w32term.c | |
parent | 461e681822ff86132a6dc18b65eb2070cb006800 (diff) | |
download | emacs-bbf53d99b57bd3d7fc0427d378df2efc6fa10e00.tar.gz |
Allow underline position variables be buffer-local
* src/nsterm.m (ns_draw_text_decoration):
* src/w32term.c (x_draw_glyph_string):
* src/xterm.c (x_draw_glyph_string): Allow underline-minimum-offset,
underline-at-descent-line, and x-use-underline-position-properties
be buffer local variables. (Bug#30553)
* src/xdisp.c (syms_of_xdisp) <underline-minimum-offset>: Add DEFSYM.
Diffstat (limited to 'src/w32term.c')
-rw-r--r-- | src/w32term.c | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/src/w32term.c b/src/w32term.c index 97afb678c1d..24950dd25ec 100644 --- a/src/w32term.c +++ b/src/w32term.c @@ -2475,31 +2475,52 @@ x_draw_glyph_string (struct glyph_string *s) else { struct font *font = font_for_underline_metrics (s); + unsigned long minimum_offset; + BOOL underline_at_descent_line; + BOOL use_underline_position_properties; + Lisp_Object val + = buffer_local_value (Qunderline_minimum_offset, + s->w->contents); + if (INTEGERP (val)) + minimum_offset = XFASTINT (val); + else + minimum_offset = 1; + val = buffer_local_value (Qx_underline_at_descent_line, + s->w->contents); + underline_at_descent_line + = !(NILP (val) || EQ (val, Qunbound)); + val + = buffer_local_value (Qx_use_underline_position_properties, + s->w->contents); + use_underline_position_properties + = !(NILP (val) || EQ (val, Qunbound)); /* Get the underline thickness. Default is 1 pixel. */ if (font && font->underline_thickness > 0) thickness = font->underline_thickness; else thickness = 1; - if (x_underline_at_descent_line || !font) + if (underline_at_descent_line + || !font) position = (s->height - thickness) - (s->ybase - s->y); else { - /* Get the underline position. This is the recommended - vertical offset in pixels from the baseline to the top of - the underline. This is a signed value according to the + /* Get the underline position. This is the + recommended vertical offset in pixels from + the baseline to the top of the underline. + This is a signed value according to the specs, and its default is ROUND ((maximum_descent) / 2), with ROUND (x) = floor (x + 0.5) */ - if (x_use_underline_position_properties + if (use_underline_position_properties && font->underline_position >= 0) position = font->underline_position; else position = (font->descent + 1) / 2; } - position = max (position, underline_minimum_offset); + position = max (position, minimum_offset); } /* Check the sanity of thickness and position. We should avoid drawing underline out of the current line area. */ @@ -7385,11 +7406,14 @@ the cursor have no effect. */); x_use_underline_position_properties, doc: /* SKIP: real doc in xterm.c. */); x_use_underline_position_properties = 0; + DEFSYM (Qx_use_underline_position_properties, + "x-use-underline-position-properties"); DEFVAR_BOOL ("x-underline-at-descent-line", x_underline_at_descent_line, doc: /* SKIP: real doc in xterm.c. */); x_underline_at_descent_line = 0; + DEFSYM (Qx_underline_at_descent_line, "x-underline-at-descent-line"); DEFVAR_LISP ("x-toolkit-scroll-bars", Vx_toolkit_scroll_bars, doc: /* SKIP: real doc in xterm.c. */); |