aboutsummaryrefslogtreecommitdiffstats
path: root/src/w32term.c
diff options
context:
space:
mode:
authorAaron Jensen2018-03-10 13:14:28 +0200
committerEli Zaretskii2018-03-10 13:14:28 +0200
commitbbf53d99b57bd3d7fc0427d378df2efc6fa10e00 (patch)
tree0d3074b8c6ad4acff71383fa8be427a03a63d8df /src/w32term.c
parent461e681822ff86132a6dc18b65eb2070cb006800 (diff)
downloademacs-bbf53d99b57bd3d7fc0427d378df2efc6fa10e00.tar.gz
emacs-bbf53d99b57bd3d7fc0427d378df2efc6fa10e00.zip
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.c36
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)
2475 else 2475 else
2476 { 2476 {
2477 struct font *font = font_for_underline_metrics (s); 2477 struct font *font = font_for_underline_metrics (s);
2478 unsigned long minimum_offset;
2479 BOOL underline_at_descent_line;
2480 BOOL use_underline_position_properties;
2481 Lisp_Object val
2482 = buffer_local_value (Qunderline_minimum_offset,
2483 s->w->contents);
2484 if (INTEGERP (val))
2485 minimum_offset = XFASTINT (val);
2486 else
2487 minimum_offset = 1;
2488 val = buffer_local_value (Qx_underline_at_descent_line,
2489 s->w->contents);
2490 underline_at_descent_line
2491 = !(NILP (val) || EQ (val, Qunbound));
2492 val
2493 = buffer_local_value (Qx_use_underline_position_properties,
2494 s->w->contents);
2495 use_underline_position_properties
2496 = !(NILP (val) || EQ (val, Qunbound));
2478 2497
2479 /* Get the underline thickness. Default is 1 pixel. */ 2498 /* Get the underline thickness. Default is 1 pixel. */
2480 if (font && font->underline_thickness > 0) 2499 if (font && font->underline_thickness > 0)
2481 thickness = font->underline_thickness; 2500 thickness = font->underline_thickness;
2482 else 2501 else
2483 thickness = 1; 2502 thickness = 1;
2484 if (x_underline_at_descent_line || !font) 2503 if (underline_at_descent_line
2504 || !font)
2485 position = (s->height - thickness) - (s->ybase - s->y); 2505 position = (s->height - thickness) - (s->ybase - s->y);
2486 else 2506 else
2487 { 2507 {
2488 /* Get the underline position. This is the recommended 2508 /* Get the underline position. This is the
2489 vertical offset in pixels from the baseline to the top of 2509 recommended vertical offset in pixels from
2490 the underline. This is a signed value according to the 2510 the baseline to the top of the underline.
2511 This is a signed value according to the
2491 specs, and its default is 2512 specs, and its default is
2492 2513
2493 ROUND ((maximum_descent) / 2), with 2514 ROUND ((maximum_descent) / 2), with
2494 ROUND (x) = floor (x + 0.5) */ 2515 ROUND (x) = floor (x + 0.5) */
2495 2516
2496 if (x_use_underline_position_properties 2517 if (use_underline_position_properties
2497 && font->underline_position >= 0) 2518 && font->underline_position >= 0)
2498 position = font->underline_position; 2519 position = font->underline_position;
2499 else 2520 else
2500 position = (font->descent + 1) / 2; 2521 position = (font->descent + 1) / 2;
2501 } 2522 }
2502 position = max (position, underline_minimum_offset); 2523 position = max (position, minimum_offset);
2503 } 2524 }
2504 /* Check the sanity of thickness and position. We should 2525 /* Check the sanity of thickness and position. We should
2505 avoid drawing underline out of the current line area. */ 2526 avoid drawing underline out of the current line area. */
@@ -7385,11 +7406,14 @@ the cursor have no effect. */);
7385 x_use_underline_position_properties, 7406 x_use_underline_position_properties,
7386 doc: /* SKIP: real doc in xterm.c. */); 7407 doc: /* SKIP: real doc in xterm.c. */);
7387 x_use_underline_position_properties = 0; 7408 x_use_underline_position_properties = 0;
7409 DEFSYM (Qx_use_underline_position_properties,
7410 "x-use-underline-position-properties");
7388 7411
7389 DEFVAR_BOOL ("x-underline-at-descent-line", 7412 DEFVAR_BOOL ("x-underline-at-descent-line",
7390 x_underline_at_descent_line, 7413 x_underline_at_descent_line,
7391 doc: /* SKIP: real doc in xterm.c. */); 7414 doc: /* SKIP: real doc in xterm.c. */);
7392 x_underline_at_descent_line = 0; 7415 x_underline_at_descent_line = 0;
7416 DEFSYM (Qx_underline_at_descent_line, "x-underline-at-descent-line");
7393 7417
7394 DEFVAR_LISP ("x-toolkit-scroll-bars", Vx_toolkit_scroll_bars, 7418 DEFVAR_LISP ("x-toolkit-scroll-bars", Vx_toolkit_scroll_bars,
7395 doc: /* SKIP: real doc in xterm.c. */); 7419 doc: /* SKIP: real doc in xterm.c. */);