* Changing font weight with buffer-face-mode-invoke @ 2024-06-25 21:58 Heime 2024-06-26 12:55 ` Eli Zaretskii 0 siblings, 1 reply; 14+ messages in thread From: Heime @ 2024-06-25 21:58 UTC (permalink / raw) To: Heime via Users list for the GNU Emacs text editor I use buffer-face-mode-invoke to change the font. I also want to change the weight, which is tricky. What option for weight are available ? Different fonts usually have different weight settings but have no clues about how to get the weights available for each font. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Changing font weight with buffer-face-mode-invoke 2024-06-25 21:58 Changing font weight with buffer-face-mode-invoke Heime @ 2024-06-26 12:55 ` Eli Zaretskii 2024-06-26 17:08 ` Heime 0 siblings, 1 reply; 14+ messages in thread From: Eli Zaretskii @ 2024-06-26 12:55 UTC (permalink / raw) To: help-gnu-emacs > Date: Tue, 25 Jun 2024 21:58:50 +0000 > From: Heime <heimeborgia@protonmail.com> > > I use buffer-face-mode-invoke to change the font. I also want to > change the weight, which is tricky. What option for weight are > available ? Different fonts usually have different weight settings > but have no clues about how to get the weights available for each font. Use standard weights: regular, medium, bold. Some font families have also additional weights: light, semi-light, semi-bold, extra-bold. The full list of weight values is in the ELisp manual, in the node "Face Attributes". ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Changing font weight with buffer-face-mode-invoke 2024-06-26 12:55 ` Eli Zaretskii @ 2024-06-26 17:08 ` Heime 2024-06-26 18:39 ` Eli Zaretskii 0 siblings, 1 reply; 14+ messages in thread From: Heime @ 2024-06-26 17:08 UTC (permalink / raw) To: Eli Zaretskii; +Cc: help-gnu-emacs On Wednesday, June 26th, 2024 at 12:55 PM, Eli Zaretskii <eliz@gnu.org> wrote: > > Date: Tue, 25 Jun 2024 21:58:50 +0000 > > From: Heime heimeborgia@protonmail.com > > > > I use buffer-face-mode-invoke to change the font. I also want to > > change the weight, which is tricky. What option for weight are > > available ? Different fonts usually have different weight settings > > but have no clues about how to get the weights available for each font. > > > Use standard weights: regular, medium, bold. Some font families have > also additional weights: light, semi-light, semi-bold, extra-bold. > The full list of weight values is in the ELisp manual, in the node > "Face Attributes". Some faces, e.g. "URW Chancery L" have "Medium Italic" and "Bold Italic". And not all faces have the weights declared in the list. Could there be an elisp function that returns a list of the available weights and styles for each entry in the list of font families ? ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Changing font weight with buffer-face-mode-invoke 2024-06-26 17:08 ` Heime @ 2024-06-26 18:39 ` Eli Zaretskii 2024-06-26 19:32 ` Heime 2024-06-26 20:54 ` Heime 0 siblings, 2 replies; 14+ messages in thread From: Eli Zaretskii @ 2024-06-26 18:39 UTC (permalink / raw) To: help-gnu-emacs > Date: Wed, 26 Jun 2024 17:08:40 +0000 > From: Heime <heimeborgia@protonmail.com> > Cc: help-gnu-emacs@gnu.org > > > Use standard weights: regular, medium, bold. Some font families have > > also additional weights: light, semi-light, semi-bold, extra-bold. > > The full list of weight values is in the ELisp manual, in the node > > "Face Attributes". > > Some faces, e.g. "URW Chancery L" have "Medium Italic" and "Bold Italic". > And not all faces have the weights declared in the list. Could there be > an elisp function that returns a list of the available weights and styles > for each entry in the list of font families ? I think you want list-fonts. See the node "Low-Level Font" in the ELisp manual, it describes this stuff. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Changing font weight with buffer-face-mode-invoke 2024-06-26 18:39 ` Eli Zaretskii @ 2024-06-26 19:32 ` Heime 2024-06-27 4:56 ` Eli Zaretskii 2024-06-26 20:54 ` Heime 1 sibling, 1 reply; 14+ messages in thread From: Heime @ 2024-06-26 19:32 UTC (permalink / raw) To: Eli Zaretskii; +Cc: help-gnu-emacs On Wednesday, June 26th, 2024 at 6:39 PM, Eli Zaretskii <eliz@gnu.org> wrote: > > Date: Wed, 26 Jun 2024 17:08:40 +0000 > > From: Heime heimeborgia@protonmail.com > > Cc: help-gnu-emacs@gnu.org > > > > > Use standard weights: regular, medium, bold. Some font families have > > > also additional weights: light, semi-light, semi-bold, extra-bold. > > > The full list of weight values is in the ELisp manual, in the node > > > "Face Attributes". > > > > Some faces, e.g. "URW Chancery L" have "Medium Italic" and "Bold Italic". > > And not all faces have the weights declared in the list. Could there be > > an elisp function that returns a list of the available weights and styles > > for each entry in the list of font families ? > > > I think you want list-fonts. See the node "Low-Level Font" in the > ELisp manual, it describes this stuff. Have done the following tools. But am getting Debugger entered--Lisp error: (wrong-type-argument stringp #<font-entity ftcrhb urw URW\ Chancery\ L nil iso10646-1 medium italic normal 0 nil nil 0 ((:font-entity "/usr/share/fonts/X11/Type1/z003034l.pfb" . 0))>) string-match("-" #<font-entity ftcrhb urw URW\ Chancery\ L nil iso10646-1 medium italic normal 0 nil nil 0 ((:font-entity "/usr/share/fonts/X11/Type1/z003034l.pfb" . 0))> 0) split-string(#<f (defun mon-font-info (font) "Get font attributes for FONT." (let ((attrs (split-string font "-"))) (vector (nth 1 attrs) ; Weight (nth 2 attrs) ; Slant (nth 3 attrs)))) ; Width (defun mon-list-font-family (font-family) "List all fonts for the specified FONT-FAMILY." (interactive (list (completing-read "Family: " (font-family-list) nil t))) (let ( (font-spec (font-spec :family font-family)) (fonts (list-fonts (font-spec :family font-family))) ) (if fonts (progn (switch-to-buffer "*Font List*") (erase-buffer) (insert (format "Fonts for family: %s\n\n" font-family)) (dolist (font fonts) (let* ( (font-info (mon-font-info font)) (weight (aref font-info 1)) (slant (aref font-info 2)) (width (aref font-info 3)) ) (insert (format "Weight: %-10s Slant: %-10s Width: %-10s Full: %s\n" weight slant width font)))) (goto-char (point-min))) (message "No fonts found for family: %s" font-family)))) ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Changing font weight with buffer-face-mode-invoke 2024-06-26 19:32 ` Heime @ 2024-06-27 4:56 ` Eli Zaretskii 0 siblings, 0 replies; 14+ messages in thread From: Eli Zaretskii @ 2024-06-27 4:56 UTC (permalink / raw) To: help-gnu-emacs > Date: Wed, 26 Jun 2024 19:32:35 +0000 > From: Heime <heimeborgia@protonmail.com> > Cc: help-gnu-emacs@gnu.org > > On Wednesday, June 26th, 2024 at 6:39 PM, Eli Zaretskii <eliz@gnu.org> wrote: > > > I think you want list-fonts. See the node "Low-Level Font" in the > > ELisp manual, it describes this stuff. > > Have done the following tools. But am getting > > Debugger entered--Lisp error: (wrong-type-argument stringp #<font-entity ftcrhb urw URW\ Chancery\ L nil iso10646-1 medium italic normal 0 nil nil 0 ((:font-entity "/usr/share/fonts/X11/Type1/z003034l.pfb" . 0))>) > string-match("-" #<font-entity ftcrhb urw URW\ Chancery\ L nil iso10646-1 medium italic normal 0 nil nil 0 ((:font-entity "/usr/share/fonts/X11/Type1/z003034l.pfb" . 0))> 0) > split-string(#<f list-font returns font _entities_, which are not strings. So they cannot be passed to split-string. > (defun mon-font-info (font) > > "Get font attributes for FONT." > > (let ((attrs (split-string font "-"))) > > (vector (nth 1 attrs) ; Weight > > (nth 2 attrs) ; Slant > > (nth 3 attrs)))) ; Width Since in your case FONT is a font entity, not a font name, the way to get attributes of FONT is to use font-get (passing it the attribute you are interested in as the 2nd argument). ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Changing font weight with buffer-face-mode-invoke 2024-06-26 18:39 ` Eli Zaretskii 2024-06-26 19:32 ` Heime @ 2024-06-26 20:54 ` Heime 2024-06-27 5:23 ` Eli Zaretskii 1 sibling, 1 reply; 14+ messages in thread From: Heime @ 2024-06-26 20:54 UTC (permalink / raw) To: Eli Zaretskii; +Cc: help-gnu-emacs On Wednesday, June 26th, 2024 at 6:39 PM, Eli Zaretskii <eliz@gnu.org> wrote: > > Date: Wed, 26 Jun 2024 17:08:40 +0000 > > From: Heime heimeborgia@protonmail.com > > Cc: help-gnu-emacs@gnu.org > > > > > Use standard weights: regular, medium, bold. Some font families have > > > also additional weights: light, semi-light, semi-bold, extra-bold. > > > The full list of weight values is in the ELisp manual, in the node > > > "Face Attributes". > > > > Some faces, e.g. "URW Chancery L" have "Medium Italic" and "Bold Italic". > > And not all faces have the weights declared in the list. Could there be > > an elisp function that returns a list of the available weights and styles > > for each entry in the list of font families ? > > > I think you want list-fonts. See the node "Low-Level Font" in the > ELisp manual, it describes this stuff. Could there be support functions (font-height-list :family family) and (font-weight-list :family family) so they can be used with (buffer-face-mode-invoke `(:family ,face-family :height ,face-height :weight ,face-weight) t) As the height and weight are customarily asked by users wanting to change font. If one can get the specific values available for a specific family, one would not run in the frequent difficulty of supplying non-existent values, resulting in no changes being applied. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Changing font weight with buffer-face-mode-invoke 2024-06-26 20:54 ` Heime @ 2024-06-27 5:23 ` Eli Zaretskii 2024-06-27 8:48 ` Heime 0 siblings, 1 reply; 14+ messages in thread From: Eli Zaretskii @ 2024-06-27 5:23 UTC (permalink / raw) To: help-gnu-emacs > Date: Wed, 26 Jun 2024 20:54:53 +0000 > From: Heime <heimeborgia@protonmail.com> > Cc: help-gnu-emacs@gnu.org > > Could there be support functions (font-height-list :family family) and > (font-weight-list :family family) so they can be used with > > (buffer-face-mode-invoke > `(:family ,face-family :height ,face-height :weight ,face-weight) t) They were never needed, and I don't really understand why you'd need them. So no, such functions are not planned. > As the height and weight are customarily asked by users wanting to change > font. Users are not asked about these attributes, certainly not "customarily", not in Emacs. In fact, users are not supposed to be bothered by that at all, they just need to specify the family/families of font(s) they want to use, and Emacs will do the rest automatically. IOW, I think you are talking about a problem that doesn't exist for most Emacs users. I understand that you decided for some reason to write some peculiar program that allows selection of these attributes interactively, and I'm prepared to help you find the related Emacs functionalities for that program. But the problem you are trying to solve is largely an academic one, because the resulting font will be largely not useful in Emacs, as you will discover next. Emacs was not designed to support selection of fonts by fine-tuning their weight, slant, and other similar attributes, so specifying such fonts works in some cases but doesn't work in others. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Changing font weight with buffer-face-mode-invoke 2024-06-27 5:23 ` Eli Zaretskii @ 2024-06-27 8:48 ` Heime 2024-06-27 9:30 ` Yuri Khan 2024-06-27 10:24 ` Eli Zaretskii 0 siblings, 2 replies; 14+ messages in thread From: Heime @ 2024-06-27 8:48 UTC (permalink / raw) To: Eli Zaretskii; +Cc: help-gnu-emacs On Thursday, June 27th, 2024 at 5:23 AM, Eli Zaretskii <eliz@gnu.org> wrote: > > Date: Wed, 26 Jun 2024 20:54:53 +0000 > > From: Heime heimeborgia@protonmail.com > > Cc: help-gnu-emacs@gnu.org > > > > Could there be support functions (font-height-list :family family) and > > (font-weight-list :family family) so they can be used with > > > > (buffer-face-mode-invoke > > `(:family ,face-family :height ,face-height :weight ,face-weight) t) > > > They were never needed, and I don't really understand why you'd need > them. So no, such functions are not planned. > > > As the height and weight are customarily asked by users wanting to change > > font. > > > Users are not asked about these attributes, certainly not > "customarily", not in Emacs. In fact, users are not supposed to be > bothered by that at all, they just need to specify the family/families > of font(s) they want to use, and Emacs will do the rest automatically. Customarily I want to set the height for good visibility which is larger than default. And bold in some cases. > IOW, I think you are talking about a problem that doesn't exist for > most Emacs users. I understand that you decided for some reason to > write some peculiar program that allows selection of these attributes > interactively, and I'm prepared to help you find the related Emacs > functionalities for that program. > But the problem you are trying to solve is largely an academic one, > because the resulting font will be largely not useful in Emacs, as > you will discover next. Not useful for the reason that it will not activate. Or because the font characteristics are not useful ? > Emacs was not designed to support selection of fonts by fine-tuning their > weight, slant, and other similar attributes, so specifying such fonts works > in some cases but doesn't work in others. If you do S-<down-mouse-1> to use "Change Buffer Font", one can select those attributes. I just want to do the same automatically in elisp code. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Changing font weight with buffer-face-mode-invoke 2024-06-27 8:48 ` Heime @ 2024-06-27 9:30 ` Yuri Khan 2024-06-27 10:24 ` Eli Zaretskii 1 sibling, 0 replies; 14+ messages in thread From: Yuri Khan @ 2024-06-27 9:30 UTC (permalink / raw) To: Heime; +Cc: Eli Zaretskii, help-gnu-emacs On Thu, 27 Jun 2024 at 15:48, Heime <heimeborgia@protonmail.com> wrote: > Customarily I want to set the height for good visibility which is larger > than default. And bold in some cases. You need to do it once, and possibly every time your vision acuity or monitor configuration changes in a major way, which should not be very often. You don’t need a maximally convenient UI for that. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Changing font weight with buffer-face-mode-invoke 2024-06-27 8:48 ` Heime 2024-06-27 9:30 ` Yuri Khan @ 2024-06-27 10:24 ` Eli Zaretskii 2024-06-27 10:59 ` Heime 1 sibling, 1 reply; 14+ messages in thread From: Eli Zaretskii @ 2024-06-27 10:24 UTC (permalink / raw) To: help-gnu-emacs > Date: Thu, 27 Jun 2024 08:48:18 +0000 > From: Heime <heimeborgia@protonmail.com> > Cc: help-gnu-emacs@gnu.org > > > Users are not asked about these attributes, certainly not > > "customarily", not in Emacs. In fact, users are not supposed to be > > bothered by that at all, they just need to specify the family/families > > of font(s) they want to use, and Emacs will do the rest automatically. > > Customarily I want to set the height for good visibility which is larger > than default. And bold in some cases. Selecting font size is easy and doesn't require all this complexity. I was talking about the other font attributes: weight, slant, and width. > > IOW, I think you are talking about a problem that doesn't exist for > > most Emacs users. I understand that you decided for some reason to > > write some peculiar program that allows selection of these attributes > > interactively, and I'm prepared to help you find the related Emacs > > functionalities for that program. > > > But the problem you are trying to solve is largely an academic one, > > because the resulting font will be largely not useful in Emacs, as > > you will discover next. > > Not useful for the reason that it will not activate. Or because the font > characteristics are not useful ? Because using such a font in various situations and APIs will not necessarily work. > > Emacs was not designed to support selection of fonts by fine-tuning their > > weight, slant, and other similar attributes, so specifying such fonts works > > in some cases but doesn't work in others. > > If you do S-<down-mouse-1> to use "Change Buffer Font", one can select those attributes. > I just want to do the same automatically in elisp code. There's no practical reason for doing so, that's all I'm saying. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Changing font weight with buffer-face-mode-invoke 2024-06-27 10:24 ` Eli Zaretskii @ 2024-06-27 10:59 ` Heime 2024-06-27 12:31 ` Eli Zaretskii 0 siblings, 1 reply; 14+ messages in thread From: Heime @ 2024-06-27 10:59 UTC (permalink / raw) To: Eli Zaretskii; +Cc: help-gnu-emacs On Thursday, June 27th, 2024 at 10:24 AM, Eli Zaretskii <eliz@gnu.org> wrote: > > Date: Thu, 27 Jun 2024 08:48:18 +0000 > > From: Heime heimeborgia@protonmail.com > > Cc: help-gnu-emacs@gnu.org > > > > > Users are not asked about these attributes, certainly not > > > "customarily", not in Emacs. In fact, users are not supposed to be > > > bothered by that at all, they just need to specify the family/families > > > of font(s) they want to use, and Emacs will do the rest automatically. > > > > Customarily I want to set the height for good visibility which is larger > > than default. And bold in some cases. > > > Selecting font size is easy and doesn't require all this complexity. > > I was talking about the other font attributes: weight, slant, and > width. > > > > IOW, I think you are talking about a problem that doesn't exist for > > > most Emacs users. I understand that you decided for some reason to > > > write some peculiar program that allows selection of these attributes > > > interactively, and I'm prepared to help you find the related Emacs > > > functionalities for that program. > > > > > But the problem you are trying to solve is largely an academic one, > > > because the resulting font will be largely not useful in Emacs, as > > > you will discover next. > > > > Not useful for the reason that it will not activate. Or because the font > > characteristics are not useful ? > > > Because using such a font in various situations and APIs will not > necessarily work. > > > > Emacs was not designed to support selection of fonts by fine-tuning their > > > weight, slant, and other similar attributes, so specifying such fonts works > > > in some cases but doesn't work in others. > > > > If you do S-<down-mouse-1> to use "Change Buffer Font", one can select those attributes. > > I just want to do the same automatically in elisp code. > > There's no practical reason for doing so, that's all I'm saying. Somehow, the "Change Buffer Font" tool allows selection of that information and gets things to work. Perhaps there are things missing for correct specification of weight, slant and width for buffer-face-mode-invoke. Could it be that using the :family, :height, :weight is not so rodust, and it is better to just use :font ? How would I call buffer-face-mode-invoke with :font or similar ? ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Changing font weight with buffer-face-mode-invoke 2024-06-27 10:59 ` Heime @ 2024-06-27 12:31 ` Eli Zaretskii 2024-06-27 16:49 ` Heime 0 siblings, 1 reply; 14+ messages in thread From: Eli Zaretskii @ 2024-06-27 12:31 UTC (permalink / raw) To: help-gnu-emacs > Date: Thu, 27 Jun 2024 10:59:46 +0000 > From: Heime <heimeborgia@protonmail.com> > Cc: help-gnu-emacs@gnu.org > > > > > Emacs was not designed to support selection of fonts by fine-tuning their > > > > weight, slant, and other similar attributes, so specifying such fonts works > > > > in some cases but doesn't work in others. > > > > > > If you do S-<down-mouse-1> to use "Change Buffer Font", one can select those attributes. > > > I just want to do the same automatically in elisp code. > > > > There's no practical reason for doing so, that's all I'm saying. > > Somehow, the "Change Buffer Font" tool allows selection of that information and > gets things to work. No, it doesn't. It sets things up to use a single font in a single buffer as the default face's font in that buffer, that's all. There are many other situations where fonts are used or passed to various functions in Emacs, and in quite a few of those using an arbitrary font with an arbitrary weight or slamt or width will not do what you expect. > Could it be that using the :family, :height, :weight is not so rodust, and it is better > to just use :font ? How would I call buffer-face-mode-invoke with :font or similar ? You should use just :family, and perhaps also specify :height. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Changing font weight with buffer-face-mode-invoke 2024-06-27 12:31 ` Eli Zaretskii @ 2024-06-27 16:49 ` Heime 0 siblings, 0 replies; 14+ messages in thread From: Heime @ 2024-06-27 16:49 UTC (permalink / raw) To: Eli Zaretskii; +Cc: help-gnu-emacs On Thursday, June 27th, 2024 at 12:31 PM, Eli Zaretskii <eliz@gnu.org> wrote: > > Date: Thu, 27 Jun 2024 10:59:46 +0000 > > From: Heime heimeborgia@protonmail.com > > Cc: help-gnu-emacs@gnu.org > > > > > > > Emacs was not designed to support selection of fonts by fine-tuning their > > > > > weight, slant, and other similar attributes, so specifying such fonts works > > > > > in some cases but doesn't work in others. > > > > > > > > If you do S-<down-mouse-1> to use "Change Buffer Font", one can select those attributes. > > > > I just want to do the same automatically in elisp code. > > > > > > There's no practical reason for doing so, that's all I'm saying. > > > > Somehow, the "Change Buffer Font" tool allows selection of that information and > > gets things to work. > > > No, it doesn't. It sets things up to use a single font in a single > buffer as the default face's font in that buffer, that's all. There > are many other situations where fonts are used or passed to various > functions in Emacs, and in quite a few of those using an arbitrary > font with an arbitrary weight or slamt or width will not do what you > expect. > > > Could it be that using the :family, :height, :weight is not so rodust, and it is better > > to just use :font ? How would I call buffer-face-mode-invoke with :font or similar ? > > > You should use just :family, and perhaps also specify :height. The "Pick a Font" of "Change Buffer Font" displays not just the family and size, but also the Style (e.g. Oblique, Regular, Bold, Bold Oblique). The Web Content Accessibility Guidelines (WCAG) refer to 14 point Bold Text or larger to define a different set of colour contrast values for both midrange and enhanced contrast (Levels AA and AAA). For acessibility, a working :weight setting is quite desirable. A useful tool in this regard is a function one can call that is similar to (font-family-list) which we can call font-weight-list to which one can pass the font family (font-weight-list :family family) Or perhaps some other way convenient you might suggest. ^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2024-06-27 16:49 UTC | newest] Thread overview: 14+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-06-25 21:58 Changing font weight with buffer-face-mode-invoke Heime 2024-06-26 12:55 ` Eli Zaretskii 2024-06-26 17:08 ` Heime 2024-06-26 18:39 ` Eli Zaretskii 2024-06-26 19:32 ` Heime 2024-06-27 4:56 ` Eli Zaretskii 2024-06-26 20:54 ` Heime 2024-06-27 5:23 ` Eli Zaretskii 2024-06-27 8:48 ` Heime 2024-06-27 9:30 ` Yuri Khan 2024-06-27 10:24 ` Eli Zaretskii 2024-06-27 10:59 ` Heime 2024-06-27 12:31 ` Eli Zaretskii 2024-06-27 16:49 ` Heime
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).