The Asian Journal of TX, Volume 4, No. 1, June 2010 Article revision 2010/5/13 KTS TH KORAN TX SOCITY SINC 2007 X TX-ko: X TX X TX-ko: A X TX Macro Package for Processing Korean Documents Dohyun Kim nomos@ktug.or.kr KYWORDS X TX, X TX-ko, Hangul, Korean, OpenType, TrueType, character spacing ABSTRACT X TX-ko is a macro package for typesetting Korean documents, including old Hangul texts as well, upon X TX engine. X TX is a sophisticated TX-engine which supports quite well full Unicode encoding and OpenType layout features. Using X TX itself, however, is not fully satisfactory in the eyes of the Korean, especially because of relatively poor quality of latin/greek/cyrillic glyphs in many Korean fonts. For this reason among others, X TX-ko has been recently developed, mainly focusing on how to typeset with different fonts between Western and Korean characters. This paper presents current state of X TX-ko package along with its main features and usages, including among others how to configure Korean fonts, how to change character spacing, and what to be prepared for typesetting old Hangul texts. At the end of the paper, some limitations of current X TX-ko package will also be discussed as a warning to the users. 1 X TX-ko X TX \usepackage{fontspec} \setmainfont[mapping=tex-text]{unbatang} \setsansfont[mapping=tex-text]{undotum} \setmonofont{untaza} \XeTeXlinebreaklocale="ko" (preamble) Copyright 2010 by the Korean TX Society
2 TH ASIAN JOURNAL OF TX X TX-ko X TX (primitive) (kerning) (ligature) X TX-ko X TX-ko (character spacing) ( ) (full-width) X TX X TX X TX
VOLUM 4, NO. 1, JUN 2010 3 2 ko.tx (catcode) 13 (active character) 1 256 (ASCII ) X TX 11,172 X TX-ko X TX X TX-ko 2008 X TX [8], 1 \newxetexintercharclass \mylatin 2 \newxetexintercharclass \myhangul 3 \XeTeXcharclass \A \mylatin 4 \XeTeXcharclass \ \myhangul 5 \XeTeXinterchartoks \mylatin \myhangul = {\myhangulfont} 6 \XeTeXinterchartoks \myhangul \mylatin = {\mylatinfont} 7 \XeTeXinterchartokenstate = 1 (1 2) (3 4 ), (5 6). 7 (0) 1. inputenc LATX ko.tx inputenc inputenc (category code) [4, 37 41]
4 TH ASIAN JOURNAL OF TX (glue), (kern), (penalty), (hbox) X TX 255 255 255 255 255 2 X TX-ko X TX ko.tx ko.tx KTS\ \ X TX-ko X TX 3 X TX-ko 20 X TX-ko X TX-ko (plain TX) LATX 3 X TX-ko \usepackage{xetexko} \usepackage{kotex} 4 \setmainfont[mapping=tex-text]{linux Libertine} \setmainhangulfont[mapping=tex-text]{} \setmainhanjafont[mapping=tex-text]{unbatang} 2. X TX X TX-ko xetexko-space.sty X TX-ko 3. X TX-ko [6] LATX fontspec X TX-ko xetexko-font.sty 4. ko.tx \usepackage{kotex} X TX X TX xetexko
VOLUM 4, NO. 1, JUN 2010 5 fontspec [7] \setmainfont fontspec X TX-ko fontspec X TX-ko (U+AC00 U+D7A3) (U+1100 U+11FF, U+D7B0 U+D7FB ) 5 (U+302 U+302F) (U+3131 U+308) fontspec \setmainfont \setsansfont \setmonofont X TX-ko \setsanshangulfont \setsanshanjafont \setmonohangulfont \setmonohanjafont X TX-ko fontspec fontspec \newfontfamily \newfontface [7]. X TX-ko fontspec \newhangulfontfamily \newhanjafontfamily \newhangulfontface \newhanjafontface fontspec \fontspec fontspec X TX-ko \hangulfontspec \hanjafontspec 5. 0x115A 0x115, 0x11A3 0x11A7, 0x11FA 0x11FF, 0xA960 0xA97C, 0xD7B0 0xD7C6, 0xD7CB 0xD7FB 2009 10 5.2
6 TH ASIAN JOURNAL OF TX A B (). 1. () () ko.tx \adhochangulfont \adhochanjafont fontspec \addfontfeature(s) (OpenType layout features) X TX-ko fontspec s \addhangulfontfeature(s) \addhanjafontfeature(s) fontspec X TX-ko fontspec fontspec [7]. 4 (punctuations) 1 A B
VOLUM 4, NO. 1, JUN 2010 7 1. alphs a b c A B C nums ( ) 1 2 3 4 5 0 parens ( ) [ ] { } < > quotes hyphens - / colons : ; puncts.?!, cjksymbols LuaTX X TX X TX-ko \latinalphs \hangulalphs \hanjaalphs \prevfontalphs \latinnums \hangulnums \hanjanums \prevfontnums \latinparens \hangulparens \hanjaparens \prevfontparens \latinquotes \hangulquotes \hanjaquotes \prevfontquotes \latinhyphens \hangulhyphens \hanjahyphens \prevfonthyphens \latincolons \hangulcolons \hanjacolons \prevfontcolons \latinpuncts \hangulpuncts \hanjapuncts \prevfontpuncts \latincjksymbols \hangulcjksymbols \hanjacjksymbols \prevfontcjksymbols latin, hangul, hanja, prevfont prevfont 1 alphs, nums, parens, quotes, hyphens, colons, puncts, cjksymbols 1 \latinalphs
8 TH ASIAN JOURNAL OF TX \hangulparens ( ) hyphens colons hyphens (-) colons U+2014 (emdash) X TX-ko colons U+2014 ( ). LuaTX (node) (token) X TX U+2014 colons X TX-ko 1 \latinmarks \hangulmarks \hanjamarks \prevfontmarks \hangulmarks \xetexkofontregime [puncts=prevfont,hyphens=prevfont,colons=prevfont,cjksymbols=hanja] {latin} 1 puncts, hyphens, colons cjksymbols alphs, nums, parens, quotes (key) 1 (value) latin, hangul, hanja, prevfont \latinmarks xkeyval X TX-ko \xetexkofontregime puncts, hyphens, colons cjksymbols
VOLUM 4, NO. 1, JUN 2010 9 fontspec X TX-ko 5 X TX-ko fontspec fontspec fontspec X TX-ko \setmainhangulfont[interhchar=-.04em]{unbatang} fontspec X TX-ko 0.04em interhchar 0pt X TX-ko \xetexkointerhchar ( X TX-ko ). (character) (glyph) \xetexkointerhchar LATX fontspec \setmainhangulfont \setsanshangulfont \newhangulfontfamily \setmainhanjafont \setsanshanjafont \newhanjafontfamily
10 TH ASIAN JOURNAL OF TX 2. interhchar 0pt hu 0.06em ( 0.12em) postmathskip hu quotewidth (natural width) \newhangulfontface \newhanjafontface \hangulfontspec \hanjafontspec \adhochangulfont \adhochanjafont \addhangulfontfeature(s) \addhanjafontfeature(s) \setmainfont fontspec \setmonohangulfont 2 (dimen) pt, em, ex interhchar 0pt hu [1] hangul unit ko.tx X TX-ko hu hu ( 1 parens, quotes, colons ) hu hu
VOLUM 4, NO. 1, JUN 2010 11 hu = 0pt hu = 0.06em hu = 0.12em hu = 0.24em nglish() a 2 + b 2 nglish() a 2 + b 2 nglish () a 2 + b 2 nglish () a 2 + b 2 2. hu \def\xksmallskip{\hskip 0.125em plus 0.1ex minus 0.1ex} xetexko-space.sty hu (inline) hu hu postmathskip quotewidth \hangulquotes \hangulmarks quotewidth (natural width) ( ), ( ), ( ), ( ), ( ) (U+201C ) X TX-ko 0.5em quotewidth 3. \hangulmarks quotewidth=0.5em () ()
12 TH ASIAN JOURNAL OF TX 3. lowerperiod 0pt lowerquestion 0pt lowerexclamation 0pt lowercomma 0pt preperiodkern 0pt prequestionkern 0pt preexclamationkern 0pt precommakern 0pt postperiodkern 0pt postquestionkern 0pt postexclamationkern 0pt postcommakern 0pt interpunctskern 0pt xetexko-space.sty \precjkopenparen 0.5em \disablecjksymbolspacing quotewidth X TX 3 X TX-ko lower pre post interpunctskern (U+2026) LATX \ldots
VOLUM 4, NO. 1, JUN 2010 13 interpunctskern \ldots 3 6 1933 (U+1100 U+11FF, U+D7B0 U+D7FB) (BMP, Basic Multilingual Plane) 6 (PUA, Private Use Area) 7 PUA [2]. X TX-ko PUA PUA X TX-ko PUA ko.tx 8 (OpenType layout features) \setmainhangulfont [Script=Hangul, Language=Korean, YetHangul=On] {UnBatang} X TX YetHangul=On/Off X TX-ko On ccmp, ljmo, 6. U+0000 U+FFFF 65,536 7. 5,299 U+0BC U+F66 8. hypua2jamo
14 TH ASIAN JOURNAL OF TX 4. GSUB LVT vjmo, tjmo Off ljmo, vjmo, tjmo ljmo, vjmo, tjmo ccmp YetHangul=Off ccmp 9 Off X TX 4 GPL GSUB (glyph substitution) 3 10 X TX-ko PUA 9. http://www.microsoft.com/typography/otspec/featurelist.htm ljmo, vjmo, tjmo ljmo, vjmo, tjmo (contextual glyph substitution) 10. http://www.ktug.or.kr/xe/?mid=ktug_open_board&document_srl=7947
VOLUM 4, NO. 1, JUN 2010 15 PUA GSUB PUA \setmainhangulfont[mapping=jamo-pua]{new Batang} Mapping=tex-text Mapping=jamo-pua PUA X TX teckit (KTUG) PUA 11 jamo-pua PDF PUA jamo-pua X TX jamo-pua X TX jamo-pua jamo-pua X TX-ko \enablejamoautojosa Mapping=jamo-pua (ancien régime) PUA 11. http://faq.ktug.or.kr/faq/hanyangpuatableproject
16 TH ASIAN JOURNAL OF TX 1948 5. 7 X TX-ko X TX-ko TX X TX (raison dêtre) 7.1 U+002, U+0028, U+3002 U+FF08 (full-width) (0.5em) 12 [5]. X TX-ko \hanjafontspec[script=kana]{hiragino Mincho Pro} \begin{japanese}... \end{japanese} 12. (discardable items) [4, 110].
VOLUM 4, NO. 1, JUN 2010 17 japanese japanese 4 (0.25em) 5 1 X TX-ko chinese japanese 2 X TX-ko japanese/chinese ptx xecjk 13 X TX-ko \inhibitglue X TX-ko \inhibitglue 0pt \inhibitglue \inhibitglue X TX-ko ( ) (). 7.2 1980 (spine) X TX vert vrt2 14 X TX 15 13. xecjk TX Live 2009 ptx TX Live 2010 14. vrt2 vert vrt2 vert vrt2 vert vrt2 vert 15. vhea/vmtx vert/vrt2 GSUB http://www.microsoft.com/typography/otspec/otff. htm
18 TH ASIAN JOURNAL OF TX vertlatin vertlatin 6. \vertlatin X TX-ko \setmainhangulfont Vertical=RotatedGlyphs X TX-ko vertical 16 \newfontfamily\vertfont [Script=Hangul, Vertical=RotatedGlyphs] {Adobe Myungjo Std} \begin{vertical}{\vertfont}{18em}... \end{vertical} vertical \newfontfamily \newhangulfontfamily \newfontfamily 17 ( ) X TX-ko vertical \setmainfont 16. xetexko-vertical.sty 17. vertical \newhangulfontfamily X TX-ko LuaTX-ko vertical fontspec vertical
VOLUM 4, NO. 1, JUN 2010 19 \vertlatin \latinalphs \vertlatin vertical (dimen) vertical 90 7.3 ko.tx \hbox \hbox (math mode) ( restricted horizontal mode) [4, 13]. 8 \hbox X TX X TX [8], X TX-ko \setmathhangulfont{yoonmyungjo Light} \hbox fontspec X TX-ko \hbox (U+AC00 U+D7A3) \setmathhangulblock{400}{9fc3}
20 TH ASIAN JOURNAL OF TX $$\frac{ + + \times 2} { \times 2}$$ + + 2 2 7. \hbox \setmathhangulfont 16 \hbox 7.4 ulem ulem X TX-ko ulem ulem 18 ( ) ( ) X TX-ko ko.tx 19 \dotemph{ } \dotemph 18. ulem X TX-ko \xetexkoulemsupport 19. xetexko-dotemph.sty
VOLUM 4, NO. 1, JUN 2010 21 \def\dotemphchar{ } \def\dotemphraise{0.4em} \dotemph{} \dotemphchar \dotemphraise 0.4em \dotemphchar ^^^^02da \char"02da (unicode code point) 16 16 10(\char730) 8(\char1332) [4, 8]. 7.5 X TX-ko (hanging punctuation) [3]. pdftx (microtype) pdftx (character expansion) (character protrusion, margin kerning ) pdftx 1000 microtype microtype pdftx LuaTX X TX
22 TH ASIAN JOURNAL OF TX 8. 20 X TX X TX-ko X TX-ko 21 X TX X TX-ko xetexko \usepackage{xetexko-hanging} \hangingpunctuation xetexko-hanging.sty \hangingpunctuation (U+002), (U+002C), (, ) 20. http://scripts.sil.org/svn-public/xetex/branchs/microtype/ 21. xetexko-hanging.sty
VOLUM 4, NO. 1, JUN 2010 23 \def\page{} \page\ \def\page{page} \page\ page \def\page{} \page\ 9. \ref X TX-ko ( ), ( ) X TX-ko 7.6 ko.tx X TX-ko 22 X TX-ko ko.tx \ref, \pageref, \nameref, \cite X TXko X TX ko.tx \def\page{} \def\page{page} \page\ X TX-ko jamo-pua jamo-pua \enablejamoautojosa X TX-ko \ \ \ \ \ \ \ \ \ \ \ \ \, \ \ U+C740 U+110B U+1173 U+11AB 22. X TX-ko xetexko-josa.sty xetexkospace.sty
24 TH ASIAN JOURNAL OF TX 7.7 xetexko kotex ko.tx X TX-ko [hangul] [hanja] (part) (chapter) 1 1 1 1 ko.tx X TX-ko (section) 1 4 [hangul] [hanja] 23 ko.tx X TX-ko 5 24 \pagenumbering{hanjanum} 24 enumerate enumitem enumerate dhucs-enumerate jaso, gana enumerate enumitem dhucs-enumitem 8 X TX-ko X TX X TX-ko ko.tx 23. konames-utf.tex 24. kolabels-utf.tex
VOLUM 4, NO. 1, JUN 2010 25 4. hangul hanja \today 2011 2 5 2011 2 5 \enclname \ccname \headtoname \seename \ \ \alsoname \ \ \contentsname \listfigurename \listtablename \refname \indexname \tablename \abstractname \bibname \appendixname \KSTH \partname \chaptername \sectionname \colorlayer \glossaryname X TX-ko hyphens colons (U+2014) (U+201C ) quotewidth
26 TH ASIAN JOURNAL OF TX \jaso \gana \ojaso \ogana \pjaso \pgana \onum \pnum \oeng \peng \hnum \Hnum \hroman \hroman \hnum \hanjanum 5. X TX-ko ⅰ ⅱ ⅲ ⅳ ⅴ ⅵ ⅶ ⅷ ⅸ ⅹ ⅺ ⅻ Ⅰ Ⅱ Ⅲ Ⅳ Ⅴ Ⅵ Ⅶ Ⅷ Ⅸ Ⅹ Ⅺ Ⅻ X TX X TX [4, 38]. LuaTX U+2014 X TX X TX pdftx X TX \XeTeXinterchartokenstate
VOLUM 4, NO. 1, JUN 2010 27 \textcolor{grey}{} \textbf{} {} \relax \dotemph{} 10. 0.5em 10 X TX-ko X TX 0.5em 0.5em 0pt \relax (\bgroup), (\egroup), \relax \relax
28 TH ASIAN JOURNAL OF TX 25 X TX-ko X TX-ko X TX-ko 0pt hu 0.06em 16 X TX-ko \inhibitglue \relax \relax 0pt (?) X TX-ko X TX-ko 10 X TX-ko 0pt X TX-ko ko.tx X TX-ko X TX-ko \nobreak \nobreak X TX-ko \ 25. X TX GPOS
VOLUM 4, NO. 1, JUN 2010 29 \penalty10000 X TX UC-KR CP949 X TX-ko [6] X TX X TX X TX ICU 26 ICU UC-KR CP949 CP949 \XeTeXinputencoding="korean" \XeTeXdefaultencoding="korean" \input UC-KR CP949 CP949 9 X TX-ko X TX X TX X TX-ko X TX-ko LuaTX LuaTX-ko 26. http://icu-project.org/. X TX ICU
30 TH ASIAN JOURNAL OF TX X TX-ko [4] X TX LuaTX X TX LuaTX 1. The Asian Journal of TX 1 (2007), no. 1, 17 30. 2. Hangul-ucs The Asian Journal of TX 1 (2007), no. 1, 31 43. 3. The Asian Journal of TX 3 (2009), no. 1 2, 51 79. 4. Donald. Knuth, The TXbook, Addison-Wesley, 1986. 5. Haruhiko Okumura, ptx and Japanese Typesetting, The Asian Journal of TX 2 (2008), no. 1, 43 51. 6. X TX-ko, 2010. http://ftp.ktug.or.kr/ktug/texlive/texmf-dist/ doc/xelatex/kotex-dev/xetexko/xetexko-doc.pdf 7. Will Robertson, The fontspec package, 2008. CTAN:macros/xetex/latex/fontspec/fontspec. pdf 8., The X TX reference guide, 2009. CTAN:info/xetexref/XeTeX-reference.pdf