Changes

Jump to navigation Jump to search
add Korean font setup (we should rename this page to CJK)
* manual by Pragma: [http://www.pragma-ade.com/general/manuals/mchinese.pdf Chinese in ConTeXt]
=Chinese in ConTeXt (ConTeXt 2005.12.19 and newer)=
If Get inspirated with importing Chinese fonts with this [https://github.com/BruXy/ConTeXt-Chinese script]. # You need some Chinese (TrueType) fonts; you have may want to get for example Microsoft Truetype fonts:## [http://archive1.village.virginia.edu/spw4s/fonts/STSONG.TTF STSong],## [Context 2005http://archive1.12village.19virginia.edu/spw4s/fonts/STZHONGS.TTF STZhongsong],## [http://archive1.village.virginia.edu/spw4s/fonts/STXIHEI.TTF STXihei], you only have to get the ## [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:
# You need some Chinese (TrueType) fonts; you may want to get [ftp://ftp.ctex.org/pub/tex/fonts/truetype/ttf/htfs.ttf FangSong], [ftp://ftp.ctex.org/pub/tex/fonts/truetype/ttf/hthei.ttf HeiTi], [ftp://ftp.ctex.org/pub/tex/fonts/truetype/ttf/htkai.ttf KaiTi] and [ftp://ftp.ctex.org/pub/tex/fonts/truetype/ttf/htsong.ttf SongTi]. Put those e.g. into $TEXMF/fonts/truetype/chinese/.
# Use Hans Hagen's experimental [http://www.physik.fu-berlin.de/~tburnus/ttf2uni.rb ttf2uni.rb] script to create .map, .tmf and .enc files. You can then put the files e.g. to $TEXMF/fonts/tfm/chinese/ (*.tmf files), $TEXMF/fonts/enc/chinese/ (*.enc files, they are basically the same for all fonts) and to $TEXMF/fonts/map/chinese/.
# You may now need to update the hash TeX uses to find the files; using teTeX this is done by running <tt>texhash</tt>.
# How you can run your Hello World program:
<texcode>
\mainlanguage[cn]
\language[cn]
\enableregime[utf]
\usemodulesetscript[chihanzi] % hyphenation % Enable fonts\usetypescriptfile[mscore]\setupbodyfont [mschinese,12pt]\usebodyfont [mschinese-00light,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>
If you want == Chinese numbers == Added by Xiao Jianfeng As far as I know, it is wrong to typset vertical textuse "零" with "一,二, use <tt>\startvertical ... \stopvertical</tt>., if you want to use 十".Following is the corresponding relationships between lower case and upper case Chinese numbers, you can use eand arabic numbers.g. <tt>\startitemize[c]</tt>; possible options are <tt>c</tt> or <tt>cn</tt> for normal  Chinese numbers (lower:〇,一, 二, 三, 四, , 六 etc.), <tt>cc</tt> for the capitalized (or financial) 七,八,九,十,百,千 Chinese numbers (upper:零,壹, 贰,叁,肆,伍,陆,柒, 叄 etc捌,玖,拾,佰,仟 Arabic :0, 1, 2,3, 4,5, 6, 7,8, 9,10,100,1000 "零" is a upper case Chinese number, so it should not be mixed with other lower case Chinese numbers.)Although in China, <tt>ec</tt> it is sometimes wrongly used. The reason why numbers in Chinese has lower case and upper case in Chinese is for an extended version which uses 廿 accounting safety. Lower case numbers are simple to write and 卅 (instead of 二十 and 三十)far more often used in daily life, while upper case numbers are almost exclusively used in accouting.  We can see that every upper case Chinese number are very different from the others, and <tt>ac</tt> for using hence cannot be easily modified to the other . But the lower case Chinese number or Arabic numbers zero (零are sometime easily to be modified. For example, "一", "二" and "三" are similar so one can easily modify a "一" to "二" or "三".And one can also modify "1" to "7" or "11", 〇) or one can modify "6" to nine (九) "8". In China, numbers must be written in the same way one does with the both Chinese upper case and Arabic digits 0 to 9form together in accounting.
=Chinese in ConTeXt (before 2005.12.19)Font setup for Korean=[[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]:
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.Example by Wolfgang (2017-12-06):
# Get the truetype You need 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/# 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 which contain hangul characters (don’t forget to set a math font files you got in step 1 to <tt>texmf-fonts/fonts/truetype/chinese</tt># Unzip because it is used for the files you got symbols in step 2 enumerations) 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 have to <tt>texmf-fonts/fonts/enc/chinese</tt># Unzip <tt>map.zip</tt>, you will get many map files, you need just enable linebreaking for korean with 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|setscript}} command.
Sample Code (save in cp936 encoding):
<texcode>
\loadmapfiledefinefallbackfamily [gbkmainface] [rm] [Nanum Myeongjo] [preset=range:korean]\usemoduledefinefontfamily [mainface] [rm] [DejaVu Serif] \definefallbackfamily [mainface] [ss] [Nanum Gothic] [preset=range:korean]\definefontfamily [mainface] [ss] [DejaVu Sans] \definefallbackfamily [mainface] [tt] [Nanum Gothic Coding] [chinesefeatures=none,preset=range:korean]\setuppagenumberingdefinefontfamily [mainface] [statett] [DejaVu Sans Mono] [features=stopnone] \definefontfamily [mainface] [mm] [DejaVu Math] \setupbodyfont[mainface] \setscript[hangul] \starttext 이 FAQ 은 자주 반복되는 질문과 그에 대한 대답을 간단명료한 양식으로모아 엮어졌습니다. {\ss 이 FAQ 은 자주 반복되는 질문과 그에 대한 대답을 간단명료한 양식으로모아 엮어졌습니다.} \starttyping이 FAQ 은 자주 반복되는 질문과 그에 대한 대답을 간단명료한 양식으로모아 엮어졌습니다.\tfdstoptyping这里什么饮料也没有真不像话! \stoptext
</texcode>
If you want to use UTF-8, the == See also ==* [http://www.ntg.nl/pipermail/ntg-context/2005/013542.html script by Lutz Haseloff[CJK fonts] 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 ??. 
[[Category:Fonts]]
[[Category:International]]

Navigation menu