From 5b1b236a2d586ae8121b953fec9d3714527aa7dd Mon Sep 17 00:00:00 2001 From: Hironori Kitagawa Date: Sun, 7 Feb 2016 15:57:24 +0900 Subject: [PATCH] lltjfont.sty: \adjustbaseline is re-implemented by luafunction --- doc/luatexja.dtx | 32 ++++++++++---------- src/patches/lltjfont.sty | 68 ++++++++++++++++++++++++++---------------- src/patches/lltjp-listings.sty | 6 ++-- 3 files changed, 61 insertions(+), 45 deletions(-) diff --git a/doc/luatexja.dtx b/doc/luatexja.dtx index 8b199df..964cb60 100644 --- a/doc/luatexja.dtx +++ b/doc/luatexja.dtx @@ -24,6 +24,7 @@ %%%%%%%% fonts \usepackage{luatexja-otf} +\directlua{luatexja.otf.enable_ivs()} \usepackage[no-math]{fontspec} \setmainfont[Ligatures=TeX]{Linux Libertine O} \setmonofont[Scale=MatchLowercase, ItalicFont=lmmono10-italic.otf, @@ -5240,11 +5241,11 @@ in \pTeX, and symbols beside each parameter has the following meaning: % \begin{itemize} %<*en> -\item ``\ast'' : values at the end of a paragraph or a hbox are +\item ``$\ast$'' : values at the end of a paragraph or a hbox are adopted in the whole paragraph or the whole hbox. % %<*ja> -\item ``\ast'':段落やhboxの終端での値がその段落/hbox全体で用いられる. +\item ``$\ast$'':段落やhboxの終端での値がその段落/hbox全体で用いられる. % %<*en> \item ``\dagger'': assignments are always global. @@ -6159,8 +6160,10 @@ to match the vertical center of ``M'' and that of ``あ'' in vertical typesetti + d_{\text{あ}} - d_{\text{M}}, \] where $h_{a}$~and~$d_{a}$ denote the height of ``$a$'' and the depth, respectively. -In \LuaTeX-ja, this \cs{adjustbaseline} does same task, namely setting the +In \LuaTeX-ja, this \cs{adjustbaseline} does similar task, namely setting the \Param{talbaselineshift} parameter. +If the \LaTeX\ is 2015/10/01 release or later, \LuaTeX-ja use a Japanese +character whose character class is zero, instead of `あ'. % %<*ja> \pLaTeXe では,\cs{adjustbaseline} は縦組時に「M」と「あ」の中心線を一致させるために, @@ -6174,8 +6177,12 @@ In \LuaTeX-ja, this \cs{adjustbaseline} does same task, namely setting the \LuaTeX-jaにおいても\cs{adjustbaseline} は同様に\Param{talbaselineshift}パラメータの調整処 理を行っている. -同時に,これも\pLaTeXe の \cs{adjustbaseline} で行われていたが, -「漢」の寸法を元に,(本節の最初に述べた,小文字で始まる)\cs{cht}, \cs{cwd} といった長さ変数を設定する. +同時に,これも\pLaTeXe の \cs{adjustbaseline} で同様の処理が行われていたが, +「漢」の寸法を元に(本節の最初に述べた,小文字で始まる)\cs{cht}, \cs{cwd} +といった長さ変数を設定する. + +なお,\LaTeX が2015/10/01 版以降の場合は,「あ」「漢」の代わりに +「文字クラス0の和文文字」を用いる. % \item[\cs{fontfamily}\{\}] @@ -6774,16 +6781,13 @@ JFMの\texttt{chars}テーブルのエントリとして \verb+'AJ1-xxx'+ の形 正しく半角幅で組むために利用されている. % -\directlua{luatexja.otf.enable_ivs()} %<*en> \paragraph{IVS support} Recent fonts support Ideographic Variation Selector (IVS). It seems that \Pkg{luaotfload} and \Pkg{fontspec} packages do not support IVS, so we implemented IVS support in \Pkg{luatexja-otf}. \emph{IVS support by the \Pkg{luatexja-otf} package is experimental. -If this feature is enabled with current \LuaTeX\ (not with LuaJIT\TeX), -we cannot use any OpenType feature, including {\tt vert}~and~{\tt vrt2}, -in vertical writing mode. If you want to enable IVS support nevertheless, load +If you want to enable IVS support, load \Pkg{luatexja-otf} and execute the following:} % %<*ja> @@ -6798,14 +6802,10 @@ IVSに対応してはいないようである.これらのパッケージで \medskip -\emph{\Pkg{luatexja-otf}によるIVS対応は試験的なものである.現行の\LuaTeX -でIVS対応を一旦有効にすると,縦組時に句読点などが横組用字形のままで組版されたり, -\Pkg{luaotfload}によるOpenType -featureが(\texttt{vert},~\texttt{vrt2}を含め)一切効かないといった -不具合がある\footnote{なぜかLuaJIT\TeX では大丈夫である.}.} -そのような不具合を知りながら有効にするには, +\emph{\Pkg{luatexja-otf}によるIVS対応は試験的なものである. +有効にするには, \Pkg{luatexja-otf}パッケージを読み込んだ上で以下の命令を実行する% -\footnote{この命令を2回以上実行しても意味がない.}: +\footnote{この命令を2回以上実行しても意味がない.}:} % \begin{lstlisting} \directlua{luatexja.otf.enable_ivs()} diff --git a/src/patches/lltjfont.sty b/src/patches/lltjfont.sty index 1bfcfa2..08f9b7f 100644 --- a/src/patches/lltjfont.sty +++ b/src/patches/lltjfont.sty @@ -3,7 +3,7 @@ % \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{lltjfont}[2015/08/28 Patch to NFSS2 for LuaTeX-ja] +\ProvidesPackage{lltjfont}[2016/02/07 Patch to NFSS2 for LuaTeX-ja] \let\k@encoding\@empty \let\ck@encoding\@empty @@ -368,22 +368,52 @@ \ifdefined\newluafunction \newluafunction\ltj@@adjust@baseline@inner + \begingroup\catcode`\~=12 \directlua{% + local nulltable = {} local t = lua.get_functions_table() + local getfont, dir_tate = font.getfont, luatexja.dir_table.dir_tate + local fmt, get_attr = luatexja.jfont.font_metric_table, tex.getattribute + local setdimen, set_attr = tex.setdimen, tex.setattribute + local dir = luatexja.unary_pars.direction t[\the\ltj@@adjust@baseline@inner] = function() - local ft = luatexja.jfont.font_metric_table[ - tex.getattribute('ltj@curtfnt')] or {} - ft = ft and ft.char_type or {} - ft = ft and ft[0] or {} - local fm = font.getfont(font.current()).characters[77] or {} %% 'M' - tex.setattribute('ltj@tablshift', - 0.5*((fm.height or 0)- (fm.depth or 0) - - (ft.height or 0)+ (ft.depth or 0))) + local ft = fmt[get_attr('ltj@curtfnt')] or nulltable + ft = ft and ft.char_type or nulltable + local fk = ft and ft[0] or nulltable + local ht, dp, wd = fk.height or 0, fk.depth or 0, + fk.width or ft.zw or 0 + local fm + = ((getfont(font.current()) or nulltable) + .characters or nulltable)[77] or nulltable %% 'M' + set_attr('ltj@tablshift', + 0.5*((fm.height or 0)- (fm.depth or 0) - ht+ dp)) + if dir() ~= dir_tate then + ft = fmt[get_attr('ltj@curjfnt')] or nulltable + ft = ft and ft.char_type or nulltable + fk = ft and ft[0] or nulltable + ht, dp, wd = fk.height or 0, fk.depth or 0, + fk.width or ft.zw or 0 + end + setdimen('cht', ht); setdimen('cdp', dp) + setdimen('cwd', wd); setdimen('chs', wd) + setdimen('cHT', ht+dp) end - } - \def\ltj@@adjust@baseline{\luafunction\ltj@@adjust@baseline@inner} + }\endgroup + \def\adjustbaseline{\luafunction\ltj@@adjust@baseline@inner + \cvs\normalbaselineskip} \else - \def\ltj@@adjust@baseline{% + \newbox\adjust@box + \newbox\adjust@box@aux + \newdimen\adjust@dimen + \def\adjustbaseline{% + \setbox\adjust@box\hbox{% + \ltj@ykblshift\z@\ltj@tkblshift\z@ 漢}% + \cht\ht\adjust@box + \cdp\dp\adjust@box + \cwd\wd\adjust@box + \cvs\normalbaselineskip + \chs\cwd + \cHT\cht \advance\cHT\cdp \setbox\adjust@box@aux\hbox{\tate\ltj@tkblshift\z@ 漢}% \setbox\adjust@box\hbox{\tate\ltj@tablshift\z@ M}% \adjust@dimen\ht\adjust@box @@ -395,20 +425,6 @@ \ltj@tablshift=\adjust@dimen } \fi -\newbox\adjust@box -\newbox\adjust@box@aux -\newdimen\adjust@dimen -\def\adjustbaseline{% - \setbox\adjust@box\hbox{% - \ltj@ykblshift\z@\ltj@tkblshift\z@ 漢}% - \cht\ht\adjust@box - \cdp\dp\adjust@box - \cwd\wd\adjust@box - \cvs\normalbaselineskip - \chs\cwd - \cHT\cht \advance\cHT\cdp - \ltj@@adjust@baseline -} \DeclareRobustCommand\romanencoding[1]{% \expandafter\ifx\csname T@#1\endcsname\relax \@latex@error{Encoding scheme `#1' unknown}\@eha diff --git a/src/patches/lltjp-listings.sty b/src/patches/lltjp-listings.sty index c1f1b9f..987cd69 100644 --- a/src/patches/lltjp-listings.sty +++ b/src/patches/lltjp-listings.sty @@ -3,7 +3,7 @@ % \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{lltjp-listings}[2015/12/11 Patch to listings for LuaTeX-ja] +\ProvidesPackage{lltjp-listings}[2016/02/07 Patch to listings for LuaTeX-ja] \RequirePackage{listings,luatexbase-cctb} %%%%%%%%%%%%%%%% Japanese support @@ -286,7 +286,7 @@ \else \lst@lExtend\lst@arg{\lst@temp~}% \expandafter\lst@InsideConvert@ - \fi #2} + \fi#2} }\endgroup \lst@AddToHook{ExitVars}{% @@ -344,7 +344,7 @@ %%%%%%%%%%%%%%%% escape to \LaTeX \lstloadaspects{escape} -\gdef\lst@Escape#1#2#3#4{ +\gdef\lst@Escape#1#2#3#4{% \lst@CArgX #1\relax\lst@CDefX {}% {\lst@ifdropinput\else -- 2.11.0