summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Master/texmf-dist/doc/luatex/luatexko/ChangeLog16
-rw-r--r--Master/texmf-dist/doc/luatex/luatexko/README17
-rw-r--r--Master/texmf-dist/doc/luatex/luatexko/luatexko-doc.pdfbin277366 -> 320828 bytes
-rw-r--r--Master/texmf-dist/doc/luatex/luatexko/luatexko-doc.tex350
-rw-r--r--Master/texmf-dist/tex/luatex/luatexko/luatexko-core.sty140
-rw-r--r--Master/texmf-dist/tex/luatex/luatexko/luatexko-normalize.lua90
-rw-r--r--Master/texmf-dist/tex/luatex/luatexko/luatexko-uhc2utf8.lua37
-rw-r--r--Master/texmf-dist/tex/luatex/luatexko/luatexko.lua524
-rw-r--r--Master/texmf-dist/tex/luatex/luatexko/luatexko.sty537
9 files changed, 1029 insertions, 682 deletions
diff --git a/Master/texmf-dist/doc/luatex/luatexko/ChangeLog b/Master/texmf-dist/doc/luatex/luatexko/ChangeLog
index d856feed9a1..e952c2ba297 100644
--- a/Master/texmf-dist/doc/luatex/luatexko/ChangeLog
+++ b/Master/texmf-dist/doc/luatex/luatexko/ChangeLog
@@ -1,3 +1,19 @@
+2014-05-11 Dohyun Kim <nomos at ktug org>
+
+ Version 1.5
+
+ * luatexko.sty: new package option [nofontspec] which prevents loading
+ of fontspec.sty
+ * luatexko.lua, luatexko.sty: use Nanum Type1 fonts as final fallback
+ fonts
+ * luatexko.sty: font option YetHangul=Off has gone now, only YetHangul
+ is still there.
+ * luatexko.lua: implemented experimental support for vertical
+ typesetting. LuaTeX version 0.79 or later is required.
+ * luatexko.lua, luatexko-core.sty: new macro \actualtext inspired by
+ accsupp.sty authored by Heiko Oberdiek.
+ * luatexko.lua: italic correction for replacing cjk fonts as well
+
2014-01-16 Dohyun Kim <nomos at ktug org>
Version 1.4
diff --git a/Master/texmf-dist/doc/luatex/luatexko/README b/Master/texmf-dist/doc/luatex/luatexko/README
index e4ead2d69f9..c8f761aba45 100644
--- a/Master/texmf-dist/doc/luatex/luatexko/README
+++ b/Master/texmf-dist/doc/luatex/luatexko/README
@@ -1,15 +1,15 @@
-LuaTeX-ko Package version 1.4 (2014/01/16)
+LuaTeX-ko Package version 1.5 (2014/05/11)
==========================================
This is a Lua(La)TeX macro package that supports typesetting Korean
documents including Old Hangul texts. As LuaTeX has opened up access to
almost all the hidden routines of TeX engine, users can obtain more
beautiful outcome using this package rather than other Hangul macros
-operating on other engines.
+operating on other engines.
Due to the backward-incompatible update of LuaTeX in early 2013, LuaTeX
version 0.76+ and luaotfload package version 2.2+ are required for this
-package to run.
+package to run.
This package also requires both cjk-ko and xetexko packages for its full
functionality.
@@ -66,7 +66,7 @@ Notice that kotex.sty is a file provided by cjk-ko package.
Under plain TeX:
- \input luatexko.sty
+ \input luatexko.sty
Package Options
@@ -79,9 +79,9 @@ interline spacing. Declares \hangulpunctuations=1 as well.
[hanja]
Load Hanja captions. Also apply other settings as [hangul] option does.
- [unfonts]
-Load font setting predefined for Un TrueType fonts available at
-[this link](http://kldp.net/projects/unfonts/).
+ [nofontspec]
+Prevents loading of fontspec package. Entire document will be typeset
+with Type1 fonts.
Hangul Font Commands
@@ -113,6 +113,9 @@ In like manner, these commands are available as well:
\hanjafontspec \newhanjafontfamily \addhanjafontfeature
\fallbackfontspec \newfallbackfontfamily \addfallbackfontfeature
+If any of these CJK fonts are not specified, Nanum Type1 fonts from
+nanumtype1 package will be used for typesetting CJK characters.
+
Hangul Font Options
-------------------
diff --git a/Master/texmf-dist/doc/luatex/luatexko/luatexko-doc.pdf b/Master/texmf-dist/doc/luatex/luatexko/luatexko-doc.pdf
index 699b12603dc..214982bcd70 100644
--- a/Master/texmf-dist/doc/luatex/luatexko/luatexko-doc.pdf
+++ b/Master/texmf-dist/doc/luatex/luatexko/luatexko-doc.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/luatex/luatexko/luatexko-doc.tex b/Master/texmf-dist/doc/luatex/luatexko/luatexko-doc.tex
index 766da7feb6b..515c581eed7 100644
--- a/Master/texmf-dist/doc/luatex/luatexko/luatexko-doc.tex
+++ b/Master/texmf-dist/doc/luatex/luatexko/luatexko-doc.tex
@@ -12,23 +12,24 @@
\usepackage{luamplib}
\setmainhangulfont[
Ligatures=TeX,
- Expansion,
- InterLatinCJK=.125em,
+ AutoFakeSlant,
UprightFont=* Light,
BoldFont=* Bold,
+ InterLatinCJK=.125em,
+ Expansion, Protrusion,
]{KoPubBatang_Pro}
\setsanshangulfont[
Ligatures=TeX,
- InterLatinCJK=.125em,
UprightFont=* Light,
BoldFont=* Bold,
+ InterLatinCJK=.125em,
]{KoPubDotum_Pro}
\usepackage[svgnames]{xcolor}
\usepackage{hologo}
\def\luatex{\hologo{LuaTeX}}
\def\MP{\hologo{METAPOST}}
\def\XeTeX{\hologo{XeTeX}}
-\usepackage[unicode,bookmarksnumbered]{hyperref}
+\usepackage[pdfencoding=auto,bookmarksnumbered,hidelinks]{hyperref}
\edef\verbatim{\unexpanded\expandafter{\verbatim
\linespread{1.1}\selectfont\color{MidnightBlue}}}
@@ -40,54 +41,72 @@
\def\kotex{\logoko\kern-.1ex .\kern-.1667em \TeX}
\edef\section#1{\unexpanded\expandafter{\section{\empty}\vskip-5pt\hrule\nobreak\vskip5pt}}
\def\hemph#1{\textsf{\bfseries #1}}
+\def\cs#1{\texttt{\color{MidnightBlue}\textbackslash\detokenize{#1}}}
+\def\ldots{$\dots$}
+\widowpenalty10000 \clubpenalty10000
\begin{document}
\title{\luatexko\ 간단 매뉴얼}
\author{Dohyun Kim \normalsize |<nomos at ktug org>| \and
- \normalsize |<http://github.com/dohyunkim/luatexko>|}
-\date{Version 1.4\quad\today}
+ \normalsize \url{<http://github.com/dohyunkim/luatexko>}}
+\date{Version 1.5\quad 2014/05/11}
\maketitle
\begin{quote}\small
For a summary introduction in English, please see |README| file.
- 주요 변경 사항:
\begin{itemize}\itemsep=0pt
- \item 플레인텍에서도 luatexko.sty을 불러야 한다.
- \item 패키지 옵션 |unfonts|가 선언되지 않으면 은글꼴을 자동으로
- 부르지 않는다.
- \item 글꼴 옵션값을 |<dimen>|으로 지시한다.
- \item 세로쓰기를 더 이상 공식적으로 지원하지 않는다.
- \item \MP\ 코드를 넣으려면 luamplib 패키지를 불러야 한다.
- \item[1.3] ------
- \item fallbackfont 계열의 명령이 추가되었다.
- \item |\hangulpunctuations| 선언 및 관련 매크로가 추가되었고, 대신
- |QuoteRaise| 옵션이 없어졌다.
- \item |\josaignoreparens=1|이 선언되면 자동조사 결정시 괄호 부분을
- 무시한다.
+ \item[v1.0] ------
+ \item \hyperref[sec:loading]{플레인텍에서도 luatexko.sty을 불러야 한다.}
+ \item \hyperref[sec:packageopt]{패키지 옵션 |unfonts|가 선언되지 않으면
+ 은글꼴을 자동으로 부르지 않는다.}
+ \item \hyperref[sec:fontoption]{글꼴 옵션값을 |<dimen>|으로 지시한다.}
+ \item \hyperref[sec:metapost]{\MP\ 코드를 넣으려면 luamplib 패키지를
+ 불러야 한다.}
+ \item[v1.3] ------
+ \item \hyperref[sec:fontcmds]{fallbackfont 계열의 명령이 추가되었다.}
+ \item \hyperref[sec:fontswitch]{\cs{hangulpunctuations} 선언이 추가되고,
+ |QuoteRaise| 옵션이 없어졌다.}
+ \item \hyperref[sec:autojosa]{\cs{josaignoreparens=1}이 선언되면
+ 자동조사 결정시 괄호 부분을 무시한다.}
+ \item[v1.5] ------
+ \item \hyperref[sec:verttype]{세로쓰기를 지원하기 위한 실험적 코드가
+ 들어갔다.}
+ \item \hyperref[sec:actualtext]{\cs{actualtext} 명령이 추가되었다.}
+ \item \hyperref[sec:fontswitch]{한글·한자 글꼴의 지정이 없으면
+ 나눔 Type1을 이용한다.}
+ \item \hyperref[sec:packageopt]{패키지 옵션 |[nofontspec]|이 추가되었다.}
\end{itemize}
\end{quote}
\section{}
\hemph{\texlive\ 2013 이상}을 사용해야 한다.
+세로쓰기를 위해서는 \texlive\ 2014 이상이 필요하다.
아직 \luatex은 베타 상태로 개발 중에 있으므로 안정적인 동작을 보장하지 않는다.
-\section{}
-\luatexko\ 로드하기: |\usepackage{luatexko}|. 플레인텍은
-|\input luatexko.sty|. 입력은 원칙적으로 UTF-8으로 한다.
+\section{}\label{sec:loading}
+\luatexko\ 로드하기: \cs{usepackage{luatexko}}. 플레인텍은
+\cs{input luatexko.sty}. 입력은 원칙적으로 UTF-8으로 한다.
BOM (Byte Order Mark)은 있어도 좋고 없어도 좋다.
CP949 인코딩에 관해서는 제\ref{sec:uhcencoding}절 참조.
-\section{}
-패키지 옵션으로 |[hangul]|과 |[hanja]|가 제공된다. 장 제목이나
-표·그림 캡션 따위가 한글 또는 한자 방식으로 표시된다. 다만
+\section{}\label{sec:packageopt}
+패키지 옵션으로 |[hangul]|과 |[hanja]|가 제공된다. 행간격 조정이 행해지며
+장 제목이나 표·그림 캡션 따위가 한글 또는 한자 방식으로 표시된다. 다만
장(chapter) 제목과 편(part) 제목에만 ``제(第)''가 붙어 ``제~1 편''
``제~3 장''과 같은 방식으로 표시되며 절 제목 이하에는 붙지 않는다.
-또한 |[unfonts]|는 은글꼴을 불러오는 패키지 옵션이다.
-이전 버전과 달리 \hemph{은글꼴이 기본으로 로드되지 않음}에 유의할 것.
+|[unfonts]|는 은글꼴 트루타입을 불러오는 패키지 옵션이다.\footnote{%
+ |nofontspec| 옵션과 함께 사용할 수 없다. 또한 이 옵션은
+ deprecated 상태로서 2015년에는 사라질 예정이다.}
+이전 버전과 달리 은글꼴이 기본으로 로드되지 않음에 유의할 것.
-\section{}
+|[nofontspec]| 옵션을 주면 fontspec을 부르지 않는다.
+따라서 아래 \ref{sec:fontcmds}, \ref{sec:fontswitch}, \ref{sec:fontoption},
+\ref{sec:verttype}, \ref{sec:mathhangul}절의 유니코드 한국어 글꼴 설정
+명령들도 사용할 수 없다.
+
+\section{}\label{sec:fontcmds}
\luatexko를 로드하면 fontspec 패키지를 자동으로 불러온다. 글꼴 설정에
대해서는 fontspec 문서를 참조하라.
@@ -100,8 +119,8 @@ CP949 인코딩에 관해서는 제\ref{sec:uhcencoding}절 참조.
\addhangulfontfeature \addhanjafontfeature \addfallbackfontfeature
\hangulfontspec \hanjafontspec \fallbackfontspec
\end{verbatim}
-|\adhochangulfont| |\adhochanjafont| |\addhocfallbackfont|는 각각
-|\hangulfontspec| |\hanjafontspec| |\fallbackfontspec|의 다른 이름이다.
+\cs{adhochangulfont} \cs{adhochanjafont} \cs{addhocfallbackfont}는 각각
+\cs{hangulfontspec} \cs{hanjafontspec} \cs{fallbackfontspec}의 다른 이름이다.
\begin{itemize}\item[]
플레인텍에서 한글 글꼴 설정은 영문 글꼴 지정하는 방식과 거의 같다.
\begin{verbatim}
@@ -109,25 +128,26 @@ CP949 인코딩에 관해서는 제\ref{sec:uhcencoding}절 참조.
\hanjafont=UnDotum at 14pt
\fallbackfont=HanaMinB at 12pt
\hangulfont=UnDotum scaled 2000
- \hanjafont{HCR Batang LVT}\relax
+ \hanjafont="HCR Batang LVT"\relax
\hangulfont={HCR Batang LVT:script=hang;+dlig} at 12pt
\end{verbatim}
\end{itemize}
-\section{}
-원칙적으로 \luatexko에서는 영문폰트에 지정한 글자가 없으면 한글폰트에서,
-한글폰트에도 없으면 한자폰트에서, \hemph{한자폰트에도 없으면 fallback
-폰트에서} 글자를 찾아 찍는다. 기존 \kotex과는 글꼴 대체 방식이 다르므로
-주의해야 한다.
+\section{}\label{sec:fontswitch}
+원칙적으로 \luatexko는 지시된 글자가 영문폰트에 없으면 한글폰트에서,
+한글폰트에도 없으면 한자폰트에서, 한자폰트에도 없으면 fallback
+폰트에서 글자를 찾아 찍는다. 세 가지 \hemph{모두 지정되지 않았다면 나눔 Type1
+폰트를} 이용한다. 기존 \kotex과는 글꼴 대체 방식이 다르므로 주의해야 한다.
-하지만 |\hanjabyhanjafont=1|을 선언하면 한자는 우선 한자글꼴로
+하지만 \cs{hanjabyhanjafont=1}을 선언하면 한자는 우선 한자글꼴로
식자한다. |0|을 선언하면 원래 방식으로 되돌아간다. 이 명령은 문단
중간에서 사용하지 않도록 주의해야 한다. 문단 중에 사용되었다면
그 문단의 처음부터 효력이 발생한다.
-|\hangulpunctuations=1|을 선언하면 영문 \hemph{문장부호들을 한글 폰트로}
+\cs{hangulpunctuations=1}을 선언하면 영문 \hemph{문장부호들을 한글 폰트로}
식자한다. |0|을 지시하면 원래 상태로 되돌린다.
-|[hangul]| 옵션을 주면 |\hangulpunctuations=1|이 자동으로 선언된다.
+|[hangul]| 옵션을 주면 \cs{hangulpunctuations=1}이 자동으로
+선언된다.\footnote{나눔 Type1 상태면 그러하지 아니하다.}
이 선언에 의해 영향 받는 문장부호들을 다음처럼 지정할 수 있다.
인자는 콤마로 연결된 숫자 형식으로서 유니코드 코드포인트를 뜻한다.
\begin{verbatim}
@@ -136,17 +156,16 @@ CP949 인코딩에 관해서는 제\ref{sec:uhcencoding}절 참조.
\end{verbatim}
-\section{}
+\section{}\label{sec:fontoption}
fontspec의 글꼴 옵션 외에 \luatexko가 따로 제공하는 것들이
있다.\footnote{ 옛한글 식자를 위해서는
- |[Script=Hangul]| 옵션을 사용하는 것으로 충분하다. 그러나
- |[YetHangul]| 옵션을 써도 무해하다.}
+ |[Script=Hangul]| 옵션을 사용하는 것으로 충분하다.}
\begin{figure}
\fboxsep=1em
\fbox{\vbox{\hsize\dimexpr\linewidth-2.1em\relax
\fontspec[Script=Hangul,Ligatures=Required]{HCR Dotum LVT}
- \leftskip3cm
+ \leftskip2.5cm
뎨 가ᄂᆞᆫ 뎌 각시 본 듯도 ᄒᆞᆫ뎌이고.\\
天텬上상白ᄇᆡᆨ玉옥京경을 엇디ᄒᆞ야 離니別별ᄒᆞ고\\
ᄒᆡ 다 져믄 날의 눌을 보라 가시ᄂᆞᆫ고
@@ -168,14 +187,15 @@ fontspec의 글꼴 옵션 외에 \luatexko가 따로 제공하는 것들이
\end{figure}
\begin{description}
-\item[InterHangul] 한글 글자 사이의 자간. 아래는 $-0.04$em 만큼 한글
- 자간을 지시한다.
+ \item[InterHangul] {\addhangulfontfeature{InterHangul=.5ex}한글 글자
+ 사이의 자간}. 아래는 $-0.04$em 만큼 한글
+ 자간을 지시한다. 플레인텍에서는 |interhangul|.
\begin{verbatim}
[InterHangul=-0.04em]
\end{verbatim}
\item[InterLatinCJK] 한글 또는 한자와 라틴 문자 사이의 자간을
- 설정한다.
+ 설정한다. 플레인텍에서는 |interlatincjk|.
\begin{verbatim}
[InterLatinCJK=0.125em]
\end{verbatim}
@@ -183,20 +203,22 @@ fontspec의 글꼴 옵션 외에 \luatexko가 따로 제공하는 것들이
\item[CharRaise] 글자의 세로 위치를
{\addhangulfontfeature{CharRaise=.3em} 조절}할 수 있는 기능이다.
이로써 주변에 식자되는 다른 글꼴과 조화를 이루게 한다.
+ 플레인텍에서는 |charraise|.
\begin{verbatim}
[CharRaise=0.1em]
\end{verbatim}
\item[PunctRaise] 한글 또는 한자 다음에 라틴 구두점---마침표에
한한다---이 왔을 때 그 세로 위치를 조절할 수 있다.
- |\hangulpunctuations|로 인해 거의 쓸 일이 없게 되었다.
+ \cs{hangulpunctuations}로 인해 거의 쓸 일이 없게 되었다.
+ 플레인텍에서는 |punctraise|.
\begin{verbatim}
[PunctRaise=-0.125em]
\end{verbatim}
\item[Protrusion] 특정 글자가 행 끌에 왔을 때 판면 바깥으로 끌어내는
기능이다. Lua\LaTeX의 기본값은 구두점들만 완전히 글자내밀기 한다. 즉
- hanging punctuation이 작동한다.
+ hanging punctuation이 작동한다. 플레인텍에서는 |protrusion|.
\begin{verbatim}
[Protrusion]
\end{verbatim}
@@ -204,7 +226,7 @@ fontspec의 글꼴 옵션 외에 \luatexko가 따로 제공하는 것들이
있으면 자신만의 설정을 만들어 지정할 수 있다.
\item[Expansion] 판면의 균일한 조판을 위해 글자들을 미세하게 늘이거나
- 줄이는 기능이다.
+ 줄이는 기능이다. 플레인텍에서는 |expansion|.
\begin{verbatim}
[Expansion]
\end{verbatim}
@@ -215,15 +237,15 @@ fontspec의 글꼴 옵션 외에 \luatexko가 따로 제공하는 것들이
\section{}
\begin{figure}\linespread{1.388}\selectfont\hfil
\fbox{\vbox{\hsize=36em \begin{chinese} \setmainfont{STFangsong}
-子曰:「學而時習之,不亦說乎?有朋自遠方來,不亦樂乎?人不知而不慍,不亦君子乎?」
-
-有子曰:「其為人也孝弟,而好犯上者,鮮矣!不好犯上,而好作亂者,未之有也!君子務本,本立而道生;孝弟也者,其為仁之本歟?」
-
-子曰:「巧言令色,鮮矣仁!」
-
-曾子曰:「吾日三省吾身:為人謀,而不忠乎?與朋友交,而不信乎?傳,不習乎?」
-
-子曰:「道千乘之國,敬事而信,節用而愛人,使民以時。」
+子曰:「學而時習之,不亦說乎?有朋自遠方來,不亦樂乎?人不知而不慍,
+不亦君子乎?」\par
+有子曰:「其為人也孝弟,而好犯上者,鮮矣!不好犯上,而好作亂者,未之有也!
+君子務本,本立而道生;孝弟也者,其為仁之本歟?」\par
+子曰:「巧言令色,鮮矣仁!」\par
+曾子曰:「吾日三省吾身:為人謀,而不忠乎?與朋友交,而不信乎?傳,
+不習乎?」\par
+子曰:「道千乘之國,敬事而信,節用而愛人,使民以時。」\par
+子曰:「弟子入則孝,出則弟;謹而信,汎愛衆;而親仁,行有餘力,則以學文。」
\end{chinese}}}\hfil
\caption{고문헌 조판 보기}\label{fig:ancientdoc}
\end{figure}
@@ -231,65 +253,62 @@ fontspec의 글꼴 옵션 외에 \luatexko가 따로 제공하는 것들이
고문헌·일본어·중국어 조판을 위해 japanese, Schinese, Tchinese 환경을
제공한다. chinese는 Schinese의 다른 이름이다. korean 환경도
마련했는데 이들 환경 안에서 잠깐 한국어를 조판하는 데
-사용한다. 일본어·중국어라도 글꼴 설정은 |\newhangulfontfamily|
-|\newhanjafontfamily| 따위를 이용한다. 그림~\ref{fig:ancientdoc} 참조.
+사용한다. 일본어·중국어라도 글꼴 설정은 \cs{newhangulfontfamily}
+\cs{newhanjafontfamily} 따위를 이용한다. 그림~\ref{fig:ancientdoc} 참조.
+플레인텍에서는 {\small(문서 전체에 적용하지 않는다면 그룹을 열고)}
+\cs{chinese} \cs{japanese} 따위를 사용한다.
-\section{}
\luatexko가 글자 사이에 삽입하는 미세간격을 사용자가 영(zero)으로
-강제하기 위해선 |\inhibitglue| 명령을 이용한다.
+강제하기 위해선 \cs{inhibitglue} 명령을 이용한다.
대체로 일본어·중국어 환경에서만 문제된다.
-\section{}
-\begin{quote}
- |$가^{나^다}$|\quad$\Rightarrow\quad가^{나^다}$
-\end{quote}
-수식 모드에서도 한글을 {\small(hbox로 감싸지 않고)} 직접 입력할 수
-있다. 문서의 기본 한글 글꼴이 자동으로 수식 한글에도 적용되므로 따로
-설정할 것이 없지만 굳이 한다면 다음처럼 지시한다.
-\begin{verbatim}
- \setmathhangulfont{HCRBatang}
-\end{verbatim}
-현재 한글만 쓸 수 있게 설정되어 있다.
+\section{}\label{sec:verttype}
+세로쓰기는 폰트의 고급 오픈타입 자질을 이용하므로 폰트가 이를 지원해야
+가능한 일이다. 폰트에 |Vertical=RotatedGlyphs| 옵션을 준다.
+플레인텍이라면 |vertical;+vrt2| 옵션. |vrt2| 자질을 갖지 않는 폰트를 쓰는
+경우 |vert| 자질을 명시해주어야 한다. 둘 다 없으면 세로쓰기에 적합하지 않은
+글꼴이다.
+세로쓰기에는 \hemph{\luatex\ 0.79 이상}, 즉 \texlive\ 2014 이후
+버전이 필요하다.
-\section{}
+문서의 일부를 세로쓰기하려면 \cs{begin{vertical}{<dimen>}} \ldots\ \cs{end{vertical}}
+환경을 이용하라. |<dimen>|으로 세로쓰기 박스의 높이를 지시한다.
+그림~\ref{fig:vertical} 참조.
+플레인텍에서는 \cs{vertical{<dimen>}} \ldots\ \cs{endvertical}.
-%\begin{figure}
-%\framebox[\linewidth]{\begin{vertical}{16em}
-%\fontspec[Vertical=RotatedGlyphs,RawFeature=+vhal]{Adobe Myungjo Std}
-%\parindent-1em\leftskip1em \linespread{1.5}\selectfont
-%\noindent 님의 침묵{\small(The Silent Beloved)}
-%\smallbreak
-%\hfil\hfil 한 용 운\hfil
-%\bigbreak
-%님은 갓슴니다 아아 사랑하는나의님은 갓슴니다\par
-%푸른산빗을깨치고 단풍나무숩을향하야난 적은길을 거러서 참어떨치고
-%갓슴니다\par
-%黃金의꽃가티 굿고빗나든 옛盟誓는 차듸찬띠끌이되야서 한숨의 微風에
-%나러갓슴니다\par
-%날카로은 첫〈키쓰〉의追憶은 나의運命의指針을 돌너노코 뒷거름처서 사러젓슴니다\\
-%%…… \par
-%\hellipsis\par
-%아아 님은갓지마는 나는 님을보내지 아니하얏슴니다\par
-%제곡조를못이기는 사랑의노래는 님의沈默을 휩싸고돔니다\par
-%\end{vertical}}
-%\caption{세로쓰기의 예}\label{fig:vertical}
-%\end{figure}
-
-\luatex 에서는 아직 \hemph{세로쓰기를 지원하지 않는다}.%
-\footnote{굳이 세로쓰기를 실험해보고자 한다면 |ttx -t vmtx <폰트>.ttf|
- 명령의 결과물인 |<폰트>.ttx| 파일을 현재 디렉토리에 두어야 한다. 그런 다음
- |\\begin\{vertical\}\{<dimen>\}...\\end\{vertical\}|
- 환경을 이용하라. ttx에 대해선
- \url{http://sourceforge.net/projects/fonttools/} 참조.
- 문서 전체에 대해 세로쓰기를 하려면 이 환경을 쓰는 대신
- |\\verticaltypesetting| 명령을 전처리부에 선언한다.}
+문서 전체를 세로쓰기한다면 이 환경을 쓰는 대신
+\cs{verticaltypesetting} 명령을 전처리부에 선언한다.
+이때 면주의 폰트에는 세로쓰기 옵션이 없어야 할 것이다.
-\section{}
-전처리부에서 |\usepackage{luamplib}|을 선언하면 \MP\ 코드를 문서 중간에 삽입할 수 있다.
-한글이나 수식은 |btex| $\ldots$ |etex| 안에 넣어야 한다. 그림~\ref{fig:mplib} 참조.
+\begin{figure}
+\framebox[\linewidth]{\begin{vertical}{17em}
+\fontspec[Vertical=RotatedGlyphs,RawFeature=+vhal]{Adobe Myungjo Std}
+\parindent-1em\leftskip1em \linespread{1.5}\selectfont
+\noindent 님의 침묵(The Silent Beloved)
+\smallbreak
+\hfil\hfil 한 용 운\hfil
+\bigbreak
+님은 갓슴니다 아아 사랑하는나의님은 갓슴니다\par
+푸른산빗을깨치고 단풍나무숩을향하야난 적은길을 거러서 참어떨치고
+갓슴니다\par
+黃金의꽃가티 굿고빗나든 옛盟誓는 차듸찬띠끌이되야서 한숨의 微風에
+나러갓슴니다\par
+날카로은 첫〈키쓰〉의追憶은 나의運命의指針을 돌너노코 뒷거름처서 사러젓슴니다\par
+%…… \par
+\hellipsis\par
+아아 님은갓지마는 나는 님을보내지 아니하얏슴니다\par
+제곡조를못이기는 사랑의노래는 님의沈默을 휩싸고돔니다\par
+\end{vertical}}
+\caption{세로쓰기의 예}\label{fig:vertical}
+\end{figure}
+
+\section{}\label{sec:metapost}
+전처리부에서 \cs{usepackage{luamplib}}을 선언하면 \MP\ 코드를 문서 중간에
+삽입할 수 있다. 한글이나 수식은 |btex| \ldots\ |etex| 안에 넣어야 한다.
+그림~\ref{fig:mplib} 참조. 상세한 것은 luamplib 패키지 문서를 참조하라.
\begin{figure}
-\setbox0\vbox{%
+\setbox0\vbox{\kern10pt
\begin{verbatim}
\usepackage{luamplib}
...
@@ -297,57 +316,70 @@ fontspec의 글꼴 옵션 외에 \luatexko가 따로 제공하는 것들이
beginfig(1);
draw fullcircle scaled 2cm;
dotlabel.bot(btex \TeX etex, origin);
- dotlabel.rt(btex 루아 etex, dir 45*1cm);
+ dotlabel.rt(btex 루아 etex, dir45*1cm);
endfig;
\end{mplibcode}
-\end{verbatim}
-\vskip-5\baselineskip
+\end{verbatim}}
\begin{mplibcode}
-verbatimtex \moveright95mm etex;
beginfig(1);
- draw fullcircle scaled 2cm;
- dotlabel.bot(btex\TeX etex, origin);
- dotlabel.rt(btex 루아 etex, dir 45*1cm);
+ draw btex \copy0 etex shifted (-\mpdim{\textwidth-3cm},-\mpdim{.5\ht0});
+ draw fullcircle scaled 2cm;
+ dotlabel.bot(btex\TeX etex, origin);
+ dotlabel.rt(btex 루아 etex, dir 45*1cm);
+ bboxmargin:=0; draw bbox currentpicture;
endfig;
\end{mplibcode}
-\vskip\baselineskip}
-\framebox[\linewidth]{\box0 }
\caption{mplib 용례}\label{fig:mplib}
\end{figure}
+\section{}\label{sec:mathhangul}
+\begin{quote}
+ |$가^{나^다}$|\quad$\Rightarrow\quad가^{나^다}$
+\end{quote}
+수식 모드에서도 한글을 {\small(hbox로 감싸지 않고)} 직접 입력할 수
+있다. 문서의 기본 한글 글꼴이 자동으로 수식 한글에도 적용되므로 따로
+설정할 것이 없지만 굳이 한다면 다음처럼 지시한다.
+\begin{verbatim}
+ \setmathhangulfont{HCRBatang}
+\end{verbatim}
+현재 한글만 쓸 수 있게 설정되어 있다.
+한자도 수식에 직접 입력하려면 사용자는
+\begin{verbatim}
+ \setmathhangulblock{4E00}{9FC3}
+\end{verbatim}
+명령으로 유니코드 블럭을 추가 지정해야 한다.
+
\section{}
-|\dotemph| 명령으로 \dotemph{드러냄표}%
+\cs{dotemph} 명령으로 \dotemph{드러냄표}%
를 이용한 강조를 할 수 있다. 기본은 글자 위에 점을 찍는 형태이나
다음과 같이 명령을 주어 개인적으로 선호하는 기호를 드러냄표로 쓸 수
있다.
-\begin{verbatim}
- \def\dotemphraise{0.4em }
- \def\dotemphchar{\bfseries ^^^^02d9}
-\end{verbatim}
-전자는 드러냄표를 피강조 글자 위로 끌어올리는 길이를, 후자는 드러냄표
-기호 자체를 정의한다. |^^^^02d9|는 유니코드 코드포인트를 뜻하는
-16진수이고 소문자로만 써야 한다. 숫자 대신 직접 문자를 입력해도 된다.
-플레인텍에서도 쓸 수 있다.
+
+①~|\def\dotemphraise{0.4em }|: 드러냄표를 피강조 글자 위로 끌어올리는 길이
+
+②~|\def\dotemphchar{\bfseries ^^^^02d9}|: 드러냄표 기호 자체를 정의.
+|^^^^02d9|는 유니코드 코드포인트를 뜻하는 16진수이고 소문자로만 써야 한다.
+숫자 대신 직접 문자를 입력해도 된다. 플레인텍에서도 쓸 수 있다.
\section{}
루비를 달 수 있다. ruby 패키지가 이미 존재하지만 \luatexko와 궁합이 잘
맞지 않아 새로 매크로를 제공한다. 플레인텍도 지원한다.
\begin{quote}
-|\ruby{漢字}{한자}|\quad$\Rightarrow$\quad\ruby{漢字}{한자}
+ \cs{ruby{漢字}{한자}}\quad$\Rightarrow$\quad\ruby{漢字}{한자}
\end{quote}
이처럼 글자별로 따로 루비를 달 필요가 없다. 관련 설정은 다음처럼
한다.
-①~|\rubyfont|: 루비를 식자할 폰트를 지시해 둔다.
+①~\cs{rubyfont}: 루비를 식자할 폰트를 지시해 둔다. 기본값은 현재 폰트.
②~|\def\rubysize{0.6}|: 루비 글자 크기를 본문 글자 크기에 대한 비율로
지정
③~|\def\rubysep{0.2ex}|: 루비와 본문 글자 사이의 간격을 지정
-④~|\rubynooverlap|: 루비의 폭이 본문 글자의 폭보다 클 때 루비가 이웃
+④~\cs{rubynooverlap}: 루비의 폭이 본문 글자의 폭보다 클 때 루비가 이웃
글자들 위로 삐져나가지 못하게 한다. 본문 글자의 흐름을 중시하여
-|\rubyoverlap|을 기본값으로 하였으므로 이는 따로 선언할 필요가 없다.
+\cs{rubyoverlap}을 기본값으로 하였으므로 이는 따로 선언할 필요가 없다.
\section{}
ulem 패키지가 \luatexko와 궁합이 잘 맞지 않아{\small (줄바꿈에 문제가 있음)}
@@ -355,13 +387,13 @@ ulem 패키지가 \luatexko와 궁합이 잘 맞지 않아{\small (줄바꿈에
\bigskip
\halign{\qquad#\hfil&\quad$\Rightarrow$\quad#\hfil\cr
-|\uline{밑줄을 그을 수 있다}|&\uline{밑줄을 그을 수 있다}\cr
-|\sout{취소선을 그을 수 있다}|&\sout{취소선을 그을 수 있다}\cr
-|\uuline{밑줄을 두 줄 긋는다}|&\uuline{밑줄을 두 줄 긋는다}\cr
-|\xout{빗금으로 취소할 수 있다}|&\xout{빗금으로 취소할 수 있다}\cr
-|\uwave{물결표로 밑줄을 삼는다}|&\uwave{물결표로 밑줄을 삼는다}\cr
-|\dashuline{대시로 밑줄을 삼는다}|&\dashuline{대시로 밑줄을 삼는다}\cr
-|\dotuline{밑줄을 점선으로 긋는다}|&\dotuline{밑줄을 점선으로 긋는다}\cr
+\cs{uline{밑줄을 그을 수 있다}}&\uline{밑줄을 그을 수 있다}\cr
+\cs{sout{취소선을 그을 수 있다}}&\sout{취소선을 그을 수 있다}\cr
+\cs{uuline{밑줄을 두 줄 긋는다}}&\uuline{밑줄을 두 줄 긋는다}\cr
+\cs{xout{빗금으로 취소할 수 있다}}&\xout{빗금으로 취소할 수 있다}\cr
+\cs{uwave{물결표로 밑줄을 삼는다}}&\uwave{물결표로 밑줄을 삼는다}\cr
+\cs{dashuline{대시로 밑줄을 삼는다}}&\dashuline{대시로 밑줄을 삼는다}\cr
+\cs{dotuline{밑줄을 점선으로 긋는다}}&\dotuline{밑줄을 점선으로 긋는다}\cr
}
\bigskip
@@ -371,46 +403,54 @@ ulem 패키지가 \luatexko와 궁합이 잘 맞지 않아{\small (줄바꿈에
②~|\def\ulinewidth{0.04em}|: 밑줄의 굵기
-\section{}
-자동조사는 \kotex 과 동일하게 |\은| |\는| |\이| |\가| |\을| |\를|
-|\와| |\과| |\로| |\으로| |\라| |\이라| 따위를 사용한다. 문장 중에서도
-작동할 뿐만 아니라 플레인텍도 지원한다.
-버전 1.3부터는 |\josaignoreparens=1|이 선언되어 있으면 자동조사는
+\section{}\label{sec:autojosa}
+자동조사는 \kotex 과 동일하게 \cs{은} \cs{는} \cs{이} \cs{가} \cs{을} \cs{를}
+\cs{와} \cs{과} \cs{로} \cs{으로} \cs{라} \cs{이라} 따위를 사용한다.
+문장 중에서도 작동할 뿐만 아니라 플레인텍도 지원한다.
+버전 1.3부터는 \cs{josaignoreparens=1}이 선언되어 있으면 자동조사는
\hemph{괄호 부분을 건너뛰고} 그 앞 글자에 매칭한다.
|0|이 선언되면 원래 방식으로 돌아간다.
\begin{quote}
- |\josaignoreparens=1| \josaignoreparens=1 \\
+ \cs{josaignoreparens=1} \josaignoreparens=1 \\
|홍길동(1992)\는|\quad$\Rightarrow$\quad 홍길동(1992)\는\\
- |홍길동(2001)\로|\quad$\Rightarrow$\quad 홍길동(2001)\로
- \medbreak
- |\josaignoreparens=0| \josaignoreparens=0 \\
+ |홍길동(2001)\로|\quad$\Rightarrow$\quad 홍길동(2001)\로\par
+ \cs{josaignoreparens=0} \josaignoreparens=0 \\
|홍길동(1992)\는|\quad$\Rightarrow$\quad 홍길동(1992)\는\\
|홍길동(2001)\로|\quad$\Rightarrow$\quad 홍길동(2001)\로
\end{quote}
\section{}
-항목 번호를 한국어 기호로 붙일 수 있다. \kotex과 동일하게 |\jaso|
-|\gana| |\ojaso| |\ogana| |\pjaso| |\pgana| |\onum| |\pnum| |\oeng|
-|\peng| |\hnum| |\Hnum| |\hroman| |\hRoman| |\hNum| |\hanjanum| 따위를
-사용한다.
+항목 번호를 한국어 기호로 붙일 수 있다. \kotex과 동일하게 \cs{jaso} \cs{gana}
+\cs{ojaso} \cs{ogana} \cs{pjaso} \cs{pgana} \cs{onum} \cs{pnum} \cs{oeng}
+\cs{peng} \cs{hnum} \cs{Hnum} \cs{hroman} \cs{hRoman} \cs{hNum} \cs{hanjanum}
+따위를 사용한다.
+
+\section{}\label{sec:actualtext}
+\cs{actualtext{...}} 명령은 인자를 식자함과 동시에, \hemph{입력한 문자 그대로}
+PDF에서 텍스트로 추출할 수 있게 해준다. 인자가 두 페이지에 나눠지지 않도록
+유의한다. 모든 PDF 리더가 이를 지원하는 것은 아니다. 예:
+$\actualtext{\sqrt 2}$,
+{\fontspec[Script=Hangul,Ligatures=Required]{HCR Dotum LVT}
+\actualtext{ᄆᆞᄎᆞᆷ〮내〯}}.
+인자가 글자 없이 그림으로만 돼있다면 \cs{actualtext*{...}} 방식을 이용한다.
\section{}
-|\luatexhangulnormalize=1|이라 지시하면 첫가끝 자모를 완성형 음절로,
+\cs{luatexhangulnormalize=1}이라 지시하면 첫가끝 자모를 완성형 음절로,
|2|라면 완성형 음절을 첫가끝 자모로 인코딩 변환한다. |0|이 할당되면
-인코딩 변환 기능이 꺼진다. \XeTeX의 |\XeTeXinputnormalization| 명령과
+인코딩 변환 기능이 꺼진다. \XeTeX의 \cs{XeTeXinputnormalization} 명령과
유사하나 오직 한글과 일부 한자에 대해서만 정규화가 작동하는 점에서
\XeTeX의 그것에 비해 기능이 한참 모자란다.
\section{}\label{sec:uhcencoding}
권장하지 않지만 불가피하게 입력 인코딩이 UHC {\small(CP949라고도 하며
-EUC-KR을 포함한다)}인 파일을 처리할 때는 |\luatexuhcinputencoding=1|을
+EUC-KR을 포함한다)}인 파일을 처리할 때는 \cs{luatexuhcinputencoding=1}을
선언한다. |0|을 할당하면 다시 UTF-8 입력으로 간주한다.
-\XeTeX의 |\XeTeXinputencoding| 명령과 유사하나 오직 한국어 문자만 처리할 수
+\XeTeX의 \cs{XeTeXinputencoding} 명령과 유사하나 오직 한국어 문자만 처리할 수
있어 \XeTeX의 그것에 비해 기능이 한참 모자란다.
\section{}
마찬가지로 바람직하지는 않지만 불가피하게 파일 이름이 UHC로 인코딩되어
-있다면 |\luatexuhcfilenames=1|을 선언한다. |0|을 할당하면 다시 UTF-8
+있다면 \cs{luatexuhcfilenames=1}을 선언한다. |0|을 할당하면 다시 UTF-8
이름으로 간주한다. 윈도 계열 운영체제에서만 문제될 것이다.
\hfill \fboxsep=-\fboxrule \fbox{\vbox to 1em{\hbox to 1em{\hss}\vss}}
diff --git a/Master/texmf-dist/tex/luatex/luatexko/luatexko-core.sty b/Master/texmf-dist/tex/luatex/luatexko/luatexko-core.sty
index 22cf34ffdfa..835f8b14baf 100644
--- a/Master/texmf-dist/tex/luatex/luatexko/luatexko-core.sty
+++ b/Master/texmf-dist/tex/luatex/luatexko/luatexko-core.sty
@@ -1,6 +1,6 @@
% luatexko-core.sty
%
-% Copyright (c) 2013 Dohyun Kim <nomos at ktug org>
+% Copyright (c) 2013-2014 Dohyun Kim <nomos at ktug org>
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3c
@@ -12,20 +12,21 @@
\ifx\ProvidesPackage\undefined
\input luaotfload.sty
+ \ifcsname ifpdf\endcsname\else \input ifpdf.sty \fi
\catcode`@ = 11
\else
- \ProvidesPackage{luatexko-core}[2014/01/04 v1.4 Typesetting Korean with LuaTeX]
+ \ProvidesPackage{luatexko-core}[2014/05/11 v1.5 Typesetting Korean with LuaTeX]
\RequirePackage{luaotfload}[2013/05/23]
\fi
%% attributes
-\newluatexattribute\finemathattr \finemathattr\@ne % finemath on by default
+\newluatexattribute\finemathattr \finemathattr\tw@ % finemath on by default
\newluatexattribute\cjtypesetattr
\newluatexattribute\dotemphattr
\newluatexattribute\autojosaattr
\newluatexattribute\luakorubyattr \chardef\luakorubyattrnum\the\allocationnumber
-\newluatexattribute\hangfntattr
-\newluatexattribute\hanjfntattr
+\newluatexattribute\hangulfntattr
+\newluatexattribute\hanjafntattr
\newluatexattribute\fallbackfntattr
\newluatexattribute\hangulpunctsattr
@@ -72,13 +73,13 @@
\def\dotemphraise{0.4em }
\unless\ifdefined\bfseries\let\bfseries\bf\fi
\def\dotemphchar{\bfseries ^^^^02d9}
-\newcount\dotemph@cnt \dotemph@cnt\z@
+\newcount\luakodotemphcnt \luakodotemphcnt\z@
\protected\def\dotemph#1{{%
- \ifnum\dotemph@cnt > 100 \global\dotemph@cnt\z@ \fi
- \global\advance\dotemph@cnt\@ne
+ \ifnum\luakodotemphcnt > 65535 \luakodotemphcnt\z@ \fi
+ \global\advance\luakodotemphcnt\@ne
\setbox\z@\hbox{\raise\dotemphraise\hbox{\dotemphchar}}\ht\z@\z@\dp\z@\z@
- \directlua{luatexko.dotemphnode[\the\dotemph@cnt] = node.copy_list(tex.box[0])}%
- \dotemphattr\dotemph@cnt #1}}
+ \directlua{luatexko.dotemphnode[\the\luakodotemphcnt] = node.copy_list(tex.box[0])}%
+ \dotemphattr\luakodotemphcnt #1}}
%% ruby : ruby.sty by Lemberg is excellent; but
%% it doesn't match well with luatexko, so implemented anew
@@ -90,12 +91,12 @@
\let\rubyoverlap\ruby@overlaptrue
\let\rubynooverlap\ruby@overlapfalse
\rubyoverlap % ruby may protrude over adjacent chars
-\newcount\luakorubyattr@cnt\luakorubyattr@cnt\z@
+\newcount\luakorubyattrcnt\luakorubyattrcnt\z@
\protected\def\ruby#1#2{%
- \ifnum\luakorubyattr@cnt > 1000 \global\luakorubyattr@cnt\z@ \fi
- \global\advance\luakorubyattr@cnt\@ne
+ \ifnum\luakorubyattrcnt > 65535 \luakorubyattrcnt\z@ \fi
+ \global\advance\luakorubyattrcnt\@ne
\begingroup
- \setbox\z@\hbox attr\luakorubyattrnum\luakorubyattr@cnt{% base character
+ \setbox\z@\hbox attr\luakorubyattrnum\luakorubyattrcnt{% base character
\vrule width\z@ height.88em depth\z@\relax #1}%
\setbox\tw@\hbox{% ruby
\ifdefined\rubyfont \rubyfont \fi
@@ -112,10 +113,13 @@
\ifdefined\hanja@font
\luatexko@resize@font\hanjafont{}\hanja@font\rubysize
\fi
+ \ifdefined\fallback@font
+ \luatexko@resize@font\fallbackfont{}\fallback@font\rubysize
+ \fi
\fi
\fi #2}\ht\tw@\z@\dp\tw@\z@
\directlua{%
- luatexko.rubynode[\the\luakorubyattr@cnt] = {
+ luatexko.rubynode[\the\luakorubyattrcnt] = {
node.copy_list(tex.box[2]),
\number\numexpr\dimexpr\rubysep\relax\relax,
\ifruby@overlap true\else false\fi}}%
@@ -123,20 +127,18 @@
\endgroup}
\ifcsname selectfont\endcsname\else
- % font resize under plain tex
- \def\luatexko@resize@font#1#2#3#4{%
- \expandafter\dimen@\pdffontsize#3\relax
- \edef\luatexko@tmp@fontname{%
- \directlua{
- local f = [===[\fontname#3]===]
- f = string.gsub(f," at .+","")
- tex.sprint(f) }}%
- #1#2=\luatexko@tmp@fontname\space at #4\dimen@
- #2}
+% font resize under plain tex
+\begingroup\edef\x{\endgroup
+ \def\noexpand\rem@vesizepart##1\detokenize{ at}##2\noexpand\end{##1}}\x
+\def\luatexko@resize@font#1#2#3#4{%
+ \begingroup
+ \edef\x@{\noexpand\rem@vesizepart\fontname#3\detokenize{ at}\noexpand\end}%
+ \edef\y@{\endgroup#1\noexpand#2 \x@\space at#4\dimexpr\pdffontsize#3\relax}%
+ \y@#2}
\fi
%% vertical typesetting
-%% EXPERIMENTAL code: don't use this
+%% EXPERIMENTAL code
\def\luatexko@vertical{%
\ifnum\cjtypesetattr<\@ne
\cjtypesetattr\z@ % korean-vertical
@@ -160,8 +162,13 @@
\vbox to\dimen@\bgroup\hbox to\dimen@ii\bgroup\hfil\else
\hbox to\dimen@ii\bgroup\vbox to\dimen@\bgroup\fi
\wd#1\z@ \ht#1\z@ \dp#1\z@
- \pdfliteral{ q 0 -1 1 0 0 0 cm}\box#1\pdfliteral{ Q}%
+ \luatexko@rotate@clockwise{\box#1}%
\ifnum\count@=\@ne\egroup\vfil\else\vfil\egroup\hfil\fi\egroup}
+\def\luatexko@rotate@clockwise#1{%
+ \ifpdf\pdfliteral{q 0 -1 1 0 0 0 cm}#1\pdfliteral{Q}%
+ \else\special{pdf:btrans rotate -90}#1\special{pdf:etrans}%
+ \fi
+}
% do not veticalize headline/footline
\ifdefined\ProvidesPackage % for latex
@@ -185,25 +192,25 @@
%% especially linebreak does not occur inside cjk words.
\def\ulinewidth{0.04em }
\def\ulinedown {0.25em }
-\newcount\ulinebox@cnt\ulinebox@cnt\z@
+\newcount\luakoulineboxcnt\luakoulineboxcnt\z@
\protected\def\uline#1{%
- \ifnum\ulinebox@cnt > 100 \global\ulinebox@cnt\z@ \fi
- \global\advance\ulinebox@cnt\@ne
+ \ifnum\luakoulineboxcnt > 65535 \luakoulineboxcnt\z@ \fi
+ \global\advance\luakoulineboxcnt\@ne
\dimen@\dimexpr\ulinedown+\ulinewidth\relax
\dimen@ii-\dimexpr\ulinedown\relax
\setbox\z@\hbox{\vrule width\z@ height\dimen@ii depth\dimen@}%
- \directlua{luatexko.ulinebox[\the\ulinebox@cnt]=node.copy_list(tex.box[0].head)}%
- \leavevmode\special{luako:ulinebegin=\the\ulinebox@cnt}%
+ \directlua{luatexko.ulinebox[\the\luakoulineboxcnt]=node.copy_list(tex.box[0].head)}%
+ \leavevmode\special{luako:ulinebegin=\the\luakoulineboxcnt}%
#1\special{luako:ulineend}}
% strike-out
\protected\def\sout#1{{\def\ulinedown{-0.5ex-\ulinewidth/2}\uline{#1}}}
% ulem with arbitray box
\protected\def\markoverwidth#1#2{%
- \ifnum\ulinebox@cnt > 100 \global\ulinebox@cnt\z@ \fi
- \global\advance\ulinebox@cnt\@ne
+ \ifnum\luakoulineboxcnt > 65535 \luakoulineboxcnt\z@ \fi
+ \global\advance\luakoulineboxcnt\@ne
\setbox\z@\hbox{#1}%
- \directlua{luatexko.ulinebox[\the\ulinebox@cnt]=node.copy_list(tex.box[0])}%
- \leavevmode\special{luako:ulinebegin=\the\ulinebox@cnt}%
+ \directlua{luatexko.ulinebox[\the\luakoulineboxcnt]=node.copy_list(tex.box[0])}%
+ \leavevmode\special{luako:ulinebegin=\the\luakoulineboxcnt}%
#2\special{luako:ulineend}}
\protected\def\uuline{\dimen@ii-\dimexpr\ulinedown\relax
\dimen@\dimexpr\ulinedown+\ulinewidth\relax
@@ -219,41 +226,42 @@
%% hangul font -- core
\def\luatexko@hangul@selectfont{%
+ \ifdefined\hangul@font
\begingroup
\let\luatexko@hangul@selectfont\relax
\let\luatexko@hanja@selectfont\relax
\let\luatexko@fallback@selectfont\relax
- \check@hangul@family
- \ifdefined\hangul@font \hangul@font \fi
+ \hangul@font
\expandafter\expandafter\expandafter
\endgroup
- \expandafter\hangfntattr\luatexfontid\font\relax
+ \expandafter\hangulfntattr\luatexfontid\font\relax
+ \fi
}
\def\luatexko@hanja@selectfont{%
+ \ifdefined\hanja@font
\begingroup
\let\luatexko@hangul@selectfont\relax
\let\luatexko@hanja@selectfont\relax
\let\luatexko@fallback@selectfont\relax
- \check@hanja@family
- \ifdefined\hanja@font \hanja@font \fi
+ \hanja@font
\expandafter\expandafter\expandafter
\endgroup
- \expandafter\hanjfntattr\luatexfontid\font\relax
+ \expandafter\hanjafntattr\luatexfontid\font\relax
+ \fi
}
\def\luatexko@fallback@selectfont{%
+ \ifdefined\fallback@font
\begingroup
\let\luatexko@hangul@selectfont\relax
\let\luatexko@hanja@selectfont\relax
\let\luatexko@fallback@selectfont\relax
- \check@fallback@family
- \ifdefined\fallback@font \fallback@font \fi
+ \fallback@font
\expandafter\expandafter\expandafter
\endgroup
\expandafter\fallbackfntattr\luatexfontid\font\relax
+ \fi
}
-\let\check@hangul@family\relax
-\let\check@hanja@family \relax
-\let\check@fallback@family\relax
+
% user interface for plain tex
\protected\def\hangulfont
{\afterassignment\luatexko@hangul@selectfont\font\hangul@font}
@@ -270,12 +278,10 @@
\ifnum\count@<"#2
\advance\count@\@ne
\repeat}
-\def\setmathhangulfont#1#{\setmathhangul@font@}
-\ifdefined\ProvidesPackage
- \let\setmathhangul@font@\@gobble
-\else
+\ifdefined\ProvidesPackage\else
% for plain; see luatexko.sty for latex
\newfam\symmathhangul
+ \def\setmathhangulfont#1#{\setmathhangul@font@}
\def\setmathhangul@font@#1{%
\font\tenhangul = "#1" at 10pt
\font\sevenhangul = "#1" at 7pt
@@ -356,6 +362,38 @@
\fi\fi
}
+% Actual Text: beware that #2 should not be divided into separate pages.
+% \actualtext* variant inserts space char from phvr8r. see accsupp manual
+\protected\def\actualtext#1#{%
+ \ifx\empty#1\empty
+ \expandafter\actualtext@\expandafter!%
+ \else
+ \expandafter\actualtext@\expandafter*%
+ \fi
+}
+\def\actualtext@#1#2{%
+ \luatexko@pdfspecial{/Span<</ActualText\directlua{
+ luatexko.actualtext("\luatexluaescapestring{\detokenize{#2}}")
+ }>>BDC}%
+ #2%
+ \ifx*#1%
+ \begingroup
+ \ifdefined\actualtext@spacefont\else
+ \global\font\actualtext@spacefont=phvr8r\relax
+ \fi
+ \setbox\z@\hbox{\actualtext@spacefont\char32}%
+ \wd\z@\z@\ht\z@\z@\dp\z@\z@
+ \leavevmode\copy\z@
+ \endgroup
+ \fi
+ \luatexko@pdfspecial{EMC}%
+}
+\def\luatexko@pdfspecial#1{%
+ \ifpdf\pdfliteral page{#1}%
+ \else\special{pdf:content #1}%
+ \fi
+}
+
%% 말줄임표
\def\hellipsis{^^^^2026^^^^2026}
diff --git a/Master/texmf-dist/tex/luatex/luatexko/luatexko-normalize.lua b/Master/texmf-dist/tex/luatex/luatexko/luatexko-normalize.lua
index 8c6e0bc3d98..4c2fde7fff0 100644
--- a/Master/texmf-dist/tex/luatex/luatexko/luatexko-normalize.lua
+++ b/Master/texmf-dist/tex/luatex/luatexko/luatexko-normalize.lua
@@ -1,6 +1,6 @@
-- luatexko-normalize.lua
--
--- Copyright (c) 2013 Dohyun Kim <nomos at ktug org>
+-- Copyright (c) 2013-2014 Dohyun Kim <nomos at ktug org>
--
-- This work may be distributed and/or modified under the
-- conditions of the LaTeX Project Public License, either version 1.3c
@@ -12,8 +12,8 @@
luatexbase.provides_module({
name = "luatexko-normalize",
- version = 1.2,
- date = "2013/06/10",
+ version = 1.5,
+ date = "2014/05/11",
author = "Dohyun Kim",
description = "Hangul normalization",
license = "LPPL v1.3+",
@@ -22,9 +22,9 @@ luatexbase.provides_module({
luatexkonormalize = luatexkonormalize or {}
local luatexkonormalize = luatexkonormalize
-local cho = "[\225\132\128-\225\132\146]"
-local jung = "[\225\133\161-\225\133\181]"
-local jong = "[\225\134\168-\225\135\130]"
+local ncho = "[\225\132\128-\225\132\146]"
+local njung = "[\225\133\161-\225\133\181]"
+local jong = "[\225\134\168-\225\135\191\237\159\139-\237\159\187]"
local ojong = "[\225\135\131-\225\135\191\237\159\139-\237\159\187]"
local compathanja = "[\239\164\128-\239\168\139]"
local chanjatohanja = {
@@ -398,36 +398,39 @@ local jamotocjamo = {
}
}
+require "unicode"
local gsub = unicode.utf8.gsub
local byte = unicode.utf8.byte
local char = unicode.utf8.char
+local find = unicode.utf8.find
+local concat = table.concat
local add_to_callback = luatexbase.add_to_callback
local remove_from_callback = luatexbase.remove_from_callback
+local priority_in_callback = luatexbase.priority_in_callback
local jamo2syllable = function(l,v,t)
+ if find(t,ojong) then return end
l, v = byte(l), byte(v)
local s = (l - 0x1100) * 21
s = (s + v - 0x1161) * 28
- if t then
- t = byte(t)
- s = s + t - 0x11a7
+ if t ~= "" then
+ s = s + byte(t) - 0x11a7
end
- s = s + 0xac00
- return char(s)
+ return char(s + 0xac00)
end
-local hanguldecompose = function(buffer)
- buffer = gsub(buffer, "[가-힣]", function(s)
+local syllable2jamo = function(s)
s = byte(s) - 0xac00
- local cho = s / (21 * 28) + 0x1100
- local jung = (s % (21 * 28)) / 28 + 0x1161
- local jong = s % 28 + 0x11a7
- if jong > 0x11a7 then
- return char(cho)..char(jung)..char(jong)
- end
- return char(cho)..char(jung)
- end)
- return buffer
+ local t = {}
+ t[1] = char(s / 588 + 0x1100)
+ t[2] = char(s % 588 / 28 + 0x1161)
+ local jong = s % 28
+ t[3] = jong > 0 and char(jong + 0x11a7) or nil
+ return concat(t)
+end
+
+local hanguldecompose = function(buffer)
+ return gsub(buffer, "[가-힣]", syllable2jamo)
end
local function hanjanormalize(c)
@@ -442,48 +445,39 @@ local function jamo2cjamocho(c)
return jamo
end
-local function jamo2cjamojung(c)
+local function jamo2cjamojung(c,t)
+ if t ~= "" then return end
local jamo = jamotocjamo.cjung[byte(c)]
jamo = jamo and char(jamo)
return jamo
end
local hangulcompose = function(buffer)
- buffer = hanguldecompose(buffer)
- buffer = gsub(buffer, "("..cho..")("..jung..")("..jong..")", jamo2syllable)
- buffer = gsub(buffer, "("..cho..")("..jung..ojong..")", "%1\1%2")
- buffer = gsub(buffer, "("..cho..")("..jung..")", jamo2syllable)
- buffer = gsub(buffer, "([\225\132\128-\225\133\153])\225\133\160", jamo2cjamocho)
- buffer = gsub(buffer, "\225\133\159([\225\133\161-\225\134\161])", jamo2cjamojung)
- buffer = gsub(buffer, "\1", "")
- buffer = gsub(buffer, "("..compathanja..")", hanjanormalize)
+ buffer = gsub(buffer, "[가-힣]"..jong, hanguldecompose)
+ buffer = gsub(buffer, "("..ncho..")("..njung..")("..jong.."?)", jamo2syllable)
+ buffer = gsub(buffer,
+ "([\225\132\128-\225\133\153])\225\133\160", jamo2cjamocho)
+ buffer = gsub(buffer,
+ "\225\133\159([\225\133\161-\225\134\161])("..jong.."?)", jamo2cjamojung)
+ buffer = gsub(buffer, compathanja, hanjanormalize)
return buffer
end
-local loaded = false
-
-local function compose()
- if loaded then
+local function unload()
+ if priority_in_callback('process_input_buffer', 'luatexko-hangul-normalize') then
remove_from_callback('process_input_buffer', 'luatexko-hangul-normalize')
end
- loaded = true
+end
+luatexkonormalize.unload = unload
+
+local function compose()
+ unload()
add_to_callback('process_input_buffer', hangulcompose, 'luatexko-hangul-normalize')
end
luatexkonormalize.compose = compose
local function decompose()
- if loaded then
- remove_from_callback('process_input_buffer', 'luatexko-hangul-normalize')
- end
- loaded = true
+ unload()
add_to_callback('process_input_buffer', hanguldecompose, 'luatexko-hangul-normalize')
end
luatexkonormalize.decompose = decompose
-
-local function unload()
- if loaded then
- remove_from_callback('process_input_buffer', 'luatexko-hangul-normalize')
- end
- loaded = false
-end
-luatexkonormalize.unload = unload
diff --git a/Master/texmf-dist/tex/luatex/luatexko/luatexko-uhc2utf8.lua b/Master/texmf-dist/tex/luatex/luatexko/luatexko-uhc2utf8.lua
index 2afdad38532..3d28a668b1f 100644
--- a/Master/texmf-dist/tex/luatex/luatexko/luatexko-uhc2utf8.lua
+++ b/Master/texmf-dist/tex/luatex/luatexko/luatexko-uhc2utf8.lua
@@ -1,6 +1,6 @@
-- luatexko-uhc2utf8.lua
--
--- Copyright (c) 2013 Dohyun Kim <nomos at ktug org>
+-- Copyright (c) 2013-2014 Dohyun Kim <nomos at ktug org>
--
-- This work may be distributed and/or modified under the
-- conditions of the LaTeX Project Public License, either version 1.3c
@@ -12,8 +12,8 @@
luatexbase.provides_module({
name = "luatexko-uhc2utf8",
- version = 1.2,
- date = "2013/06/10",
+ version = 1.5,
+ date = "2014/05/11",
author = "Dohyun Kim",
description = "UHC (CP949) input encoding",
license = "LPPL v1.3+",
@@ -22,11 +22,12 @@ luatexbase.provides_module({
luatexkouhc2utf8 = luatexkouhc2utf8 or {}
local luatexkouhc2utf8 = luatexkouhc2utf8
-local find = string.find
+local match = string.match
local gsub = string.gsub
local byte = string.byte
-local len = string.len
local format = string.format
+local utfvalues = string.utfvalues
+require "unicode"
local ugsub = unicode.utf8.gsub
local ubyte = unicode.utf8.byte
local uchar = unicode.utf8.char
@@ -43,7 +44,7 @@ local function get_uhc_uni_table()
while true do
local line = file:read("*line")
if not line then break end
- local _,_,ea,eb,uni = find(line,"<(%x+)>%s+<(%x+)>%s+<(%x+)>")
+ local ea,eb,uni = match(line,"<(%x+)>%s+<(%x+)>%s+<(%x+)>")
if ea and eb and uni then
ea, eb, uni = tonumber(ea,16),tonumber(eb,16),tonumber(uni,16)
for i=ea,eb do
@@ -62,16 +63,18 @@ local t_uhc2ucs = t_uhc2ucs or get_uhc_uni_table()
local uhc_to_utf8 = function(buffer)
if not buffer then return end
-- check if buffer is already utf-8; better solution?
- local t = gsub(buffer,"[\0-\127]","")
- t = gsub(t,"[\194-\223][\128-\191]","")
- t = gsub(t,"[\224-\239][\128-\191][\128-\191]","")
- t = gsub(t,"[\240-\244][\128-\191][\128-\191][\128-\191]","")
- if len(t) == 0 then return buffer end
+ local isutf = true
+ for v in utfvalues(buffer) do
+ if v == 0xFFFD then -- REPLACEMENT CHARACTER
+ isutf = false
+ break
+ end
+ end
+ if isutf == true then return buffer end
-- now convert to utf8
buffer = gsub(buffer, "([\129-\253])([\65-\254])",
function(a, b)
- a, b = byte(a), byte(b)
- local utf = t_uhc2ucs[a * 256 + b]
+ local utf = t_uhc2ucs[byte(a) * 256 + byte(b)]
if utf then return uchar(utf) end
end)
return buffer
@@ -105,8 +108,9 @@ local function utf8_to_uhc (name)
name = ugsub(name, "[\161-\239\191\166]", -- 00A1..FFE6
function(u)
local c = t_ucs2uhc[ubyte(u)]
- if not c then return u end
- return format("%c%c", floor(c/256), c%256)
+ if c then
+ return format("%c%c", floor(c/256), c%256)
+ end
end)
return name
end
@@ -115,8 +119,7 @@ local function uhc_find_file (file, ...)
local f = kpse_find_file(file, ...)
if f then return f end
f = utf8_to_uhc(file)
- f = f and kpse_find_file(f, ...)
- return f
+ return f and kpse_find_file(f, ...)
end
local function start_uhc_filename ()
diff --git a/Master/texmf-dist/tex/luatex/luatexko/luatexko.lua b/Master/texmf-dist/tex/luatex/luatexko/luatexko.lua
index 8ef25e1f439..aa14bbc249f 100644
--- a/Master/texmf-dist/tex/luatex/luatexko/luatexko.lua
+++ b/Master/texmf-dist/tex/luatex/luatexko/luatexko.lua
@@ -1,6 +1,6 @@
-- luatexko.lua
--
--- Copyright (c) 2013 Dohyun Kim <nomos at ktug org>
+-- Copyright (c) 2013-2014 Dohyun Kim <nomos at ktug org>
--
-- This work may be distributed and/or modified under the
-- conditions of the LaTeX Project Public License, either version 1.3c
@@ -12,8 +12,8 @@
local err,warn,info,log = luatexbase.provides_module({
name = 'luatexko',
- date = '2014/01/06',
- version = 1.4,
+ date = '2014/05/11',
+ version = 1.5,
description = 'Korean linebreaking and font-switching',
author = 'Dohyun Kim',
license = 'LPPL v1.3+',
@@ -26,21 +26,21 @@ local dotemphnode,rubynode,ulinebox = {},{},{}
luatexko.dotemphnode = dotemphnode
luatexko.rubynode = rubynode
luatexko.ulinebox = ulinebox
-luatexko.hanjafontforhanja = luatexko.hanjafontforhanja or false
local stringbyte = string.byte
local stringgsub = string.gsub
local stringchar = string.char
local stringfind = string.find
local stringmatch = string.match
-local stringgmatch = string.gmatch
local stringformat = string.format
local string_sub = string.sub
local mathfloor = math.floor
local tex_round = tex.round
local tex_sp = tex.sp
+local texcount = tex.count
local fontdefine = font.define
-local utf8char = unicode.utf8.char
+
+local kpse_find_file = kpse.find_file
local fontdata = fonts.hashes.identifiers
@@ -57,14 +57,17 @@ local nodecount = node.count
local nodeslide = node.slide
local nodedimensions = node.dimensions
local nodetail = node.tail
+local end_of_math = node.end_of_math
+local nodenext = node.next
+local nodeprev = node.prev
local finemathattr = luatexbase.attributes.finemathattr
local cjtypesetattr = luatexbase.attributes.cjtypesetattr
local dotemphattr = luatexbase.attributes.dotemphattr
local autojosaattr = luatexbase.attributes.autojosaattr
local luakorubyattr = luatexbase.attributes.luakorubyattr
-local hangfntattr = luatexbase.attributes.hangfntattr
-local hanjfntattr = luatexbase.attributes.hanjfntattr
+local hangulfntattr = luatexbase.attributes.hangulfntattr
+local hanjafntattr = luatexbase.attributes.hanjafntattr
local fallbackfntattr = luatexbase.attributes.fallbackfntattr
local hangulpunctsattr = luatexbase.attributes.hangulpunctsattr
local luakoglueattr = luatexbase.new_attribute("luakoglueattr")
@@ -552,7 +555,6 @@ local function get_cjk_class (ch, cjtype)
end
return c
end
- return nil
end
local function get_font_table (fid)
@@ -597,8 +599,8 @@ end
local function get_unicode_char(curr)
local uni = curr.char
- if (uni > 0 and uni < 0xE000) or (uni > 0xF8FF and uni < 0xF0000) then
- return uni -- no pua
+ if (uni > 0xFF and uni < 0xE000) or (uni > 0xF8FF and uni < 0xF0000) then
+ return uni -- no pua. no nanumgtm??
end
-- tounicode is now reliable. backend is fixed
uni = get_font_char(curr.font, curr.char)
@@ -622,7 +624,7 @@ local function get_hlist_class_first (hlist)
elseif curr.id == gluenode then
if curr.spec and curr.spec.width ~= 0 then return end
end
- curr = curr.next
+ curr = nodenext(curr)
end
end
@@ -638,7 +640,7 @@ local function get_hlist_class_last (hlist,prevchar,prevfont)
elseif curr.id == gluenode then
if curr.spec and curr.spec.width ~= 0 then return end
end
- curr = curr.prev
+ curr = nodeprev(curr)
end
return prevchar, prevfont
end
@@ -679,7 +681,7 @@ end
local function koreanlatinskip (head,curr,currfont,prevfont,was_penalty)
local width = 0 -- default: 0em
- if has_attribute(curr,finemathattr) == 1 then -- not ttfamily
+ if (has_attribute(curr,finemathattr) or 0) > 0 then -- not ttfamily
local latincjk = get_font_feature(currfont, "interlatincjk")
if not latincjk then
latincjk = get_font_feature(prevfont, "interlatincjk")
@@ -700,8 +702,8 @@ local function cjk_insert_nodes(head,curr,currchar,currfont,prevchar,prevfont)
local p = get_cjk_class(prevchar, currentcjtype)
local c = get_cjk_class(currchar, currentcjtype)
---[[raise latin puncts
- if curr.id == glyphnode and has_attribute(curr,finemathattr) == 1 and c < 10 then -- not ttfamily
- local nn, raise = curr.next, nil
+ if curr.id == glyphnode and (has_attribute(curr,finemathattr) or 0) > 0 and c < 10 then -- not ttfamily
+ local nn, raise = nodenext(curr), nil
while nn do
if nn.id == glyphnode and latin_fullstop[nn.char] then
if not raise then
@@ -709,12 +711,11 @@ local function cjk_insert_nodes(head,curr,currchar,currfont,prevchar,prevfont)
raise = raise and tex_sp(raise)
end
if raise then
- nn.yoffset = nn.yoffset or 0
- nn.yoffset = nn.yoffset + raise
+ nn.yoffset = (nn.yoffset or 0) + raise
end
- nn = nn.next
+ nn = nodenext(nn)
elseif nn.id == kernnode then
- nn = nn.next
+ nn = nodenext(nn)
else
break
end
@@ -796,7 +797,8 @@ end
local function cjk_spacing_linebreak (head)
local prevchar,prevfont = nil,nil
- for curr in traverse(head) do
+ local curr = head
+ while curr do
if has_attribute(curr,finemathattr) then
if curr.id == gluenode then
prevchar,prevfont = nil,nil
@@ -815,8 +817,8 @@ local function cjk_spacing_linebreak (head)
end
if curr.subtype == 0 then
cjk_insert_nodes(head,curr,currchar,nil,prevchar,prevfont)
- prevchar,prevfont = nil,nil
- else
+ curr = end_of_math(curr)
+ if not curr then break end
prevchar,prevfont = currchar,nil
end
unset_attribute(curr,finemathattr)
@@ -831,6 +833,7 @@ local function cjk_spacing_linebreak (head)
else
prevchar,prevfont = 0,nil -- treat \verb as latin character.
end
+ curr = nodenext(curr)
end
end
@@ -838,55 +841,61 @@ end
-- remove japanese/chinese spaceskip
------------------------------------
local function remove_cj_spaceskip (head)
- for curr in traverse_id(gluenode,head) do
- local cjattr = has_attribute(curr,cjtypesetattr)
- local prv, nxt = curr.prev, curr.next
- if cjattr and cjattr > 0 and prv and nxt then
- local prevclass, prevchar, prevfont, nextclass
- if prv.id == hlistnode or prv.id == vlistnode then
- prevclass = get_hlist_class_last(prv)
- else
- -- what is this strange kern before \text??
- if prv.id == kernnode and prv.kern == 0 then
- prv = prv.prev
+ local curr, prevfont = head, nil
+ while curr do
+ if curr.id == mathnode and curr.subtype == 0 then
+ curr = end_of_math(curr)
+ elseif curr.id == gluenode then
+ local cjattr = has_attribute(curr,cjtypesetattr)
+ local prv, nxt = nodeprev(curr), nodenext(curr)
+ if cjattr and cjattr > 0 and prv and nxt then
+ local prevclass, prevchar, nextclass
+ if prv.id == hlistnode or prv.id == vlistnode then
+ prevclass = get_hlist_class_last(prv)
+ else
+ -- what is this strange kern before \text??
+ if prv.id == kernnode and prv.kern == 0 then
+ prv = nodeprev(prv)
+ end
+ if prv.id == glyphnode then
+ prevclass = get_cjk_class(get_unicode_char(prv), cjattr)
+ prevchar, prevfont = prv.char, prv.font
+ end
end
- if prv.id == glyphnode then
- prevclass = get_cjk_class(get_unicode_char(prv), cjattr)
- prevchar, prevfont = prv.char, prv.font
+ if nxt.id == glyphnode then
+ nextclass = get_cjk_class(get_unicode_char(nxt), cjattr)
+ elseif nxt.id == hlistnode or nxt.id == vlistnode then
+ nextclass = get_hlist_class_first(nxt)
end
- end
- if nxt.id == glyphnode then
- nextclass = get_cjk_class(get_unicode_char(nxt), cjattr)
- elseif nxt.id == hlistnode or nxt.id == vlistnode then
- nextclass = get_hlist_class_first(nxt)
- end
- if (prevclass and prevclass < 10) or (nextclass and nextclass < 10) then
- local subtype = curr.subtype
- if subtype == 13 then -- do not touch on xspaceskip for now
- remove_node(head,curr)
- else -- before \text?? spaceskip is replaced by glue type 0
- local spec = curr.spec
- local csp = spec and spec.width
- local cst = spec and spec.stretch
- local csh = spec and spec.shrink
- local fp = get_font_table(prevfont)
- fp = fp and fp.parameters
- local sp = fp and fp.space
- local st = fp and fp.space_stretch
- local sh = fp and fp.space_shrink
- sp = sp and tex_round(sp)
- st = st and tex_round(st)
- sh = sh and tex_round(sh)
- if prevchar and prevchar >= 65 and prevchar <= 90 then
- st = st and mathfloor(st*(999/1000))
- sh = sh and mathfloor(sh*(1001/1000))
- end
- if sp == csp and st == cst and sh == csh then
+ if (prevclass and prevclass < 10) or (nextclass and nextclass < 10) then
+ local subtype = curr.subtype
+ if subtype == 13 then -- do not touch on xspaceskip for now
remove_node(head,curr)
+ else -- before \text?? spaceskip is replaced by glue type 0
+ local spec = curr.spec
+ local csp = spec and spec.width
+ local cst = spec and spec.stretch
+ local csh = spec and spec.shrink
+ local fp = get_font_table(prevfont)
+ fp = fp and fp.parameters
+ local sp = fp and fp.space
+ local st = fp and fp.space_stretch
+ local sh = fp and fp.space_shrink
+ sp = sp and tex_round(sp)
+ st = st and tex_round(st)
+ sh = sh and tex_round(sh)
+ if prevchar and prevchar >= 65 and prevchar <= 90 then
+ st = st and mathfloor(st*(999/1000))
+ sh = sh and mathfloor(sh*(1001/1000))
+ end
+ if sp == csp and st == cst and sh == csh then
+ remove_node(head,curr)
+ end
end
end
end
end
+ curr = nodenext(curr)
end
end
@@ -906,7 +915,7 @@ local function compress_fullwidth_punctuations (head)
local ensize = emsize/2
local oneoften = emsize/10
local bbox = get_char_boundingbox(curr.font, curr.char)
- if not bbox then return head end --
+ bbox = bbox or {ensize-oneoften, ensize-oneoften, ensize+oneoften, ensize+oneoften}
if class == 2 or class == 4 then
local wd
if get_font_feature(curr.font,'vertical') then
@@ -1025,14 +1034,14 @@ local function get_ruby_side_kern (head)
if curr.width < rubywidth then
local _,fid = get_hlist_class_first(curr)
emsize = get_font_emsize(fid)
- local leftwidth,leftmargin = get_ruby_side_width(basewidth,rubywidth,curr.prev)
+ local leftwidth,leftmargin = get_ruby_side_width(basewidth,rubywidth,nodeprev(curr))
if leftwidth > 0 then
curr.width = curr.width + leftwidth
end
if leftmargin > 0 then
rubynode[attr].leftmargin = leftmargin
end
- local rightwidth,rightmargin = get_ruby_side_width(basewidth,rubywidth,curr.next)
+ local rightwidth,rightmargin = get_ruby_side_width(basewidth,rubywidth,nodenext(curr))
if rightwidth > 0 then
curr.width = curr.width + rightwidth
end
@@ -1079,13 +1088,14 @@ local function no_ruby_at_margin(head)
end
margin = rubynode[attr].rightmargin
if margin then
- if curr.next then
- if curr.next.id == gluenode then
+ local nn = nodenext(curr)
+ if nn then
+ if nn.id == gluenode then
insert_after(head,curr,get_kernnode(-margin))
head = zero_width_rule_with_dir(head,curr)
insert_after(head,curr,get_kernnode(margin))
- elseif curr.next.id == penaltynode and curr.next.penalty < 10000 then
- insert_after(head,curr.next,get_kernnode(-margin))
+ elseif nn.id == penaltynode and nn.penalty < 10000 then
+ insert_after(head,nn,get_kernnode(-margin))
head = zero_width_rule_with_dir(head,curr)
insert_after(head,curr,get_kernnode(margin))
end
@@ -1104,14 +1114,15 @@ local function inject_char_widow_penalty (head,curr,uni,cjattr)
local class = get_cjk_class(uni, cjattr)
if class and class < 9 then
local pv = cjattr and 500 or 5000
- if curr.prev and curr.prev.id == rulenode then
- curr = curr.prev
+ local np = nodeprev(curr)
+ if np and np.id == rulenode then
+ curr = np; np = nodeprev(curr)
end
- if curr.prev and curr.prev.id == gluenode then
- curr = curr.prev
+ if np and np.id == gluenode then
+ curr = np; np = nodeprev(curr)
end
- if curr.prev and curr.prev.id == penaltynode then
- curr = curr.prev
+ if np and np.id == penaltynode then
+ curr = np
if curr.penalty < pv then
curr.penalty = pv
end
@@ -1141,7 +1152,7 @@ local function discourage_char_widow (head,curr)
local cjattr = has_attribute(curr,cjtypesetattr)
curr = inject_char_widow_penalty(head,curr,uni,cjattr)
end
- curr = curr.prev
+ curr = nodeprev(curr)
end
end
@@ -1228,7 +1239,7 @@ end
local function get_hanja_hangul_table (table,file,init)
local i = 0
- local file = kpse.find_file(file)
+ local file = kpse_find_file(file)
if not file then return table end
file = io.open(file, "r")
if not file then return table end
@@ -1301,7 +1312,7 @@ local function get_josaprevs(curr,josaprev,ignoreparens,halt)
josaprev = get_josaprevs(nodeslide(curr.head),josaprev,ignoreparens,halt)
end
if #josaprev == 3 then break end
- curr = curr.prev
+ curr = nodeprev(curr)
end
return josaprev
end
@@ -1311,13 +1322,12 @@ local function korean_autojosa (head)
if has_attribute(curr,autojosaattr) and has_attribute(curr,finemathattr) then
local ignoreparens = has_attribute(curr,autojosaattr) > 1 and true or false
local josaprev = {}
- josaprev = get_josaprevs(curr.prev,josaprev,ignoreparens)
+ josaprev = get_josaprevs(nodeprev(curr),josaprev,ignoreparens)
local josacode = get_josacode(josaprev)
local thischar = get_unicode_char(curr)
if thischar == 0xC774 then
- if curr.next
- and curr.next.id == glyphnode
- and get_unicode_char(curr.next) == 0xB77C then
+ local nn = nodenext(curr)
+ if nn and nn.id == glyphnode and get_unicode_char(nn) == 0xB77C then
curr.char = josa_list[0xC774][josacode]
else
curr.char = josa_list[0xAC00][josacode]
@@ -1353,30 +1363,65 @@ local function hangulspaceskip (engfont, hfontid, spec)
return tex_round(hsp), tex_round(hst), tex_round(hsh)
end
+local type1fonts = {} -- due to too verbose log
+local function nanumtype1font(curr)
+ if curr.char > 0xFFFF then return end
+ local fnt_t = get_font_table(curr.font)
+ local family = (has_attribute(curr,finemathattr) or 0) > 1 and not is_hanja(curr.char) and "nanummj" or "nanumgt"
+ local series = fnt_t.shared and fnt_t.shared.rawdata.metadata.pfminfo.weight
+ if series then
+ series = series > 500 and "b" or "m"
+ else
+ series = stringfind(fnt_t.name,"^cmb") and "b" or "m"
+ end
+ local shape = fnt_t.parameters.slant > 0 and "o" or ""
+ local subfnt = stringformat("%s%s%s%02x",family,series,shape,curr.char/256)
+ local fsize = fnt_t.size or 655360
+ local fspec = stringformat("%s@%d",subfnt,fsize)
+ local newfnt = type1fonts[fspec]
+ local newchr = curr.char % 256
+ local function ital_corr (curr,chr_t)
+ if shape ~= "o" then return end
+ local nxt = nodenext(curr)
+ if nxt and nxt.id == kernnode and nxt.subtype == 1 and nxt.kern == 0 then
+ nxt.kern = chr_t.italic or 0
+ end
+ end
+ if newfnt then
+ local fntchr = get_font_char(newfnt,newchr)
+ if fntchr then
+ curr.font, curr.char = newfnt, newchr
+ ital_corr(curr,fntchr)
+ end
+ else
+ local ft, id = fonts.constructors.readanddefine(subfnt,fsize)
+ local fntchr = ft and ft.characters[newchr]
+ if id and fntchr then
+ type1fonts[fspec], curr.font, curr.char = id, id, newchr
+ ital_corr(curr,fntchr)
+ end
+ end
+end
+
local function font_substitute(head)
- local noinmath = true
- for curr in traverse(head) do
- if curr.id == mathnode then
- if curr.subtype == 0 then
- noinmath = false
- else
- noinmath = true
- end
- elseif noinmath and curr.id == glyphnode then
+ local curr = head
+ while curr do
+ if curr.id == mathnode and curr.subtype == 0 then
+ curr = end_of_math(curr)
+ elseif curr.id == glyphnode then
local eng = get_font_table(curr.font)
- local engfontchar = nil
+ local myfontchar = nil
if eng and eng.encodingbytes and eng.encodingbytes == 2 -- exclude type1
and hangulpunctuations[curr.char]
and has_attribute(curr, hangulpunctsattr)
- and has_attribute(curr, finemathattr) == 1
+ and (has_attribute(curr, finemathattr) or 0) > 0 -- not ttfamily
and not get_font_char(curr.font, 0xAC00) then -- exclude hangul font
else
- engfontchar = get_font_char(curr.font, curr.char)
+ myfontchar = get_font_char(curr.font, curr.char)
end
- if curr.char and not engfontchar then
- local korid = false
- local hangul = has_attribute(curr, hangfntattr)
- local hanja = has_attribute(curr, hanjfntattr)
+ if curr.char and not myfontchar then
+ local hangul = has_attribute(curr, hangulfntattr)
+ local hanja = has_attribute(curr, hanjafntattr)
local fallback = has_attribute(curr,fallbackfntattr)
local ftable = {hangul, hanja, fallback}
if luatexko.hanjafontforhanja then
@@ -1384,17 +1429,15 @@ local function font_substitute(head)
uni = uni and get_cjk_class(uni)
if uni and uni < 7 then ftable = {hanja, hangul, fallback} end
end
- for i=1,#ftable do
+ for i = 1,3 do
local fid = ftable[i]
- if fid then
- local c = get_font_char(fid, curr.char)
- if c then
- korid = true
- curr.font = fid
+ myfontchar = get_font_char(fid, curr.char)
+ if myfontchar then
+ curr.font = fid
+ local nxt = nodenext(curr)
+ if eng and nxt then
-- adjust next glue by hangul font space
- local nxt = curr.next
- if eng
- and nxt and nxt.id == gluenode
+ if nxt.id == gluenode
and nxt.subtype and nxt.subtype == 0
and nxt.spec and nxt.spec.writable
and get_font_char(fid,32) then
@@ -1404,25 +1447,32 @@ local function font_substitute(head)
hg.width, hg.stretch, hg.shrink = sp, st, sh
nxt.spec = hg
end
+ -- adjust next italic correction kern
+ elseif nxt.id == kernnode
+ and nxt.subtype == 1 and nxt.kern == 0 then
+ local ksl = get_font_table(fid).parameters.slant
+ if ksl and ksl > 0 then
+ nxt.kern = myfontchar.italic or 0
+ end
end
- --- charraise option charraise
- local charraise = get_font_feature(fid, "charraise")
- if charraise then
- charraise = tex_sp(charraise)
- curr.yoffset = curr.yoffset and (curr.yoffset + charraise) or charraise
- end
- ---
- break
end
+ --- charraise option charraise
+ local charraise = get_font_feature(fid, "charraise")
+ if charraise then
+ charraise = tex_sp(charraise)
+ curr.yoffset = charraise + (curr.yoffset or 0)
+ end
+ ---
+ break
end
end
- if not korid and not is_unicode_vs(curr.char) then
- warn("!Missing character: %s U+%04X", utf8char(curr.char),curr.char)
+ if not myfontchar then
+ nanumtype1font(curr)
end
end
end
+ curr = nodenext(curr)
end
- return head
end
-----------------------------
@@ -1440,19 +1490,25 @@ end
-----------------------------
local function reorderTM (head)
for curr in traverse_id(glyphnode, head) do
- if curr.width > 0 then -- old hangul vertical typesetting is broken?
- local uni = get_unicode_char(curr)
- if uni and (uni == 0x302E or uni == 0x302F) then
- local p = curr.prev
+ local uni = get_unicode_char(curr)
+ if uni and (uni == 0x302E or uni == 0x302F) then
+ local unichar = get_font_char(curr.font, uni)
+ if unichar.width > 0 then
+ local p = nodeprev(curr)
while p do
- if p.id ~= glyphnode then break end
- local pc = get_cjk_class(get_unicode_char(p))
- if pc == 7 or pc == 8 then
- head = insert_before(head,p,copy_node(curr))
- head = remove_node(head,curr)
+ if p.id == glyphnode then
+ local pc = get_cjk_class(get_unicode_char(p))
+ if pc == 7 or pc == 8 then
+ head = insert_before(head,p,copy_node(curr))
+ head = remove_node(head,curr)
+ break
+ end
+ elseif unichar.commands and p.id == kernnode then
+ -- kerns in vertical typesetting mode
+ else
break
end
- p = p.prev
+ p = nodeprev(p)
end
end
end
@@ -1467,7 +1523,7 @@ local function hanja_vs_support (head)
for curr in traverse_id(glyphnode, head) do
local cc = curr.char
if is_unicode_vs(cc) then
- local prev = curr.prev
+ local prev = nodeprev(curr)
if prev and prev.id == glyphnode then
local f = get_font_table(prev.font)
local ivs = f and f.resources and f.resources.variants
@@ -1496,9 +1552,9 @@ add_to_callback('hpack_filter', function(head)
end, 'luatexko.hpack_filter_first',1)
add_to_callback('hpack_filter', function(head)
- get_ruby_side_kern(head)
+ if texcount["luakorubyattrcnt"]>0 then get_ruby_side_kern(head) end
cjk_spacing_linebreak(head)
- spread_ruby_base_box(head)
+ if texcount["luakorubyattrcnt"]>0 then spread_ruby_base_box(head) end
head = compress_fullwidth_punctuations(head)
-- head = no_ruby_at_margin(head)
head = reorderTM(head)
@@ -1515,12 +1571,12 @@ add_to_callback('pre_linebreak_filter', function(head)
end, 'luatexko.pre_linebreak_filter_first',1)
add_to_callback('pre_linebreak_filter', function(head)
- get_ruby_side_kern(head)
+ if texcount["luakorubyattrcnt"]>0 then get_ruby_side_kern(head) end
cjk_spacing_linebreak(head)
- spread_ruby_base_box(head)
+ if texcount["luakorubyattrcnt"]>0 then spread_ruby_base_box(head) end
head = compress_fullwidth_punctuations(head)
discourage_char_widow(head, nodeslide(head))
- head = no_ruby_at_margin(head)
+ if texcount["luakorubyattrcnt"]>0 then head = no_ruby_at_margin(head) end
head = reorderTM(head)
return head
end, 'luatexko.pre_linebreak_filter')
@@ -1540,7 +1596,7 @@ local function after_linebreak_dotemph (head)
if cc and (cc == 0 or cc == 7 or cc == 8) then
local basewd = curr.width or 0
if cc == 8 then -- check next char for old hangul jung/jongseong
- local nn = curr.next
+ local nn = nodenext(curr)
while nn do
if nn.id ~= glyphnode then break end
local uni = get_unicode_char(nn)
@@ -1550,7 +1606,7 @@ local function after_linebreak_dotemph (head)
else
break
end
- nn = nn.next
+ nn = nodenext(nn)
end
end
local d = copy_node(dotemphnode[attr])
@@ -1623,7 +1679,7 @@ end
local function after_linebreak_underline(head,glueorder,glueset,gluesign,ulinenum)
local ulstart = ulinenum and head or false
- if ulstart and ulstart.id == gluenode then ulstart = ulstart.next end
+ if ulstart and ulstart.id == gluenode then ulstart = nodenext(ulstart) end
for curr in traverse(head) do
if curr.id == hlistnode then
curr.head,ulinenum = after_linebreak_underline(curr.head,curr.glue_order,curr.glue_set,curr.glue_sign,ulinenum)
@@ -1652,48 +1708,61 @@ end
-- add to callback : post-linebreak
-----------------------------------
add_to_callback('vpack_filter', function(head)
- head = after_linebreak_dotemph(head)
- after_linebreak_ruby(head)
- head = after_linebreak_underline(head)
+ if texcount["luakodotemphcnt"]>0 then head = after_linebreak_dotemph(head) end
+ if texcount["luakorubyattrcnt"]>0 then after_linebreak_ruby(head) end
+ if texcount["luakoulineboxcnt"]>0 then head = after_linebreak_underline(head) end
return head
end, 'luatexko.vpack_filter')
add_to_callback("post_linebreak_filter", function(head)
- head = after_linebreak_dotemph(head)
- after_linebreak_ruby(head)
- head = after_linebreak_underline(head)
+ if texcount["luakodotemphcnt"]>0 then head = after_linebreak_dotemph(head) end
+ if texcount["luakorubyattrcnt"]>0 then after_linebreak_ruby(head) end
+ if texcount["luakoulineboxcnt"]>0 then head = after_linebreak_underline(head) end
return head
end, 'luatexko.post_linebreak_filter')
------------------------------------
--- vertical typesetting: EXPERIMENTAL -- don't use this
+-- vertical typesetting: EXPERIMENTAL
------------------------------------
----[[no vwidth in luaotfload v2
-local tsbtable = {}
-
-local function read_tsb_table(filename)-- for ttx-generated vmtx table
- if tsbtable[filename] then
- return tsbtable[filename]
+local tsbtable, mytime, currtime, cachedir, lfsattributes, lfstouch
+
+local function get_vwidth_tsb_table (filename,fontname)
+ if tsbtable[fontname] then return tsbtable[fontname] end
+ local cachefile = stringformat("%s/luatexko_vertical_metrics_%s.lua",
+ cachedir,stringgsub(fontname,"%W","_"))
+ local cattr = lfs.isfile(cachefile) and lfsattributes(cachefile)
+ local fonttime = lfsattributes(filename,"modification")
+ if cattr and cattr.access > mytime and cattr.modification == fonttime then
+ tsbtable[fontname] = dofile(cachefile)
+ return tsbtable[fontname]
end
- local filepath = kpse.find_file(filename)
- if not filepath then return end
- local file = io.open(filepath, "r")
- if not file then return end
- local tsbtb = {}
- local patt = 'name="(.-)" height="(.-)" tsb="(.-)"'
- while true do
- local l = file:read("*line")
- if not l then break end
- for name, height, tsb in stringgmatch(l,patt) do
- tsbtb[name] = {}
- tsbtb[name].height = height
- tsbtb[name].tsb = tsb
+ local metrics = nil
+ local font = fontloader.open(filename,fontname)
+ if font then
+ metrics = fontloader.to_table(font)
+ fontloader.close(font)
+ local glyph_t = {}
+ if metrics.subfonts then
+ for _,v in ipairs(metrics.subfonts) do
+ for ii,vv in pairs(v.glyphs) do
+ glyph_t[ii] = { ht = vv.vwidth, tsb = vv.tsidebearing }
+ end
+ end
+ else
+ for i,v in ipairs(metrics.glyphs) do
+ glyph_t[i] = { ht = v.vwidth, tsb = v.tsidebearing }
+ end
end
+ if lfstouch then
+ table.tofile(cachefile,glyph_t,"return")
+ if not lfstouch(cachefile,currtime,fonttime) then
+ warn("Writing cache file '%s' failed!",cachefile)
+ end
+ end
+ tsbtable[fontname] = glyph_t
+ return glyph_t
end
- file:close()
- tsbtable[filename] = tsbtb
- return tsbtb
end
local function cjk_vertical_font (vf)
@@ -1702,25 +1771,13 @@ local function cjk_vertical_font (vf)
if not vf.shared.features["vertical"] then return end
if vf.type == "virtual" then return end
- ---[[ for read-ttx
- local filename = vf.filename
- filename = stringgsub(filename,".*/","")
- filename = stringgsub(filename,"[tToO][tT][fF]$","ttx")
- local tsbtable = read_tsb_table(filename)
- if not tsbtable then
- warn("Cannot read %s. Aborting vertical typesetting.",filename)
- return
- end
- --]]
+ -- load font (again)
+ local tsbtable = get_vwidth_tsb_table(vf.filename,vf.fontname)
+ if not tsbtable then return end
local tmp = table.copy(vf) -- fastcopy takes time too long.
local id = fontdefine(tmp)
- local hash = vf.properties and vf.properties.hash and vf.properties.hash..' @ vertical'
- hash = hash or (vf.name and vf.size and vf.name..' @ '..vf.size..' @ vertical')
-
- vf.properties = vf.properties or {}
- vf.properties.hash = hash
vf.type = 'virtual'
vf.fonts = {{ id = id }}
local quad = vf.parameters and vf.parameters.quad or 655360
@@ -1728,31 +1785,21 @@ local function cjk_vertical_font (vf)
local ascender = vf.parameters and vf.parameters.ascender or quad*0.8
local factor = vf.parameters and vf.parameters.factor or 655.36
local xheight = vf.parameters and vf.parameters.x_height or quad/2
- local halfxht = xheight/2
+ local goffset = xheight/2 - quad/2
for i,v in pairs(vf.characters) do
local dsc = descriptions[i]
- local gname = dsc.name
- -- local vw = dsc and dsc.vwidth
- ---[[ for read-ttx
- local vw = tsbtable and tsbtable[gname] and tsbtable[gname].height
- local tsb = tsbtable and tsbtable[gname] and tsbtable[gname].tsb
- if not vw and dsc.index then
- local cid = stringformat("cid%05d", dsc.index)
- vw = tsbtable and tsbtable[cid] and tsbtable[cid].height
- tsb = tsbtable and tsbtable[cid] and tsbtable[cid].tsb
- end
- tsb = tsb and factor and tsb*factor
- --]]
+ local gl = v.index
+ -- from loaded font
+ local vw = tsbtable and tsbtable[gl] and tsbtable[gl].ht
vw = vw and vw * factor or quad
- local hw = v.width or quad
- local offset = hw/2 - quad/2 + halfxht
- local vh = (hw > 0) and hw/2 or nil
+ local tsb = tsbtable and tsbtable[gl] and tsbtable[gl].tsb
local bb4 = dsc and dsc.boundingbox and dsc.boundingbox[4]
- bb4 = bb4 and bb4*factor
- local asc = bb4 and tsb and (bb4 + tsb)
- asc = asc or ascender
+ local asc = bb4 and tsb and (bb4+tsb)*factor or ascender
+ local hw = v.width or quad
+ local offset = hw/2 + goffset
+ local vh = hw > 0 and hw/2 or nil
v.commands = {
- {'right', asc}, -- bbox4 + top_side_bearing! But, tsb not available!
+ {'right', asc}, -- bbox4 + top_side_bearing
{'down', offset},
{'special', 'pdf: q 0 1 -1 0 0 0 cm'},
{'push'},
@@ -1800,6 +1847,15 @@ local function activate_vertical_virtual (tfmdata,value)
local loaded = luatexbase.priority_in_callback("luaotfload.patch_font",
"luatexko.vertical_virtual_font")
if value and not loaded then
+ require "fontloader"
+ require "lfs"
+ lfstouch = lfs.touch
+ lfsattributes = lfs.attributes
+ tsbtable = {}
+ currtime = os.time()
+ mytime = kpse_find_file("luatexko.lua")
+ mytime = mytime and lfsattributes(mytime,"modification")
+ cachedir = caches.getwritablepath("..","luatexko")
add_to_callback("luaotfload.patch_font",
cjk_vertical_font,
"luatexko.vertical_virtual_font")
@@ -1814,7 +1870,6 @@ otffeatures.register {
node = activate_vertical_virtual,
}
}
---no vwidth in luaotfload v2]]
------------------------------------
-- italic correction for fake-slant font
@@ -1834,7 +1889,62 @@ local function fakeslant_itlc (tfmdata)
end
end
+------------------------------------
+-- tounicode for old hangul
+------------------------------------
+local function tounicode_oldhangul (tfmdata)
+ local script = tfmdata.properties and tfmdata.properties.script
+ if script ~= "hang" then return end
+ local desc = tfmdata.shared and tfmdata.shared.rawdata and tfmdata.shared.rawdata.descriptions
+ local chrs = tfmdata.characters
+ if not desc or not chrs then return end
+ if not chrs[0x1100] then return end
+ local last = 0
+ for _,v in ipairs({{0x1100,0x11FF},{0xA960,0xA97C},{0xD7B0,0xD7FB}}) do
+ for i = v[1],v[2] do
+ local ds = desc[i] and desc[i].slookups
+ if ds then
+ for _,s in pairs(ds) do
+ if type(s) == "number" and s >= 0xF0000 and chrs[s] and not chrs[s].tounicode then
+ chrs[s].tounicode = stringformat("%04X",i)
+ last = s > last and s or last
+ end
+ end
+ end
+ end
+ end
+ if stringfind(tfmdata.fontname,"^HCR.+LVT") then
+ local touni = "1112119E"
+ for i = last+1, last+2 do
+ local dsc,chr = desc[i],chrs[i]
+ if dsc and chr and dsc.class == "ligature" and not chr.tounicode then
+ chr.tounicode = touni
+ end
+ touni = touni.."11AB"
+ end
+ end
+end
+
add_to_callback("luaotfload.patch_font",
- fakeslant_itlc,
- "luatexko.fakeslant_itlc")
+ function(tfmdata)
+ fakeslant_itlc(tfmdata)
+ tounicode_oldhangul(tfmdata)
+ end, "luatexko.font_patches")
+
+------------------------------------
+-- Actual Text
+------------------------------------
+local function actualtext (str)
+ local t = {}
+ for uni in string.utfvalues(str) do
+ if uni < 0x10000 then
+ t[#t+1] = stringformat("%04X",uni)
+ else -- surrogate
+ uni = uni - 0x10000
+ t[#t+1] = stringformat("%04X%04X", uni/0x400+0xD800, uni%0x400+0xDC00)
+ end
+ end
+ tex.sprint(stringformat("<FEFF%s>", table.concat(t)))
+end
+luatexko.actualtext = actualtext
diff --git a/Master/texmf-dist/tex/luatex/luatexko/luatexko.sty b/Master/texmf-dist/tex/luatex/luatexko/luatexko.sty
index 5d6d6d69fa8..a34b53bae9a 100644
--- a/Master/texmf-dist/tex/luatex/luatexko/luatexko.sty
+++ b/Master/texmf-dist/tex/luatex/luatexko/luatexko.sty
@@ -1,6 +1,6 @@
% luatexko.sty
%
-% Copyright (c) 2013 Dohyun Kim <nomos at ktug org>
+% Copyright (c) 2013-2014 Dohyun Kim <nomos at ktug org>
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3c
@@ -22,162 +22,282 @@
\expandafter\endinput
\fi
-\ProvidesPackage{luatexko}[2014/01/15 v1.4 Typesetting Korean with LuaLaTeX]
-\RequirePackage{fontspec}
-\RequirePackage{luatexko-core}
-
-%% fontspec Korean options
-\ExplSyntaxOn
-
-\DeclareDocumentCommand \newhangulfontfeature {mmmm}
- {
- \fontspec_define_font_feature:n {#1}
- \keys_define:nn {fontspec}
- {
- #1 .default:n = {#3} ,
- #1 / unknown .code:n = {
- \fontspec_update_fontid:n {#2:##1}
- \fontspec_update_featstr:n {#2=##1}#4
- }
- }
- }
-
-\fontspec_define_font_feature:n {YetHangul}
-\keys_define:nn {fontspec}
- {
- YetHangul .default:n = {On} ,
- YetHangul / On .code:n = {
- \fontspec_update_fontid:n {yethangul:on}
- \fontspec_update_featstr:n {script=hang;+ccmp;+ljmo;+vjmo;+tjmo}
- } ,
- YetHangul / Off .code:n = {
- \fontspec_update_fontid:n {yethangul:off}
- \fontspec_update_featstr:n {-ljmo;-vjmo;-tjmo}
- }
- }
-
-\ExplSyntaxOff
-
-\newhangulfontfeature{InterHangul}{interhangul}{0}{}
-\newhangulfontfeature{InterLatinCJK}{interlatincjk}{0}{}
-\newhangulfontfeature{PunctRaise}{punctraise}{0}{}
-\newhangulfontfeature{CharRaise}{charraise}{0}{}
-\newhangulfontfeature{Protrusion}{protrusion}{default}{\aftergroup\pdfprotrudechars\aftergroup\tw@}
-\newhangulfontfeature{Expansion}{expansion}{default}{\aftergroup\pdfadjustspacing\aftergroup\tw@}
-
-%% macros for Korean fonts
-\protected\def\setmainhangulfont{\newfontfamily\serifhangul@font}
-\protected\def\setmainhanjafont {\newfontfamily\serifhanja@font}
-\protected\def\setmainfallbackfont{\newfontfamily\seriffallback@font}
-\protected\def\setsanshangulfont{\newfontfamily\sanshangul@font}
-\protected\def\setsanshanjafont {\newfontfamily\sanshanja@font}
-\protected\def\setsansfallbackfont{\newfontfamily\sansfallback@font}
-\protected\def\setmonohangulfont{\newfontfamily\monohangul@font}
-\protected\def\setmonohanjafont {\newfontfamily\monohanja@font}
-\protected\def\setmonofallbackfont{\newfontfamily\monofallback@font}
-
-\protected\def\newhangulfontfamily#1{%
- \protected\def#1{\expandafter\let\expandafter\hangul@font
- \csname luatexko@\string#1\endcsname
- \luatexko@hangul@selectfont}\expandafter\newfontfamily
- \csname luatexko@\string#1\endcsname}
-\protected\def\newhanjafontfamily#1{%
- \protected\def#1{\expandafter\let\expandafter\hanja@font
- \csname luatexko@\string#1\endcsname
- \luatexko@hanja@selectfont}\expandafter\newfontfamily
- \csname luatexko@\string#1\endcsname}
-\protected\def\newfallbackfontfamily#1{%
- \protected\def#1{\expandafter\let\expandafter\fallback@font
- \csname luatexko@\string#1\endcsname
- \luatexko@fallback@selectfont}\expandafter\newfontfamily
- \csname luatexko@\string#1\endcsname}
+\ProvidesPackage{luatexko}[2014/05/11 v1.5 Typesetting Korean with LuaLaTeX]
-\protected\def\newhangulfontface#1{%
- \protected\def#1{\expandafter\let\expandafter\hangul@font
- \csname luatexko@\string#1\endcsname
- \luatexko@hangul@selectfont}\expandafter\newfontface
- \csname luatexko@\string#1\endcsname}
-\protected\def\newhanjafontface#1{%
- \protected\def#1{\expandafter\let\expandafter\hanja@font
- \csname luatexko@\string#1\endcsname
- \luatexko@hanja@selectfont}\expandafter\newfontface
- \csname luatexko@\string#1\endcsname}
-\protected\def\newfallbackfontface#1{%
- \protected\def#1{\expandafter\let\expandafter\fallback@font
- \csname luatexko@\string#1\endcsname
- \luatexko@fallback@selectfont}\expandafter\newfontface
- \csname luatexko@\string#1\endcsname}
+%% package options
+\newif\if@hangul
+\newif\if@hanja
+\newif\if@unfonts
+\newif\if@luatexko@loadfontspec\@luatexko@loadfontspectrue
+\DeclareOption{hangul}{\@hangultrue}
+\DeclareOption{hanja}{\@hangultrue\@hanjatrue}
+\DeclareOption{unfonts}{\@unfontstrue}
+\DeclareOption{nofontspec}{\@luatexko@loadfontspecfalse}
+\ProcessOptions\relax
-\protected\def\hangulfontspec#1#{%
- \def\luatexko@fontspec@temp{#1}\hangulfontspec@}
-\def\hangulfontspec@#1{%
- \expandafter\newfontfamily\expandafter\hangul@font\luatexko@fontspec@temp{#1}%
- \luatexko@hangul@selectfont\ignorespaces}
-\let\adhochangulfont\hangulfontspec
-\protected\def\hanjafontspec#1#{%
- \def\luatexko@fontspec@temp{#1}\hanjafontspec@}
-\def\hanjafontspec@#1{%
- \expandafter\newfontfamily\expandafter\hanja@font\luatexko@fontspec@temp{#1}%
- \luatexko@hanja@selectfont\ignorespaces}
-\let\adhochanjafont\hanjafontspec
-\protected\def\fallbackfontspec#1#{%
- \def\luatexko@fontspec@temp{#1}\fallbackfontspec@}
-\def\fallbackfontspec@#1{%
- \expandafter\newfontfamily\expandafter\fallback@font\luatexko@fontspec@temp{#1}%
- \luatexko@fallback@selectfont\ignorespaces}
-\let\adhocfallbackfont\fallbackfontspec
+\if@luatexko@loadfontspec
+ %% euenc redefines \f@size by \DeclareErrorFont. sigh
+ \let\luatexko@f@size\f@size
+ \RequirePackage{fontspec}
+ \let\f@size\luatexko@f@size
+\fi
-% add{hangul/hanja}fontfeature
-\protected\def\addhangulfontfeature#1{%
- \begingroup
- \check@hangul@family
- \ifdefined\hangul@font\hangul@font\fi\addfontfeature{#1}%
- \global\let\luatexko@fontspec@temp\f@family
- \endgroup
- \def\hangul@font{\fontfamily\luatexko@fontspec@temp\selectfont}%
- \luatexko@hangul@selectfont \ignorespaces}
-\let\addhangulfontfeatures\addhangulfontfeature
-\protected\def\addhanjafontfeature#1{%
- \begingroup
- \check@hanja@family
- \ifdefined\hanja@font\hanja@font\fi\addfontfeature{#1}%
- \global\let\luatexko@fontspec@temp\f@family
- \endgroup
- \def\hanja@font{\fontfamily\luatexko@fontspec@temp\selectfont}%
- \luatexko@hanja@selectfont \ignorespaces}
-\let\addhanjafontfeatures\addhanjafontfeature
-\protected\def\addfallbackfontfeature#1{%
- \begingroup
- \check@fallback@family
- \ifdefined\fallback@font\fallback@font\fi\addfontfeature{#1}%
- \global\let\luatexko@fontspec@temp\f@family
- \endgroup
- \def\fallback@font{\fontfamily\luatexko@fontspec@temp\selectfont}%
- \luatexko@fallback@selectfont \ignorespaces}
-\let\addfallbackfontfeatures\addfallbackfontfeature
+\RequirePackage{luatexko-core}
-% check hangul/hanja family
-\def\check@hangul@family{%
- \unless\ifdefined\hangul@font
- \ifx\f@family\sfdefault \let\hangul@font\sanshangul@font
- \else\ifx\f@family\ttdefault \let\hangul@font\monohangul@font
- \else \let\hangul@font\serifhangul@font
- \fi\fi\fi
-}
-\def\check@hanja@family{%
- \unless\ifdefined\hanja@font
- \ifx\f@family\sfdefault \let\hanja@font\sanshanja@font
- \else\ifx\f@family\ttdefault \let\hanja@font\monohanja@font
- \else \let\hanja@font\serifhanja@font
- \fi\fi\fi
-}
-\def\check@fallback@family{%
- \unless\ifdefined\fallback@font
- \ifx\f@family\sfdefault \let\fallback@font\sansfallback@font
- \else\ifx\f@family\ttdefault \let\fallback@font\monofallback@font
- \else \let\fallback@font\seriffallback@font
- \fi\fi\fi
-}
+\if@luatexko@loadfontspec
+ %% fontspec Korean options
+ \newfontfeature{YetHangul}{script=hang}
+ \newfontfeature{InterHangul}{interhangul=#1}
+ \newfontfeature{InterLatinCJK}{interlatincjk=#1}
+ \newfontfeature{PunctRaise}{punctraise=#1}
+ \newfontfeature{CharRaise}{charraise=#1}
+ \ExplSyntaxOn
+ \DeclareDocumentCommand \newhangulfontfeature {mmmm}
+ {
+ \keys_define:nn { fontspec }
+ {
+ #1 .code:n =
+ {
+ \fontspec_update_featstr:n {#2=##1}
+ #4
+ },
+ #1 .default:n = {#3}
+ }
+ }
+ \newhangulfontfeature{Protrusion}{protrusion}{default}
+ {\aftergroup\pdfprotrudechars\aftergroup\tw@}
+ \newhangulfontfeature{Expansion}{expansion}{default}
+ {\aftergroup\pdfadjustspacing\aftergroup\tw@}
+ %% macros for Korean fonts
+ \DeclareDocumentCommand \setmainhangulfont { O{} m }
+ {
+ \newfontfamily \serifhangul@font [#1] {#2}
+ \str_if_eq_x:nnT \familydefault \rmdefault
+ {
+ \cs_set_eq:NN \hangul@font \serifhangul@font
+ \luatexko@hangul@selectfont
+ }
+ \ignorespaces
+ }
+ \DeclareDocumentCommand \setmainhanjafont { O{} m }
+ {
+ \newfontfamily \serifhanja@font [#1] {#2}
+ \str_if_eq_x:nnT \familydefault \rmdefault
+ {
+ \cs_set_eq:NN \hanja@font \serifhanja@font
+ \luatexko@hanja@selectfont
+ }
+ \ignorespaces
+ }
+ \DeclareDocumentCommand \setmainfallbackfont { O{} m }
+ {
+ \newfontfamily \seriffallback@font [#1] {#2}
+ \str_if_eq_x:nnT \familydefault \rmdefault
+ {
+ \cs_set_eq:NN \fallback@font \seriffallback@font
+ \luatexko@fallback@selectfont
+ }
+ \ignorespaces
+ }
+ \DeclareDocumentCommand \setsanshangulfont { O{} m }
+ {
+ \newfontfamily \sanshangul@font [#1] {#2}
+ \str_if_eq_x:nnT \familydefault \sfdefault
+ {
+ \cs_set_eq:NN \hangul@font \sanshangul@font
+ \luatexko@hangul@selectfont
+ }
+ \ignorespaces
+ }
+ \DeclareDocumentCommand \setsanshanjafont { O{} m }
+ {
+ \newfontfamily \sanshanja@font [#1] {#2}
+ \str_if_eq_x:nnT \familydefault \sfdefault
+ {
+ \cs_set_eq:NN \hanja@font \sanshanja@font
+ \luatexko@hanja@selectfont
+ }
+ \ignorespaces
+ }
+ \DeclareDocumentCommand \setsansfallbackfont { O{} m }
+ {
+ \newfontfamily \sansfallback@font [#1] {#2}
+ \str_if_eq_x:nnT \familydefault \sfdefault
+ {
+ \cs_set_eq:NN \fallback@font \sansfallback@font
+ \luatexko@fallback@selectfont
+ }
+ \ignorespaces
+ }
+ \DeclareDocumentCommand \setmonohangulfont { O{} m }
+ {
+ \newfontfamily \monohangul@font [#1] {#2}
+ \str_if_eq_x:nnT \familydefault \ttdefault
+ {
+ \cs_set_eq:NN \hangul@font \monohangul@font
+ \luatexko@hangul@selectfont
+ }
+ \ignorespaces
+ }
+ \DeclareDocumentCommand \setmonohanjafont { O{} m }
+ {
+ \newfontfamily \monohanja@font [#1] {#2}
+ \str_if_eq_x:nnT \familydefault \ttdefault
+ {
+ \cs_set_eq:NN \hanja@font \monohanja@font
+ \luatexko@hanja@selectfont
+ }
+ \ignorespaces
+ }
+ \DeclareDocumentCommand \setmonofallbackfont { O{} m }
+ {
+ \newfontfamily \monofallback@font [#1] {#2}
+ \str_if_eq_x:nnT \familydefault \ttdefault
+ {
+ \cs_set_eq:NN \fallback@font \monofallback@font
+ \luatexko@fallback@selectfont
+ }
+ \ignorespaces
+ }
+ \DeclareDocumentCommand \newhangulfontfamily { m O{} m }
+ {
+ \exp_after:wN \newfontfamily
+ \cs:w luatexkofont@ \token_to_str:N #1 \cs_end: [#2] {#3}
+ \DeclareRobustCommand #1
+ {
+ \cs_set_eq:Nc \hangul@font { luatexkofont@ \token_to_str:N #1 }
+ \luatexko@hangul@selectfont
+ }
+ }
+ \DeclareDocumentCommand \newhanjafontfamily { m O{} m }
+ {
+ \exp_after:wN \newfontfamily
+ \cs:w luatexkofont@ \token_to_str:N #1 \cs_end: [#2] {#3}
+ \DeclareRobustCommand #1
+ {
+ \cs_set_eq:Nc \hanja@font { luatexkofont@ \token_to_str:N #1 }
+ \luatexko@hanja@selectfont
+ }
+ }
+ \DeclareDocumentCommand \newfallbackfontfamily { m O{} m }
+ {
+ \exp_after:wN \newfontfamily
+ \cs:w luatexkofont@ \token_to_str:N #1 \cs_end: [#2] {#3}
+ \DeclareRobustCommand #1
+ {
+ \cs_set_eq:Nc \fallback@font { luatexkofont@ \token_to_str:N #1 }
+ \luatexko@fallback@selectfont
+ }
+ }
+ \DeclareDocumentCommand \newhangulfontface { m O{} m }
+ {
+ \exp_after:wN \newfontface
+ \cs:w luatexkofont@ \token_to_str:N #1 \cs_end: [#2] {#3}
+ \DeclareRobustCommand #1
+ {
+ \cs_set_eq:Nc \hangul@font { luatexkofont@ \token_to_str:N #1 }
+ \luatexko@hangul@selectfont
+ }
+ }
+ \DeclareDocumentCommand \newhanjafontface { m O{} m }
+ {
+ \exp_after:wN \newfontface
+ \cs:w luatexkofont@ \token_to_str:N #1 \cs_end: [#2] {#3}
+ \DeclareRobustCommand #1
+ {
+ \cs_set_eq:Nc \hanja@font { luatexkofont@ \token_to_str:N #1 }
+ \luatexko@hanja@selectfont
+ }
+ }
+ \DeclareDocumentCommand \newfallbackfontface { m O{} m }
+ {
+ \exp_after:wN \newfontface
+ \cs:w luatexkofont@ \token_to_str:N #1 \cs_end: [#2] {#3}
+ \DeclareRobustCommand #1
+ {
+ \cs_set_eq:Nc \fallback@font { luatexkofont@ \token_to_str:N #1 }
+ \luatexko@fallback@selectfont
+ }
+ }
+ \DeclareDocumentCommand \hangulfontspec { O{} m }
+ {
+ \newfontfamily \hangul@font [#1] {#2}
+ \luatexko@hangul@selectfont
+ \ignorespaces
+ }
+ \cs_set_eq:NN \adhochangulfont \hangulfontspec
+ \DeclareDocumentCommand \hanjafontspec { O{} m }
+ {
+ \newfontfamily \hanja@font [#1] {#2}
+ \luatexko@hanja@selectfont
+ \ignorespaces
+ }
+ \cs_set_eq:NN \adhochanjafont \hanjafontspec
+ \DeclareDocumentCommand \fallbackfontspec { O{} m }
+ {
+ \newfontfamily \fallback@font [#1] {#2}
+ \luatexko@fallback@selectfont
+ \ignorespaces
+ }
+ \cs_set_eq:NN \adhocfallbackfont \fallbackfontspec
+ \DeclareDocumentCommand \addhangulfontfeature { m }
+ {
+ \group_begin:
+ \cs_if_exist:NT \hangul@font { \hangul@font }
+ \addfontfeature {#1}
+ \use:x
+ {
+ \group_end:
+ \exp_not:N \tl_set:Nn \exp_not:N \hangul@font
+ {
+ \exp_not:N \fontfamily { \f@family } \exp_not:N \selectfont
+ }
+ }
+ \luatexko@hangul@selectfont
+ \ignorespaces
+ }
+ \cs_set_eq:NN \addhangulfontfeatures \addhangulfontfeature
+ \DeclareDocumentCommand \addhanjafontfeature { m }
+ {
+ \group_begin:
+ \cs_if_exist:NT \hanja@font { \hanja@font }
+ \addfontfeature {#1}
+ \use:x
+ {
+ \group_end:
+ \exp_not:N \tl_set:Nn \exp_not:N \hanja@font
+ {
+ \exp_not:N \fontfamily { \f@family } \exp_not:N \selectfont
+ }
+ }
+ \luatexko@hanja@selectfont
+ \ignorespaces
+ }
+ \cs_set_eq:NN \addhanjafontfeatures \addhanjafontfeature
+ \DeclareDocumentCommand \addfallbackfontfeature { m }
+ {
+ \group_begin:
+ \cs_if_exist:NT \fallback@font { \fallback@font }
+ \addfontfeature {#1}
+ \use:x
+ {
+ \group_end:
+ \exp_not:N \tl_set:Nn \exp_not:N \fallback@font
+ {
+ \exp_not:N \fontfamily { \f@family } \exp_not:N \selectfont
+ }
+ }
+ \luatexko@fallback@selectfont
+ \ignorespaces
+ }
+ \cs_set_eq:NN \addfallbackfontfeatures \addfallbackfontfeature
+ % hangul math font command
+ \DeclareDocumentCommand \setmathhangulfont { O{} m }
+ {
+ \fontspec_set_family:Nnn \luatexko@math@hangul@family {#1} {#2}
+ }
+ \ExplSyntaxOff
+\fi
\RequirePackage{everysel}
\EverySelectfont{%
@@ -186,33 +306,55 @@
\luatexko@fallback@selectfont
}
-% don't forget to redefine \normalfont
-\protected\edef\normalfont{\unexpanded{%
- \let\hangul@font\luatexko@undefined
- \let\hanja@font\luatexko@undefined
- \let\fallback@font\luatexko@undefined
- }%
- \unexpanded\expandafter{\normalfont}}
-\let\reset@font\normalfont
-
-% normal : finemathattr = 1
+% serif : finemathattr = 2
+% sans : finemathattr = 1
% tt : finemathattr = 0
-% verbatim : finemathattr = off
-\protected\edef\ttfamily{\unexpanded\expandafter{\ttfamily
- \finemathattr\z@}}
+% verbatim : finemathattr = nil
+\def\luatexko@serif@fonts{%
+ \let\hangul@font\serifhangul@font
+ \let\hanja@font\serifhanja@font
+ \let\fallback@font\seriffallback@font
+ \finemathattr\tw@
+}
+\def\luatexko@sans@fonts{%
+ \let\hangul@font\sanshangul@font
+ \let\hanja@font\sanshanja@font
+ \let\fallback@font\sansfallback@font
+ \finemathattr\@ne
+}
+\def\luatexko@mono@fonts{%
+ \let\hangul@font\monohangul@font
+ \let\hanja@font\monohanja@font
+ \let\fallback@font\monofallback@font
+ \finemathattr\z@
+}
+
+\protected\edef\rmfamily{%
+ \unexpanded{\luatexko@serif@fonts}\unexpanded\expandafter{\rmfamily}}
+\protected\edef\sffamily{%
+ \unexpanded{\luatexko@sans@fonts}\unexpanded\expandafter{\sffamily}}
+\protected\edef\ttfamily{%
+ \unexpanded{\luatexko@mono@fonts}\unexpanded\expandafter{\ttfamily}}
\edef\verbatim@font{\unexpanded\expandafter{\verbatim@font
\unsetluatexattribute\finemathattr}}
-%% package options
-\newif\if@hangul
-\newif\if@hanja
-\newif\if@unfonts
-\DeclareOption{hangul}{\@hangultrue}
-\DeclareOption{hanja}{\@hangultrue\@hanjatrue}
-\DeclareOption{unfonts}{\@unfontstrue}
-\ProcessOptions\relax
+% don't forget to redefine \normalfont
+\expandafter\ifx\familydefault\rmdefault
+ \protected\edef\normalfont{%
+ \unexpanded{\luatexko@serif@fonts}\unexpanded\expandafter{\normalfont}}
+ \finemathattr\tw@
+\else\expandafter\ifx\familydefault\sfdefault
+ \protected\edef\normalfont{%
+ \unexpanded{\luatexko@sans@fonts}\unexpanded\expandafter{\normalfont}}
+ \finemathattr\@ne
+\else
+ \protected\edef\normalfont{%
+ \unexpanded{\luatexko@mono@fonts}\unexpanded\expandafter{\normalfont}}
+ \finemathattr\z@
+\fi\fi
+\let\reset@font\normalfont
-\if@unfonts
+\if@unfonts\if@luatexko@loadfontspec
\setmainhangulfont[
InterHangul=-0.04em,
InterLatinCJK=0.125em,
@@ -238,15 +380,15 @@
BoldSlantedFont=*Bold, BoldSlantedFeatures={FakeSlant=0.2},
BoldItalicFont=*Bold, BoldItalicFeatures={FakeSlant=0.2},
]{UnDotum}
-\fi
+\fi\fi
\AtBeginDocument{
\unless\ifdefined\serifhangul@font\let\serifhangul@font\sanshangul@font\fi
\unless\ifdefined\sanshangul@font \let\sanshangul@font\serifhangul@font\fi
\unless\ifdefined\monohangul@font \let\monohangul@font\sanshangul@font \fi
-\luatexko@hangul@selectfont
-\luatexko@hanja@selectfont
-\luatexko@fallback@selectfont
+\unless\ifdefined\serifhangul@font\unless\ifdefined\sanshangul@font
+ \hangulpunctuations=0 % nanumtype1
+\fi\fi
% for hyperref
\@ifpackageloaded{hyperref}{\pdfstringdefDisableCommands{%
\let\dotemph\@firstofone
@@ -258,6 +400,8 @@
\let\uwave\@firstofone
\let\dashuline\@firstofone
\let\dotuline\@firstofone
+ \let\actualtext\@firstofone
+ \let\inhibitglue\empty
\def\는{는}%
\def\은{은}%
\def\을{을}%
@@ -272,25 +416,24 @@
}}{}
}
-%% hangul in math --- latex
-\protected\def\setmathhangulfont{%
- \@ifnextchar[{\setmathhangul@font@}{\setmathhangul@font@[]}}
-\def\setmathhangul@font@[#1]#2{%
- \zf@fontspec{#1}{#2}\xdef\luatexko@math@hangul@family{\zf@family}}
-\AtBeginDocument{%
- \begingroup
- \unless\ifdefined\luatexko@math@hangul@family
- \check@hangul@family
- \ifdefined\hangul@font \hangul@font \fi
- \xdef\luatexko@math@hangul@family{\f@family}%
+\if@luatexko@loadfontspec
+ %% hangul in math --- latex
+ \AtBeginDocument{
+ \begingroup
+ \unless\ifdefined\luatexko@math@hangul@family
+ \ifdefined\hangul@font \hangul@font \fi
+ \xdef\luatexko@math@hangul@family{\f@family}%
+ \fi
+ \endgroup
+ \DeclareSymbolFont{mathhangul}%
+ \zf@enc\luatexko@math@hangul@family\mddefault\updefault
+ \ifcsname\zf@enc/\luatexko@math@hangul@family/\bfdefault/\updefault\endcsname
+ \SetSymbolFont{mathhangul}{bold}%
+ \zf@enc\luatexko@math@hangul@family\bfdefault\updefault
\fi
- \endgroup
- \DeclareSymbolFont{mathhangul}\zf@enc\luatexko@math@hangul@family\mddefault\updefault
- \ifcsname\zf@enc/\luatexko@math@hangul@family/\bfdefault/\updefault\endcsname
- \SetSymbolFont{mathhangul}{bold}\zf@enc\luatexko@math@hangul@family\bfdefault\updefault
- \fi
- \setmathhangulblock{AC00}{D7A3}
-}
+ \setmathhangulblock{AC00}{D7A3}
+ }
+\fi
\RequirePackage{kolabels-utf}
\if@hangul