Add new fonts for Linux

Source: Internet
Author: User

I. Prepare a font file

I always think that if I have the right to use Windows XP (via OEM), I also have the right to use this Windows product only for my personal use, this includes the right to use the font. Therefore, there should be no infringement when copying the WINXP font to Linux.

Windows fonts are generally stored in the c: \ windows \ fonts directory. The fonts I copied to Linux include:

Simfang. TTF imitation
Simhei. TTF simhei
Simkai. TTF entity
Simsun. TTF and, original file name: simsun. TTC
Tahoma. TTF tahoma font
Tahomabd. TTF tahoma font in bold
Verdana. TTF verdana font
Verdanab. TTF verdana in bold
Verdanai. TTF verdana font in italic format
Verdanaz. TTF verdana font in bold + italic format

The copied font files are stored in the/home/fwolf/tools/fonts directory.

2. Add the font to the available fonts in Linux

First, link the font file to the directory where the font is stored.

CD/usr/share/Fonts
Ln-S/home/fwolf/tools/fonts xpfonts
CD xpfonts
Mkfontscale
Mkfontdir

This is the same as copying the font to a directory in/usr/share/fonts. The following two mkfont commands generate the index information of the font contained in the xpfonts directory. Then run the FC-Cache command to update the font cache:

FC-Cache

Now, we should say that Linux can use these newly installed Chinese fonts. Let's take a look at it in openoffic:

In this example, the is fangsong_gb2312, simhei, kaiti_gb2312, simsun, and Chinese.

3. Modify the font rendering sequence of/etc/fonts. conf.

Let's modify and analyze fonts. the content of the conf file. Note that some comments (content between <-and->) and irrelevant or duplicated content will be skipped and will not be explained.

<? XML version = "1.0"?> Declare this file as an XML document
<! Doctype fontconfig System "fonts. DTD"> XML document format Declaration (DTD = Document Type define)
<! -/Etc/fonts. conf file to configure system font access->
<Fontconfig> root node required by the XML file <! -
Do not edit this file.
It will be replaced when fontconfig is updated.
Local changes belong in 'local. conf '.

The document prompts you Not to manually modify fonts. conf, personal settings can be written to local. CONF file, and will be automatically used by fonts. conf, but I still don't know how to create this file. I will release it later. Now I will use fonts first. open the conf file and back up the file in advance.

<Dir>/usr/share/fonts </dir>
<Dir>/usr/x11r6/lib/X11/fonts/type1 </dir> <dir>/usr/local/share/fonts </dir>
<Dir> ~ /. Fonts </dir>

The first one is the directory/usr/share/fonts where the font files are stored.

<! -
Accept deprecated 'mono' alias, replacing it with 'monospace'
->
<Match target = "pattern">
<Test qual = "any" name = "family">
<String> mono </string>
</Test>
<Edit name = "family" mode = "Assign">
<String> monospace </string>
</Edit>
</Match>

Replace the alias mono in this file with the full name monospace. This is an automatic replacement statement for XML. the alias should be used to simplify writing or maintain compatibility with the old version. There are several replicas that will not be described one by one.

<! -
Serif faces
-> <Alias>
<Family> bitstream Vera serif </family>
<Family> Vera sans yuanti </family> <! -Added by lifesinger->
<Family> Times </family>
<Family> Times New Roman </family>

The font order to be used by the serif font. When you want to display the content of the serif font, select the font from the list below. The matching sequence is top-down. You can see that the installed circle beautification is modified here. If we want to use as our first choice, we can simply add a line to the front of bitstream Vera serif font than the gourd image.

As for the serif and sans-serif fonts, you can take a look at the text in sans serif and serif vs sans serif.Article. I think they are called fonts or word families, which are more appropriate than fonts.

The processing methods in the Sans-serif faces and monospace faces segments are the same.

<! -
If the font still has no generic name, add sans-serif
->
<Match target = "pattern">

