Beautify CMD and powershell with Monaco and Fonts

Source: Internet
Author: User

First (sell a customs token. This figure contains xuanjicang ......)

In addition, I wonder if you can observe the differences between the two pictures:

1. Introduction

The default font of Microsoft console programs (CMD and powershell) is very ugly. There are many articles on the Internet about how to modify the font. Most of them are by switching the code page (936 to 437), and then selecting a font added in the registry. However, the Chinese font is rarely set. If you can use as a Chinese font, but is not defined as an equal-width font, you cannot use it directly.

Later, I accidentally discovered that Windows has a fontlink function. That is to say, if a font contains characters that cannot be displayed, replace them with some alternative fonts (familiar with Java, remember fontconfig. properties ). These can be set in the registry. Therefore, if you use a Windows Font system program, you can obtain this function. If you set the alternative font for an English font of equal width to, you can select the English font. If you need to display Chinese characters, no box is displayed, but is used for display!

2. Operation

First, search for "Modify cmd font" on the Internet and follow the instructions to familiarize yourself with how to set the English font (that is, add a key such as 0 00 000 in the Registry, and then select the font by modifying the code page ). At this time, it should be achieved. The English text is displayed in the font you set, and the Chinese text is still the default. If you want to completely follow me, install and select Monaco, which is a nice font from Apple.

Then we need to modify the fontlink of Monaco. First Open regedit and find

HKLM/Software/Microsoft/Windows NT/CurrentVersion/FontLink/SystemLink

You will find that there are many fonts and keys, and then you will understand why you choose an English font, but it can still be displayed normally when you enter Chinese. Now we need to create a key like this, create a new string key Monaco, and then input it as follows:

 

You may find that the font msyh. TTF also appears in other keys (such as segoe UI), and there are two. The first one is followed by two numbers (the default value is, 96 ). But I set it to 205,154. What does this mean?

1. What are numbers? If an English font cannot display a Chinese font, use its alternative font. The font size is the same. However, if the font size is the same for both Chinese and English characters, the actual size is different, and the font size is not harmonious. Therefore, we need to provide a scaling factor for the Chinese font to make the corresponding font larger or smaller to match the corresponding English font.

2. Why do we need to repeat a number without a number? In fact, this fontlink is a function of GDI and GDI +, but GDI + cannot identify the following numbers (in fact, in many aspects, GDI + is weaker than GDI, ). So repeat it once. If the first font cannot be found in GDI +, the second font is used.

3. Why should I choose a different value? There are two fonts available at will. How should I choose the factor? It should be different. I didn't find any information on the Internet. I first tried it with the default, 96, and found that the effect was the second one. The Chinese character felt very short and the English was not in the same horizontal line. I have also seen this phenomenon in Emacs. In Emacs, the font size ratio of Monaco and is 1:1. at, a Chinese character is exactly the width of the two English letters, which is very harmonious. Therefore, I multiply the default values by 1.6 and then 205,154. I tried it several times. If it is too large (for example, it is doubled), it will return to the Initial State (as shown in the second figure ). Therefore, 1.6 is the most appropriate choice.

This is a feature of GDI, which is quite the underlying layer. Therefore, you need to restart the system after the settings, and then you will see the effect!

3. Discussion

At first, I said that the first figure containing xuanjicang is the same font. The input is of equal width, but the rendering feedback from CMD is of varying width! It can be seen that there are still many problems with the character rendering of CMD. One possibility is that the output uses the non-width information of the font, Which is narrower than the input. With this setting, the width of the in Notepad must be slightly greater than two English characters.

In fact, setting CMD in this way actually bypasses the hack of some defects of CMD itself. However, CMD can now use a nice font combination, so this "flaw" can still be tolerated. After all, is a non-width font containing advanced typographical information. If necessary, you can replace with a child circle.

This setting is also useful. For example, VIM itself has weak support for fonts. It only needs UTF-8 to set the fonts separately. It does not support non-width fonts. So if you use fontlink, directly select Monaco as the font, everything is OK. For example, if you set the notepad font to Monaco, the Chinese language will naturally become.

Are all subsequent font settings saved? No. Only software that uses the font rendering function of Windows can use this function. E. g., E. E. G. is more powerful than windows. Java also renders the font by itself. Although it is a bit buggy (for example, when swing shows in bold italic, It is garbled, but normal is okay; I guess this is the case now ).

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.