Question

In .emacs, I've set a larger font for Kanji, but want to retain the smaller font for Hiragana and Katakana:

(set-fontset-font "fontset-default" 'han "Sazanami Gothic:size=18")
(set-fontset-font "fontset-default" '(#x3000 . #x30ff) "Sans")

That works when loading files etc.

When I use a horizontally split window, and switch to other subwindow, the font of the Hiragana in the subwindow I'm leaving sometimes changes to the large font. Is that because the unicode ranges overlap, and the order of the definitions is not respected? How should I correctly specify the ranges, i.e. can I exclude the range from 'han, or do I need to hunt down the definition of 'han and correct the ranges manually?

Was it helpful?

Solution 3

To answer my own question: I replaced the 'han (script name symbol) with cons'd ranges

'(#x3400 . #x4dff) '(#x4e00 . #x9fff) '(#x20000 . #x2bfff)

to the CJK unicode blocks in 3 different calls. That works.

Apparently overlapping font definitions using script name symbols and ranges are evaluated somewhat nondeterministically, so I got sometimes one and sometimes the other.

OTHER TIPS

In general, fonts such as buffer background and buffer foreground are changed globally -- either on a per frame basis or all frames -- not on a per buffer or per window basis. The following are two examples of how to affect only one buffer:

(defun buffer-background-red ()
(interactive)
  (setq buffer-face-mode-face `(:background "red"))
  (buffer-face-mode 1))

(defun zoom ()
(interactive)
  (setq buffer-face-mode-face `(:height 375))
  (buffer-face-mode 1))

As a workaround (untested), you might try using font-lock to apply a different face to the chars in question (assuming you can easily target them for font-lock using either a regexp or a function). The face can specify the character size.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top