From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#54646: 29.0.50; set-fontset-font and font clipping issues Date: Fri, 01 Apr 2022 18:27:22 +0300 Message-ID: <831qyg6cyt.fsf@gnu.org> References: <875ynuokqt.fsf@gmail.com> <83r16i7kim.fsf@gnu.org> <871qyiob70.fsf@gmail.com> <83lewq7g1j.fsf@gnu.org> <87czi27bnu.fsf@gmail.com> <83h77e7as6.fsf@gnu.org> <874k3e79mc.fsf@gmail.com> <83fsmy793g.fsf@gnu.org> <87v8vu5j9k.fsf@gmail.com> <837d8a6wm7.fsf@gnu.org> <87lewqjh41.fsf@gmail.com> <83wnga5ap3.fsf@gnu.org> <87a6d69g46.fsf@gmail.com> <87h77dk3zn.fsf@gmail.com> <87a6d5jyat.fsf@gmail.com> <87wng989ym.fsf@gmail.com> <83ilrt5b1v.fsf@gnu.org> <87h77cetq9.fsf@gmail.com> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33117"; mail-complaints-to="usenet@ciao.gmane.io" Cc: rpluim@gmail.com, 54646@debbugs.gnu.org To: Visuwesh Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Apr 01 17:28:47 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1naJCh-0008Pi-2I for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 01 Apr 2022 17:28:47 +0200 Original-Received: from localhost ([::1]:57200 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1naJCf-0003FE-Mq for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 01 Apr 2022 11:28:45 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:52042) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1naJBy-0001nX-6Z for bug-gnu-emacs@gnu.org; Fri, 01 Apr 2022 11:28:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:49260) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1naJBx-0001a0-Og for bug-gnu-emacs@gnu.org; Fri, 01 Apr 2022 11:28:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1naJBx-0003WX-Ln for bug-gnu-emacs@gnu.org; Fri, 01 Apr 2022 11:28:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 01 Apr 2022 15:28:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54646 X-GNU-PR-Package: emacs Original-Received: via spool by 54646-submit@debbugs.gnu.org id=B54646.164882683713471 (code B ref 54646); Fri, 01 Apr 2022 15:28:01 +0000 Original-Received: (at 54646) by debbugs.gnu.org; 1 Apr 2022 15:27:17 +0000 Original-Received: from localhost ([127.0.0.1]:43155 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1naJBF-0003VD-9M for submit@debbugs.gnu.org; Fri, 01 Apr 2022 11:27:17 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:35952) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1naJBD-0003Uy-NY for 54646@debbugs.gnu.org; Fri, 01 Apr 2022 11:27:16 -0400 Original-Received: from [2001:470:142:3::e] (port=55248 helo=fencepost.gnu.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1naJB8-0001Vu-Dh; Fri, 01 Apr 2022 11:27:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=7s+KY6kpeLPzL3e/sDlK85xNreEFJfLXxkE5xZYIbXY=; b=VmcxWVQfMnuh Kv6+86oI5wN4gnEtGmUoacxQ6gHHlvSUFUY8lkUwun/8yW2efF63X9T1hJQ0sutyu1lxbuKSOtLKl niXt4JUFNApKq971hxqJTnZrwE5keglZkgva+S9Ymq619lTpd8N5ZLcb5UkG2YvBspDvn8vWbSr5x nCBT3wDXNoid/sT9+tkJe7c9X+UilB5IaMzD0YmGe+BvcWv4TE1zLWul2PGoao4aAlEFhcMut1d6r BxU+hpr2kJKTCd58sisYTagFyli3Wgf99+9aOC0Hy5iuB7y+EJXzqJy68PTt+Y4WOrpYtCTUW0lm8 3UOxTl0QBSMotNep5l/8cw==; Original-Received: from [87.69.77.57] (port=2405 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1naJB7-0000H5-QH; Fri, 01 Apr 2022 11:27:10 -0400 In-Reply-To: <87h77cetq9.fsf@gmail.com> (message from Visuwesh on Fri, 01 Apr 2022 20:28:06 +0530) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:229229 Archived-At: > From: Visuwesh > Cc: Robert Pluim , 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?