commit 60199ac01d711d3240146afedd830b774eb5c5d2 (HEAD, refs/remotes/origin/master) Author: Po Lu Date: Tue Dec 26 14:09:42 2023 +0800 ; * src/ftfont.c (ftfont_glyph_metrics): Comment on advance rounding. diff --git a/src/ftfont.c b/src/ftfont.c index d3c836c0f2d..46abe35ff9a 100644 --- a/src/ftfont.c +++ b/src/ftfont.c @@ -1572,6 +1572,12 @@ ftfont_glyph_metrics (FT_Face ft_face, int c, int *advance, int *lbearing, if (FT_Load_Glyph (ft_face, c, FT_LOAD_DEFAULT) == 0) { FT_Glyph_Metrics *m = &ft_face->glyph->metrics; + + /* At first glance this might appear to truncate the glyph's + horizontal advance, but FreeType internally rounds the + advance width to a pixel boundary prior to returning these + metrics. */ + *advance = m->horiAdvance >> 6; *lbearing = m->horiBearingX >> 6; *rbearing = (m->horiBearingX + m->width) >> 6; commit cd91ecedcbdf03ae13f45cb173360b11f13a0bc0 Author: Po Lu Date: Tue Dec 26 14:07:58 2023 +0800 Consistently round glyph advances in the SFNT font backend * src/sfnt.h (SFNT_ROUND_FIXED): New macro. * src/sfntfont.c (sfntfont_get_glyph_outline): Don't apply advance width distortion before the glyph is instructed or decomposed. Round advance width as measured between both phantom points subsequent to instruction code execution. (sfntfont_draw): Don't take the advance's ceiling when advancing origin point. diff --git a/src/sfnt.h b/src/sfnt.h index 7baed372212..576d287e8e6 100644 --- a/src/sfnt.h +++ b/src/sfnt.h @@ -1455,6 +1455,7 @@ #define sfnt_fixed_float(fixed) ((sfnt_fixed) (fixed) / 65535.0f) #define SFNT_CEIL_FIXED(fixed) (((fixed) + 0177777) & 037777600000) +#define SFNT_ROUND_FIXED(fixed) (((fixed) + 0100000) & 037777600000) #define SFNT_FLOOR_FIXED(fixed) ((fixed) & 037777600000) diff --git a/src/sfntfont.c b/src/sfntfont.c index c626e76b52b..b20a7c91115 100644 --- a/src/sfntfont.c +++ b/src/sfntfont.c @@ -2257,9 +2257,6 @@ sfntfont_get_glyph_outline (sfnt_glyph glyph_code, head, maxp)) goto fail; - /* Add the advance width distortion. */ - temp.advance += distortion.advance; - if (interpreter) { if (glyph->simple) @@ -2295,8 +2292,11 @@ sfntfont_get_glyph_outline (sfnt_glyph glyph_code, if (outline) { - /* Save the new advance width. */ - temp.advance = advance; + /* Save the new advance width. This advance width is + rounded again, as the instruction code executed might + have moved both phantom points such that they no + longer measure a fractional distance. */ + temp.advance = SFNT_ROUND_FIXED (advance); /* Finally, adjust the left side bearing of the glyph metrics by the origin point of the outline, should a @@ -2319,6 +2319,11 @@ sfntfont_get_glyph_outline (sfnt_glyph glyph_code, sfntfont_get_metrics, &dcontext); + /* Add the advance width distortion, which is not applied to + glyph metrics in advance of their being instructed, and thus + has to be applied before the metrics are. */ + temp.advance += distortion.advance; + /* At this point, the glyph metrics are unscaled. Scale them up. If INTERPRETER is set, use the scale placed within. */ sfnt_scale_metrics (&temp, scale); @@ -2328,7 +2333,6 @@ sfntfont_get_glyph_outline (sfnt_glyph glyph_code, been applied by either instruction code or glyph variation. The left side bearing is the distance from the origin point to the left most point on the X axis. */ - if (index != -1) temp.lbearing = outline->xmin - outline->origin; } @@ -3707,7 +3711,7 @@ sfntfont_draw (struct glyph_string *s, int from, int to, if (s->padding_p) current_x += 1; else - current_x += SFNT_CEIL_FIXED (metrics.advance) / 65536; + current_x += metrics.advance / 65536; } /* Call the window system function to put the glyphs to the commit a6ef458e3831001b0acad57cf8fa75b77a4aff3f Author: João Távora Date: Tue Dec 26 00:31:29 2023 +0000 Eglot: partial fix for middle-of-symbol completions * lisp/progmodes/eglot.el (eglot-completion-at-point): Fix completion reversion in :exit-function. In a rust-ts-mode buffer such as this main.rs file fn main() { let v: usize = 1; v.c1234.1234567890 } the server wants to edit the line to read, after C-M-i and selecting "count_ones" v.count_ones.1234567890 But it couldn't apply the edit to the correct initial state because that state wasn't correctly restored. This commit fixes that. However, if the initial state is v.count_on1234.1234567890 then completion still fails, because the 'try-completion' call in eglot-completion-at-point will just return complete to "count_ones" and Emacs doesn't consider this a completion "exit", so it'll completely ignore the exit function. I think 'try-completion' (and 'test-completion') simply can't be used here (for one, they obey styles, and styles are off-limits in LSP), but I'll leave that for another commit. Github-reference: https://github.com/joaotavora/eglot/issues/1339 diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 8235bbe1751..d777e488c43 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -3031,6 +3031,7 @@ eglot-completion-at-point (let* ((server (eglot--current-server-or-lose)) (bounds (or (bounds-of-thing-at-point 'symbol) (cons (point) (point)))) + (bounds-string (buffer-substring (car bounds) (cdr bounds))) (sort-completions (lambda (completions) (cl-sort completions @@ -3213,9 +3214,10 @@ eglot-completion-at-point ;; Revert buffer back to state when the edit ;; was obtained from server. If a `proxy' ;; "bar" was obtained from a buffer with - ;; "foo.b", the LSP edit applies to that' + ;; "foo.b", the LSP edit applies to that ;; state, _not_ the current "foo.bar". (delete-region orig-pos (point)) + (insert (substring bounds-string (- orig-pos (car bounds)))) (eglot--dbind ((TextEdit) range newText) textEdit (pcase-let ((`(,beg . ,end) (eglot-range-region range))) commit 2d15389554432277227af0567cd7da8b21d5930d Author: Stefan Kangas Date: Mon Dec 25 19:26:14 2023 +0100 Add Python to `recentf-arrange-rules` * lisp/recentf.el (recentf-arrange-rules): Add rule for Python. diff --git a/lisp/recentf.el b/lisp/recentf.el index 94ae871763b..7040b432074 100644 --- a/lisp/recentf.el +++ b/lisp/recentf.el @@ -805,25 +805,31 @@ recentf-relative-filter ;;; Rule based menu filters ;; (defcustom recentf-arrange-rules - '( - ("Elisp files (%d)" ".\\.el\\'") - ("Java files (%d)" ".\\.java\\'") - ("C/C++ files (%d)" "c\\(pp\\)?\\'") + `( + ("Elisp files (%d)" ,(rx nonl ".el" eos)) + ("C/C++ files (%d)" ,(rx nonl "." + (or "c" "cc" "cpp" "h" "hpp" "cxx" "hxx") + eos)) + ("Python files (%d" ,(rx nonl ".py" eos)) + ("Java files (%d)" ,(rx nonl ".java" eos)) ) "List of rules used by `recentf-arrange-by-rule' to build sub-menus. + A rule is a pair (SUB-MENU-TITLE . MATCHER). SUB-MENU-TITLE is the displayed title of the sub-menu where a `%d' `format' pattern is replaced by the number of items in the sub-menu. MATCHER is a regexp or a list of regexps. Items matching one of the regular expressions in MATCHER are added to the corresponding sub-menu. -SUB-MENU-TITLE can be a function. It is passed every items that + +SUB-MENU-TITLE can be a function. It is passed every item that matched the corresponding MATCHER, and it must return a pair (SUB-MENU-TITLE . ITEM). SUB-MENU-TITLE is a computed sub-menu title that can be another function. ITEM is the received item which may have been modified to match another rule." :group 'recentf-filters :type '(repeat (cons (choice string function) - (repeat regexp)))) + (repeat regexp))) + :version "30.1") (defcustom recentf-arrange-by-rule-others "Other files (%d)" "Title of the `recentf-arrange-by-rule' sub-menu.