diff options
Diffstat (limited to 'src/nsterm.m')
| -rw-r--r-- | src/nsterm.m | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/src/nsterm.m b/src/nsterm.m index 1919c6defaf..75e0b837c67 100644 --- a/src/nsterm.m +++ b/src/nsterm.m | |||
| @@ -3487,23 +3487,38 @@ ns_draw_text_decoration (struct glyph_string *s, struct face *face, | |||
| 3487 | { | 3487 | { |
| 3488 | struct font *font = font_for_underline_metrics (s); | 3488 | struct font *font = font_for_underline_metrics (s); |
| 3489 | unsigned long descent = s->y + s->height - s->ybase; | 3489 | unsigned long descent = s->y + s->height - s->ybase; |
| 3490 | unsigned long minimum_offset; | ||
| 3491 | BOOL underline_at_descent_line, use_underline_position_properties; | ||
| 3492 | Lisp_Object val = buffer_local_value (Qunderline_minimum_offset, | ||
| 3493 | s->w->contents); | ||
| 3494 | if (INTEGERP (val)) | ||
| 3495 | minimum_offset = XFASTINT (val); | ||
| 3496 | else | ||
| 3497 | minimum_offset = 1; | ||
| 3498 | val = buffer_local_value (Qx_underline_at_descent_line, | ||
| 3499 | s->w->contents); | ||
| 3500 | underline_at_descent_line = !(NILP (val) || EQ (val, Qunbound)); | ||
| 3501 | val = buffer_local_value (Qx_use_underline_position_properties, | ||
| 3502 | s->w->contents); | ||
| 3503 | use_underline_position_properties = | ||
| 3504 | !(NILP (val) || EQ (val, Qunbound)); | ||
| 3490 | 3505 | ||
| 3491 | /* Use underline thickness of font, defaulting to 1. */ | 3506 | /* Use underline thickness of font, defaulting to 1. */ |
| 3492 | thickness = (font && font->underline_thickness > 0) | 3507 | thickness = (font && font->underline_thickness > 0) |
| 3493 | ? font->underline_thickness : 1; | 3508 | ? font->underline_thickness : 1; |
| 3494 | 3509 | ||
| 3495 | /* Determine the offset of underlining from the baseline. */ | 3510 | /* Determine the offset of underlining from the baseline. */ |
| 3496 | if (x_underline_at_descent_line) | 3511 | if (underline_at_descent_line) |
| 3497 | position = descent - thickness; | 3512 | position = descent - thickness; |
| 3498 | else if (x_use_underline_position_properties | 3513 | else if (use_underline_position_properties |
| 3499 | && font && font->underline_position >= 0) | 3514 | && font && font->underline_position >= 0) |
| 3500 | position = font->underline_position; | 3515 | position = font->underline_position; |
| 3501 | else if (font) | 3516 | else if (font) |
| 3502 | position = lround (font->descent / 2); | 3517 | position = lround (font->descent / 2); |
| 3503 | else | 3518 | else |
| 3504 | position = underline_minimum_offset; | 3519 | position = minimum_offset; |
| 3505 | 3520 | ||
| 3506 | position = max (position, underline_minimum_offset); | 3521 | position = max (position, minimum_offset); |
| 3507 | 3522 | ||
| 3508 | /* Ensure underlining is not cropped. */ | 3523 | /* Ensure underlining is not cropped. */ |
| 3509 | if (descent <= position) | 3524 | if (descent <= position) |
| @@ -9465,11 +9480,14 @@ This variable is ignored on macOS < 10.7 and GNUstep. Default is t. */); | |||
| 9465 | x_use_underline_position_properties, | 9480 | x_use_underline_position_properties, |
| 9466 | doc: /* SKIP: real doc in xterm.c. */); | 9481 | doc: /* SKIP: real doc in xterm.c. */); |
| 9467 | x_use_underline_position_properties = 0; | 9482 | x_use_underline_position_properties = 0; |
| 9483 | DEFSYM (Qx_use_underline_position_properties, | ||
| 9484 | "x-use-underline-position-properties"); | ||
| 9468 | 9485 | ||
| 9469 | DEFVAR_BOOL ("x-underline-at-descent-line", | 9486 | DEFVAR_BOOL ("x-underline-at-descent-line", |
| 9470 | x_underline_at_descent_line, | 9487 | x_underline_at_descent_line, |
| 9471 | doc: /* SKIP: real doc in xterm.c. */); | 9488 | doc: /* SKIP: real doc in xterm.c. */); |
| 9472 | x_underline_at_descent_line = 0; | 9489 | x_underline_at_descent_line = 0; |
| 9490 | DEFSYM (Qx_underline_at_descent_line, "x-underline-at-descent-line"); | ||
| 9473 | 9491 | ||
| 9474 | /* Tell Emacs about this window system. */ | 9492 | /* Tell Emacs about this window system. */ |
| 9475 | Fprovide (Qns, Qnil); | 9493 | Fprovide (Qns, Qnil); |