) Add a new font for Redhat Linux

Source: Internet
Author: User
Tags gtk
/*************************************** ************************************
* File: $ home/projects/linuxp/howto_zhfontsconfig
* Title: Add a new font for Redhat Linux
* Author: CURE <angeleyes@eyou.com>
* Date: 03-04-19 16:00
*-------------------------------------------------------------------------
* Description:
* Record how to add Chinese characters to RedHat Linux and jbuider, j2sdk, and j2se
* Supported.
*-------------------------------------------------------------------------
* Change logs:
* 03-04-19 cure add JRE section.
* 03-04-19 cure JRE is changed to Java. For details, refer to JBuilder, j2sdk,
* J2re Chinese problems.
*
**************************************** ***********************************/

One day of tossing, I originally planned to simply write down what I was looking for later. I accidentally wrote it so long, so
I decided to share it with you. If you find any errors, please be sure to point them out. Thank you!

In addition, if you think this article is worth sharing with your friends, you must keep the above File Header during the forwarding. It is a small support for my code word for a day!

A nice operating system is never our goal. I hope this article will free at least one or two friends from the problem of Chinese beautification in Linux, and I am truly devoted to using Linux to serve us, linux is used for development.

The following content includes:

1. Add a font for the two font subsystems of RedHat
2. Enlightenment to display Chinese Characters
3. Java Chinese problems:

-JBuilder Chinese problems
-J2sdk Chinese problems
-J2re Chinese problems

You just need to pick what you need.

Add a new font for Redhat Linux

[Note]
The following process is successfully tested on RedHat 9.0.

Prepare the fonts to be installed, such as simsun. TTC, tahoma. TTF...
Add the font for the core X Font sub-system and fontconfig font sub-system as described in the release notes:

Add a font for the core X Font Subsystem

[Note]
The following sections should also apply to versions earlier than RedHat 9.0, because the core X Font subsystem exists.
In the version so far.

"If you want to add a new font to your Red Hat Linux 9 system
Set
, You must specify the required steps. For the core X Font subsystem, you must:
1. Create/usr/share/fonts/local/directory (if it does not exist ):
Mkdir/usr/share/fonts/local /"

-This step is okay.

"If you must create/usr/share/fonts/local/, you must add it to the X Font Server
Road
Path:
Chkfontpath -- add/usr/share/fonts/local /"

-If you created/usr/share/fonts/local/, an error will be prompted when you execute this command.
Because the system cannot find the fonts. dir file in this directory, and then it will not add... but it doesn't matter,
This step jumps over and is done after step 3.

"2. Copy the new font file to/usr/share/fonts/local"

-Do as you like.

"3. Use the following command to update the font information:
Ttmkfdir-D/usr/share/fonts/local/-O/usr/share/fonts/local/fonts. Scale"

-Do as follows. Then:
1) Copy fonts. scale to a copy of fonts. dir.
2) chkfontpath -- add/usr/share/fonts/local/

"4. Run the following command to restart the XFS font server:
Service XFS reload"

-I did not succeed in this step, because I found that RedHat 9 does not contain the service command.
Use a stupid solution: Exit X and then startx.

After the above steps are completed, all the GTK 1.2 programs have the relevant font section (such as xmms font settings ).
And the new fonts we need, such as simsun and tahoma, can be directly used in the program.
For example, if we want to use simsum for Chinese characters in the song list and tahoma for English, we can do this:

1) First, check the option "use fontsets" in the xmms fonts-enable xmms to support dual-byte
Chinese font;
2) browse the font in the playlist area and select simsum:
-MISC-simsun-Medium-r-normal-*-120-*-C-*-koi8-r
(You don't need to copy this file. Select simsun and it will come out)

Tahoma should be used for English fonts. tips:

Cut down this section "-MISC-simsun-Medium-r-normal-*-120-*-C-*-koi8-r" ^ X,
Select tahoma as the font, and the following will appear:

-Microsoft-tahoma-Medium-r-normal-*-120-*-p-*-viscii1.1-1

Now, add a comma to the end and paste the cut section ^ V into the following:

-Microsoft-tahoma-Medium-r-normal-*-120-*-p-*-viscii1.1-1,
-MISC-simsun-Medium-r-normal-*-120-*-C-*-koi8-r

Save this line, so the song list will use simsum for Chinese and tahoma for English.
Copy the text in the main window below this line (to hook it with "use X Font"), then the xmms Main Window
The font in the mouth (like the font of the rolling back and forth song information) is the same as that in the song list.

Note: What I just talked about is the internal program, just like the xmms song list, and the program itself, that is, the xmms self-
The window is still bold and large, and you need to change the GTK font settings:

1) Use the root account: VI/etc/gtkrc. zh_cn
2) put the original:

Fontset = "-Adobe-Helvetica-Medium-r-normal -- 16-*-iso8859-1,
-*-Medium-r-normal -- 16-*-gb2312.1980-0, *-r -*"

The font is the same as the one we used in xmms:

Fontset =
"-Microsoft-tahoma-Medium-r-normal-*-120-*-p-*-viscii1.1-1,
-MISC-simsun-Medium-r-normal-*-120-*-C-*-koi8-r"

3) Save and exit, turn off the xmms programs, and re-open them. The effect will come out! Enjoy!

Add font for fontconfig font Subsystem

[Note]
In addition to the "Graphical font installation" section, the following section is unique to rehat 9.0. Others should be available in earlier versions.
You can try it.

This part is much simpler. See the RedHat 9 Release Notes:

