Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to set the font for CJK characters separately? #123

Open
nemo-nullius opened this issue Sep 21, 2017 · 5 comments
Open

Is there a way to set the font for CJK characters separately? #123

nemo-nullius opened this issue Sep 21, 2017 · 5 comments

Comments

@nemo-nullius
Copy link

nemo-nullius commented Sep 21, 2017

At first I want to say I like LilyTerm very much. It is one of the best terminal emulators I have ever used for it is quick, pretty, and can display CJK characters very well.

I am just wondering whether I can set the font for English alphabets and CJK characters separately, just like the options in .vimrc guifont and guifontwide for gvim. As I spend most of my time each day writing things in vim in the terminal, it would help me a lot if I could use a different font for CJK characters rather than the few ones originally designed for English alphabets.

Thanks for your help!

@Tetralet
Copy link
Owner

We may try to "bind" an English font and a CJK font into a single font by editing ~/.config/fontconfig/fonts.conf:

<test compare="eq" name="family" >

    <string>monospace</string>

</test>

<edit mode="assign" binding="strong" name="family" >

    <string>DejaVu Sans Mono</string>

    <string>WenQuanYi Zen Hei</string>

</edit>

http://lilyterm.luna.com.tw/html/document.html#Monospace%20fonts

@nemo-nullius
Copy link
Author

nemo-nullius commented Sep 22, 2017

Thanks!

It does not seem to work so well on my system... After editing ~/.config/fontconfig/fonts.conf and adding the following lines, LilyTerm does not seem to change. In other terminal emulators like st for example, the CJK characters appear to be faily good, but the English alphabets are arranged in disorder - they are not "monospace" any more. Do you have any idea about it please?

These are the codes in fonts.conf:

  <match target="pattern" >
       <test compare="eq" name="family" >
           <string>Ubuntu Mono derivative Powerline</string>
       </test>                                                                                                        
       <edit mode="assign" binding="strong" name="family" >
           <string>WenQuanYi Zen Hei</string>
       </edit>
   </match>

Before editing fonts.conf in LilyTerm:
beforeeditingfonts conf_inlilyterm
After editing fonts.conf in LilyTerm: (no change)
aftereditingfonts conf_inlilyterm
After editing fonts.conf in st:
in_st

My environment:

  • OS: ubuntu 14.04 + i3wm
  • LilyTerm ver: 0.9.9.4 (2017-05-28)
  • Set font "Ubuntu Mono derivative Powerline" in LilyTerm

Thank you so much for your help!

@nemo-nullius
Copy link
Author

nemo-nullius commented Sep 22, 2017

All right... Now I see what the problem is. I have to restart the X in order for fonts.conf to take effect in LilyTerm. How stupid I am!

However, the configuration in your last comment and in the link above does not seem to be a good fit for my system though. The problem that I showed above still remains. After trying many times, I happened to write the following codes which fit me most in my case:

     <match target="pattern">
         <test qual="any" name="family" compare="eq">
             <string>Ubuntu Mono derivative Powerline</string>
         </test>
         <edit name="family" mode="append" binding="strong">                                                        
             <string>WenQuanYi Zen Hei</string>
         </edit>
     </match>

(The thing which makes a difference I think is that I changed mode="assign" to mode="append".)

Ubuntu Mono derivative Powerline is for English alphabets as well as WenQuanYi Zen Hei for CJK characters, and both are arranged in order now:

good

But there are still some questions perplexing me all the time. For I have also set a font in LilyTerm, what's the relationship between this font and the font I set in fonts.conf? What's more, what are the functions of such elements and expressions, like mode=append, name="family", qual="any", in the configuration file? Although I have checked the man page of fonts.conf, I still could not fully get it. Is there any document on this in detail?

I really appreciate it a lot if you could help!

@Tetralet
Copy link
Owner

How about using the Noto fonts?

https://github.com/adobe-fonts/source-han-sans/tree/release

@nemo-nullius
Copy link
Author

nemo-nullius commented Sep 22, 2017

Yes, I am also using that, including both Source Code Pro and Source Han Sans. They are really pretty fonts. But I still need to change mode="assign" to mode="append" in fonts.conf in order to make both fonts display correctly.

Here is my setting:

     <match target="pattern">
          <test qual="any" name="family" compare="eq">
              <string>Source Code Pro for Powerline</string>
          </test>
          <edit name="family" mode="append" binding="strong">
              <string>Source Han Sans Regular</string>
          </edit>
      </match>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants