all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Set :family but don't set :size in font-spec when calling set-fontset-font
@ 2024-09-07 16:05 Rodrigo Morales
  0 siblings, 0 replies; only message in thread
From: Rodrigo Morales @ 2024-09-07 16:05 UTC (permalink / raw)
  To: help-gnu-emacs


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?



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-09-07 16:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-07 16:05 Set :family but don't set :size in font-spec when calling set-fontset-font Rodrigo Morales

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.