Author: Xoo (at linuxsir.org)
Original source: http://www.linuxsir.org/bbs/showthread.php? S = & threadid = 81056
Written in front:
The first question that has just faced the friends who have just put Linux is Chinese, beautify. Linux default font is not very beautiful, especially
This is even more likely to Chinese. I started to use two or three months. It has not been very good. When I am a little lazy, when I am ready to roll back to Windowz, I accidentally saw a beautification article, I did it.
And it succeeded (at least what I wanted), from that, slowly fell in love with Linux until the Windowz was completely entered to the toilet.
There is already a lot of articles on the Internet, but most of them tell you how the first step is how, how is the second step, as for the simple truth, there is little involvement. result
Careful to know that it did not know how it did, once the article didn't succeed, it was equal to white. I have encountered problems in the future, or I have no hand.
I wrote this purpose is to combine all kinds of situations I have encountered in my actual, combined my own experience, write an article to help those who want to beautify success, and think about probably
Know "why you want to do this" friend. Of course, I just can talk about some of my own understanding, and I don't understand the truth, huh, huh. There are wrong places
THank you for everyones suggestions. This article is based on Freetype / Fontconfig / XFT, XTT I useless, the fonts used are TrueType.
Let's start below.
I strongly recommend that you take a closer look at this section, this is a great help to the specific operations of the next! !
There are three common GUI programs under Linux, GTK1, GTK2, and QT, the procedures based on these three graphics libraries have different requirements in beautification. Drawn fonts under xfree86
The solution has XTT, FreeType / Fontconfig / XFT. Let's take a look at it.
1.GTK1 program does not support fontconfig. So a little bit trouble. Get a font, you first let X find it right? This step is to explain the detailed manner described in the fontpath attribute inside / etc / x11 / xf86config section "files" segment. Ok, X is now known where the font is. The GTK1 program can't use them directly, because we have not "registered" it yet, this is required to generate two files in the previous Fonts.Dir fonts.scale in these two files, FontPath, all fonts List information is a "index". With this "index", GTK1 can find the corresponding font. The tools that generate these two files are mkfontdir, mkfontscale, TTMKFDIR, and more. Ok, if the above steps are completed correctly, your GTK1 program can now display the Chinese characters normally.
Common GTK1 programs have XMMS, GIMP .....
2.Gtk2 and QT programs can use fontconfig. FontConfig is a stuff to display the font and decide how to display these fonts. Similar to the previous mentioned
The fontpath attribute in XF86Config and Fonts.dir and Fonts.scale are the function of let the program find these fonts. So, for GTK2 and QT programs XF86Config and
Fonts.dir is useless. So for such programs, the main profile is /etc/fonts/fonts.conf.
FontConfig's advanced features have a lot of detailed instructions. You can refer to here: http://www.linuxfans.org/nuke/modult...pic&t=48331GTK2 and QT programs are large, KDE, GNOME, Firebird .... ........
The above two paragraphs mentioned just let the program find the font, not responsible for the specific display work. They can only guarantee that your program can find the font and there will be no garbled, that is, the so-called "Chinese"
As for Freetype / XFT or XTT? My understanding is that it is responsible for displaying the font to the screen, which determines what the font you see is. The famous "Firefly Beautify Pack" did a lot of efforts to improve Chinese display. That is, the so-called "beautification"
At this point you should have a probably concept of Chinese, beautification. Next is the specific operation
I am using Slackware 9.1, but the principle of landscapeing Chinesei is very small for other issues. After reading the article, I can understand the other releases by practical understanding.
The following command is indicated by the # beginning with a root identity, and the beginning is operated by ordinary user.
Step1.
Prepare TrueType fonts, commonly used, such as SIMSUN.TTTF Tahoma.ttf Verdana.ttf, etc. Then decide which directory you want to put the font. This directory likes you like, I put them in / usr / x11r6 / lib / x11 / fonts / ttf /.
For example, the TTF fonts you download are in / home / username / myfonts / below, do the following
#CP /HOME/USERNAME/myfonts/*.ttf / usr / x11r6 / lib / x11 / fonts / TTF /
STEP2.
Let the GTK1 program find the font you just put in. What is mentioned above, you haven't forgotten it yet? Let us first modify XF86Config
#vi / etc / x11 / xf86config
turn up
Section "Files"
.................
This paragraph, plus a fontpath property inside.
Fontpath "/ usr / x11r6 / lib / x11 / fonts / ttf /"
Of course, if there is already the path you put by your font, if your path is not the same, you will write your path, you can also add your font path at any time.
If you discover the Load "XTT" line in XF86Config, comment out. I don't have to use XTT
Next, it is of course preparing Fonts.Dir and fonts.scale. Generate these two file tools before saying. Slackware comes with MKFONTDIR and MKFONTSCALE, I personally don't recommend these two tools, and the Fonts.dir they generate is very unhappy, and the GBK's Encoding cannot be found in SIMSUN.TTF. You can download a tool called TTMKFDIR: ftp: //216.254.0.38/linux/RawHide/1.....0.9-7.i386.rpm
Suppose you have installed this tool, do the following
#ttmkfdir / usr / x11r6 / lib / x11 / fonts / ttf / -o /usr/x11r6/lib/x11/FONTS/TTF /FONTS.SCALE
Check now this file
#vi /usr/x11r6/lib/x11/FONTS/TTF /FONTS.SCALE
If there is: 1: SIMSUN.TTFXXXXXXXXXXXXXXXXXXXXXXX This is: 1: starting, it is deleted, and FreeType doesn't need this thing, and may cause some problems. Special note that is the result of SIMSUN.TTTF-MISC-SIMSUN-Medium-R-Normal - 0-0-0-0-C-0-GB2312.1980-0 SIMSUN.TTTTTTF -MISC-SIMSUN-Medium- R-NORMAL - 0-0-0-0-C-0-GBK-0 These two lines, because Encoding is very important, Mkfontdir generated fonts.dir is likely to have no -GBK-0 encoding, which will also Result in some problems. So I use TTMKFDIR to make sure after the error
#cp /usr/x11r6/lib/x11/fonts/ttf/fonts.scale /usr/x11r6/lib/x11/fonts/ttf/fonts.dir (these two files are actually the same)
Your GTK1 program is already available, but in the gtk1 program, you must also specify what fonts you want to use. What font is used for GTK1 programs has a global profile /etc/gtk/gtkrc.zh_cn
Post my profile
# This file defines the fontsets for chinese language (en) Using
# The Simplified Chinese Standard Guobiao As in Mainland China (CN)
#
# 1999, Pablo Saratxaga
#
STYLE "gtk-default-zh-cn" {
Fontset = "- * - BITSTREAM VERA SANS-Medium-R-NORMAL - * - * - 120 - * - * - P - * - Microsoft-CP1252, /
- * - SIMSUN-MEDIUM-R-NORMAL - * - 12 - * - * - * - * - * - GBK-0 "
}
Class "gtkwidget" style "gtk-default-zh-cn"
This file tells the procedure, which is prioritized to use the BitStream Vera Sans font for English fonts. For Chinese, the back SIMSUN font is used for Chinese.
At this point, the Chinese Chemicals of the GTK1 program are all completed.
Now you can startX
Take a look at an XMMS, how is the interface? As for the XMMS list, Chinese can search for other articles. It is also very simple
Add some techniques and descriptions:
1. - * - BitStream Vera Sans-Medium-R-NORMAL - * - * - 120 - * - * - P - * - Microsoft-CP1252 This font indication method is not very complicated? Have a tip to help you choose the font you want, / usr / x11r6 / bin / there is a program XFontsel, run it. I will understand yourself. Here you can see the TTF fonts found by the GTK1 program, some are read from the Fonts.dir you just generated. With it you can also get the correct expression format of the font you need.
2. Slackware 9.1 has a series of excellent TTF fonts such as BitStream Vera Sans. They are also in / usr / x11r6 / lib / x11 / fonts / ttf / directory by default, those of the Veraxx.ttf. However, the fonts.dir in that directory did not listed them in. If you are doing in front of my method, the TTMKFDIR has just been included in it. If you just operate other directories, TTMKFDIR is once in this / usr / x11r6 / lib / x11 / fonts / ttf, the method is the same as before.
3. Ttmkfdir generated fonts.dir and fonts.scale may have some excess coding, such as those ending with ASCII-0 and Adobe Standard-0, causing some problems here, if you think is an exception, First delete such a line first. STEP3
Get GTK2 and QT programs.
Based on Fontconfig Select fonts is easy to configure, Fontconfig also provides some more advanced features.
Similar to GTK1, these programs are now found. The FontPath and Fonts.Dir files in XF86Config have not been needed. Fontconfig's core profile is /etc/fonts/fonts.conf to open this file with VI
There is such a paragraph start
This is telling Fontconfig to go to these directorys to find fonts in their subdirectory. Is it more than fontpath and fonts.dir?
What you have to do is plus the path of your font, I have just been included in it. So don't modify it.
run
# fc-cache
Update font information.
Ok, now GTK2 and QT procedures can use the font you added, too simple? And the modification of Fonts.conf will come into effect immediately. Unlike the GTK1 program to modify the gtkrc, you must re-run, modify XF86Config, even RESTART X, etc.
Similar to GTK1 programs, GTK2 and QT programs have a global font configuration.
GTK2 program global profile is /etc/gtk-2.0/gtkrc
Also put my content up
STYLE "user-font" {
FONT_NAME = "BitStream Vera Sans 9"}
Class "*" Style "User-font"
Is telling the procedure to use BitStream Vera Sans, font size is 9
QT program's default font configuration
$ / usr / lib / qt-3.2.1 / bin / qtconfig
Out of a graphical interface, you can easily choose the font you want.
Add some techniques and descriptions:
1. Just mentioned XFontSel to help you check the font available of GTK1, then What fonts have fontconfig? There is also a program called FC-List, default in / usr / x11r6 / bin / below, run it, will display one List. The font name inside is the font that can be used. For example, the font name of the GTK2 configuration file I just was in it.
There are many powerful features of 2./etc/fonts/fonts.conf, which is also very complicated. The detailed settings can refer to the article that is given in this article.
3. You should find it. For example, when selecting a font in the KDE Control Center, you can choose all the fonts are Tahoma, Vera Sans, and I write in my gtkrc is also an English font, so the English font looks very PP, and the Chinese font is how Decided? Why do I choose an English font and the Chinese font still displayed normally? This is the trial of Fontconfig, there are two paragraphs in my fonts.config:
Sans-Serif Faces
->
alias>
with
prefer>
alias>
This section tells the procedure, encountering the font to display Sans-Serif, prioritize in the list in the previous font, here is Bitstream Vera Sans, if the font cannot display the desired characters, continue in the following, for Chinese, find the last SIMSUN (Song). If you want to use other default Chinese, you can use the Chinese characters you need in
So, in fact, Hanhua is over, if you think this effect is not bad, then let it. If you think it's a little imperfect, such as the Chinese details are not very good, then you can help Firefly's beautification package.
It is very simple to install these packages. I briefly say the function of these packages.
FontConfig-2.2.1-i486-1.firefly.tgz will replace your current /etc/fonts/fonts.conf, plus some of the Firefly modified properties.
Freetype-2.1.5-i486-1.firefly.tgz XFT-2.1.2-i486-1.firefly.tgz These two are the core part of the font, install them to make Chinese display more perfect, specific principles I don't understand, huh, huh, I have no effort to study. Xfree86-4.3.0-i486-5.firefly.tgz can also improve font display effect, I don't have it, the Chinese bold of the taskbar and the title bar can not display. If your network is not very good, this package is also quite big, you can not install it, it is not a big problem.
QT-3.2.1-i486-1.firefly.tgz This packaging is not installed, it is quite big. I think in addition to let your Qt program select the font to display a Chinese character name (SIMSUN is displayed as "Song") There is no more valuable function, which is not available.