unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Feng Shu" <tumashu@163.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: luangruo@yahoo.com, larsi@gnus.org, 51821@debbugs.gnu.org
Subject: bug#51821: 29.0.50; Suggest add variable or frame parameter: line-height
Date: Fri, 19 Nov 2021 09:57:25 +0800	[thread overview]
Message-ID: <87v90o9abe.fsf@163.com> (raw)
In-Reply-To: <83v90pwcab.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 18 Nov 2021 20:26:20 +0200")

[-- Attachment #1: Type: text/plain, Size: 1148 bytes --]

Eli Zaretskii <eliz@gnu.org> writes:

>> Date: Tue, 16 Nov 2021 18:45:16 +0200
>> From: Eli Zaretskii <eliz@gnu.org>
>> Cc: tumashu@163.com, 51821@debbugs.gnu.org
>> 
>> > From: Lars Ingebrigtsen <larsi@gnus.org>
>> > Cc: tumashu@163.com,  51821@debbugs.gnu.org
>> > Date: Tue, 16 Nov 2021 16:20:52 +0100
>> > 
>> > > That shouldn't happen, normally.  Emacs selects fonts of the same size
>> > > for a face.
>> > 
>> > No, not really.  Here's a trivial example:
>> > 
>> > 
>> > Note how the lines with jidanni are taller than the rest.
>> 
>> OK, let me see what can be done about that.
>
> Please try the patch below.  I have a very limited number of cases
> with which I can test it, so I think users of CJK scripts should say
> what they think.  Basically, set the new variable line-height-factor
> to something like 1.2 (more if you enlarge the non-ASCII font to make
> double-width characters take close to 2 columns), and see if you get
> the desired effect.
>
> If this is what people want, I will install it and document it.
>

I think the below patch has problem, maybe it relate to font
baseline, I do not know, please see attachement.


[-- Attachment #2: test-2021-11-19_09.50.06.mkv --]
[-- Type: video/x-matroska, Size: 1227807 bytes --]

[-- Attachment #3: Type: text/plain, Size: 6098 bytes --]





> diff --git a/src/window.c b/src/window.c
> index e801ff8..a368b6d 100644
> --- a/src/window.c
> +++ b/src/window.c
> @@ -5246,7 +5246,10 @@ grow_mini_window (struct window *w, int delta)
>  {
>    struct frame *f = XFRAME (w->frame);
>    int old_height = window_body_height (w, true);
> -  int min_height = FRAME_LINE_HEIGHT (f);
> +  int min_height =
> +    FLOATP (Vline_height_factor)
> +    ? FRAME_LINE_HEIGHT (f) * XFLOAT_DATA (Vline_height_factor)
> +    : FRAME_LINE_HEIGHT (f);
>  
>    eassert (MINI_WINDOW_P (w));
>  
> @@ -5279,7 +5282,11 @@ grow_mini_window (struct window *w, int delta)
>  shrink_mini_window (struct window *w)
>  {
>    struct frame *f = XFRAME (w->frame);
> -  int delta = window_body_height (w, true) - FRAME_LINE_HEIGHT (f);
> +  int min_line_height =
> +    FLOATP (Vline_height_factor)
> +    ? FRAME_LINE_HEIGHT (f) * XFLOAT_DATA (Vline_height_factor)
> +    : FRAME_LINE_HEIGHT (f);
> +  int delta = window_body_height (w, true) - min_line_height;
>  
>    eassert (MINI_WINDOW_P (w));
>  
> diff --git a/src/xdisp.c b/src/xdisp.c
> index ef49297..d1f4043 100644
> --- a/src/xdisp.c
> +++ b/src/xdisp.c
> @@ -22073,6 +22073,18 @@ append_space_for_newline (struct it *it, bool default_face_p)
>  		  it->descent = it->override_descent;
>  		  boff = it->override_boff;
>  		}
> +	      else
> +		{
> +		  /* Enlarge the ascent to make the row higher by
> +		     line-height-factor if needed.  */
> +		  if (face == face->ascii_face && it->voffset == 0
> +		      && FLOATP (Vline_height_factor))
> +		    {
> +		      int enlarged_height = ((it->ascent + it->descent)
> +					     * XFLOAT_DATA (Vline_height_factor));
> +		      it->ascent = enlarged_height - it->descent;
> +		    }
> +		}
>  	      if (EQ (height, Qt))
>  		extra_line_spacing = 0;
>  	      else
> @@ -30587,9 +30599,9 @@ gui_produce_glyphs (struct it *it)
>  	  /* When no suitable font is found, display this character by
>  	     the method specified in the first extra slot of
>  	     Vglyphless_char_display.  */
> -	      Lisp_Object acronym = lookup_glyphless_char_display (-1, it);
> +	  Lisp_Object acronym = lookup_glyphless_char_display (-1, it);
>  
> -	      eassert (it->what == IT_GLYPHLESS);
> +	  eassert (it->what == IT_GLYPHLESS);
>  	  produce_glyphless_glyph (it, true,
>  				   STRINGP (acronym) ? acronym : Qnil);
>  	  goto done;
> @@ -30613,6 +30625,15 @@ gui_produce_glyphs (struct it *it)
>   	    {
>   	      it->ascent = FONT_BASE (font) + boff;
>   	      it->descent = FONT_DESCENT (font) - boff;
> +	      /* If this glyph uses the ASCII face, enlarge the ascent
> +		 to make the row higher by line-height-factor.  */
> +	      if (face == face->ascii_face && it->voffset == 0
> +		  && FLOATP (Vline_height_factor))
> +		{
> +		  int enlarged_height = ((it->ascent + it->descent)
> +					 * XFLOAT_DATA (Vline_height_factor));
> +		  it->ascent = enlarged_height - it->descent;
> +		}
>   	    }
>  
>  	  if (get_char_glyph_code (it->char_to_display, font, &char2b))
> @@ -30763,6 +30784,13 @@ gui_produce_glyphs (struct it *it)
>  		{
>  		  it->ascent = FONT_BASE (font) + boff;
>  		  it->descent = FONT_DESCENT (font) - boff;
> +		  if (face == face->ascii_face && it->voffset == 0
> +		      && FLOATP (Vline_height_factor))
> +		    {
> +		      int enlarged_height = ((it->ascent + it->descent)
> +					     * XFLOAT_DATA (Vline_height_factor));
> +		      it->ascent = enlarged_height - it->descent;
> +		    }
>  		}
>  	    }
>  
> @@ -30886,6 +30914,13 @@ gui_produce_glyphs (struct it *it)
>  		{
>  		  it->ascent = FONT_BASE (font) + boff;
>  		  it->descent = FONT_DESCENT (font) - boff;
> +		  if (face == face->ascii_face && it->voffset == 0
> +		      && FLOATP (Vline_height_factor))
> +		    {
> +		      int enlarged_height = ((it->ascent + it->descent)
> +					     * XFLOAT_DATA (Vline_height_factor));
> +		      it->ascent = enlarged_height - it->descent;
> +		    }
>  		}
>  	      it->phys_ascent = it->ascent;
>  	      it->phys_descent = it->descent;
> @@ -31243,6 +31278,24 @@ gui_produce_glyphs (struct it *it)
>  	  if (it->glyph_row
>  	      && (metrics.lbearing < 0 || metrics.rbearing > metrics.width))
>  	    it->glyph_row->contains_overlapping_glyphs_p = true;
> +	  if (it->voffset == 0 && FLOATP (Vline_height_factor))
> +	    {
> +	      Lisp_Object font_object = LGSTRING_FONT (gstring);
> +	      struct font *gstring_font = XFONT_OBJECT (font_object);
> +
> +	      /* This is for when the grapheme cluster displays some
> +		 ligature using ASCII font: if the height is smaller
> +		 than line-height-factor says, enlarge the ascent.  */
> +	      if (face == face->ascii_face
> +		  && face->ascii_face->font == gstring_font)
> +		{
> +		  int enlarged_height =
> +		    ((FONT_BASE (gstring_font) + FONT_DESCENT (gstring_font))
> +		     * XFLOAT_DATA (Vline_height_factor));
> +		  if (metrics.ascent + metrics.descent < enlarged_height)
> +		    metrics.ascent = enlarged_height - metrics.descent;
> +		}
> +	    }
>  	  it->ascent = it->phys_ascent = metrics.ascent;
>  	  it->descent = it->phys_descent = metrics.descent;
>  	}
> @@ -35581,6 +35634,16 @@ syms_of_xdisp (void)
>  mini-window frame's default font's height.  */);
>    Vmax_mini_window_height = make_float (0.25);
>  
> +  DEFVAR_LISP ("line-height-factor", Vline_height_factor,
> +    doc: /* Factor for enlarging the height of lines that use the default font.
> +The value should be a float number greater than 1.  It determines how
> +much will Emacs enlarge the height of a screen line that shows only
> +characters displayed with the default face's font for ASCII characters.
> +This is to avoid differences in height between lines that use the
> +ASCII font and those which use non-ASCII (for example, Chinese)
> +font, which is typically higher than the ASCII one.  */);
> +  Vline_height_factor = Qnil;
> +
>    DEFVAR_LISP ("resize-mini-windows", Vresize_mini_windows,
>      doc: /* How to resize mini-windows (the minibuffer and the echo area).
>  A value of nil means don't automatically resize mini-windows.

-- 

  parent reply	other threads:[~2021-11-19  1:57 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-13 23:28 bug#51821: 29.0.50; Suggest add variable or frame parameter: line-height Feng Shu
2021-11-14  1:23 ` Lars Ingebrigtsen
2021-11-14  1:46   ` Feng Shu
2021-11-14  6:59   ` Eli Zaretskii
2021-11-14  7:01     ` Lars Ingebrigtsen
2021-11-14  7:04       ` Feng Shu
2021-11-14  8:03         ` Eli Zaretskii
2021-11-14  7:23       ` Eli Zaretskii
2021-11-15  5:33         ` Lars Ingebrigtsen
2021-11-19 23:03     ` Feng Shu
2021-11-20  7:00       ` Eli Zaretskii
2021-11-20  7:13         ` Feng Shu
2021-11-20  7:34           ` Eli Zaretskii
2021-11-20  7:43             ` Feng Shu
2021-11-14 11:29 ` Eli Zaretskii
2021-11-14 17:55   ` Lars Ingebrigtsen
2021-11-14 18:14     ` Eli Zaretskii
2021-11-14 22:42       ` Feng Shu
2021-11-15 12:39         ` Eli Zaretskii
2021-11-15  5:39       ` Lars Ingebrigtsen
2021-11-15 13:02         ` Eli Zaretskii
2021-11-16  7:34           ` Lars Ingebrigtsen
2021-11-16 15:10             ` Eli Zaretskii
2021-11-16 15:20               ` Lars Ingebrigtsen
2021-11-16 16:45                 ` Eli Zaretskii
2021-11-18 18:26                   ` Eli Zaretskii
2021-11-19  0:26                     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-19  7:01                       ` Eli Zaretskii
2021-11-19  1:57                     ` Feng Shu [this message]
2021-11-19  7:08                       ` Eli Zaretskii
2021-11-19  7:18                         ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-19  7:31                           ` bug#51821: " tumashu
2021-11-19  8:28                             ` Eli Zaretskii
2021-11-19  8:45                               ` tumashu
2021-11-19  8:06                           ` Eli Zaretskii
2021-11-19  9:33                             ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-19 12:27                               ` Eli Zaretskii
2021-11-19 12:36                                 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-19  7:26                         ` tumashu
2021-11-19  8:25                           ` Eli Zaretskii
2021-11-19  8:54                             ` tumashu
2021-11-19  9:09                             ` tumashu
2021-11-19 12:18                               ` Eli Zaretskii
2021-11-19  7:12                     ` Lars Ingebrigtsen
2021-11-19  8:04                       ` Eli Zaretskii
2021-11-20  8:26                         ` Lars Ingebrigtsen
2021-11-20  8:39                           ` Eli Zaretskii
2021-11-20  8:51                             ` Lars Ingebrigtsen
2021-11-20  9:06                               ` Eli Zaretskii
2021-11-20  9:27                                 ` Lars Ingebrigtsen
2021-11-20  9:53                                   ` Eli Zaretskii
2021-11-20  9:58                                     ` Lars Ingebrigtsen
2021-11-20 10:15                                       ` Eli Zaretskii
2021-11-21  8:06                                         ` Lars Ingebrigtsen
2021-11-21  8:18                                           ` Eli Zaretskii
2021-11-21  8:21                                             ` Lars Ingebrigtsen
2021-11-21  8:32                                               ` Eli Zaretskii
2021-11-21  8:38                                                 ` Lars Ingebrigtsen
2021-11-21 10:00                                                   ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-21 14:05                                                   ` Eli Zaretskii
2021-11-19 14:48                     ` Feng Shu
2021-11-14 22:37   ` Feng Shu
2021-11-15 12:38     ` Eli Zaretskii
2021-11-16  3:51       ` Feng Shu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87v90o9abe.fsf@163.com \
    --to=tumashu@163.com \
    --cc=51821@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=larsi@gnus.org \
    --cc=luangruo@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).