From e3ab92df447cf11f30d0c6e59d7877d938209c83 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 2 Dec 2019 21:59:03 +0000 Subject: luatexko (2dec19) git-svn-id: svn://tug.org/texlive/trunk@53001 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/luatex/luatexko/ChangeLog | 7 + Master/texmf-dist/doc/luatex/luatexko/README | 2 +- .../doc/luatex/luatexko/luatexko-doc.pdf | Bin 288860 -> 291555 bytes .../doc/luatex/luatexko/luatexko-doc.tex | 179 +++++--- .../tex/luatex/luatexko/luatexko-normalize.lua | 4 +- .../tex/luatex/luatexko/luatexko-uhc2utf8.lua | 4 +- Master/texmf-dist/tex/luatex/luatexko/luatexko.lua | 499 ++++++++++++++------- Master/texmf-dist/tex/luatex/luatexko/luatexko.sty | 69 +-- 8 files changed, 493 insertions(+), 271 deletions(-) diff --git a/Master/texmf-dist/doc/luatex/luatexko/ChangeLog b/Master/texmf-dist/doc/luatex/luatexko/ChangeLog index 38e815ea960..68169c3efbe 100644 --- a/Master/texmf-dist/doc/luatex/luatexko/ChangeLog +++ b/Master/texmf-dist/doc/luatex/luatexko/ChangeLog @@ -1,3 +1,10 @@ +2019-12-01 Dohyun Kim + + Version 2.5 + + * luatexko.lua: start to support luahbtex + * luatexko.sty: 2020 expl3 deprecation removals + 2019-08-01 Dohyun Kim Version 2.4 diff --git a/Master/texmf-dist/doc/luatex/luatexko/README b/Master/texmf-dist/doc/luatex/luatexko/README index 1284ed2271e..9f57e298285 100644 --- a/Master/texmf-dist/doc/luatex/luatexko/README +++ b/Master/texmf-dist/doc/luatex/luatexko/README @@ -1,4 +1,4 @@ -LuaTeX-ko Package version 2.4 (2019/08/01) +LuaTeX-ko Package version 2.5 (2019/12/01) =========================================== This is a Lua(La)TeX macro package that supports typesetting Korean diff --git a/Master/texmf-dist/doc/luatex/luatexko/luatexko-doc.pdf b/Master/texmf-dist/doc/luatex/luatexko/luatexko-doc.pdf index 0eb5a5078fc..91e26a46747 100644 Binary files a/Master/texmf-dist/doc/luatex/luatexko/luatexko-doc.pdf and b/Master/texmf-dist/doc/luatex/luatexko/luatexko-doc.pdf differ diff --git a/Master/texmf-dist/doc/luatex/luatexko/luatexko-doc.tex b/Master/texmf-dist/doc/luatex/luatexko/luatexko-doc.tex index 517fe4d2ed4..b0785e692bc 100644 --- a/Master/texmf-dist/doc/luatex/luatexko/luatexko-doc.tex +++ b/Master/texmf-dist/doc/luatex/luatexko/luatexko-doc.tex @@ -43,6 +43,7 @@ Expansion, Protrusion=notoserifcjk, ] \setsanshangulfont{Noto Sans CJK KR}[ + \ifluahbtex Renderer=OpenType\fi, Scale=0.98, Script=Hangul, Language=Korean, @@ -83,7 +84,14 @@ \edef\verbatim{\unexpanded\expandafter{\verbatim\linespread{1.1}\selectfont}} \edef\itemize{\unexpanded\expandafter{\itemize\small}} \catcode`|=13 \protected\def|{\verb|\let\\=\textbackslash} -\protected\def\cs#1{\texttt{\language=1 \textbackslash\detokenize{#1}}} +\def\nohyphen{\language\csname l@nohyphenation\endcsname} +\protected\def\cs#1{\texttt{\nohyphen \textbackslash\detokenize{#1}}} +\protected\def\pkgkwd#1#{\leavevmode + \ifx\relax#1\relax \expandafter\luatexkopkgkwd + \else \expandafter\luatexkopkgkwdX \fi} +\def\luatexkopkgkwd#1{\texttt{\nohyphen \string#1}\luatexkopkgkwdX{#1}} +\def\luatexkopkgkwdX#1{\marginpar{% + \hfuzz\maxdimen \texttt{\nohyphen \footnotesize \string#1}}} \def\logoko{\textsf{k}\kern-.0625em\textit{o}} \def\luatexko{\luatex-\logoko} \def\texlive{\TeX\ Live} @@ -96,13 +104,15 @@ \author{Dohyun Kim \normalsize || \and Soojin Nam \normalsize || \and \normalsize <\url{http://github.com/dohyunkim/luatexko}>} -\date{Version 2.4\quad 2019/08/01} +\date{Version 2.5\quad 2019/12/01} \maketitle \begin{quote}\small For a summary introduction in English, please see |README| file. \begin{itemize}\linespread{1.1}\selectfont + \item[v2.5] ------ + \item LuaHB\TeX\ 지원 \item[v2.2] ------ \item \hyperref[sec:fontoption]{글꼴옵션 |InterCharStretch| 제공} \item[v2.0] ------ @@ -135,7 +145,7 @@ CP949 인코딩에 관해서는 제\ref{sec:uhcencoding}절 참조. \section{패키지 옵션}\label{sec:packageopt} -패키지 옵션으로 |[hangul]|과 |[hanja]|가 제공된다.% +패키지 옵션으로 \pkgkwd{hangul}과 \pkgkwd{hanja}가 제공된다.% \footnote{% |[nofontspec]| 옵션은 v2.0부터 더는 제공되지 않는다. } 행간격 조정이 행해지며 @@ -145,8 +155,8 @@ CP949 인코딩에 관해서는 제\ref{sec:uhcencoding}절 참조. \section{글꼴명령}\label{sec:fontcmds} -\luatexko를 로드하면 fontspec 패키지를 자동으로 불러온다. 글꼴 설정에 -대해서는 fontspec 문서를 참조. +\luatexko를 로드하면 fontspec 패키지를 자동으로 불러온다. 글꼴 설정은 +fontspec 문서를 참조. 한국어 글꼴을 위해 새로 마련한 명령은 다음과 같다. 첫 두 줄, 즉 main/sans 글꼴들에는 |Ligatures=TeX| 옵션이 자동으로 주어진다.% @@ -159,6 +169,13 @@ CP949 인코딩에 관해서는 제\ref{sec:uhcencoding}절 참조. \cs{hangulfont=UnDotum\relax}\\ \cs{hanjafont=UnDotum at 14pt}\\ \cs{fallbackfont=HanaMinB at 12pt} } +\pkgkwd*{\setmainhangulfont}% +\pkgkwd*{\setsanshangulfont}% +\pkgkwd*{\setmonohangulfont}% +\pkgkwd*{\newhangulfontfamily}% +\pkgkwd*{\newhangulfontface}% +\pkgkwd*{\addhangulfontfeature}% +\pkgkwd*{\hangulfontspec}% \begin{verbatim} \setmainhangulfont \setmainhanjafont \setmainfallbackfont \setsanshangulfont \setsanshanjafont \setsansfallbackfont @@ -179,22 +196,23 @@ CP949 인코딩에 관해서는 제\ref{sec:uhcencoding}절 참조. \footnote{% 은글꼴 트루타입은 \texlive에 포함되어 있다. } -하지만 \cs{hangulbyhangulfont=1}을 선언하면 한글은 우선 한글폰트로 -식자한다. 또한 \cs{hanjabyhanjafont=1}을 선언하면 한자는 우선 한자폰트로 +하지만 \pkgkwd{\hangulbyhangulfont}|=1|을 선언하면 한글은 우선 한글폰트로 +식자한다. 또한 \pkgkwd{\hanjabyhanjafont}|=1|을 선언하면 한자는 우선 한자폰트로 식자한다. 두 경우 모두 |0|을 선언하면 원래 방식으로 되돌아간다. 문단 중간에서 사용해도 동작한다. 그러나 루아코드가 실행되므로 텍의 그룹에 의해 영향받지 않는 전역적 효과를 가진다. 일정한 영문 문장부호들은 한글 폰트로 식자된다. -즉, \cs{hangulpunctuations=1}이 기본으로 작동하고, +즉, \pkgkwd{\hangulpunctuations}|=1|이 기본으로 작동하고, |0|을 지시해야 이 기능이 비로소 꺼진다. verbatim 코드를 식자할 때는 이 기능이 작동하지 않는다.% \footnote{% - 좀 더 정확히 말하면 \cs{language=1} 상황에서는 작동하지 않는다. - 부연하건대, \cs{language=1}인 상황에서 작동하지 않는 그밖의 기능들은 - 다음과 같다: 줄바꿈 허용, InterCharacter, InterHangul, InterLatinCJK, - CompressPunctuations, RemoveClassicSpaces, - 한글^^b7한자 폰트 문자 다음에 오는 공백의 크기 조정 등. }\,% + 정확히 말하자면 |\\language=\\l@nohyphenation|, 즉 하이프네이션이 + 허용 안 되는 상황에서는 작동하지 않는다. + 부연하건대, |\\language=\\l@nohyphenation| 상황에서 작동하지 않는 + 그밖의 기능은 다음과 같다: 줄바꿈 허용, InterCharacter, InterHangul, + InterLatinCJK, CompressPunctuations, RemoveClassicSpaces, + 한글^^b7한자 폰트 문자 다음의 공백 크기 조정 등. }\,% \footnote{% 또한 플레인텍에서는 영문글꼴을 트루타입/오픈타입으로 지정해야만 작동한다. } 영향 받는 문장부호들의 기본값은 다음과 같다: @@ -208,7 +226,9 @@ verbatim 코드를 식자할 때는 이 기능이 작동하지 않는다.% 다음과 같은 명령으로 이 목록에 문자를 추가하거나 제거할 수 있다. 인자는 콤마로 분리된 숫자 형식으로서 유니코드 코드포인트를 뜻한다. -이들 명령은 문단 중간에서도 쓸 수 있지만, 전역적 효과를 가진다. +이들 명령은 문단 중간에서도 쓸 수 있지만, 전역적 효과를 가진다.% +\pkgkwd*{\registerpunctuations}% +\pkgkwd*{\unregisterpunctuations} \begin{verbatim} \registerpunctuations{45, "2D, `-} \unregisterpunctuations{"2D, "2015} @@ -216,7 +236,9 @@ verbatim 코드를 식자할 때는 이 기능이 작동하지 않는다.% \section{줄바꿈 허용}\label{sec:break} -어떤 글자 앞이나 뒤에서 줄바꿈을 허용하고 싶을 때 아래와 같이 명령을 준다. +어떤 글자 앞이나 뒤에서 줄바꿈을 허용하고 싶을 때 아래와 같이 명령을 준다.% +\pkgkwd*{\registerbreakableafter}% +\pkgkwd*{\registerbreakablebefore} \begin{verbatim} \registerbreakableafter{"2460, "2461} \registerbreakablebefore{"2460, "2461} @@ -271,7 +293,8 @@ fontspec의 글꼴 옵션 외에 \luatexko가 따로 제공하는 것들이 있 \end{figure} \begin{description} - \item[InterHangul] {\addhangulfontfeature{InterHangul=.5ex}한글 글자 + \item[InterHangul] \pkgkwd*{InterHangul}% + {\addhangulfontfeature{InterHangul=.5ex}한글 글자 사이의 자간}. 아래는 $-0.04$em 만큼 한글 자간을 지시한다.% \footnote{% 플레인텍에서는 |interhangul=|. } @@ -279,7 +302,8 @@ fontspec의 글꼴 옵션 외에 \luatexko가 따로 제공하는 것들이 있 [InterHangul=-0.04em] \end{verbatim} -\item[InterLatinCJK] 한글 또는 한자와 Latin문자 사이의 자간을 설정한다.% +\item[InterLatinCJK] \pkgkwd*{InterLatinCJK}% + 한글 또는 한자와 Latin문자 사이의 자간을 설정한다.% \footnote{% 플레인텍에서는 |interlatincjk=|. } 한글^^b7한자 다음에 라틴 문자가 오는 경우 원래는 줄바꿈이 되지 않지만 @@ -288,7 +312,8 @@ fontspec의 글꼴 옵션 외에 \luatexko가 따로 제공하는 것들이 있 [InterLatinCJK=0.25em] \end{verbatim} -\item[InterCharacter] CJK 글자들 사이의 자간을 지시한다.% +\item[InterCharacter] \pkgkwd*{InterCharacter}% + CJK 글자들 사이의 자간을 지시한다.% \footnote{% 플레인텍에서는 |intercharacter=|. } fontspec의 |LetterSpace| 옵션과 기능이 유사하지만, 옛한글을 깨뜨리는 등의 @@ -297,15 +322,16 @@ fontspec의 글꼴 옵션 외에 \luatexko가 따로 제공하는 것들이 있 [InterCharacter=.125em] \end{verbatim} -\item[InterCharStretch] CJK 글자간 가변공백{\small(글루)}의 - stretch 값을 지시한다.% +\item[InterCharStretch] \pkgkwd*{InterCharStretch}% + CJK 글자간 가변공백{\small(글루)}의 stretch 값을 지시한다.% \footnote{% 플레인텍에서는 |intercharstretch=|. } \begin{verbatim} [InterCharStretch=0.5pt] \end{verbatim} -\item[CharRaise] 글자의 세로 위치를 +\item[CharRaise] \pkgkwd*{CharRaise}% + 글자의 세로 위치를 {\addhangulfontfeature{CharRaise=.3em} 조절}할 수 있는 기능이다. 이로써 주변에 식자되는 다른 글꼴과 조화를 이루게 한다.% \footnote{% @@ -318,11 +344,13 @@ fontspec의 글꼴 옵션 외에 \luatexko가 따로 제공하는 것들이 있 크기가 다른 폰트들간에 중앙정렬이 이루어진다. 세로쓰기에서 이 옵션을 주지 않으면 |0.5ex|가 기본값으로 동작한다. -\item[RemoveClassicSpaces] 고문헌 조판시에 CJK 글자들 사이의 공백을 없애준다.% +\item[RemoveClassicSpaces] \pkgkwd*{RemoveClassicSpaces}% + 고문헌 조판시에 CJK 글자들 사이의 공백을 없애준다.% \footnote{% 플레인텍에서는 |+removeclassicspaces|. } -\item[CompressPunctuations] CJK 구두점 {\small (낫표 따위)}의 글자폭을 +\item[CompressPunctuations] \pkgkwd*{CompressPunctuations}% + CJK 구두점 {\small (낫표 따위)}의 글자폭을 반각으로 만든다. v2.0부터는 사용자가 지시하지 않는 한 자동으로 글자폭을 줄여주지 않는다.% \footnote{% @@ -333,7 +361,8 @@ fontspec의 글꼴 옵션 외에 \luatexko가 따로 제공하는 것들이 있 플레인텍에서는 각각 |+halt| 및 |+vhal|이다. 이들과 완전 동일하진 않다. 가령 U+3002 (\char"3002) 처리의 경우.} -\item[Protrusion] 특정 글자가 행 끌에 왔을 때 판면 바깥으로 끌어내는 +\item[Protrusion] \pkgkwd*{Protrusion}% + 특정 글자가 행 끌에 왔을 때 판면 바깥으로 끌어내는 기능이다. Lua\TeX은 기본값으로 온점 반점 등을 완전 글자내밀기 한다. |Protrusion|은 |Protrusion=default|와 같은 뜻이다.% \footnote{% @@ -344,7 +373,8 @@ fontspec의 글꼴 옵션 외에 \luatexko가 따로 제공하는 것들이 있 \leftskip=3em\noindent \cs{directlua{ fonts.protrusions.setups.default[0x201C] = { 1, 0 } }} } -\item[Expansion] 판면의 균일한 조판을 위해 글자들을 미세하게 늘이거나 +\item[Expansion] \pkgkwd*{Expansion}% + 판면의 균일한 조판을 위해 글자들을 미세하게 늘이거나 줄이는 기능이다. |Expansion|은 |Expansion=default|와 마찬가지 뜻이다.% \footnote{% 플레인텍에서는 |expansion=default|. } @@ -373,7 +403,7 @@ fontspec의 글꼴 옵션 외에 \luatexko가 따로 제공하는 것들이 있 \caption{고문헌 조판 보기. typesetclassic 환경을 이용했다.}\label{fig:gomun} \end{figure} -고문헌 조판을 위해 |typesetclassic| 환경을 제공한다.% +고문헌 조판을 위해 \pkgkwd{typesetclassic} 환경을 제공한다.% \footnote{% 플레인텍에서는 (문서 전체에 적용하지 않는다면 그룹 안에서) \cs{typesetclassic}을 사용한다. @@ -387,25 +417,31 @@ v2.0부터는 고문헌 조판에서 한글^^b7한자와 영문자가 붙어 나 또한 불필요한 공백이 오더라도 자동으로 제거해주지 않으므로 이런 경우 사용자가 |RemoveClassicSpaces| 옵션을 주어야 한다. -|typesetmodern|은 고문헌 조판 중에 잠깐 현대 한국어를 조판하는 데 사용한다.% +\pkgkwd{typesetmodern} 환경은 고문헌 조판 중에 잠깐 현대 한국어를 조판하는 데 +사용한다.% \footnote{% 플레인텍에서는 (문서 전체에 적용하지 않는다면 그룹 안에서) \cs{typesetmodern}을 사용한다. } -고문헌 조판 중 \luatexko가 글자 사이에 삽입하는 미세간격을 -사용자가 영{\small(zero)}으로 강제하기 위해선 \cs{inhibitglue} 명령을 이용한다. +고문헌 조판 중 \luatexko가 글자 사이에 삽입하는 미세간격을 사용자가 +영{\small(zero)}으로 강제하기 위해선 \pkgkwd{\inhibitglue} 명령을 이용한다. \section{세로쓰기}\label{sec:verttype} 세로쓰기는 폰트의 고급 오픈타입 속성을 이용하므로 폰트가 이를 지원해야 -가능한 일이다. 폰트에 |Vertical=Alternates|와 |RawFeature=vertical| 옵션을 -준다.% +가능한 일이다. 폰트에 |Vertical=Alternates|와 \pkgkwd{RawFeature=vertical} +옵션을 준다.% \footnote{% 이는 플레인텍에서 |vertical;+vert| 옵션을 주는 것과 같다. 사실 |vertical|을 선언하면 |vert|는 자동으로 켜지도록 해 두었다. }\,% \footnote{% |vmtx| 정보를 가지고 있지 않은 글꼴은 세로쓰기에 적합치 않은 글꼴이다. - |otfinfo -t <파일>| 명령으로 글꼴에 들어있는 테이블 정보를 알 수 있다. } + |otfinfo -t <파일>| 명령으로 글꼴에 들어있는 테이블 정보를 알 수 있다. }\,% +\footnote{% + 폰트 옵션 |Renderer=OpenType| 등(플레인텍에서는 |mode=harf| 옵션)을 주고 + |luahblatex|으로 컴파일하여 Harfbuzz 모듈을 이용하려는 경우 세로쓰기가 + 현재로서는 지원되지 않는다. 세로쓰기를 하려면 이 옵션을 빼고 디폴트 값인 + |Renderer=Node| (플레인텍에서는 |mode=node|)를 사용하라.} 세로쓰기에서 |CharRaise| 옵션의 효과에 대해서는 제\ref{sec:fontoption}절을 참조할 것. @@ -414,7 +450,7 @@ v2.0부터는 고문헌 조판에서 한글^^b7한자와 영문자가 붙어 나 \begin{figure} \framebox[\linewidth]{\begin{vertical}{19.6em}\sffamily - \addhangulfontfeature{Vertical=Alternates, RawFeature=vertical} + \addhangulfontfeature{Renderer=Node, Vertical=Alternates, RawFeature=vertical} \linespread{1.5}\selectfont \hunmintxt \end{vertical}} @@ -423,9 +459,10 @@ v2.0부터는 고문헌 조판에서 한글^^b7한자와 영문자가 붙어 나 \begin{figure} \framebox[\linewidth]{\begin{vertical}{18.62em}\sffamily - \addhangulfontfeature{Vertical=Alternates, RemoveClassicSpaces, + \addhangulfontfeature{Renderer=Node, Vertical=Alternates, RemoveClassicSpaces, InterCharStretch=1pt, CompressPunctuations, RawFeature=vertical} \linespread{1.5}\selectfont + \parindent=-1em \leftskip=1em \analectstext \end{vertical}} \caption{세로쓰기의 다른 예. 박스 높이 |19em|을 지시했다. @@ -434,18 +471,19 @@ v2.0부터는 고문헌 조판에서 한글^^b7한자와 영문자가 붙어 나 넉넉하게 주는 것이 좋다.}\label{fig:vertical3} \end{figure} -문서의 일부를 세로쓰기하려면 \cs{begin{vertical}{}} \ldots\ \cs{end{vertical}} +문서의 일부를 세로쓰기하려면 +|\begin{|\pkgkwd{vertical}|}{}| \ldots\ |\end{vertical}| 환경을 이용한다. ||으로 세로쓰기 박스의 높이를 지시한다.% \footnote{% 플레인텍에서는 \cs{vertical{}} \ldots\ \cs{endvertical}. } 그림~\ref{fig:vertical},~\ref{fig:vertical3} 및 \ref{fig:vertical2} 참조. 문서 전체를 세로쓰기한다면 이 환경을 쓰는 대신 -\cs{verticaltypesetting} 명령을 전처리부에 선언한다. +\pkgkwd{\verticaltypesetting} 명령을 전처리부에 선언한다. 이때 면주는 가로로 식자되며 면주 폰트의 설정은 사용자의 몫이다. 세로쓰기 도중에 문서의 일부를 가로쓰기하려면 -\cs{begin{horizontal}{}} \ldots\ \cs{end{horizontal}} +|\begin{|\pkgkwd{horizontal}|}{}| \ldots\ |\end{horizontal}| 환경을 이용한다. ||은 가로쓰기 박스의 너비를 지시한다.% \footnote{% 플레인텍에서는 \cs{horizontal{}} \ldots\ \cs{endhorizontal}. } @@ -454,7 +492,7 @@ v2.0부터는 고문헌 조판에서 한글^^b7한자와 영문자가 붙어 나 \begin{figure} \framebox[\linewidth]{\begin{vertical}{16.66em}\sffamily - \addhangulfontfeature{Vertical=Alternates, CharRaise=3.2pt, + \addhangulfontfeature{Renderer=Node, Vertical=Alternates, CharRaise=3.2pt, CompressPunctuations, CharacterWidth=Full, RawFeature=vertical} \parindent-1em\leftskip1em \linespread{1.5}\selectfont \spaceskip=.5em plus.25em minus.125em @@ -480,34 +518,35 @@ v2.0부터는 고문헌 조판에서 한글^^b7한자와 영문자가 붙어 나 \section{드러냄표}\label{sec:dotemph} -\cs{dotemph} 명령으로 \dotemph{드러냄표}% +\pkgkwd{\dotemph} 명령으로 \dotemph{드러냄표}% 를 이용한 강조를 할 수 있다. 기본은 글자 위에 점을 찍는 형태이나 다음과 같이 명령을 주어 개인적으로 선호하는 기호를 드러냄표로 쓸 수 있다. \medskip -①~|\def\dotemphraise{0.4em }|: 드러냄표를 피강조 글자 위로 끌어올리는 길이 +①~|\def|\pkgkwd{\dotemphraise}|{0.4em }|: +드러냄표를 피강조 글자 위로 끌어올리는 길이 -②~|\def\dotemphchar{\bfseries ^^^^02d9}|: 드러냄표 기호 자체를 정의. +②~|\def|\pkgkwd{\dotemphchar}|{\bfseries ^^^^02d9}|: 드러냄표 기호 자체를 정의. \section{루비}\label{sec:ruby} 루비를 달 수 있다. ruby 패키지가 이미 존재하지만 \luatexko와 궁합이 잘 맞지 않아 새로 매크로를 제공한다. \begin{quote} - \cs{ruby{漢字}{한자}}\quad$\Rightarrow$\quad\ruby{漢字}{한자} + \pkgkwd{\ruby}|{漢字}{한자}|\quad$\Rightarrow$\quad\ruby{漢字}{한자} \end{quote} 이처럼 글자별로 따로 루비를 달 필요가 없다. 관련 설정은 다음처럼 한다. \medskip -①~\cs{rubyfont}: 루비를 식자할 폰트를 지시해 둔다. 기본값은 현재 폰트% +①~\pkgkwd{\rubyfont}: 루비를 식자할 폰트를 지시해 둔다. 기본값은 현재 폰트% \footnote{% 루비는 글자 크기가 작기 때문에 본문 폰트보다 약간 굵은 폰트로 지정하는 것이 좋다. } -②~|\def\rubysize{0.6}|: 루비 글자 크기를 본문 글자 크기에 대한 비율로 -지정% +②~|\def|\pkgkwd{\rubysize}|{0.6}|: +루비 글자 크기를 본문 글자 크기에 대한 비율로 지정% \footnote{% 플레인텍에서는 루비의 글꼴크기를 따로 조정해주지 않는다. 사용자가 \cs{rubyfont}를 설정할 때 크기도 함께 지시하도록 한다. @@ -515,21 +554,28 @@ v2.0부터는 고문헌 조판에서 한글^^b7한자와 영문자가 붙어 나 \leftskip=3em\noindent |\\font\\rubyfont=UnBatang at \\rubysize em| } -③~|\def\rubysep{0.1ex}|: 루비와 본문 글자 사이의 간격을 지정 +③~|\def|\pkgkwd{\rubysep}|{0.1ex}|: 루비와 본문 글자 사이의 간격을 지정 -④~\cs{rubynooverlap}: 루비의 폭이 본문 글자의 폭보다 클 때 루비가 이웃 +④~\pkgkwd{\rubynooverlap}: 루비의 폭이 본문 글자의 폭보다 클 때 루비가 이웃 글자들 위로 삐져나가지 못하게 한다. 본문 글자의 흐름을 중시하여 -\cs{rubyoverlap}을 기본값으로 하였으므로 이는 따로 선언할 필요가 없다. +\pkgkwd{\rubyoverlap}을 기본값으로 하였으므로 이는 따로 선언할 필요가 없다. \medskip 한편, 연속된 본문 글자들에 각각 한 글자씩 루비를 달고자 한다면 -\cs{xxruby{...}{...}} 명령을 사용한다. 글자들 사이에 줄바꿈이 허용된다. +\pkgkwd{\xxruby}|{...}{...}| 명령을 사용한다. 글자들 사이에 줄바꿈이 허용된다. 두 인자의 글자 수가 동일해야 한다. \section{밑줄긋기}\label{sec:uline} -ulem 패키지가 \luatexko와 궁합이 잘 맞지 않아{\small (줄바꿈에 문제가 있음)} -명령을 따로 제공한다. +ulem 패키지가 \luatexko와 궁합이 맞지 않아{\small (줄바꿈에 문제가 있음)} +명령을 따로 제공한다.% +\pkgkwd*{\uline}% +\pkgkwd*{\sout}% +\pkgkwd*{\uuline}% +\pkgkwd*{\xout}% +\pkgkwd*{\uwave}% +\pkgkwd*{\dashuline}% +\pkgkwd*{\dotuline} \def\RA{\>$\Rightarrow$\>} \begin{tabbing} @@ -546,12 +592,13 @@ ulem 패키지가 \luatexko와 궁합이 잘 맞지 않아{\small (줄바꿈에 관련하여 다음 설정을 할 수 있다. \medskip -①~|\def\ulinedown{0.5ex}|: 밑줄을 베이스라인 아래로 끌어내리는 정도 +①~|\def|\pkgkwd{\ulinedown}|{0.5ex}|: 밑줄을 베이스라인 아래로 끌어내리는 정도 -②~|\def\ulinewidth{0.04em}|: 밑줄의 굵기 +②~|\def|\pkgkwd{\ulinewidth}|{0.04em}|: 밑줄의 굵기 \medskip -사실 위 밑줄 양식들을 만드는 데는 예외없이 \cs{markoverwith} 명령이 사용되었다. +사실 위 밑줄 양식들을 만드는 데는 예외없이 +\pkgkwd{\markoverwith} 명령이 사용되었다. 따라서 사용자는 이를 이용해 원하는 양식을 만들 수 있다. 가령 노란색 마커펜을 흉내내려면,% \footnote{% @@ -577,7 +624,7 @@ ulem 패키지가 \luatexko와 궁합이 잘 맞지 않아{\small (줄바꿈에 자동조사는 \kotex 과 동일하게 \cs{은} \cs{는} \cs{이} \cs{가} \cs{을} \cs{를} \cs{와} \cs{과} \cs{로} \cs{으로} \cs{라} \cs{이라} 따위를 사용한다. -버전 1.3부터는 \cs{josaignoreparens=1}이 선언되어 있으면 자동조사는 +버전 1.3부터는 \pkgkwd{\josaignoreparens}|=1|이 선언되어 있으면 자동조사는 \hemph{괄호 부분을 건너뛰고} 그 앞 글자에 매칭한다. |0|이 선언되면 원래 방식으로 돌아간다. \begin{quote} @@ -614,7 +661,8 @@ ulem 패키지가 \luatexko와 궁합이 잘 맞지 않아{\small (줄바꿈에 |\\font\\scripthangul="Noto Sans CJK KR Regular" at 7pt|\\ |\\font\\scriptscripthangul="Noto Sans CJK KR Medium" at 5pt|\\ |\\setmathhangulfonts\\texthangul\\scripthangul\\scriptscripthangul| } -v2.0부터는 자동으로 수식 한글을 잡아주지 않는다. +v2.0부터는 자동으로 수식 한글을 잡아주지 않는다.% +\pkgkwd*{\setmathhangulfont} \begin{verbatim} \setmathhangulfont{Noto Sans CJK KR}[ SizeFeatures={ @@ -623,9 +671,9 @@ v2.0부터는 자동으로 수식 한글을 잡아주지 않는다. {Size=9-, Font=* DemiLight}, } ] \end{verbatim} -현재 한글만 쓸 수 있게 설정되어 있다. -한자도 수식에 직접 입력하려면 사용자는 -다음 명령으로 유니코드 블럭을 추가 지정해야 한다. +현재 한글만 쓸 수 있게 설정되어 있다. 한자도 수식에 직접 입력하려면 사용자는 +다음 명령으로 유니코드 블럭을 추가 지정해야 한다.% +\pkgkwd*{\setmathhangulblock} \begin{verbatim} \setmathhangulblock{4E00}{9FC3} \end{verbatim} @@ -638,9 +686,9 @@ v2.0부터는 자동으로 수식 한글을 잡아주지 않는다. \cs{onum} \cs{pnum} \cs{oeng} \cs{peng} \cs{hnum} \cs{Hnum} \cs{hroman} \cs{hRoman} \cs{hNum} \cs{hanjanum} 따위를 사용한다. } -\section{입력 변환}\label{sec:noramlize} +\section{입력 변환}\label{sec:normalize} -\cs{luatexhangulnormalize=1}이라 지시하면 첫가끝 자모를 완성형 음절로, +\pkgkwd{\luatexhangulnormalize}|=1|이라 지시하면 첫가끝 자모를 완성형 음절로, |2|라면 완성형 음절을 첫가끝 자모로 인코딩 변환한다. |0|이 할당되면 인코딩 변환 기능이 꺼진다. \XeTeX의 \cs{XeTeXinputnormalization} 명령과 유사하나, 오직 한글과 일부 한자에 대해서만 정규화가 작동할 뿐이다. @@ -650,15 +698,14 @@ v2.0부터는 자동으로 수식 한글을 잡아주지 않는다. 권장하지 않지만 불가피하게 입력 인코딩이 UHC (Unified Hangul Code)% \footnote{% CP949라고도 하며 EUC-KR을 포함한다. }% -로 되어 있는 파일을 처리할 때는 -\cs{luatexuhcinputencoding=1}을 선언한다. -|0|을 할당하면 다시 UTF-8 입력으로 간주한다. -\XeTeX의 \cs{XeTeXinputencoding} 명령과 유사하나, 오직 한국어 문자만 처리할 수 -있다.% +로 되어 있는 파일을 처리할 때는 \pkgkwd{\luatexuhcinputencoding}|=1|을 선언한다. +|0|을 할당하면 다시 UTF-8 입력으로 간주한다. \XeTeX의 \cs{XeTeXinputencoding} +명령과 유사하나, 오직 한국어 문자만 처리할 수 있다.% \footnote{% 윈도 운영체제에서의 한글 파일이름 불러오기 기능은 v2.0부터는 제공하지 않는다. 대신 |luatex -cmdx ...|, |lualatex -cmdx ...|와 같이 컴파일시 명령행에 |-cmdx| 옵션을 주면 된다고 하니 테스트해 보시기 바란다. } + \hfill \fboxsep=-\fboxrule \fbox{\vbox to 1em{\hbox to 1em{\hss}\vss}} \end{document} diff --git a/Master/texmf-dist/tex/luatex/luatexko/luatexko-normalize.lua b/Master/texmf-dist/tex/luatex/luatexko/luatexko-normalize.lua index 97c2b0ccf87..40e05687ec4 100644 --- a/Master/texmf-dist/tex/luatex/luatexko/luatexko-normalize.lua +++ b/Master/texmf-dist/tex/luatex/luatexko/luatexko-normalize.lua @@ -13,8 +13,8 @@ luatexbase.provides_module({ name = "luatexko-normalize", - version = "2.4", - date = "2019/08/01", + version = "2.5", + date = "2019/12/01", author = "Dohyun Kim, Soojin Nam", description = "Hangul normalization", license = "LPPL v1.3+", diff --git a/Master/texmf-dist/tex/luatex/luatexko/luatexko-uhc2utf8.lua b/Master/texmf-dist/tex/luatex/luatexko/luatexko-uhc2utf8.lua index 82d11379cb5..b7156998295 100644 --- a/Master/texmf-dist/tex/luatex/luatexko/luatexko-uhc2utf8.lua +++ b/Master/texmf-dist/tex/luatex/luatexko/luatexko-uhc2utf8.lua @@ -13,8 +13,8 @@ luatexbase.provides_module({ name = "luatexko-uhc2utf8", - version = "2.4", - date = "2019/08/01", + version = "2.5", + date = "2019/12/01", author = "Dohyun Kim, Soojin Nam", description = "UHC (CP949) input encoding", license = "LPPL v1.3+", diff --git a/Master/texmf-dist/tex/luatex/luatexko/luatexko.lua b/Master/texmf-dist/tex/luatex/luatexko/luatexko.lua index 3ab4f18961a..f7819aec89d 100644 --- a/Master/texmf-dist/tex/luatex/luatexko/luatexko.lua +++ b/Master/texmf-dist/tex/luatex/luatexko/luatexko.lua @@ -13,8 +13,8 @@ luatexbase.provides_module { name = 'luatexko', - date = '2019/08/01', - version = '2.4', + date = '2019/12/01', + version = '2.5', description = 'typesetting Korean with LuaTeX', author = 'Dohyun Kim, Soojin Nam', license = 'LPPL v1.3+', @@ -59,9 +59,13 @@ local texsp = tex.sp local set_macro = token.set_macro +local mathmax = math.max + local stringformat = string.format +local stringunpack = string.unpack local tableconcat = table.concat +local tableinsert = table.insert local tableunpack = table.unpack local add_to_callback = luatexbase.add_to_callback @@ -230,8 +234,8 @@ local function option_in_font (fontdata, optionname) if type(fontdata) == "number" then fontdata = get_font_data(fontdata) end - if fontdata.shared then - return fontdata.shared.features[optionname] + if fontdata.specification then + return fontdata.specification.features.normal[optionname] end end @@ -245,6 +249,28 @@ local function my_node_props (n) return t.luatexko end +local function is_harf (f) + if type(f) == "number" then + f = get_font_data(f) + end + return f.hb +end + +local function is_not_harf (f) + if option_in_font(f, "mode") == "harf" then -- mode=harf with non-luahbtex + return false + end + return not is_harf(f) +end + +local function harf_reordered_tonemark (curr) + if is_harf(curr.font) then + local props = getproperty(curr) or {} + local actualtext = props.luaotfload_startactualtext or "" + return actualtext:find"302[EF]$" + end +end + -- font fallback local force_hangul = { @@ -283,6 +309,8 @@ luatexko.updateforcehangul = update_force_hangul local active_processes = {} local char_font_options = { + ascender = {}, + charraise = {}, hangulspaceskip = {}, intercharacter = {}, intercharstretch = {}, @@ -292,7 +320,7 @@ local char_font_options = { } local function hangul_space_skip (curr, newfont) - if curr.lang ~= nohyphen then + if curr.lang ~= nohyphen and curr.font ~= newfont then local n = getnext(curr) if n and n.id == glueid and n.subtype == spaceskip then local params = getparameters(curr.font) @@ -306,17 +334,24 @@ local function hangul_space_skip (curr, newfont) local newwd = char_font_options.hangulspaceskip[newfont] if newwd == nil then - local newsp = nodecopy(curr) - newsp.char, newsp.font = 32, newfont - newsp = nodes.simple_font_handler(newsp) - newwd = newsp and newsp.width or false - if newwd then - newwd = { texsp(newwd), texsp(newwd/2), texsp(newwd/3) } + if is_harf(newfont) then + newwd = getparameters(newfont) or false + if newwd then + newwd = { newwd.space, newwd.space_stretch, newwd.space_shrink } + end + else + local newsp = nodecopy(curr) + newsp.char, newsp.font = 32, newfont + newsp = nodes.simple_font_handler(newsp) + newwd = newsp and newsp.width or false + if newwd then + newwd = { texsp(newwd), texsp(newwd/2), texsp(newwd/3) } + end + if newsp then + nodefree(newsp) + end end char_font_options.hangulspaceskip[newfont] = newwd - if newsp then - nodefree(newsp) - end end if newwd then setglue(n, newwd[1], newwd[2], newwd[3]) @@ -345,6 +380,7 @@ local function process_fonts (head) if not active_processes.reorderTM and hangul_tonemark[c] and + is_not_harf(curr.font) and option_in_font(curr.font, "script") == "hang" then luatexko.activate("reorderTM") -- activate reorderTM here active_processes.reorderTM = true @@ -410,6 +446,7 @@ local intercharclass = { [0] = { [0] = {1,0}, {1,0}, nil, {1.5,.5},nil, {1,0}, {1,0} }, { [0] = nil, {1,1}, nil, {.5,.5} }, { [0] = {1,1}, {1,1}, nil, {.5,.5} }, + { }, -- vertical colon } local charclass = setmetatable({ @@ -447,8 +484,8 @@ local SC_charclass = setmetatable({ }, { __index = charclass }) local vert_charclass = setmetatable({ - [0xFF1A] = 5, -- 0xFE13 - [0xFF1B] = 5, -- 0xFE14 + [0xFF1A] = 7, -- 0xFE13 + [0xFF1B] = 7, -- 0xFE14 }, { __index = charclass }) local function get_char_class (c, classic) @@ -579,18 +616,17 @@ end local function get_actualtext (curr) local actual = my_node_props(curr).startactualtext if type(actual) == "table" then - return actual[0], actual[1], actual[#actual] + return actual.init, actual[1], actual[#actual] end end local function goto_end_actualtext (curr) local n = getnext(curr) while n do - if n.id == whatsitid - and n.mode == directmode - and my_node_props(n).endactualtext then - curr = n - break + if n.id == whatsitid and + n.mode == directmode and + my_node_props(n).endactualtext then + curr = n; break end n = getnext(n) end @@ -731,7 +767,8 @@ local function process_glyph_width (head) if class >= 1 and class <= 4 and (old or cc < 0x2000 or cc > 0x202F) then -- exclude general puncts - local gpos = class == 1 and getprev(curr) or getnext(curr) + -- harf-node always puts kern after the glyph + local gpos = class == 1 and is_not_harf(curr.font) and getprev(curr) or getnext(curr) gpos = gpos and gpos.id == kernid and gpos.subtype == fontkern if not gpos then @@ -898,7 +935,6 @@ local function process_interlatincjk (head, par) head, pc, pf, pcl = do_interlatincjk_option(head, curr, pc, pf, pcl, c, glyf.font, par) curr = goto_end_actualtext(curr) end - elseif id == mathid then if pc == 1 then head = do_interlatincjk_option(head, curr, pc, pf, pcl, 0x30, pf, par) @@ -962,7 +998,7 @@ local function process_remove_spaces (head) end if ok then head = noderemove(head, curr) - to_free[#to_free + 1] = curr + tableinsert(to_free, curr) break end end @@ -1048,9 +1084,9 @@ local function prevjosacode (n, parenlevel) local id = n.id if id == glyphid then local c = my_node_props(n).unicode or n.char -- beware hlist/vlist - if ignore_parens and c == 0x29 then + if ignore_parens and c == 0x29 then -- ) parenlevel = parenlevel + 1 - elseif ignore_parens and c == 0x28 then + elseif ignore_parens and c == 0x28 then -- ( parenlevel = parenlevel - 1 elseif parenlevel <= 0 then josacode = josa_code[c] @@ -1091,7 +1127,7 @@ local function process_josa (head) curr.char = cc else head = noderemove(head, curr) - tofree[#tofree + 1] = curr + tableinsert(tofree, curr) end end unset_attribute(curr, autojosaattr) @@ -1107,6 +1143,26 @@ end -- dotemph +local function shift_put_top (bot, top) + local shift = top.shift or 0 + + if bot.id == hlistid then + bot = has_glyph(bot.list) or {} + end + local bot_off = bot.yoffset or 0 + + if bot_off ~= 0 then + if top.id == hlistid then + top = has_glyph(top.list) or {} + end + local top_off = top.yoffset or 0 + + return shift + top_off - bot_off + end + + return shift +end + local dotemphbox = {} luatexko.dotemphbox = dotemphbox @@ -1123,6 +1179,12 @@ local function process_dotemph (head, tofree) is_chosong(c) or is_hanja(c) or is_kana(c) then + + -- harf font: skip reordered tone mark + if harf_reordered_tonemark(curr) then + curr = getnext(curr) + end + local currwd = curr.width if currwd >= get_en_size(curr.font) then local box = nodecopy(dotemphbox[dotattr]) @@ -1133,6 +1195,10 @@ local function process_dotemph (head, tofree) k.kern = shift box.list = insert_before(list, list, k) end + + -- consider charraise + box.shift = shift_put_top(curr, box) + box.width = 0 head = insert_before(head, curr, box) tofree[dotattr] = true @@ -1299,6 +1365,42 @@ local function process_ruby_pre_linebreak (head) return head end +local os2tag = luaotfload.harfbuzz and luaotfload.harfbuzz.Tag.new"OS/2" + +-- luaharfbuzz's Font:get_h_extents() gets ascender value from hhea table; +-- Node mode's parameters.ascender is gotten from OS/2 table. +-- TypoAscender in OS/2 table seems to be more suitable for our purpose. +local function get_font_ascender (f) + local ascender = char_font_options.ascender + local ascend = ascender[f] + if ascend == nil then + local hb = is_harf(f) + if hb and os2tag then + local hbface = hb.shared.face + local tags = hbface:get_table_tags() + local hasos2 = false + for _,v in ipairs(tags) do + if v == os2tag then + hasos2 = true + break + end + end + if hasos2 then + local os2 = hbface:get_table(os2tag) + local length = os2:get_length() + if length > 69 then -- sTypoAscender (int16) + local data = os2:get_data() + local typoascender = stringunpack(">h", data, 69) + ascend = typoascender * hb.scale + end + end + end + ascend = ascend or get_font_param(f, "ascender") or false + ascender[f] = ascend + end + return ascend +end + local function process_ruby_post_linebreak (head) local curr = head while curr do @@ -1316,9 +1418,13 @@ local function process_ruby_post_linebreak (head) ruby.list = insert_before(list, list, k) end ruby.width = 0 + + -- consider charraise + local shift = shift_put_top(curr, ruby) + local _, f = ruby_char_font(curr) - local ascender = get_font_param(f, "ascender") or curr.height - ruby.shift = -ascender - ruby.depth - ruby_t[2] -- rubysep + local ascender = get_font_ascender(f) or curr.height + ruby.shift = shift - ascender - ruby.depth - ruby_t[2] -- rubysep head = insert_before(head, curr, ruby) end ruby_t = nil @@ -1387,72 +1493,68 @@ local function get_tonemark_width (curr, uni) end local function process_reorder_tonemarks (head) - local curr = head + local curr, init = head while curr do local id = curr.id - if id == glyphid and option_in_font(curr.font, "script") == "hang" then + if id == glyphid and + is_not_harf(curr.font) and + option_in_font(curr.font, "script") == "hang" then + local fontdata = get_font_data(curr.font) local uni = my_node_props(curr).unicode or curr.char if is_hangul(uni) or is_chosong(uni) or uni == 0x25CC then - - local syllable = { [0]=curr, uni } - - local n = getnext(curr) - while n do - local nid = n.id - if nid == glyphid then - local u = my_node_props(n).unicode or n.char - if is_jungsong(u) - or is_jongsong(u) - or hangul_tonemark[u] then - syllable[#syllable + 1] = u - curr, uni = n, u - else - break + init = curr + elseif is_jungsong(uni) or is_jongsong(uni) then + elseif hangul_tonemark[uni] then + if init then + local n, syllable = init, { init = init } + while n do + if n.id == glyphid then + local u = my_node_props(n).unicode or n.char + if u then tableinsert(syllable, u) end end - elseif nid ~= kernid or n.subtype == userkern then - break + if n == curr then break end + n = getnext(n) end - n = getnext(n) - end - if #syllable > 1 - and hangul_tonemark[uni] - and get_tonemark_width(curr, uni) ~= 0 then + if #syllable > 1 and get_tonemark_width(curr, uni) ~= 0 then + local TM = curr - local ini, fin = syllable[0], curr - local actual = pdfliteral_direct_actual(syllable) - local endactual = pdfliteral_direct_actual() - head = insert_before(head, ini, actual) - head, curr = insert_after(head, curr, endactual) + local actual = pdfliteral_direct_actual(syllable) + local endactual = pdfliteral_direct_actual() + head = insert_before(head, init, actual) + head, curr = insert_after(head, curr, endactual) - head = noderemove(head, fin) - head = insert_before(head, ini, fin) - end + head = noderemove(head, TM) + head = insert_before(head, init, TM) + end - elseif hangul_tonemark[uni] -- isolated tone mark - and char_in_font(fontdata, 0x25CC) then - - local dotcircle = nodecopy(curr) - dotcircle.char = 0x25CC - if get_tonemark_width(curr, uni) ~= 0 then - local actual = pdfliteral_direct_actual{ [0]=curr, uni } - local endactual = pdfliteral_direct_actual() - head = insert_before(head, curr, actual) - head, curr = insert_after(head, curr, dotcircle) - head, curr = insert_after(head, curr, endactual) - else - head = insert_before(head, curr, dotcircle) + init = nil + elseif char_in_font(fontdata, 0x25CC) then -- isolated tone mark + local dotcircle = nodecopy(curr) + dotcircle.char = 0x25CC + if get_tonemark_width(curr, uni) ~= 0 then + local actual = pdfliteral_direct_actual{ init = curr, uni } + local endactual = pdfliteral_direct_actual() + head = insert_before(head, curr, actual) + head, curr = insert_after(head, curr, dotcircle) + head, curr = insert_after(head, curr, endactual) + else + head = insert_before(head, curr, dotcircle) + end end - end - elseif id == whatsitid - and curr.mode == directmode - and my_node_props(curr).startactualtext then - - curr = goto_end_actualtext(curr) - elseif id == mathid then - curr = end_of_math(curr) + else + init = nil + end + elseif id == kernid and curr.subtype ~= userkern then -- skip + elseif id == whatsitid then + if curr.mode == directmode and my_node_props(curr).startactualtext then + curr, init = goto_end_actualtext(curr), nil + end + else + init = nil + if id == mathid then curr = end_of_math(curr) end end curr = getnext(curr) end @@ -1587,12 +1689,21 @@ local function get_tsb_table (filename, subfont) end end +local function fontdata_warning(activename, ...) + if not active_processes[activename] then + warning(...) + active_processes[activename] = true + end +end + local function process_vertical_font (fontdata) local subfont = fontdata.specification and fontdata.specification.sub local tsb_tab = get_tsb_table(fontdata.filename, subfont) + if not tsb_tab then - warning("Vertical metrics table (vmtx) not found in the font\n".. - "`%s'", fontdata.fullname) + local fullname = fontdata.fullname + fontdata_warning("vertical."..fullname, + "Vertical metrics table (vmtx) not found in the font\n`%s'", fullname) return end @@ -1690,24 +1801,23 @@ luatexko.gethorizboxmoveleft = get_horizbox_moveleft -- charraise -local function process_charriase_font (fontdata) - local raise = fontdata_opt_dim(fontdata, "charraise") - if raise then - local shared = fontdata.shared or {} - local descriptions = shared.rawdata and shared.rawdata.descriptions or {} - local scale = fontdata.parameters.factor or 655.36 - for i, v in pairs( fontdata.characters ) do - v.commands = { - {"down", -raise }, - {"char", i}, - } - local bbox = descriptions[i] and descriptions[i].boundingbox or {0,0,0,0} - local ht = bbox[4] * scale + raise - local dp = bbox[2] * scale + raise - v.height = ht > 0 and ht or nil - v.depth = dp < 0 and -dp or nil +local function process_charraise (head) + local curr = head + while curr do + if curr.id == glyphid then + local f = curr.font + local raise = get_font_opt_dimen(f, "charraise") + if raise and not option_in_font(f, "vertical") then + local props = my_node_props(curr) + if not props.charraised then + curr.yoffset = (curr.yoffset or 0) + raise + props.charraised = true + end + end end + curr = getnext(curr) end + return head end -- fake italic correctioin @@ -1718,28 +1828,34 @@ local function process_fake_slant_corr (head) -- for font fallback local id = curr.id if id == kernid then if curr.subtype == italcorr and curr.kern == 0 then - local p = getprev(curr) - while p do -- skip jungsong/jongsong - if p.id == glyphid and p.width < get_en_size(p.font) then + local p, t = getprev(curr), {} + while p do + if p.id == glyphid then + -- harf font: break before reordered tone mark + if harf_reordered_tonemark(p) then + break + end + + local slant = option_in_font(p.font, "slant") + if slant and slant > 0 then + tableinsert(t, char_in_font(p.font, p.char).italic or 0) + end + local c = my_node_props(p).unicode or p.char - if not is_jungsong(c) and not is_jongsong(c) then + if is_jungsong(c) or is_jongsong(c) or hangul_tonemark[c] then + else break end - elseif p.id == whatsitid - and p.mode == directmode - and my_node_props(p).endactualtext then -- skip else break end p = getprev(p) end - if p.id == glyphid then - local fontdata = get_font_data(p.font) - if fontdata.slant and fontdata.slant > 0 then - local italic = char_in_font(fontdata, p.char).italic - if italic then - curr.kern = italic - end + + if p.id == glyphid and #t > 0 then + local italic = mathmax(tableunpack(t)) + if italic > 0 then + curr.kern = italic end end end @@ -1757,12 +1873,33 @@ local function process_fake_slant_font (fontdata) fsl = fsl/1000 local params = fontdata.parameters or {} params.slant = (params.slant or 0) + fsl*65536 -- slant per point - local scale = params.factor or 655.36 + + local hb = is_harf(fontdata) + local scale = hb and hb.scale or params.factor or 655.36 + local shared = fontdata.shared or {} - local descriptions = shared.rawdata and shared.rawdata.descriptions or {} + local descrs = shared.rawdata and shared.rawdata.descriptions or {} + for i, v in pairs(fontdata.characters) do - local bbox = descriptions[i] and descriptions[i].boundingbox or {0,0,0,0} - local italic = (v.height or 0) * fsl - (v.width or 0) + bbox[3]*scale + local ht = v.height and v.height > 0 and v.height or 0 + local wd = v.width and v.width > 0 and v.width or 0 + local rbearing = 0 + + if wd > 0 then -- or, jong/jung italic could by very large value + if hb then + local extents = hb.shared.font:get_glyph_extents(v.index) + if extents then + rbearing = wd - (extents.x_bearing + extents.width)*scale + end + else + local bbox = descrs[i] and descrs[i].boundingbox + if bbox then + rbearing = wd - bbox[3]*scale + end + end + end + + local italic = ht * fsl - rbearing if italic > 0 then v.italic = italic end @@ -1773,37 +1910,41 @@ end -- wrap up local pass_fun = function(...) return ... end -create_callback("luatexko_pre_hpack", "data", pass_fun) -create_callback("luatexko_pre_prelinebreak", "data", pass_fun) -create_callback("luatexko_post_hpack", "data", pass_fun) -create_callback("luatexko_post_prelinebreak", "data", pass_fun) +create_callback("luatexko_hpack_first", "data", pass_fun) +create_callback("luatexko_prelinebreak_first", "data", pass_fun) +create_callback("luatexko_hpack_second", "data", pass_fun) +create_callback("luatexko_prelinebreak_second", "data", pass_fun) add_to_callback("hpack_filter", function(h) h = process_fonts(h) - h = call_callback("luatexko_pre_hpack", h) - h = call_callback("luatexko_post_hpack", h) + h = call_callback("luatexko_hpack_first", h) + h = call_callback("luatexko_hpack_second", h) return process_linebreak(h) end, "luatexko.hpack_filter.pre_rendering", 1) add_to_callback("pre_linebreak_filter", function(h) h = process_fonts(h) - h = call_callback("luatexko_pre_prelinebreak", h, true) - h = call_callback("luatexko_post_prelinebreak", h, true) + h = call_callback("luatexko_prelinebreak_first", h, true) + h = call_callback("luatexko_prelinebreak_second", h, true) return process_linebreak(h, true) end, "luatexko.pre_linebreak_filter.pre_rendering", 1) local font_opt_procs = { removeclassicspaces = { - luatexko_pre_hpack = process_remove_spaces, - luatexko_pre_prelinebreak = process_remove_spaces, + luatexko_hpack_first = process_remove_spaces, + luatexko_prelinebreak_first = process_remove_spaces, }, interhangul = { - luatexko_post_hpack = process_interhangul, - luatexko_post_prelinebreak = process_interhangul, + luatexko_hpack_second = process_interhangul, + luatexko_prelinebreak_second = process_interhangul, }, interlatincjk = { - luatexko_post_hpack = process_interlatincjk, - luatexko_post_prelinebreak = process_interlatincjk, + luatexko_hpack_second = process_interlatincjk, + luatexko_prelinebreak_second = process_interlatincjk, + }, + charraise = { + hpack_filter = process_charraise, + pre_linebreak_filter = process_charraise, }, compresspunctuations = { hpack_filter = process_glyph_width, @@ -1815,50 +1956,73 @@ local font_opt_procs = { }, } -local function process_patch_font (fontdata) - for name, procs in pairs( font_opt_procs ) do - if not active_processes[name] and option_in_font(fontdata, name) then - for cbnam, cbfun in pairs( procs ) do - add_to_callback(cbnam, cbfun, "luatexko."..cbnam.."."..name) - end - active_processes[name] = true +local font_opt_procs_single = { + expansion = function() + if not active_processes.expansion then + texset("global", "adjustspacing", 2) + active_processes.expansion = true end - end + end, - if not active_processes.expansion - and option_in_font(fontdata, "expansion") then - texset("global", "adjustspacing", 2) - active_processes.expansion = true - end - - if option_in_font(fontdata, "protrusion") then + protrusion = function(fontdata) if not active_processes.protrusion then texset("global", "protrudechars", 2) active_processes.protrusion = true end - if not active_processes[fontdata.fullname] and - option_in_font(fontdata, "compresspunctuations") then - warning("Both `compresspunctuations' and `protrusion' are\n".. - "enabled for the font `%s'.\n".. - "Beware that this could result in bad justifications.\n", - fontdata.fullname) - active_processes[fontdata.fullname] = true + if option_in_font(fontdata, "compresspunctuations") then + local fullname = fontdata.fullname + fontdata_warning("protrude."..fullname, + "Both `compresspunctuations' and `protrusion' are\nenabled for `%s'.\n".. + "Beware bad justifications.", fullname) end - end + end, + + slant = process_fake_slant_font, + + vertical = function(fontdata) + local fullname = fontdata.fullname + if is_harf(fontdata) then + fontdata_warning("vertical."..fullname, + "Currently, vertical writing is not supported\nby harf mode.".. + "`Renderer=Node' option is needed for\n`%s'", fullname) + elseif fontdata.type == "virtual" then + fontdata_warning("vitrual."..fullname, + "Virtual font `%s' cannot be\nused for vertical writing.", fullname) + else + process_vertical_font(fontdata) + end + end, +} - if option_in_font(fontdata, "vertical") then - process_vertical_font(fontdata) - elseif option_in_font(fontdata, "charraise") then - process_charriase_font(fontdata) +local function process_patch_font (fontdata) + if type(fontdata) ~= "table" or + fontdata.format ~= "opentype" and fontdata.format ~= "truetype" then + return + end -- as we have called patch_font_unsafe for hb fonts + + for name, procs in pairs( font_opt_procs ) do + if not active_processes[name] and option_in_font(fontdata, name) then + if name == "charraise" and option_in_font(fontdata, "vertical") then + else + for cbnam, cbfun in pairs( procs ) do + add_to_callback(cbnam, cbfun, "luatexko."..cbnam.."."..name) + end + active_processes[name] = true + end + end end - if option_in_font(fontdata, "slant") then - process_fake_slant_font(fontdata) + for name, func in pairs( font_opt_procs_single ) do + if option_in_font(fontdata, name) then + func(fontdata) + end end end add_to_callback("luaotfload.patch_font", process_patch_font, "luatexko.patch_font") +add_to_callback("luaotfload.patch_font_unsafe", process_patch_font, +"luatexko.patch_font") local auxiliary_procs = { dotemph = { @@ -1875,12 +2039,12 @@ local auxiliary_procs = { vpack_filter = process_ruby_post_linebreak, }, autojosa = { - luatexko_pre_hpack = process_josa, - luatexko_pre_prelinebreak = process_josa, + luatexko_hpack_first = process_josa, + luatexko_prelinebreak_first = process_josa, }, reorderTM = { - luatexko_pre_hpack = process_reorder_tonemarks, - luatexko_pre_prelinebreak = process_reorder_tonemarks, + luatexko_hpack_first = process_reorder_tonemarks, + luatexko_prelinebreak_first = process_reorder_tonemarks, }, } @@ -1939,12 +2103,13 @@ local function deactivate_all (str) "pre_linebreak_filter", "vpack_filter", "hyphenate", + "luaotfload.patch_font_unsafe", -- added for harf "luaotfload.patch_font" } do local t = {} for i, v in ipairs( callback_descriptions(name) ) do if v:find(str or "^luatexko%.") then local ff, dd = remove_from_callback(name, v) - t[#t + 1] = { ff, dd, i } + tableinsert(t, { ff, dd, i }) end end luatexko.deactivated[name] = t diff --git a/Master/texmf-dist/tex/luatex/luatexko/luatexko.sty b/Master/texmf-dist/tex/luatex/luatexko/luatexko.sty index 7599a0977b7..76bb940fe89 100644 --- a/Master/texmf-dist/tex/luatex/luatexko/luatexko.sty +++ b/Master/texmf-dist/tex/luatex/luatexko/luatexko.sty @@ -13,7 +13,7 @@ \ifdefined\luatexkohangulfontattr \endinput\fi \ifdefined\selectfont - \ProvidesPackage{luatexko}[2019/08/01 v2.4 typesetting Korean with LuaTeX] + \ProvidesPackage{luatexko}[2019/12/01 v2.5 typesetting Korean with LuaTeX] \RequirePackage{luatexbase} \RequirePackage{fontspec} \else @@ -149,7 +149,8 @@ \directlua{ if \the\luatexkoulinecount == 1 then luatexko.activate("uline") end luatexko.ulboundary(\the\count@, tex.box[0].list, \luatexkoleaderstype) - }#2\directlua{ + }#2\relax + \directlua{ luatexko.ulboundary(\the\count@) }\endgroup } \protected\def\uline{\markoverwith{% @@ -309,8 +310,10 @@ \else \directlua{ luatexko.uhc2utf8.startconvert() }% \fi} % actualtext not provided -\protected\def\actualtext#1#{\luatexkoactualtext} -\def\luatexkoactualtext#1{#1} +\ifdefined\actualtext\else + \protected\def\actualtext#1#{\luatexkoactualtext} + \def\luatexkoactualtext#1{#1} +\fi % math hangul \def\setmathhangulblock#1#2{% \count@="#1 @@ -369,8 +372,8 @@ \afterassignment\luatexkosetmathhangulfonts\font\textmathhangul} \def\luatexkosetmathhangulfonts{% \toks@\expandafter{\directlua{ - local n = string.gsub("\fontname\textmathhangul", " at .+", "") - tex.sprint(n) }}% + local n = tex.fontname(font.id"textmathhangul"):gsub(" at .+", "") + tex.sprint(string.unquoted(n)) }}% \dimen@\fontdimen 6 \textmathhangul \font\scriptmathhangul= {\the\toks@} at .7\dimen@ \font\scriptscriptmathhangul = {\the\toks@} at .5\dimen@ @@ -407,11 +410,11 @@ \DeclareDocumentCommand \setmainhangulfont { O{} m O{} } { \fontspec_set_family:Nnn \luatexkomainhangulfamily { Ligatures=TeX, #1, #3 } { #2 } - \DeclareRobustCommand \luatexkomainhangulfont + \cs_set_protected_nopar:Npn \luatexkomainhangulfont { \fontfamily \luatexkomainhangulfamily \selectfont } - \str_if_eq_x:nnT \familydefault \rmdefault + \str_if_eq:eeT \familydefault \rmdefault { \cs_set_eq:NN \luatexkohangulfont \luatexkomainhangulfont \luatexkohangulselectfont @@ -421,11 +424,11 @@ \DeclareDocumentCommand \setsanshangulfont { O{} m O{} } { \fontspec_set_family:Nnn \luatexkosanshangulfamily { Ligatures=TeX, #1, #3 } { #2 } - \DeclareRobustCommand \luatexkosanshangulfont + \cs_set_protected_nopar:Npn \luatexkosanshangulfont { \fontfamily \luatexkosanshangulfamily \selectfont } - \str_if_eq_x:nnT \familydefault \sfdefault + \str_if_eq:eeT \familydefault \sfdefault { \cs_set_eq:NN \luatexkohangulfont \luatexkosanshangulfont \luatexkohangulselectfont @@ -435,11 +438,11 @@ \DeclareDocumentCommand \setmonohangulfont { O{} m O{} } { \fontspec_set_family:Nnn \luatexkomonohangulfamily { #1, #3 } { #2 } - \DeclareRobustCommand \luatexkomonohangulfont + \cs_set_protected_nopar:Npn \luatexkomonohangulfont { \fontfamily \luatexkomonohangulfamily \selectfont } - \str_if_eq_x:nnT \familydefault \ttdefault + \str_if_eq:eeT \familydefault \ttdefault { \cs_set_eq:NN \luatexkohangulfont \luatexkomonohangulfont \luatexkohangulselectfont @@ -449,9 +452,9 @@ \DeclareDocumentCommand \newhangulfontfamily { m O{} m O{} } { \fontspec_set_family:cnn { luatexko_user_family_ \cs_to_str:N #1 } { #2, #4 } { #3 } - \DeclareRobustCommand #1 + \cs_set_protected_nopar:Npn #1 { - \tl_set:Nn \luatexkohangulfont + \cs_set_nopar:Npn \luatexkohangulfont { \exp_args:Nc \fontfamily { luatexko_user_family_ \cs_to_str:N #1 } \selectfont } @@ -466,7 +469,7 @@ \DeclareDocumentCommand \hangulfontspec { O{} m O{} } { \fontspec_set_family:Nnn \luatexkohangulfontfamily { #1, #3 } { #2 } - \tl_set:Nn \luatexkohangulfont + \cs_set_nopar:Npn \luatexkohangulfont { \fontfamily \luatexkohangulfontfamily \selectfont } @@ -476,11 +479,11 @@ \DeclareDocumentCommand \setmainhanjafont { O{} m O{} } { \fontspec_set_family:Nnn \luatexkomainhanjafamily { Ligatures=TeX, #1, #3 } { #2 } - \DeclareRobustCommand \luatexkomainhanjafont + \cs_set_protected_nopar:Npn \luatexkomainhanjafont { \fontfamily \luatexkomainhanjafamily \selectfont } - \str_if_eq_x:nnT \familydefault \rmdefault + \str_if_eq:eeT \familydefault \rmdefault { \cs_set_eq:NN \luatexkohanjafont \luatexkomainhanjafont \luatexkohanjaselectfont @@ -490,11 +493,11 @@ \DeclareDocumentCommand \setsanshanjafont { O{} m O{} } { \fontspec_set_family:Nnn \luatexkosanshanjafamily { Ligatures=TeX, #1, #3 } { #2 } - \DeclareRobustCommand \luatexkosanshanjafont + \cs_set_protected_nopar:Npn \luatexkosanshanjafont { \fontfamily \luatexkosanshanjafamily \selectfont } - \str_if_eq_x:nnT \familydefault \sfdefault + \str_if_eq:eeT \familydefault \sfdefault { \cs_set_eq:NN \luatexkohanjafont \luatexkosanshanjafont \luatexkohanjaselectfont @@ -504,11 +507,11 @@ \DeclareDocumentCommand \setmonohanjafont { O{} m O{} } { \fontspec_set_family:Nnn \luatexkomonohanjafamily { #1, #3 } { #2 } - \DeclareRobustCommand \luatexkomonohanjafont + \cs_set_protected_nopar:Npn \luatexkomonohanjafont { \fontfamily \luatexkomonohanjafamily \selectfont } - \str_if_eq_x:nnT \familydefault \ttdefault + \str_if_eq:eeT \familydefault \ttdefault { \cs_set_eq:NN \luatexkohanjafont \luatexkomonohanjafont \luatexkohanjaselectfont @@ -518,9 +521,9 @@ \DeclareDocumentCommand \newhanjafontfamily { m O{} m O{} } { \fontspec_set_family:cnn { luatexko_user_family_ \cs_to_str:N #1 } { #2, #4 } { #3 } - \DeclareRobustCommand #1 + \cs_set_protected_nopar:Npn #1 { - \tl_set:Nn \luatexkohanjafont + \cs_set_nopar:Npn \luatexkohanjafont { \exp_args:Nc \fontfamily { luatexko_user_family_ \cs_to_str:N #1 } \selectfont } @@ -535,7 +538,7 @@ \DeclareDocumentCommand \hanjafontspec { O{} m O{} } { \fontspec_set_family:Nnn \luatexkohanjafontfamily { #1, #3 } { #2 } - \tl_set:Nn \luatexkohanjafont + \cs_set_nopar:Npn \luatexkohanjafont { \fontfamily \luatexkohanjafontfamily \selectfont } @@ -546,11 +549,11 @@ \DeclareDocumentCommand \setmainfallbackfont { O{} m O{} } { \fontspec_set_family:Nnn \luatexkomainfallbackfamily { Ligatures=TeX, #1, #3 } { #2 } - \DeclareRobustCommand \luatexkomainfallbackfont + \cs_set_protected_nopar:Npn \luatexkomainfallbackfont { \fontfamily \luatexkomainfallbackfamily \selectfont } - \str_if_eq_x:nnT \familydefault \rmdefault + \str_if_eq:eeT \familydefault \rmdefault { \cs_set_eq:NN \luatexkofallbackfont \luatexkomainfallbackfont \luatexkofallbackselectfont @@ -560,11 +563,11 @@ \DeclareDocumentCommand \setsansfallbackfont { O{} m O{} } { \fontspec_set_family:Nnn \luatexkosansfallbackfamily { Ligatures=TeX, #1, #3 } { #2 } - \DeclareRobustCommand \luatexkosansfallbackfont + \cs_set_protected_nopar:Npn \luatexkosansfallbackfont { \fontfamily \luatexkosansfallbackfamily \selectfont } - \str_if_eq_x:nnT \familydefault \sfdefault + \str_if_eq:eeT \familydefault \sfdefault { \cs_set_eq:NN \luatexkofallbackfont \luatexkosansfallbackfont \luatexkofallbackselectfont @@ -574,11 +577,11 @@ \DeclareDocumentCommand \setmonofallbackfont { O{} m O{} } { \fontspec_set_family:Nnn \luatexkomonofallbackfamily { #1, #3 } { #2 } - \DeclareRobustCommand \luatexkomonofallbackfont + \cs_set_protected_nopar:Npn \luatexkomonofallbackfont { \fontfamily \luatexkomonofallbackfamily \selectfont } - \str_if_eq_x:nnT \familydefault \ttdefault + \str_if_eq:eeT \familydefault \ttdefault { \cs_set_eq:NN \luatexkofallbackfont \luatexkomonofallbackfont \luatexkofallbackselectfont @@ -588,9 +591,9 @@ \DeclareDocumentCommand \newfallbackfontfamily { m O{} m O{} } { \fontspec_set_family:cnn { luatexko_user_family_ \cs_to_str:N #1 } { #2, #4 } { #3 } - \DeclareRobustCommand #1 + \cs_set_protected_nopar:Npn #1 { - \tl_set:Nn \luatexkofallbackfont + \cs_set_nopar:Npn \luatexkofallbackfont { \exp_args:Nc \fontfamily { luatexko_user_family_ \cs_to_str:N #1 } \selectfont } @@ -605,7 +608,7 @@ \DeclareDocumentCommand \fallbackfontspec { O{} m O{} } { \fontspec_set_family:Nnn \luatexkofallbackfontfamily { #1, #3 } { #2 } - \tl_set:Nn \luatexkofallbackfont + \cs_set_nopar:Npn \luatexkofallbackfont { \fontfamily \luatexkofallbackfontfamily \selectfont } -- cgit v1.2.3