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

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

How does fontset work in emacs?


From: winterTTr
Subject: How does fontset work in emacs?
Date: Mon, 31 Dec 2012 10:14:31 +0800

I read some documentation about font configuration in Emacs, I found two concept, which areFONT andFONTSET. Currently, my understanding is that, fontset is a set of font which are grouped by thescript( aka encoding ), and we can create a fontset and specify some set of chars to use specific font.

But until now, some experiments code does not always work as I wish, so I want to find what's the problem is?

First, I create my own fontset

(create-fontset-from-fontset-spec
 "-outline-Cousine-normal-normal-normal-*-*-*-*-*-*-*-fontset-Consolas")

Then I want to use it as current emacs fontset( or is this possible? I am not sure), the following code seems works:

(set-frame-font "fontset-Consolas" nil t)

Then I try to customize my fontset for some specific character or encoding:

(set-fontset-font "fontset-Consolas" 'han "Microsoft YaHei" nil 'prepend)

However, it's pity that this does not work, and the char in 'han category do not change its font. Then I got some sample code and try the following one:

(set-fontset-font "fontset-Default" 'han "Microsoft YaHei" nil 'prepend)

This time, it works, the char in 'han category use the correct font. But why i need to change fontset-default instead of my fontset-consolas. Then I try to revert my change, with following code:

(set-fontset-font "fontset-Default" 'han "Consolas" nil 'prepend)

However, the 'han category char remains the same, which I expect these char should not display correctly, as I use a font does not contains those char. Why does changing fontset-default not work this time?

Besides the code above, some more universal question:

  1. How to change the emacs default fontset to my own one, is it possible?
  2. Is multi fontset works at the same time or only one fontset work? Why my test code need to changedefault instead of mine?
  3. The set-fontset-font second parameter is target, how can I know which script name is suitable for the char under current cursor. I can use describe-char to display the char information, but I don't find which word in this description is the correct one for that target param.
  4. Some points worthy of notice for font configuration in emacs?

My question is kind of lengthy, so thanks for your patient and share your suggestion.


BTW, the char that I used to test is #x6d4b, it's a chinese character.


-winterTTr


reply via email to

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