简体   繁体   English

Windows下特定Unicode字符的emacs set-fontset-font

[英]emacs set-fontset-font for specific unicode char under windows

I use the following setting to config the font for emacs under windows system 我使用以下设置为Windows系统下的emacs配置字体

(create-fontset-from-fontset-spec
 "-outline-Cousine-normal-normal-normal-*-*-*-*-*-*-*-fontset-Consolas")
(set-fontset-font "fontset-Consolas" 
                  '(#x6d4b . #x6d4c) 
                  "Microsoft YaHei" nil 'prepend)
(set-face-attribute 'default nil :font "fontset-Consolas")

After emacs start up, I input that char #x6d4b into the emacs buffer, but it turns out to be a square, which means the font setting does not work. emacs启动后,我将char #x6d4b输入到emacs缓冲区中,但结果是一个正方形,这意味着字体设置不起作用。 I also use describe-char to show detail information, and get the following result: 我还使用describe-char来显示详细信息,并获得以下结果:

             position: 2888 of 4342 (66%), column: 13
            character: 测 (displayed as 测) (codepoint 27979, #o66513, #x6d4b)
    preferred charset: unicode-bmp (Unicode Basic Multilingual Plane (U+0000..U+FFFF))
code point in charset: 0x6D4B
               syntax: w    which means: word
             category: .:Base, C:2-byte han, L:Left-to-right (strong), c:Chinese, |:line breakable
          buffer code: #xE6 #xB5 #x8B
            file code: #xE6 #xB5 #x8B (encoded by coding system utf-8-dos)
              display: no font available

We can find that the display property shows it does not have available font for it, but I indeed give that in the font config. 我们可以发现display属性显示它没有可用的字体,但是我确实在font config中给出了该字体。

Could you point out where is the problem? 您能指出问题出在哪里吗? I suppose the set-fontset-font should work even under windows system 我想即使在Windows系统下set-fontset-font也应该工作

As long as you just want to set the default font and a different font for two specific characters, the following works for me: 只要您只想为两个特定字符设置默认字体和其他字体,以下内容对我有用:

(set-face-attribute 'default nil :family "Consolas")
(set-fontset-font "fontset-default" '(#x6d4b . #x6d4c)
                  "Microsoft YaHei" nil 'prepend)

( prepend is unnecessary with Consolas, but may help with your font). prepend不需要与索拉,但可能与您的字体帮助)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM