summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPo Lu <luangruo@yahoo.com>2023-08-22 12:35:33 +0800
committerPo Lu <luangruo@yahoo.com>2023-08-22 12:35:33 +0800
commit48eb022debb85ec3b844e6833194bb05d35cb5c5 (patch)
tree68c676387ceb73009ecb7b983f53100b937039ae
parent354766bcc0431da906411baefc493e757671ca44 (diff)
downloademacs-48eb022debb85ec3b844e6833194bb05d35cb5c5.tar.gz
Avoid errors in posn-col-row if fonts disappear from an X server
* lisp/window.el (window-font-width, window-font-height): Resort to frame-char-width/height should the font returned by font-info be unavailable.
-rw-r--r--lisp/window.el23
1 files changed, 14 insertions, 9 deletions
diff --git a/lisp/window.el b/lisp/window.el
index d91bbabc010..b0970cfb064 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -2121,12 +2121,16 @@ remapped (see `face-remapping-alist'), the function returns the
information for the remapped face."
(with-selected-window (window-normalize-window window t)
(if (display-multi-font-p)
- (let* ((face (if face face 'default))
- (info (font-info (face-font face)))
- (width (aref info 11)))
- (if (> width 0)
- width
- (aref info 10)))
+ ;; Opening the XLFD returned by `font-info' may be
+ ;; unsuccessful. Use `frame-char-width' as a recourse if
+ ;; such a situation transpires.
+ (or (when-let* ((face (if face face 'default))
+ (info (font-info (face-font face)))
+ (width (aref info 11)))
+ (if (> width 0)
+ width
+ (aref info 10)))
+ (frame-char-width))
(frame-char-width))))
(defun window-font-height (&optional window face)
@@ -2138,9 +2142,10 @@ remapped (see `face-remapping-alist'), the function returns the
information for the remapped face."
(with-selected-window (window-normalize-window window t)
(if (display-multi-font-p)
- (let* ((face (if face face 'default))
- (info (font-info (face-font face))))
- (aref info 3))
+ (or (when-let* ((face (if face face 'default))
+ (info (font-info (face-font face))))
+ (aref info 3))
+ (frame-char-height))
(frame-char-height))))
(defvar overflow-newline-into-fringe)