編譯utf8編碼的tex文件使用中文truetype

發信人: aickgaven (Michael), 信區: TeX
標 題: 編譯utf8編碼的tex文件使用中文truetype
發信站: 水木社區 (Fri Apr 21 12:51:50 2006), 站內

要從truetype安裝新的中文GBK字體,使用hooklee的xGBKfonts
xGBKfonts -usesys -o c:\Downloads HWXW.ttf xinwei
將產生的文件移到localtexmf相應的位置。然後在updmap.cfg中加入關於type1
信息的map文件
initexmf -u initexmf --mkmaps
這樣latex沒有問題,dvips可以使用type1字體,dvipdfmx可以使用type1或者直
接使用truetype字體,只要編譯使用
dvipdfmx -f cid-x.map *.dvi
就可以,pdflatex可以使用type1字體,若要直接使用truetype,在preamble中
加入\pdfmapfile{=cjk_ttf.map}。但是奇怪的是使用simsun或者華文的ttf編譯
通過,使用方正的ttf產生的enc和map就始終出錯……而dvipdfmx使用方正的ttf卻
沒有問題。

倘若tex文件是utf8編碼的,也可以使用CJK。需要把
\begin{CJK}{GBK}{kai}
之類的改爲
\begin{CJK}{UTF8}{}
當然也可以在最後一個花括號里加入song,kai之類的,但是如果文件中含有其
他語言編碼的話會出錯,可行的方法是
\begin{CJK}{UTF8}{cyberb}
不過裏面的中文字體非常難看,可以在中文的地方改爲
\CJKfamily{kai}
之類的。比如下面這個例子
----------------------------------------------------------------------------------------------
\documentclass[a4paper,11pt]{article}
\usepackage{CJK}
%\pdfmapfile{=cyberbit.map}
%\pdfmapfile{=ttf-unixinwei.map}
\begin{document}
\begin{CJK*}{UTF8}{}
\CJKfamily{kai}%中文
機遇與挑戰並存,新的世界商務體系對並不成熟的中國服務業提出了新的要求。
當今中國服務業的國際化程度如何?從歷史數據中又能否推測出中國服務業發展
國際化怎樣的趨勢?本文收集了近20年來中國的國際收支平衡表和其它相關數據
進行分析,並借鑑已有的研究成果,來淺談這個問題。

\CJKfamily{cyberb}
%韓語
일부 시스템에서 Gabest Filter들이 연결되지 않던 문제

%德語
Alle Produkte werden auf einer größtmöglichen Anzahl von Plattformen
(Windows, Mac, Linux, Unix-Varianten, Mainframes) und
Entwicklungsumgebungen (COM, C, C++, Java, Perl, PHP, Python, Cobol,
RPG, and Tcl) angeboten.

%日語
PDFlib GmbH社は、ウェブサーバやデータベースサーバ上でオンデマンドのPDF
処理を可能にする、最先端のソフトウェア開発ツールを提供します。

%法語
Le Centre du cancer Roger Maris à Fargo, Dakota du Nord
\end{CJK*}
\end{document}
-------------------------------------------------------------------------------------
將上面的文件保存爲utf8編碼,用latex編譯可以通過。注意需要有
c70cyberb.fd和c70kai.fd兩個文件,如果沒有可以參考下面aloft的例子,放在
localtexmf\tex\latex\CJK\UTF8\下
-------------------------------------------------------------------------------------
% This is the file c70kai.fd of the CJK package
% for using Asian logographs (Chinese/Japanese/Korean) with LaTeX2e
%
% created by Aloft <[email protected]>
%
% Version 4.6.0 (26-Nov-2005)

\def\fileversion{4.6.0}
\def\filedate{2005/11/25}
\ProvidesFile{c70kai.fd}[\filedate\space\fileversion]


% character set: Unicode U+0080 - U+FFFD
% font encoding: Unicode

\DeclareFontFamily{C70}{kai}{\hyphenchar \font\m@ne}

\DeclareFontShape{C70}{kai}{m}{n}{<-> CJK * unikai}{}
\DeclareFontShape{C70}{kai}{bx}{n}{<-> CJKb * unikai}{\CJKbold}
\DeclareFontShape{C70}{kai}{m}{sl}{<-> CJK * unikaisl}{}
\DeclareFontShape{C70}{kai}{bx}{sl}{<-> CJKb * unikaisl}{\CJKbold}
\DeclareFontShape{C70}{kai}{m}{it}{<-> CJK * unikaisl}{}
\DeclareFontShape{C70}{kai}{bx}{it}{<-> CJKb * unikaisl}{\CJKbold}

\endinput
---------------------------------------------------------------------------------
當然還要有tfm文件,一般在\localtexmf\fonts\tfm\bitstrea\cyberbit\和
\localtexmf\fonts\tfm\chinese\unikai(sl)下,如果沒有可以參考下文自己產
生。這樣產生的dvi文件可以用dvipdfmx編譯爲pdf,需要在cid-x.map中加入
unikai@Unicode@ UniGB-UTF16-H :0:simkai.ttf
unikaisl@Unicode@ UniGB-UTF16-H :0:simkai.ttf -s .167
cyberb@Unicode@ Identity-H :0:cyberbit.ttf
通過以上步驟就可以編譯多語言的utf8 tex文件爲pdf。

若要使用pdflatex編譯utf8編碼tex文件使用truetype字體需要有enc文件。將
\texmf\ttf2tfm\base下的Unicode.sfd以及ttf文件拷貝到
c:\temp
運行ttf2tfm
ttf2tfm simkai.ttf -w unikai@Unicode@
ttf2tfm simkai.ttf -w -s 0.167 unikaisl@Unicode@
ttf2tfm cyberbit.ttf -w cyberb@Unicode@
將產生的*.enc文件放入相應目錄,如果沒有tfm文件的也把tfm文件放入相應目
錄,然後自己創建map文件,比如叫ttf-unikai.map和cyberbit.map,文件中是
類似
unikai00 <unikai00.enc <simkai.ttf
unikai01 <unikai01.enc <simkai.ttf
unikai02 <unikai02.enc <simkai.ttf
unikai03 <unikai03.enc <simkai.ttf
unikai04 <unikai04.enc <simkai.ttf
unikai20 <unikai20.enc <simkai.ttf
unikai21 <unikai21.enc <simkai.ttf
unikai22 <unikai22.enc <simkai.ttf
的內容。在tex文件的preamble中加入
\pdfmapfile{=cyberbit.map}
\pdfmapfile{=ttf-unixinwei.map}
這樣就可以使用pdflatex編譯了。產生utf8的type1字體沒有試過。不知道在linux下怎麼樣
--

※ 來源:·水木社區 http://newsmth.net·[FROM: 162.105.106.*]
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章