"Adding a new font to the fontconfig font subsystem is simple and clear. You only need to copy the new font
/Usr/share/fonts/directory (individual users can copy the new font ~ /. Fonts/directory to repair
Change their font configuration)

After the new font is copied, use FC-cache to update the font information cache:

FC-Cache <directory>

(Here <directory> Should Be/usr/share/fonts/or ~ /. Fonts/directory .) "

-I copied the font in this way ~ /. Fonts/The following is successful. (do not want to use root user, HH)

"Individual users can also install fonts graphically. The method is: browse fonts: // in Nautilus, and then
Drag and Drop the new font file. "

-I failed to use this method. No matter whether I use a common user or a root user, I cannot use the font file.
Copy or drag and drop the file to the fonts: // folder of Nautilus. If you do not know the reason, you have to give up.

After the first method is successfully added, the new font can be freely used for setting the font in the GTK 2 program.
For example, in the control center, change all application fonts to simsum. (In addition, I found that
Simsun has the best effect and is clear without using a single color. You can consider using it)

In general, adding a new font for Redhat Linux is nothing too difficult and mysterious. I have done it myself.
After
I think it is not as difficult as I think, especially the font part of the GTK 1.2 program. I don't have to change so much as I 've said.
File,

Actually, you only need to add the font and change the font to/etc/gtkrc. zh_cn.

Enlightenment to display Chinese Characters

It is also simple. On the premise above, find the E topic you are currently using, for example

~ /. Enlightenment/themes/aquax/

The simplest way to access this directory is:
Gedit textclass. cfg

Use the replace function of gedit to replace all font strings, such:

"-*-Helvetica-bold-r-normal-*-120 -*-*-*-*-*-*"

All Replace the same as xmms:

-Microsoft-tahoma-Medium-r-normal-*-120-*-p-*-viscii1.1-1,
-MISC-simsun-Medium-r-normal-*-120-*-C-*-koi8-r"

Save and exit, clear the cache of E, restart E, done.

Java Chinese display

1. JBuilder Chinese problems

VI/etc/profile

Add:

Java_fonts =/path/to/Your/zhfonts/
Export java_fonts

For example, we need to use the simsum and tahoma fonts we just made, because we have placed them in:
/Usr/share/fonts/local, so here you can fill in:

Java_fonts =/usr/share/fonts/local

Note: JBuilder obviously uses the fontconfig font subsystem. Therefore, let it recognize it.
Fonts. Scale and fonts. dir are required.
Compared to the font folder of the core X Font sub-system above, that is, my ~ /. Fonts only
The font file and a file named "fonts. cache-1" can be compared and understood.

The program opened by JBuilder can display Chinese characters, but there is a problem with the JBuilder's Chinese characters. below:
Modify the font configuration of JBuilder. For example, if my JBuilder is installed in:

~ /Apps/Devs/JBuilder

So:
VI ~ /Apps/Devs/jbuilder8/jdk1.4/JRE/lib/font. Properties

Put something like this:

Serif.0 =-B & H-lucidabright-Medium-r-normal -- *-% d-*-p-*-iso8859-1
Serif.1 = -- standard symbols L-Medium-r-normal -- *-% d-*-p-*-urw-fontspecific

Serif. italic.0 =-B & H-lucidabright-Medium-I-normal -- *-% d-*-p-*-iso8859-1
Serif. italic.1 = -- standard symbols L-Medium-r-normal -- *-% d-*-p-*-urw-fontsp
Ecific

Replace all:

Serif.0 =-Microsoft-tahoma-Medium-r-normal-*-120-*-p-*-viscii1.1-1
Serif.1 =-MISC-simsun-Medium-r-normal-*-120-*-C-*-koi8-r

Serif. italic.0 =-Microsoft-tahoma-Medium-r-normal-*-120-*-p-*-viscii1.1-1
Serif. italic.1 =-MISC-simsun-Medium-r-normal-*-120-*-C-*-koi8-r

(Use the same xmms font as above)

All these "*. 0 = .." describe the fonts used in English.
All "*. 1 =..." describes the font used in Chinese.

Save and exit. The English in JBuilder is tahoma, and all Chinese characters are simsun.
Naturally, because java_fonts has been set, all Java applications can be found normally.
Chinese font and display.

Note one thing that I failed to try:

Remember when we configured the core X Font subsystem above ~ /. Fonts/is placed in GTK 1.2
If you point java_fonts to the font file used by the program, the following occurs:

The program opened in JBuilder can display Chinese Characters
However, JBuilder's own window cannot display Chinese characters.

I personally think that fontconfig's fonts. dir, fonts. Scale, and core x
"Fonts. cache-1" has something to do with it. I don't understand it.
Therefore, we can experience the differences between the two font subsystems.

2. j2sdk Chinese problems:

After the above configuration, Chinese characters can be displayed normally only when a program is developed in the JBuilder environment.
(Because JBuilder helps you find the font). If we return to the command line and use j2sdk for development,
At this time, we will find that we still cannot display Chinese characters. Let's look at the JRE of JBuilder.
After modifying font. properties, you can display Chinese characters. Similarly, j2sdk has its own
JRE... that's right! Just copy the fonts. properties modified for JBuilder.
Under $ java_home/JRE/lib, overwrite the original one. Everything is OK!

3. j2re Chinese problems:

I haven't thought of the test method yet. Let's go back and talk about it... it's estimated that the same is true.
Font. properties, so we should be able to reuse JBuilder's fonts. properties.
In short, all this is based on the fact that you have to add the correct font at the beginning, and everything else is easy to do, just copy the file .'


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.