From: Hironori Kitagawa Date: Sat, 11 Jun 2016 12:07:54 +0000 (+0900) Subject: lltjfont.sty etc.: \@text@composite@r based on pLaTeX <2016-06-10> X-Git-Tag: 20160618.0~4 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=db76b5795659e90f88555b7faddf40ebdd519d6f;p=luatex-ja%2Fluatexja.git lltjfont.sty etc.: \@text@composite@r based on pLaTeX <2016-06-10> --- diff --git a/src/ltj-jfmglue.lua b/src/ltj-jfmglue.lua index 1a3a975..34472a2 100644 --- a/src/ltj-jfmglue.lua +++ b/src/ltj-jfmglue.lua @@ -122,7 +122,6 @@ end local function skip_table_to_glue(n) local g, st = node_new(id_glue), ltjs.fast_get_stack_skip(n) setglue(g, st.width, st.stretch, st.shrink, st.stretch_order, st.shrink_order) - -- luatexja.ext_show_node(to_node(g), 'sg ',print) return g, (st.width==1073741823) end @@ -302,7 +301,7 @@ end local ltjw_apply_ashift_math = ltjw.apply_ashift_math local ltjw_apply_ashift_disc = ltjw.apply_ashift_disc local min, max = math.min, math.max -local function calc_np_aux_glyph_common(lp) +local function calc_np_aux_glyph_common(lp, acc_flag) Np.nuc = lp Np.first= (Np.first or lp) if getfield(lp, 'lang') == lang_ja then @@ -380,7 +379,7 @@ local function calc_np_aux_glyph_common(lp) node_free(r) elseif (ct.left_protruding or 0) == 0 then head = insert_before(head, npn, r) - Np.first = (Np.first==npn) and r or npn + Np.first = acc_flag and Np.first or ((Np.first==npn) and r or npn) elseif (ct.right_protruding or 0) == 0 then insert_after(head, npn, r); Np.last, lp = r, r else @@ -490,7 +489,7 @@ local calc_np_auxtable = { set_attr(lp, attr_icflag, PROCESSED); lp = node_next(lp) set_attr(lp, attr_icflag, PROCESSED); lp = node_next(lp) set_attr(lp, attr_icflag, PROCESSED); - return calc_np_aux_glyph_common(lp) + return calc_np_aux_glyph_common(lp, true) else Np.first = Np.first or lp Np.id = id_kern; set_attr(lp, attr_icflag, PROCESSED) diff --git a/src/luatexja-core.sty b/src/luatexja-core.sty index f6d0e86..0d01f10 100644 --- a/src/luatexja-core.sty +++ b/src/luatexja-core.sty @@ -758,6 +758,7 @@ \protected\def\ltjsetht{\directlua{luatexja.direction.set_box_dim('height')}} \protected\def\ltjsetdp{\directlua{luatexja.direction.set_box_dim('depth')}} + %%------------------ Load module for the format \ifltj@in@latex %<*LaTeX> diff --git a/src/luatexja.lua b/src/luatexja.lua index 370141a..2cf0075 100644 --- a/src/luatexja.lua +++ b/src/luatexja.lua @@ -230,8 +230,8 @@ end do luatexja.binary_pars = { jacharrange = function(c, t) - if type(c)~='number' or c<0 or c>31*ltjc.ATTR_RANGE then - -- 0 はエラーにしない(隠し) + if type(c)~='number' or c<-1 or c>31*ltjc.ATTR_RANGE then + -- 0, -1 はエラーにしない(隠し) ltjb.package_error('luatexja', 'invalid character range number (' .. tostring(c) .. ')', 'A character range number should be in the range 1..' @@ -344,6 +344,24 @@ function luatexja.ext_cleanup() end +-- lastnodechar +do + local id_glyph = node.id('glyph') + function luatexja.pltx_composite_last_node_char() + local n = tex.nest[tex.nest.ptr].tail + local r = '-1' + if n then + if n.id==id_glyph then + while n.componetns and n.subtype and n.subtype%4 >= 2 do + n = node.tail(n) + end + r = tostring(n.char) + end + end + tex.sprint(r) + end +end + -- debug do diff --git a/src/patches/lltjfont.sty b/src/patches/lltjfont.sty index cacf903..1b95d95 100644 --- a/src/patches/lltjfont.sty +++ b/src/patches/lltjfont.sty @@ -725,4 +725,56 @@ %%%% patch \@text@composite because of {y,t}albaselineshift +%% \pltx@isletter from plfonts.dtx +\def\pltx@mark{\pltx@mark@} +\let\pltx@scanstop\relax +\long\def\pltx@cond#1\fi{% + #1\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi} +\long\def\pltx@isletter#1{% + \expandafter\pltx@isletter@i\romannumeral-`0#1\pltx@scanstop} +\long\def\pltx@isletter@i#1\pltx@scanstop{% + \pltx@cond\ifx\pltx@mark#1\pltx@mark\fi{\@firstoftwo}% + {\pltx@isletter@ii\pltx@scanstop#1\pltx@scanstop{}#1\pltx@mark}} +\long\def\pltx@isletter@ii#1\pltx@scanstop#{% + \pltx@cond\ifx\pltx@mark#1\pltx@mark\fi% + {\pltx@isletter@iii}{\pltx@isletter@iv}} +\long\def\pltx@isletter@iii#1\pltx@mark{\@secondoftwo} +\long\def\pltx@isletter@iv#1#2#3\pltx@mark{% + \pltx@cond\ifx\pltx@mark#3\pltx@mark\fi{% + \pltx@cond{\ifnum0\ifcat A\noexpand#21\fi\ifcat=\noexpand#21\fi>\z@}\fi + {\@firstoftwo}{\@secondoftwo}% + }{\@secondoftwo}} + +\def\@text@composite@x#1#2{% + \ifx#1\relax + #2% + \else\pltx@isletter{#1}{#1}{% + \begingroup + \setbox\z@\hbox\bgroup% + \ltj@yablshift\z@ \ltj@tablshift\z@ + #1% + \@tempcntb\directlua{luatexja.pltx_composite_last_node_char()}%) + \xdef\pltx@composite@temp{\noexpand\@tempcntb=\the\@tempcntb\relax}% + \aftergroup\pltx@composite@temp + \egroup + \ifnum\ltjgetparameter{direction}=3 % + \@tempdima=\ltj@tablshift sp\else\@tempdima=\ltj@yablshift sp\fi + \ifnum\@tempcntb<\z@\@tempcnta\z@\else + \@tempcnta=\ltjgetparameter{jacharrange}{\ltjgetparameter{chartorange}{\@tempcntb}}\relax + \ifnum\@tempcnta=\z@\@tempdima\z@\fi + \fi + \ifnum\@tempcnta>\z@ + \ifodd\ltjgetparameter{alxspmode}{\@tempcntb}\else\leavevmode\hbox{}\fi + \begingroup\mathsurround\z@$% + \hbox{\lower\@tempdima\box\z@} + $\endgroup% + \ifnum\ltjgetparameter{alxspmode}{\@tempcntb}<2\hbox{}\fi + \else + \ifdim\@tempdima=\z@{\ltj@yablshift\z@ \ltj@tablshift\z@#1}% + \else\lower\@tempdima\box\z@\fi + \fi + \endgroup}% + \fi +} + \endinput diff --git a/test/test23-composite.tex b/test/test23-composite.tex new file mode 100644 index 0000000..775dede --- /dev/null +++ b/test/test23-composite.tex @@ -0,0 +1,22 @@ +%#!ptex2pdf -l text_composite.tex +\documentclass{ltjarticle} +%\DeclareTextComposite{\"}{OT1}{圏}{`点}% invalid +%\usepackage[utf8x]{inputenc} +%\usepackage[T1]{fontenc} +\DeclareTextCompositeCommand{\"}{OT1}{圏}{テン} +\DeclareTextCompositeCommand{\"}{T1}{圏}{テン} +\def\test{あ\AA あ\'(あ\'eあ\'圏い\"圏うa\"圏a\AA a(\AA)\'e} +\makeatletter +\begin{document} +\ltjsetparameter{xkanjiskip=15pt, yalbaselineshift=10pt} +\test +\setbox2=\hbox{あ\'eい} +\directlua{luatexja.ext_show_node_list(tex.getbox(2), ' ', print)} +\par +\ltjsetparameter{yalbaselineshift=0pt} +\test + +\mathsurround20pt +\test + +\end{document}