In the terminal, CMD, editor occasionally have Chinese characters appear, Windows under the default bitmap font "Arial" and the equal width English characters together very vainly disobey. One workaround is to download hybrid fonts, such as "consolas + Yahei hybrid","source Code Pro + Yahei hybrid". But these font combinations are limited after all, what if you want to use "anonymous Pro + young circles, or change the character weight and use italic? This will use the Fontlink function of the registry.
Fontlink, as the name implies, maps characters not contained in one font to another. For example, set the default font in the editor is "consolas", if the file has Chinese characters, Windows will default to display as "Arial", but Fontlink set "Ya Black", you can use "Ya black" to display.
Take "consolas + ya-hei" For example, here is the implementation method:
- Press
Win + R to open "Run", enter regedit Click OK, open "registration form";
Positioning to the following position;
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Nt\currentversion\fontlink\systemlink
- Locate the
Consolas item, double-click Open, enter the following in the Value Data text box and click OK;
Msyh. TTF,205,154msyh. TTF
- Log off or restart your computer
Beautify cmd and PowerShell with Monaco and Microsoft Ya-Black fonts
Windows itself has a fontlink function, that is, if a font has characters that cannot be displayed,
Replace it with some alternate font (the classmate who is familiar with Java, remember Fontconfig.properties bar).
These can be set in the registration table. So if you are using a Windows font System program, you can get this feature.
If you set an alternate font for an equal-width English font to black, then if you choose the English font,
If there is a Chinese need to display, it will not appear in the box, but with Jachelle display!
Please install and select Monaco, which is a good-looking font for Apple.
Then we have to modify Monaco's fontlink. First open regedit to find
Hklm/software/microsoft/windows Nt/currentversion/fontlink/systemlink
You will find that there are many keys to the name of the font, and then you can see why you chose an English font, but it still works when you type in Chinese.
now we need to create a key like this, create a new string key Monaco, and then enter :
You may find, msyh. TTF This font also appears in other keys (such as the Segoe UI), and there are two, followed by two digits (the default is 128,96). But I set it to 205,154. What does that mean?
first, what is the number? If an English font cannot display a Chinese font, it is displayed with its alternate font, and the font size is the same. But the Chinese and English characters, if the same, the actual size is different, it seems very discordant. So to the Chinese font a scaling factor, so that the corresponding font size or become smaller, and the corresponding English font matching.
Second, why do you want to repeat a no number? in fact, this fontlink is GDI and GDI + functions, but GDI + does not recognize the following numbers (in fact, in many ways GDI + is weaker than GDI, hey). So to repeat, GDI + cannot find the first font, just use the second one.
Three, why do I choose a different value? random Matching two fonts, the factor how to choose, it should be different, I did not find online how to choose this information. I first use the default 128, 96来 test, found that the effect is the second one, Chinese feeling is very short, feeling and English is not a horizontal line. I have seen this phenomenon in Emacs. In Emacs, Monaco and ya black font size ratio is 1:1.6, a Chinese is exactly two English width, very harmonious, so I will be the default value is multiplied by 1.6, out of 205,154. I tried a couple of times, and if it was too big (twice times bigger, for example), I went back to the first state (the second one). So 1.6 is the most appropriate choice.
Because this is the GDI feature, quite the bottom, so set up to restart the system, and then see the effect!
3. Discussion
At first I said, the first one contains the mystery, is the same font, input is equal width, but the cmd feedback rendering is unequal ! There are a number of problems with the rendering of cmd-visible characters. One possibility is that the output uses the non-equal width information of the Jas font, which is narrower than the input. With this setting, the width of Notepad in black is slightly greater than two English characters.
In fact, we set up the cmd, in fact, bypassing the cmd itself some defects of the hack. But CMD can now use a nice combination of fonts, so this "flaw" can still be tolerated. After all, ya-hei is a non-equal-width font that contains advanced typesetting information. If you really need to, you can replace the Jache with Cheng.
This setting also has a more useful place. For example, VIM itself has weak support for fonts, and UTF-8 encoding is also not supported for non-equal-width fonts. So if you use Fontlink, just choose Monaco as the font, everything OK. For example, the Notepad font is selected AS Monaco, Chinese will naturally become ya black.
So are all future font settings saved? No. This can only be used by software that uses the Windows own font rendering feature. Like Emacs's own hands-on, the font support is very perfect, much more powerful than the small thing in Windows. Java is also its own rendering of fonts, although a bit buggy (such as swing display ya black coarse italic, incredibly garbled, but normal is OK; I guess it still is).
Using the registry to optimize the terminal, editor of the Chinese and English fonts mixed display, such as "consolas + ya black""monaco + ya Black"