Difference between revisions of "Chinese Japanese and Korean"

From Wiki
Jump to navigation Jump to search
(Note that 2005.12.19 also supports UTF-8 & mention \startvertical; page nees some clean up.)
m (fix pragma links & typos)
(22 intermediate revisions by 11 users not shown)
Line 1: Line 1:
< [[Fonts]] | [[Encodings and Regimes]] >
+
* old introduction [[Uptodate]] by Pragma: [http://www.pragma-ade.nl/general/uptodate/up-007-s.pdf screen] and [http://www.pragma-ade.nl/general/uptodate/up-007-p.pdf paper] version
 +
* manual by Pragma: [[manual:mchinese.pdf|Chinese in ConTeXt]] (Old 2001)
  
* old introduction [[Uptodate]] by Pragma: [http://www.pragma-ade.com/general/uptodate/up-007-s.pdf screen] and [http://www.pragma-ade.com/general/uptodate/up-007-p.pdf paper] version
+
=Chinese in ConTeXt=
* manual by Pragma: [http://www.pragma-ade.com/general/manuals/mchinese.pdf Chinese in ConTeXt]
 
  
 +
Get inspirated with importing Chinese fonts with this [https://github.com/BruXy/ConTeXt-Chinese script].
  
[[User:Xiaojf|Xiao Jianfeng]] wrote in a [http://archive.contextgarden.net/message/20050606.080842.5e1c2057.en.html mail to the mailing list on 2005-06-06]:
+
# You need some Chinese (TrueType) fonts; you may want to get for example Microsoft Truetype fonts:
 +
## [http://archive1.village.virginia.edu/spw4s/fonts/STSONG.TTF STSong],
 +
## [http://archive1.village.virginia.edu/spw4s/fonts/STZHONGS.TTF STZhongsong],
 +
## [http://archive1.village.virginia.edu/spw4s/fonts/STXIHEI.TTF STXihei],
 +
## [http://archive1.village.virginia.edu/spw4s/fonts/STKAITI.TTF STKaiti],
 +
## [http://archive1.village.virginia.edu/spw4s/fonts/STFANGSO.TTF STFangsong].
 +
# Example of some basic document with enabled Chinese:
  
Here is my way of Chinese setup in ConTeXt. I hope this can be of any help to some newbies like me who have problems in processing Chinese.
+
<texcode>
 +
\mainlanguage[cn]
 +
\language[cn]
 +
\enableregime[utf]
 +
\setscript[hanzi] % hyphenation
 +
 
 +
% Enable fonts
 +
\usetypescriptfile[mscore]
 +
\setupbodyfont [mschinese,12pt]
 +
\usebodyfont  [mschinese-light,12pt]
 +
\definebodyfontenvironment[24pt]
 +
\definebodyfontenvironment[18pt]
 +
 
 +
\setuppagenumber [numberconversion=cn]
 +
\definestructureconversionset[chinese][numbers][cn]
 +
\setupheads [sectionconversionset=chinese]
 +
 
 +
\define[2]\ChineseChapter{第#1章 #2}
 +
\setuphead[chapter][command=\ChineseChapter,style={\bf\switchtobodyfont[24pt]}]
 +
\setuphead[section][style={\bf\switchtobodyfont[18pt]}]
 +
 
 +
 
 +
\setuppagenumbering[state=start,
 +
    alternative=singlesided,
 +
    location={footer, center},
 +
    style={\bf\switchtobodyfont[11pt]}
 +
]
 +
 
 +
\starttext
 +
\chapter{华文字体系列}
 +
 +
在微软提供的 Office 套装中附带了一定数量的中文字体,这些字体是常州华文印刷新技术有限公司制造的。
 +
 
 +
\startitemize
 +
\item \type{\it}: {\it 华文仿宋}
 +
\item \type{\rm}: {\rm 华文仿宋}
 +
\item \type{\bf}: {\bf 华文中宋}
 +
\item \type{\ss}: {\ss 华文细黑}
 +
\item \type{\tfxx}: {\tfxx 华文仿宋}
 +
\item \type{\tfx}: {\tfx 华文仿宋}
 +
\item \type{\tf}: {\tf 华文仿宋}
 +
\item \type{\tfa}: {\tfa 华文仿宋}
 +
\item \type{\tfb}: {\tfb  华文仿宋}
 +
\item \type{\tfc}: {\tfc 华文仿宋}
 +
\item \type{\tfd}: {\tfd 华文仿宋}
 +
\stopitemize
 +
\stoptext
 +
</texcode>
 +
 
 +
=Font setup for Korean=
 +
 
 +
Example by Wolfgang (2017-12-06):
  
# Get the truetype fonts <tt>[ftp://ftp.ctex.org/pub/tex/fonts/truetype/ttf/htfs.ttf htfs.ttf], [ftp://ftp.ctex.org/pub/tex/fonts/truetype/ttf/hthei.ttf hthei.ttf], [ftp://ftp.ctex.org/pub/tex/fonts/truetype/ttf/htkai.ttf htkai.ttf]</tt> and <tt>[ftp://ftp.ctex.org/pub/tex/fonts/truetype/ttf/htsong.ttf htsong.ttf]</tt> from ftp://ftp.ctex.org/pub/tex/fonts/truetype/ttf/
+
You need fonts which contain hangul characters (don’t forget to set a math font because it is used for the symbols in enumerations) and you have to enable linebreaking for Korean with the {{cmd|setscript}} command.
# Get corresponding tfm files <tt>[ftp://ftp.ctex.org/pub/tex/fonts/truetype/for_pdftex/tfm/gbfs.zip gbfs.zip], [ftp://ftp.ctex.org/pub/tex/fonts/truetype/for_pdftex/tfm/gbhei.zip gbhei.zip], [ftp://ftp.ctex.org/pub/tex/fonts/truetype/for_pdftex/tfm/gbkai.zip gbkai.zip]</tt> and <tt>[ftp://ftp.ctex.org/pub/tex/fonts/truetype/for_pdftex/tfm/gbsong.zip gbsong.zip]</tt> from ftp://ftp.ctex.org/pub/tex/fonts/truetype/for_pdftex/tfm/
 
# Get the enc file <tt>[ftp://ftp.ctex.org/pub/tex/fonts/truetype/for_pdftex/enc_map/Gbk.zip Gbk.zip]</tt> from ftp://ftp.ctex.org/pub/tex/fonts/truetype/for_pdftex/enc_map/
 
# Get the map file <tt>[ftp://ftp.ctex.org/pub/tex/fonts/truetype/for_pdftex/enc_map/map.zip map.zip]</tt> from ftp://ftp.ctex.org/pub/tex/fonts/truetype/for_pdftex/enc_map/
 
# Put the ttf font files you got in step 1 to <tt>texmf-fonts/fonts/truetype/chinese</tt>
 
# Unzip the files you got in step 2 and you get four corresponding directories (which contain tfm files), then put them  in <tt>texmf-fonts/fonts/tfm/chinese</tt>
 
# Unzip <tt>Gbk.zip</tt>, you will get a directory named <tt>Gbk</tt> which contains many enc files. Put the directory to <tt>texmf-fonts/fonts/enc/chinese</tt>
 
# Unzip <tt>map.zip</tt>, you will get many map files, you need just the <tt>gbk.map</tt>. You need to edit <tt>gbk.map</tt>, delete entries of gbli* at the end of the file (lines 505-629). Then, put the modified <tt>gbk.map</tt> to <tt>texmf-fonts/fonts/map/chinese</tt>. Note that newer pdfetex don't read [[pdftex.cfg]] so better use <cmd>loadmapfile[gbk]</cmd> in your document.
 
# Your document should be compilable now. See sample below.
 
# I haven't tried to compile Traditional Chinese documents. Maybe just get corresponding files for Traditional Chinese and put there to the right location will work. I'm not sure.
 
  
Sample Code (save in cp936 encoding):
 
 
<texcode>
 
<texcode>
\loadmapfile[gbk]
+
\definefallbackfamily [mainface] [rm] [Nanum Myeongjo] [preset=range:korean]
\usemodule[chinese]
+
\definefontfamily    [mainface] [rm] [DejaVu Serif]
\setuppagenumbering[state=stop]
+
 
\starttext
+
\definefallbackfamily [mainface] [ss] [Nanum Gothic] [preset=range:korean]
\tfd
+
\definefontfamily    [mainface] [ss] [DejaVu Sans]
这里什么饮料也没有真不像话!
+
 
\stoptext
+
\definefallbackfamily [mainface] [tt] [Nanum Gothic Coding] [features=none,preset=range:korean]
 +
\definefontfamily    [mainface] [tt] [DejaVu Sans Mono] [features=none]
 +
 
 +
\definefontfamily    [mainface] [mm] [DejaVu Math]
 +
 
 +
\setupbodyfont[mainface]
 +
 
 +
\setscript[hangul]
 +
 
 +
\starttext
 +
 
 +
이 FAQ 은 자주 반복되는 질문과 그에 대한 대답을 간단명료한 양식으로
 +
모아 엮어졌습니다.
 +
 
 +
{\ss 이 FAQ 은 자주 반복되는 질문과 그에 대한 대답을 간단명료한 양식으로
 +
모아 엮어졌습니다.}
 +
 
 +
\starttyping
 +
이 FAQ 은 자주 반복되는 질문과 그에 대한 대답을 간단명료한 양식으로
 +
모아 엮어졌습니다.
 +
\stoptyping
 +
 
 +
\stoptext
 
</texcode>
 
</texcode>
  
If you want to use UTF-8, the [http://www.ntg.nl/pipermail/ntg-context/2005/013542.html script by Lutz Haseloff] might of interest to you; the needed perl module Encode::HanConvert is [http://search.cpan.org/dist/Encode-HanConvert/ available at CPAN]. Note, however, that you may only use characters representable in gbk, German umlauts for instance are converted into ??.
+
== See also ==
 
+
* [[CJK fonts]]
Starting from [[Context 2005.12.19]] UTF-8 encoded files also work (<tt>\enableregime[utf]</tt>).
 
  
If you want to have the text vertically typeset, use <tt>\startvertical ... \stopvertical</tt>.
 
 
[[Category:Fonts]]
 
[[Category:Fonts]]
[[Category:International]]
+
[[Category:Languages]]

Revision as of 08:20, 1 July 2022

Chinese in ConTeXt

Get inspirated with importing Chinese fonts with this script.

  1. You need some Chinese (TrueType) fonts; you may want to get for example Microsoft Truetype fonts:
    1. STSong,
    2. STZhongsong,
    3. STXihei,
    4. STKaiti,
    5. STFangsong.
  2. Example of some basic document with enabled Chinese:
\mainlanguage[cn]
\language[cn]
\enableregime[utf]
\setscript[hanzi] % hyphenation

% Enable fonts
\usetypescriptfile[mscore]
\setupbodyfont [mschinese,12pt]
\usebodyfont   [mschinese-light,12pt]
\definebodyfontenvironment[24pt]
\definebodyfontenvironment[18pt]

\setuppagenumber [numberconversion=cn]
\definestructureconversionset[chinese][numbers][cn]
\setupheads [sectionconversionset=chinese]

\define[2]\ChineseChapter{#1章 #2}
\setuphead[chapter][command=\ChineseChapter,style={\bf\switchtobodyfont[24pt]}]
\setuphead[section][style={\bf\switchtobodyfont[18pt]}]


\setuppagenumbering[state=start,
    alternative=singlesided,
    location={footer, center},
    style={\bf\switchtobodyfont[11pt]}
]

\starttext
\chapter{华文字体系列}
 
在微软提供的 Office 套装中附带了一定数量的中文字体,这些字体是常州华文印刷新技术有限公司制造的。

\startitemize
\item \type{\it}: {\it 华文仿宋}
\item \type{\rm}: {\rm 华文仿宋}
\item \type{\bf}: {\bf 华文中宋}
\item \type{\ss}: {\ss 华文细黑}
\item \type{\tfxx}: {\tfxx 华文仿宋}
\item \type{\tfx}: {\tfx 华文仿宋}
\item \type{\tf}: {\tf 华文仿宋}
\item \type{\tfa}: {\tfa 华文仿宋}
\item \type{\tfb}: {\tfb  华文仿宋}
\item \type{\tfc}: {\tfc 华文仿宋}
\item \type{\tfd}: {\tfd 华文仿宋}
\stopitemize
\stoptext

Font setup for Korean

Example by Wolfgang (2017-12-06):

You need fonts which contain hangul characters (don’t forget to set a math font because it is used for the symbols in enumerations) and you have to enable linebreaking for Korean with the \setscript command.

\definefallbackfamily [mainface] [rm] [Nanum Myeongjo] [preset=range:korean]
\definefontfamily     [mainface] [rm] [DejaVu Serif]

\definefallbackfamily [mainface] [ss] [Nanum Gothic] [preset=range:korean]
\definefontfamily     [mainface] [ss] [DejaVu Sans]

\definefallbackfamily [mainface] [tt] [Nanum Gothic Coding] [features=none,preset=range:korean]
\definefontfamily     [mainface] [tt] [DejaVu Sans Mono] [features=none]

\definefontfamily     [mainface] [mm] [DejaVu Math]

\setupbodyfont[mainface]

\setscript[hangul]

\starttext

이 FAQ 은 자주 반복되는 질문과 그에 대한 대답을 간단명료한 양식으로
모아 엮어졌습니다.

{\ss 이 FAQ 은 자주 반복되는 질문과 그에 대한 대답을 간단명료한 양식으로
모아 엮어졌습니다.}

\starttyping
이 FAQ 은 자주 반복되는 질문과 그에 대한 대답을 간단명료한 양식으로
모아 엮어졌습니다.
\stoptyping

\stoptext

See also