Control: tags -1 fixed-upstream patch On 2020-11-01 01:37:18 +0100, Vincent Lefevre wrote: > The cause is that with the cairo version (like in Debian), > row->phys_ascent > row->ascent. There are 2 issues: > > 1. The fact that this condition is true with misc-fixed 13-pixel fonts.
I've eventually found the root cause: a ceil() is applied on a value that is expected to be an integer here (this is a bitmap font, thus with integer parameters), but due to a rounding error in Cairo, one gets a slightly larger value, so that ceil() gives the next integer: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=44284#74 Note that this explains why the issue occurs only with a particular font size (the rounding error depends on the font size, and the issue can occur only when this error is positive and large enough). I've suggested several solutions: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=44284#80 In short: Cairo should ideally produce a correctly rounded value, but guaranteeing that in general may be complex and may yield a performance drop. Alternatively, assume in Emacs that a value slightly above the integer is this integer. That's how this has been patched by Eli Zaretskii: - cache->ascent = ceil (- extents.y_bearing); + cache->ascent = ceil (- extents.y_bearing - 1.0 / 256); (see attached patch, which applies to the Debian version too). > 2. The fact that this condition is handled incorrectly by Emacs. Thanks to the above patch, this condition no longer occurs in this case. I don't know whether there are issues when it occurs in other cases. -- Vincent Lefèvre <vinc...@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)
commit 33e2418a7cfd2ac1b98b86c5ddaf99c1d90daaf0 Author: Eli Zaretskii <e...@gnu.org> Date: 2020-11-07 09:27:15 +0100 Fix scrolling problems with misc-fixed fonts under Cairo * src/ftcrfont.c (ftcrfont_glyph_extents): Avoid rounding up the glyph ascent to a higher value than needed due to floating-point roundoff errors. (Bug#44284) diff --git a/src/ftcrfont.c b/src/ftcrfont.c index a10308c62e..b89510704e 100644 --- a/src/ftcrfont.c +++ b/src/ftcrfont.c @@ -84,7 +84,12 @@ ftcrfont_glyph_extents (struct font *font, cache->lbearing = floor (extents.x_bearing); cache->rbearing = ceil (extents.width + extents.x_bearing); cache->width = lround (extents.x_advance); - cache->ascent = ceil (- extents.y_bearing); + /* The subtraction of a small number is to avoid rounding up due + to floating-point inaccuracies with some fonts, which then + could cause unpleasant effects while scrolling (see bug + #44284), since we then think that a glyph row's ascent is too + small to accommodate a glyph with a higher phys_ascent. */ + cache->ascent = ceil (- extents.y_bearing - 1.0 / 256); cache->descent = ceil (extents.height + extents.y_bearing); }