unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Visuwesh <visuweshm@gmail.com>
Cc: rpluim@gmail.com, 54646@debbugs.gnu.org
Subject: bug#54646: 29.0.50; set-fontset-font and font clipping issues
Date: Fri, 01 Apr 2022 18:27:22 +0300	[thread overview]
Message-ID: <831qyg6cyt.fsf@gnu.org> (raw)
In-Reply-To: <87h77cetq9.fsf@gmail.com> (message from Visuwesh on Fri, 01 Apr 2022 20:28:06 +0530)

> From: Visuwesh <visuweshm@gmail.com>
> Cc: Robert Pluim <rpluim@gmail.com>,  54646@debbugs.gnu.org
> Date: Fri, 01 Apr 2022 20:28:06 +0530
> 
> >   hb_font_t *hb_font
> >     = font->driver->begin_hb_font
> >     ? font->driver->begin_hb_font (font, &position_unit)
> >     : NULL;
> >
> > The value of position_unit then affects the values returned in the
> > Lisp glyph object used to display the grapheme cluster:
> >
> >       xoff = lround (pos[i].x_offset * position_unit);
> >       yoff = - lround (pos[i].y_offset * position_unit);
> >       wadjust = lround (pos[i].x_advance * position_unit);
> >       if (xoff || yoff || wadjust != metrics.width)
> > 	LGLYPH_SET_ADJUSTMENT (lglyph, CALLN (Fvector,
> > 					      make_fixnum (xoff),
> > 					      make_fixnum (yoff),
> > 					      make_fixnum (wadjust)));
> >
> > I'd be interested in what happens there in the "good" vs the "bad"
> > cases.
> >
> > If we pass the same information to HarfBuzz, and it returns different
> > results, then it's probably a problem in HarfBuzz.
> 
> I get the same value for position_unit just after begin_hb_font call and
> just after setting the value of wadjust, in the bad and the good case:
> 0.015625.  In case I was not clear, here's a patch that shows where I
> added the printf calls
> 
> diff --git a/src/hbfont.c b/src/hbfont.c
> index 2721a66120..887e0c0e86 100644
> --- a/src/hbfont.c
> +++ b/src/hbfont.c
> @@ -490,6 +490,7 @@ hbfont_shape (Lisp_Object lgstring, Lisp_Object direction)
>      : NULL;
>    if (!hb_font)
>      return make_fixnum (0);
> +  printf("position_unit begin_hb_font: %f\n", position_unit);
>  
>    hb_bool_t success = hb_shape_full (hb_font, hb_buffer, NULL, 0, NULL);
>    if (font->driver->end_hb_font)
> @@ -593,6 +594,7 @@ hbfont_shape (Lisp_Object lgstring, Lisp_Object direction)
>        xoff = lround (pos[i].x_offset * position_unit);
>        yoff = - lround (pos[i].y_offset * position_unit);
>        wadjust = lround (pos[i].x_advance * position_unit);
> +      printf("position_unit after lround: %f\n", position_unit);
>        if (xoff || yoff || wadjust != metrics.width)
>  	LGLYPH_SET_ADJUSTMENT (lglyph, CALLN (Fvector,
>  					      make_fixnum (xoff),
> 
> So I see "position_unit begin_hb_font: 0.0015625" and "position_unit
> after lround: 0.0015625" in the good and the bad case.

So we pass the same data to HarfBuzz and get back different results in
xoff, yoff, and wadjust?  IOW, the results of shaping are different in
the two cases, although the inputs are identical?  Can you print the
other values involved in the data that gets put into lglyph, and see
whether any of it is different between the two cases?

the lglyph data is shown in this excerpt from the code:

      LGLYPH_SET_CHAR (lglyph, chars[char_idx]);
      LGLYPH_SET_CODE (lglyph, info[i].codepoint);

      unsigned code = info[i].codepoint;
      font->driver->text_extents (font, &code, 1, &metrics);
      LGLYPH_SET_WIDTH (lglyph, metrics.width);
      LGLYPH_SET_LBEARING (lglyph, metrics.lbearing);
      LGLYPH_SET_RBEARING (lglyph, metrics.rbearing);
      LGLYPH_SET_ASCENT (lglyph, metrics.ascent);
      LGLYPH_SET_DESCENT (lglyph, metrics.descent);

      xoff = lround (pos[i].x_offset * position_unit);
      yoff = - lround (pos[i].y_offset * position_unit);
      wadjust = lround (pos[i].x_advance * position_unit);
      if (xoff || yoff || wadjust != metrics.width)
	LGLYPH_SET_ADJUSTMENT (lglyph, CALLN (Fvector,
					      make_fixnum (xoff),
					      make_fixnum (yoff),
					      make_fixnum (wadjust)));

WHat is different between the two cases in this data?  Does the call
to font->driver->text_extents produce different data in 'metrics',
perhaps?  Do the values in pos[i] structure differ?  Something else?





  reply	other threads:[~2022-04-01 15:27 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-31  3:37 bug#54646: 29.0.50; set-fontset-font and font clipping issues Visuwesh
2022-03-31  5:34 ` Eli Zaretskii
2022-03-31  7:03   ` Visuwesh
2022-03-31  7:11     ` Eli Zaretskii
2022-03-31  7:35       ` Visuwesh
2022-03-31  8:45       ` Visuwesh
2022-03-31  9:04         ` Eli Zaretskii
2022-03-31  9:29           ` Visuwesh
2022-03-31  9:41             ` Eli Zaretskii
2022-03-31 12:16               ` Visuwesh
2022-03-31 14:04                 ` Eli Zaretskii
2022-03-31 13:44               ` Visuwesh
2022-03-31 14:10                 ` Eli Zaretskii
2022-03-31 14:12                   ` Eli Zaretskii
2022-03-31 15:07                   ` Visuwesh
2022-03-31 16:49                     ` Eli Zaretskii
2022-03-31 17:38                       ` Robert Pluim
2022-04-01  1:05                         ` Visuwesh
2022-04-01  3:08                           ` Visuwesh
2022-04-01  8:49                             ` Robert Pluim
2022-04-01 10:54                               ` Eli Zaretskii
2022-04-01 11:38                                 ` Visuwesh
2022-04-01 12:14                                   ` Eli Zaretskii
2022-04-01 13:10                                     ` Visuwesh
2022-04-01 14:19                                       ` Eli Zaretskii
2022-04-01 14:58                                 ` Visuwesh
2022-04-01 15:27                                   ` Eli Zaretskii [this message]
2022-04-01 16:40                                     ` Visuwesh
2022-04-01 17:58                                       ` Eli Zaretskii
2022-04-03  9:15                                         ` Visuwesh
2022-04-03 10:06                                           ` Eli Zaretskii
2022-04-03 10:26                                             ` Visuwesh
2022-04-03 10:50                                               ` Eli Zaretskii
2022-04-03 11:10                                                 ` Visuwesh
2022-04-21 14:50                                                   ` Visuwesh
2022-04-22  7:23                                                     ` Eli Zaretskii
2022-04-22 10:46                                                       ` Visuwesh
2022-04-22 10:48                                                         ` Eli Zaretskii
2022-06-11 13:54                                                           ` Visuwesh
2022-06-12  1:34                                                             ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-06-12  5:55                                                               ` Eli Zaretskii
2022-06-12  4:49                                                             ` Visuwesh
2022-06-12  5:53                                                             ` Eli Zaretskii
2022-06-12  7:47                                                               ` Visuwesh
2022-06-12 10:16                                                                 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-08 11:48                                                             ` Visuwesh
2022-10-08 12:42                                                               ` Eli Zaretskii
2022-10-08 12:53                                                                 ` Visuwesh
2022-10-08 13:00                                                                   ` Eli Zaretskii
2022-10-09 11:31                                                                   ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-09 11:59                                                                     ` Visuwesh
2022-03-31  7:48     ` Eli Zaretskii
2022-03-31  8:47       ` Visuwesh

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=831qyg6cyt.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=54646@debbugs.gnu.org \
    --cc=rpluim@gmail.com \
    --cc=visuweshm@gmail.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).