There are three replicas, which means that if the above font match is not successful, try to replace them with the default font of sans-serif, Serif, and monospace, use the Sans-serif font forcibly. (I don't know if this understanding is correct)

<! -
Some Asian fonts misadvertise themselves as monospaced when
In fact they are dual-spaced (half and full). This makes
FreeType very confused as it forces all widths to match.
Undo this magic by disabling the width forcing code->
<Match target = "font">
<Test name = "family"> <string> gulimche </string> </test>
<Edit name = "globaladvance"> <bool> false </bool> </Edit>
</Match>

Some Asian fonts actually use an equal-width font, but there is no clear statement. This section is to be compatible with this process and remain unchanged.

<! -
The bitstream Vera fonts have gasp entries suggesting that hinting be
Disabled below 8 ppem, but FreeType ignores those, preferring to use
The data found in the specified ucted hints. The initial Vera release
Didn't include the right instructions in the 'prep' table. Fix this
By disabling hinting manually at smaller sizes (<8 ppem)
->

Fixed the problem of displaying bitstream Vera fonts when they are less than 8 points. Keep them unchanged.

<! -
Load local system customization File

<Include ignore_missing = "yes"> Local. conf </include>
->

Load the configuration file local. conf ~ /. Fonts. conf is the same.

<! -
Provide required aliases for standard names
->
<Alias>
<Family> serif </family>
<Prefer>
<Family> bitstream Vera serif </family>

It is also the font alias of three series fonts. I don't know how this is related to the previous similar settings. The previous settings are about alternative fonts. Here is the recommended font? However, we added simsun as an example.

<! -
Artificial oblique for fonts without an italic or oblique version
->

The Font Processing Method without italics remains unchanged.

<! -
Synthetic emboldening for fonts that do not have bold face available
->

There is no handling method for the font in the black Chinese text, just keep it unchanged.

<! -
These are the default Unicode chars that are expected to be blank
In fonts. All other blank chars are assumed to be broken and
Won't appear in the resulting charsets
->

The empty encoding table should be displayed in all fonts in Unicode encoding.

<! -Rescan configuration every 30 seconds when fcfontsetlist is called
->

Check the setting file again every 30 seconds (see if the setting has changed) and keep it unchanged.

Now, the standard configuration file is complete, and all the major modifications we need to make are complete. Restart X to see the Chinese interface. However, some other Font Processing settings can be made in the fonts. conf file. This example is provided in the fonts. conf file of the Yuanyuan beautification file, for example:


<! -Win XP effect->
<Match target = "font">
<Test name = "family"> <string> Vera sans yuanti </string> </test>
<Edit name = "globaladvance"> <bool> false </bool> </Edit>
</Match>

This indicates that in the processing of the Vera sans yuanti font, The globaladvance parameter is set to false, and other settings are also similar to this syntax. I do not know the specific meaning and effect :).

Iv. Chinese font display optimization

After the above method is configured, will be able to display it, but the font is a little dotted, A simple method is to select monochrome from system> preference> font ), however, all fonts, including English fonts, will have a little small offset, so the alternative method is to modify fonts. conf to remove the and replace the bold with the conf. Add the following in fonts. conf:

<! -Replace bold->
<Match target = "pattern">
<Test name = "family"> <string> simsun </string> </test>
<Test name = "weight" compare = "more_eq"> <const> bold </const> </test>
<Edit name = "family" mode = "Assign"> <string> simhei </string> </Edit>
</Match>
<! -Disable the AA->
<Match target = "font">
<Test qual = "any" name = "family"> <string> simsun </string> </test>
<Edit name = "antialias" mode = "Assign"> <bool> false </bool> </Edit>
</Match>
<! -Solve the problem that the Chinese font name cannot be recognized.->
<Match target = "pattern">
<Test name = "family"> <string> </string> </test>
<Edit name = "family" mode = "Assign"> <string> simsun </string> </Edit>
</Match>
<Match target = "pattern">
<Test name = "family"> <string> </string> </test>
<Edit name = "family" mode = "Assign"> <string> simsun </string> </Edit>
</Match>
<Match target = "pattern">
<Test name = "family"> <string> _ gb2312 </string> </test>
<Edit name = "family" mode = "Assign"> <string> fangsong_gb2312 </string> </Edit>
</Match>
<Match target = "pattern">
<Test name = "family"> <string> _ gb2312 </string> </test>
<Edit name = "family" mode = "Assign"> <string> kaiti_gb2312 </string> </Edit>
</Match>
<Match target = "pattern">
<Test name = "family"> <string> </string> </test>
<Edit name = "family" mode = "Assign"> <string> simhei </string> </Edit>
</Match>

Why should we replace the bold character of with the bold character of, because the font of does not actually contain the bold character, and is also used in windows, but Windows uses more advanced methods to indirectly implement the bold character of.

Summary

The above is a simple Chinese font setting method, and I have a simple understanding of fonts. conf. I hope it will be useful to everyone, and I also hope that the hero will correct the mistakes and shortcomings. In addition, you can refer to the next detailed Chinese beautification solution (FreeType/fontconfig/xft), which is much deeper than I have.

 

From: http://blog.chinaunix.net/space.php? Uid = 8613773 & Do = Blog & id = 2018326

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.