2007年7月28日星期六

[转]XeTeX 中文字体设置

XeTeX 中文字体设置

lyanry posted @ 2007年07月27日 07:29AM in 文档标记语言 with tags xetex 中文 tex

首先在终端,使用 fc-list 查看你的系统中装了哪些中文字体:

  1. $ fc-list :lang=zh-cn
  2. Adobe 黑体 Std R,Adobe Heiti Std,Adobe 黑体 Std,Adobe Heiti Std R:style=R,Regular
  3. 文鼎PL中楷Uni,AR PL ZenKai Uni:style=Medium
  4. 文鼎PL简报宋,AR PL SungtiL GB:style=Regular
  5. ... ...

所输出的字体列表中选择自己喜欢的字体名,推荐选择英文那列,比如 "AR PL SungtiL GB"。

/usr/local/texlive/texmf-local/tex/latex/local 目录下,新建 zhfontcfg 目录,然后在该目录下创建zhfontcfg.sty 宏包文件,内容如下:

% xetex/xelatex 字体设定宏包,作者:lyanry (2007.7.24)

\ProvidesPackage{zhfontcfg}
\usepackage{fontspec,xunicode }
\defaultfontfeatures{Mapping=tex-text} %如果没有它,会有一些 tex 特殊字符无法正常使用,比如连字符。

% 中文断行
\XeTeXlinebreaklocale "zh"
\XeTeXlinebreakskip = 0pt plus 1pt minus 0.1pt

%将系统字体名映射为逻辑字体名称,主要是为了维护的方便
\newcommand\fontnamehei{Adobe Heiti Std}
\newcommand\fontnamesong{Adobe Song Std }
\newcommand\fontnamekai{AR PL ZenKai Uni}
\newcommand\fontnamemono{Bitstream Vera Sans Mono }
\newcommand\fontnameroman{Bitstream Vera Serif}

%设置文档正文字体为宋体
\setmainfont [BoldFont=\fontnamehei]{\fontnamesong }
\setsansfont[BoldFont=\fontnamehei]{ \fontnamekai}
\setmonofont{\fontnamemono}

%楷体
\newfontinstance\KAI {\fontnamekai}
\newcommand{\kai}[ 1]{{\KAI #1}}

%黑体
\newfontinstance\HEI{ \fontnamehei}
\newcommand{\hei}[ 1]{{\HEI # 1}}

%英文
\newfontinstance\ENF{\fontnameroman }
\newcommand{\en}[1 ]{\,{\ENF #1 }\,}
\newcommand{\EN}{\,\ENF\, }

在终端,进入 /usr/local/texlive/2007/bin/i386-linux 目录,然后执行:

$ sudo ./mktexlsr

最后在 LaTeX 文稿中,加载该宏包即可:

\usepackage{zhfontcfg}

zhfontcfg.sty 宏包中定义了 LaTeX 文稿的正文字体 (mainfont) 为 Adobe Song Std ,其加粗字体为 Adobe Heiti Std。文稿中的无衬线字体 (sans font) 被定义为 AR PL ZenKai Uni,其加粗字体同样为 Adobe Heiti Std。

因为上述设置将 LaTeX 文稿的默认字体定义为 Adobe Song Std 与 Adobe Heiti Std,为了在文稿中局部使用其它一些特定字体,有做了一些字体环境定义,比如楷体、黑体与英文字体,这些字体环境的用法如下:

  1. 我是\kai{楷体}
  2. 你是\hei{黑体}
  3. 她是\en{Roman font}

6 条评论:

匿名 说...

Apply 2 to 3 inches of mulch over the plants root system
once all foliage is removed and discarded. It has a very strong odor that will
take your breath away. In this same respect, mulch aids in the prevention of soil splashing onto plants.


Also visit my website: mulching

匿名 说...

Apply 2 to 3 inches of mulch over the plants root system once
all foliage is removed and discarded. It has a
very strong odor that will take your breath away.
In this same respect, mulch aids in the prevention
of soil splashing onto plants.

Also visit my homepage; mulching

匿名 说...

It is through the use of this medium that they wish to make in roads in the communications
market. E-papers are able to take advantage of story, sacrificing other, decidedly less important stories and giving as much detail about breaking news
as possible. Today, Most of newspapers are offering their online editions.

Some say it would have, because there is an ongoing collaboration between the two groups in attacks on Israel.

This is why various newspapers are now helping to find unclaimed property owners by listing their names.



Here is my webpage - click here

匿名 说...

The DE particles act to puncture the exoskeletons of most insects, mites, fleas, ticks,
etcetera, causing them to die by dehydration. So, I propose to you that you might
want to consider doing your own organic gardening right in
your own back yard. In some cases, the quantity of materials for making compost in the amounts desired (an
annual layer 2 inches deep across the garden) cannot be obtained.


Look at my blog post predominate

匿名 说...

http://paleodietrecipesbook.net/
http://howtoloseweightfastindays.com
http://purelivinghcg.com/
http://getlaid2night.us/male-enhancement
http://getlaid2night.us/penis-pump

匿名 说...

http://paleodietrecipesbook.net/
http://howtoloseweightfastindays.com
http://purelivinghcg.com/
http://getlaid2night.us/male-enhancement
http://getlaid2night.us/penis-pump