如何对emacs中的某些utf-8字符使用不同的ttf字体?
我想使用如何对emacs中的某些utf-8字符使用不同的ttf字体?,emacs,fonts,persian,emacs-faces,farsi,Emacs,Fonts,Persian,Emacs Faces,Farsi,我想使用SourceCodePro作为默认字体,但它不包括波斯字符,例如\x0600直到\x06FF为止。 我试过这样的东西 (set-fontset-font t 'ascii "Source Code Pro-12") (set-fontset-font t (cons (decode-char 'ucs #x0600) (decode-char 'ucs #x6FF)) "Roya-13
SourceCodePro
作为默认字体,但它不包括波斯字符,例如\x0600
直到\x06FF
为止。
我试过这样的东西
(set-fontset-font t
'ascii
"Source Code Pro-12")
(set-fontset-font t
(cons (decode-char 'ucs #x0600)
(decode-char 'ucs #x6FF))
"Roya-13")
(set-face-font 'default "fontset-default")
(set-fontset-font "fontset-default"
'emacs (font-spec :name "Source Code Pro"))
(set-fontset-font "fontset-default"
'iso-8859-1 (font-spec :name "Source Code Pro"))
(set-face-attribute 'font-lock-comment-face nil
:family "Inconsolata" :height 140)
(set-fontset-font "fontset-default"
'(#x0600 . #x06FF) (font-spec :name "Roya:pixelsize=16:foundry=farsiweb:weight=normal:slant=normal:width=normal:scalable=true"))
(set-fontset-font "fontset-default"
'(#x0750 . #x075F) (font-spec :name "Roya:pixelsize=16:foundry=farsiweb:weight=normal:slant=normal:width=normal:scalable=true"))
(set-fontset-font "fontset-default"
'(#x08A0 . #x08FF) (font-spec :name "Roya:pixelsize=16:foundry=farsiweb:weight=normal:slant=normal:width=normal:scalable=true"))
(set-fontset-font "fontset-default"
'(#xFB50 . #xFDFF) (font-spec :name "Roya:pixelsize=16:foundry=farsiweb:weight=normal:slant=normal:width=normal:scalable=true"))
(set-fontset-font "fontset-default"
'(#xFD70 . #xFEFF) (font-spec :name "Roya:pixelsize=16:foundry=farsiweb:weight=normal:slant=normal:width=normal:scalable=true"))
(set-fontset-font "fontset-default"
'(#x1EE00 . #x1EEFF) (font-spec :name "Roya:pixelsize=16:foundry=farsiweb:weight=normal:slant=normal:width=normal:scalable=true"))
但它不起作用。
我还试着像这样使用fontset-standard
和fontset-default
(set-fontset-font t
'ascii
"Source Code Pro-12")
(set-fontset-font t
(cons (decode-char 'ucs #x0600)
(decode-char 'ucs #x6FF))
"Roya-13")
(set-face-font 'default "fontset-default")
(set-fontset-font "fontset-default"
'emacs (font-spec :name "Source Code Pro"))
(set-fontset-font "fontset-default"
'iso-8859-1 (font-spec :name "Source Code Pro"))
(set-face-attribute 'font-lock-comment-face nil
:family "Inconsolata" :height 140)
(set-fontset-font "fontset-default"
'(#x0600 . #x06FF) (font-spec :name "Roya:pixelsize=16:foundry=farsiweb:weight=normal:slant=normal:width=normal:scalable=true"))
(set-fontset-font "fontset-default"
'(#x0750 . #x075F) (font-spec :name "Roya:pixelsize=16:foundry=farsiweb:weight=normal:slant=normal:width=normal:scalable=true"))
(set-fontset-font "fontset-default"
'(#x08A0 . #x08FF) (font-spec :name "Roya:pixelsize=16:foundry=farsiweb:weight=normal:slant=normal:width=normal:scalable=true"))
(set-fontset-font "fontset-default"
'(#xFB50 . #xFDFF) (font-spec :name "Roya:pixelsize=16:foundry=farsiweb:weight=normal:slant=normal:width=normal:scalable=true"))
(set-fontset-font "fontset-default"
'(#xFD70 . #xFEFF) (font-spec :name "Roya:pixelsize=16:foundry=farsiweb:weight=normal:slant=normal:width=normal:scalable=true"))
(set-fontset-font "fontset-default"
'(#x1EE00 . #x1EEFF) (font-spec :name "Roya:pixelsize=16:foundry=farsiweb:weight=normal:slant=normal:width=normal:scalable=true"))
这也没用
更新:
多亏了使用“后生成框架函数”的指导,它才适合我
(defun zzgraph/fix-fontset (&optional frame)
(set-fontset-font "fontset-default" 'arabic "Roya"))
(add-hook 'after-make-frame-functions 'zzgraph/fix-fontset)
在Emacs 24中,不需要将框架的字体设置为
“fontset default”
。只需修改fontset default
就足以改变默认的回退行为。在您发布的代码片段中,font:name
属性包含许多不属于名称的额外行李。试着消除这一点,只使用“Roya”。如果您有其他称为“Roya”的字体不合适,您可能需要包含的不仅仅是字体名称来区分哪种字体,但您应该使用单独的属性来实现这一点,而不是将它们作为:name
属性的一部分进行捆绑
总而言之:
(set-face-font 'default "SourceCodePro")
(set-fontset-font "fontset-default"
'(#x0600 . #x06FF) (font-spec :name "Roya"))
(set-fontset-font "fontset-default"
'(#x0750 . #x075F) (font-spec :name "Roya"))
(set-fontset-font "fontset-default"
'(#x08A0 . #x08FF) (font-spec :name "Roya"))
(set-fontset-font "fontset-default"
'(#xFB50 . #xFEFF) (font-spec :name "Roya"))
(set-fontset-font "fontset-default"
'(#x1EE00 . #x1EEFF) (font-spec :name "Roya"))
这些片段对我很有用。@legoscia谢谢!第二个很好用。所以当我们制作新的框架时,我们总是要调用钩子!这很奇怪,而且它对拉丁语脚本不起作用,因为我使用了
(添加到“默认帧列表”(font.“Source code Pro”))
在函数外部更改拉丁语的默认面characters@legoscia你能回答一下你的评论吗?还有,你知道为什么在make frame函数之后使用是必要的吗?这与在守护进程模式下运行Emacs有关吗?请自己写一个答案!我使用了两种不同的方法,所以请使用对您有效的方法。回答你自己的问题。至于制作框架函数之后的,我从来没有使用过守护进程,但仍然需要它,所以它与此无关。我尝试过,它就是不起作用,我认为这可能与我运行守护进程模式有关,但是@legossia在制作框架函数之后使用
挂钩,效果非常好。