emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What is a default font?


From: Štěpán Němec
Subject: Re: What is a default font?
Date: Wed, 04 Dec 2019 20:38:26 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

On Wed, 4 Dec 2019 19:04:10 +0100
martin rudalics wrote:

>> You will see that functions which use the likes of default-font-height
>> are interested in the selected window on the selected frame.
>
> But in that case the first line of the doc-string of
> 'default-font-height'
>
>   Return the height in pixels of the current buffer's default face font.
>
> is totally misleading because, as you noted above, asking for such a
> value is meaningless when the current buffer is not displayed in the
> selected window.  Please try to fix these doc-strings so they tell
> what the functions actually do and not how they are used.

Indeed, FWIW I've been bitten by this recently, too, and have been
meaning to submit the patch attached, although now seeing this
discussion, more clarification (and from a more knowledgeable person)
might be needed. I simply corrected what seemed to be obvious errors,
but maybe it can at least serve as another evidence of the confusion.

-- 
Štěpán

>From 4edb174e38b3fb61ea95f11a938e648fd789a2e9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C5=A0t=C4=9Bp=C3=A1n=20N=C4=9Bmec?= <address@hidden>
Date: Thu, 29 Aug 2019 20:06:47 +0200
Subject: [PATCH] Correct default-font-{height,width}, default-line-height doc
 strings

* doc/lispref/display.texi (Low-Level Font): Correct doc strings of
default-font-height and default-font-width.  They return information
for the selected frame, not the current buffer.

* lisp/simple.el (default-font-height, default-font-width,
default-line-height): Correct doc strings.
---
 doc/lispref/display.texi | 4 ++--
 lisp/simple.el           | 8 ++++----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi
index 1f7cc93c9c..6704c714e2 100644
--- a/doc/lispref/display.texi
+++ b/doc/lispref/display.texi
@@ -3934,12 +3934,12 @@ Low-Level Font
 
 @defun default-font-width
 This function returns the average width in pixels of the font used by
-the current buffer's default face.
+the selected frame's default face.
 @end defun
 
 @defun default-font-height
 This function returns the height in pixels of the font used by the
-current buffer's default face.
+selected frame's default face.
 @end defun
 
 @defun window-font-width &optional window face
diff --git a/lisp/simple.el b/lisp/simple.el
index 47ce0364d1..28a416fa2c 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -6183,7 +6183,7 @@ line-move-visual
 (declare-function font-info "font.c" (name &optional frame))
 
 (defun default-font-height ()
-  "Return the height in pixels of the current buffer's default face font.
+  "Return the height in pixels of the selected frame's default face font.
 
 If the default font is remapped (see `face-remapping-alist'), the
 function returns the height of the remapped face."
@@ -6198,7 +6198,7 @@ default-font-height
      (t (frame-char-height)))))
 
 (defun default-font-width ()
-  "Return the width in pixels of the current buffer's default face font.
+  "Return the width in pixels of the selected frame's default face font.
 
 If the default font is remapped (see `face-remapping-alist'), the
 function returns the width of the remapped face."
@@ -6217,9 +6217,9 @@ default-font-width
      (t (frame-char-width)))))
 
 (defun default-line-height ()
-  "Return the pixel height of current buffer's default-face text line.
+  "Return the pixel height of the selected frame's default-face text line.
 
-The value includes `line-spacing', if any, defined for the buffer
+The value includes `line-spacing', if any, defined for the current buffer
 or the frame."
   (let ((dfh (default-font-height))
        (lsp (if (display-graphic-p)
-- 
2.24.0


reply via email to

[Prev in Thread] Current Thread [Next in Thread]