help-gnu-emacs
[Top][All Lists]
Advanced

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

Set :family but don't set :size in font-spec when calling set-fontset-fo


From: Rodrigo Morales
Subject: Set :family but don't set :size in font-spec when calling set-fontset-font
Date: Sat, 7 Sep 2024 11:05:14 -0500

I have used the sexp shown below to change the font family for characters whose 
script is =han=. Note that =font-spec= sets the font size.

#+begin_src elisp
(set-fontset-font t 'han (font-spec :family "Noto Sans Mono CJK SC" :size 50))
#+end_src

I have defined some utilities that allow me to change the font size of those 
characters, so the value of =:size= can be an arbitrary integer.

For some reason, sometimes I need to change the font family of those 
characters, but I don't want to change the size, because the size could set to 
an arbitrary value. When I evaluate the sexp shown below, the font family is 
changed and the size too, but I don't want to change :size (i.e. I want to keep 
using the same :size that was used when :family equal "Noto Sans Mono CJK SC")

#+begin_src elisp
(set-fontset-font t 'han (font-spec :family "FandolKai"))
#+end_src

I have read the docstring of the parameter of :size in =font-spec= and it 
doesn't mention anything about using the value of the previous =font-spec=.

My question is: How to reference the previous value of a font-spec in a new 
font-spec?

I have thought of these solutions:

1) Keep track of the font size that the user wants to use for han characters in 
a variable. Whenever the font size for han characters change, that variable 
should be updated.
2) Find a way to get :size of the current font-spec for =han= characters and 
use that value for =:size= when changing the font-spec

Do any of you know another solution?



reply via email to

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