Fix Proced display header alignment under 'text-scale-adjust'

* lisp/proced.el (proced-mode): Force the header-line to scale
according to 'text-scale-adjust'.
(proced-header-line): Use width of the header-line's face's
characters as align-to units, not the width of the frame's
default face's font.  (Bug#64752)

* src/xdisp.c (calc_pixel_width_or_height): Use font's
average_width or space_width, not max_width, as the correct
measure of the font's width.  This is consistent with the rest of
the display engine.
This commit is contained in:
Eli Zaretskii 2023-07-21 15:19:02 +03:00
parent c55e67081e
commit 845d6561ed
2 changed files with 7 additions and 3 deletions

View file

@ -776,12 +776,12 @@ of the process. A value of nil indicates that there are no active refinements."
(while (string-match "[ \t\n]+" hl pos)
(setq pos (match-end 0))
(put-text-property (match-beginning 0) pos 'display
`(space :align-to ,(+ pos base))
`(space :align-to (,(+ pos base) . width))
hl)))
(setq hl (replace-regexp-in-string ;; preserve text properties
"\\(%\\)" "\\1\\1"
hl)))
(list (propertize " " 'display `(space :align-to ,base))
(list (propertize " " 'display `(space :align-to (,base . width)))
hl)))
(defun proced-pid-at-point ()
@ -894,6 +894,8 @@ normal hook `proced-post-display-hook'.
(setq-local font-lock-defaults
'(proced-font-lock-keywords t nil nil beginning-of-line))
(setq-local switch-to-buffer-preserve-window-point nil)
;; So that the heading scales together with the body of the table.
(setq-local text-scale-remap-header-line t)
(if (and (not proced-auto-update-timer) proced-auto-update-interval)
(setq proced-auto-update-timer
(run-at-time t proced-auto-update-interval

View file

@ -29093,7 +29093,9 @@ calc_pixel_width_or_height (double *res, struct it *it, Lisp_Object prop,
/* 'width': the width of FONT. */
if (EQ (prop, Qwidth))
return OK_PIXELS (font
? FONT_WIDTH (font)
? (font->average_width
? font->average_width
: font->space_width)
: FRAME_COLUMN_WIDTH (it->f));
#else
if (EQ (prop, Qheight) || EQ (prop, Qwidth))