unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Vincent Lefevre <vincent@vinc17.net>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 44284@debbugs.gnu.org
Subject: bug#44284: 27.1; with some Unicode font, scrolling upward with the mouse wheel actually scrolls downward when the cursor needs repositioning
Date: Sun, 1 Nov 2020 19:34:58 +0100	[thread overview]
Message-ID: <20201101183458.GP27593@zira.vinc17.org> (raw)
In-Reply-To: <83a6w1ezwv.fsf@gnu.org>

On 2020-11-01 19:43:12 +0200, Eli Zaretskii wrote:
> > When the cache is filled with
> > 
> >       cache->ascent = ceil (- extents.y_bearing);
> > 
> > extents.y_bearing (whose type is double) is equal to:
> > 
> > Font size 13: -0x1.6000000000001p+3 ≈ -11.000000000000002
> > Font size 14: -0x1.8p+3 = -12
> > 
> > With ceil(), 11.000000000000002 rounds to 12, while the expected value
> > is 11. A rounding issue, as I guessed at
> > 
> >   https://debbugs.gnu.org/cgi/bugreport.cgi?bug=44284#29
> 
> Thanks.  Do you have a suggestion for a fix?

Well, I think that there are 3 potential issues.

1. That fact that here, extents.y_bearing is slightly incorrect,
which appears to be a bug in Cairo.

If I understand correctly, Cairo can handle any font size (not just
integer ones), e.g. with scalable fonts. Thus rounding cannot be
avoided. Ideally one should have correct rounding on each visible
result, but I suppose that this can be very complex and slow down
applications, so that in general, an indeterminate rounding error
may be acceptable, and applications / rendering algorithms should
cope with that (when discontinuous functions are involved, such as
rounding to an integer): if continuity is preserved in some way,
the user will never see an error of, say, 2^(-45) pixel.

Now, there's the particular case of integer font sizes, in particular
with X fonts, and one may want to preserve integers exactly on the
Cairo side. I don't know whether this can be done or there are tricky
issues.

2. The fact that the cache->ascent integer gets incorrect in Emacs.

This could be fixed either on the Cairo side (see above) or on the
application (Emacs) side. In the latter case:

First, if Emacs knows that under some condition, extents.y_bearing
should be an integer, it could round to nearest. For instance, if
this is an X font like here, is this necessarily the case?

Alternatively, Emacs could use some heuristic: if extents.y_bearing
is very close to an integer, assume that it should be this integer.
This is rather ugly as this might yield unexpected results in some
applications, but would this be OK in Emacs?

3. The fact that row->phys_ascent > row->ascent in compute_line_metrics
yields an incorrect behavior. This is about the following comment:

      /* If first line's physical ascent is larger than its logical
         ascent, use the physical ascent, and make the row taller.
         This makes accented characters fully visible.  */

Or is the bug I've reported about that is specific to the incorrect
cache->ascent issue (item 2), in which case fixing (2) would be
sufficient for everyone?

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)





  reply	other threads:[~2020-11-01 18:34 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-28 16:36 bug#44284: 27.1; with some Unicode font, scrolling upward with the mouse wheel actually scrolls downward when the cursor needs repositioning Vincent Lefevre
2020-10-28 16:44 ` Vincent Lefevre
2020-10-28 16:53 ` Eli Zaretskii
2020-10-30 10:52   ` Vincent Lefevre
2020-10-30 11:31     ` Eli Zaretskii
2020-10-30 13:33       ` Vincent Lefevre
2020-10-30 13:37         ` Eli Zaretskii
2020-10-30 16:31           ` Vincent Lefevre
2020-10-30 20:34             ` Vincent Lefevre
2020-10-30 20:57               ` Vincent Lefevre
2020-10-30 21:09                 ` Eli Zaretskii
2020-10-30 23:00                   ` Vincent Lefevre
2020-10-31  0:46                     ` Vincent Lefevre
2020-10-31  1:13                       ` Vincent Lefevre
2020-10-31  7:38                         ` Eli Zaretskii
2020-10-31 22:43                           ` Vincent Lefevre
2020-11-01  0:24                             ` Vincent Lefevre
2020-11-01  0:28                               ` Vincent Lefevre
2020-11-01 16:15                                 ` Eli Zaretskii
2020-11-01 16:15                               ` Eli Zaretskii
2020-11-01 17:32                                 ` Vincent Lefevre
2020-11-01 17:43                                   ` Eli Zaretskii
2020-11-01 18:34                                     ` Vincent Lefevre [this message]
2020-11-01 18:47                                       ` Eli Zaretskii
2020-11-01 21:13                                         ` Vincent Lefevre
2020-11-07  8:29                                         ` Eli Zaretskii
2020-11-07 10:35                                           ` Vincent Lefevre
2020-11-07 13:22                                             ` Eli Zaretskii
2020-11-01 15:55                             ` Eli Zaretskii
2020-11-01 17:26                               ` Vincent Lefevre
2020-10-30 20:58               ` Eli Zaretskii

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=20201101183458.GP27593@zira.vinc17.org \
    --to=vincent@vinc17.net \
    --cc=44284@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /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).