In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-13 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to solve the problem of Chinese garbled code and box in NetBeans under Ubuntu". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "how to solve the problem of Chinese garbled code and box in NetBeans under Ubuntu"!
When I installed netbeans 7.0in ubuntu 11.04, there was a strange phenomenon. When I started netbeans, I found that many Chinese characters could not be displayed, so I directly displayed a box. Obviously, there is no display data for some characters, but it is strange that some Chinese characters can be displayed. It is amazing that the font used by netbeans is not complete.
And ubuntu can display Chinese characters normally, indicating that the font of ubuntu itself should be no problem. So what's the problem?
The answer is: JRE
Netbean is written in java, and its operation depends on JRE, as we all know. The font used by JRE depends on the configuration file of JRE itself to decide which font file corresponds to in the system.
Therefore, it is determined that there is something wrong with this correspondence.
According to Java's official document (http://download.oracle.com/javase/1.5.0/docs/guide/intl/fontconfig.html#loading), the font correspondence configuration file is located under jre/lib, and there are two forms, one is src file, the other is bfc file. The bfc file is binary and predefined by the system, so what we need to modify is the src file. Go to this directory and take a look, as shown in the following figure:
When I saw these file names, I got a general idea. If you look at the format of fontconfig.OS.version.properties.src, you should understand that this is a configuration file for different operating system platforms. Jre will automatically select the corresponding configuration file according to the operating system. Therefore, I opened the corresponding file of ubuntu and looked at the first line:
The code is as follows:
Allfonts.chinese-cn-iso10646=-arphic-ar pl uming cn-light-r-normal--*-%d-*-*-c-*-iso10646-1
The correspondence between the logical font and the physical font used by jre is specified here. The logical font used by jre is on the left side of the equal sign, and the physical font needs to be used on the right side of the equal sign.
It's just that this physical font looks similar to the Martian text, but this Martian text is an authentic X logical font description (XLFD) description, so there's nothing more to say here. Readers who want to know can go to google for themselves.
Then look at the # Font File Names section of the configuration file, where there is a line:
The code is as follows:
Filename.-arphic-ar_pl_uming_cn-light-r-normal--*-%d-*-*-c-*-iso10646-1=/usr/share/fonts/truetype/arphic/uming.ttc
This is the corresponding description of the physical font and the system font file described above.
Isn't that the physical font name on the left that we look like in Martian? I don't know where to find this font, so there's an answer. I even told you the catalogue.
Immediately go to the / usr/share/fonts/truetype directory to have a look, not to mention uming.ttc, not even the arphic directory!
Now we have two choices:
1. Modify the configuration file to point to the font file available on the system.
That is, modify: / usr/share/fonts/truetype/arphic/uming.ttc this part, change to the existing font file name.
two。 Install a uming.tcc font file.
As the uming.tcc font is more famous, it is a high-quality Chinese font. So I decided to choose the second option.
After a goole on the Internet, I immediately found the download address: http://ftp.br.debian.org/debian/pool/main/t/ttf-arphic-uming/ttf-arphic-uming_0.2.20080216.1-3_all.deb
After downloading: sudo dpkg-I ttf-arphic-uming_0.2.20080216.1-3_all.deb
Installation completed successfully, at this time go to the / usr/share/fonts/truetype directory to have a look, this time there is an arphic this directory, and then open the directory to see, uming.ttc is there!
Immediately open netbeans, a long wait, and finally see the window, everything has, the font looks really beautiful, worthy of arphic products ah.
Since then the problem has been solved perfectly, no matter how the version changes, the problem can be solved in this way.
Some articles on the Internet talk about cp fonts to jre/lib/fonts/fallback, but many people don't understand the principle. The fallback directory is the jre font backup directory, which means that if the font information cannot be found in the normal configuration, it will be found in the font file in the order set by the configuration file in this directory. There are two problems with this way. One is inefficiency. Second, the font is not uniform, there will be such as: document this word, the text is bold, the piece is boldface "spectacular" scene! Why? Because the text was found in the italic font, but there was no word in this font, so I went to the boldface font in fallback and found it. This phenomenon miraculously appeared!
So this way actually belongs to the correct method, many people muddled show normal, also do not understand the principle. On the other hand, other people will have different fonts.
Of course, none of the above will happen on windows. Because windows is more unified, so the configuration of the configuration file must work properly, there will not be similar to linux even the font file may not be found. This also proves the importance of specification and unification in software.
At this point, I believe you have a deeper understanding of "how to solve the problem of Chinese garbled codes and boxes in NetBeans under Ubuntu". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 272
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.