OSDN Git Service

Merge branch 'kmaeda-manual' into kitagawa_test
authorHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Fri, 30 Dec 2011 07:36:29 +0000 (16:36 +0900)
committerHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Fri, 30 Dec 2011 07:36:29 +0000 (16:36 +0900)
31 files changed:
.gitignore [new file with mode: 0644]
doc/man-en.pdf
doc/man-ja.pdf
doc/manual.dtx
src/addons/luatexja-ajmacros.sty [moved from src/luatexja-ajmacros.sty with 100% similarity]
src/addons/luatexja-fontspec.sty [moved from src/luatexja-fontspec.sty with 52% similarity]
src/addons/luatexja-otf.sty [moved from src/luatexja-otf.sty with 100% similarity]
src/luatexja-core.lua
src/luatexja-core.sty
src/luatexja-latex.sty
src/luatexja-plain.sty
src/luatexja/jfmglue.lua
src/luatexja/math.lua
src/luatexja/pretreat.lua
src/luatexja/setwidth.lua
src/luatexja/stack.lua
src/patches/lltjcore.sty [moved from src/lltjcore.sty with 95% similarity]
src/patches/lltjdefs.sty [moved from src/lltjdefs.sty with 96% similarity]
src/patches/lltjfont.sty [moved from src/lltjfont.sty with 99% similarity]
src/patches/lltjp-listings.sty [moved from doc/lltjlisting.sty with 96% similarity]
src/patches/lltjp-unicode-math.sty [new file with mode: 0644]
src/patches/lltjp-xunicode.sty [new file with mode: 0644]
test/test01-noembed.pdf
test/test01-noembed.tex
test/test01.pdf
test/test01.tex
test/test04-jfm.pdf
test/test07-math-unicode.pdf [new file with mode: 0644]
test/test07-math-unicode.tex [new file with mode: 0644]
test/test07-math.pdf
test/test07-math.tex

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..e01d227
--- /dev/null
@@ -0,0 +1,6 @@
+*.log
+*.aux
+*.toc
+*.out
+*.tmp
+*~
index e0926e9..e65af16 100644 (file)
Binary files a/doc/man-en.pdf and b/doc/man-en.pdf differ
index 544a53d..a683a1c 100644 (file)
Binary files a/doc/man-ja.pdf and b/doc/man-ja.pdf differ
index a0fa04b..de3b14f 100644 (file)
@@ -5,7 +5,7 @@
 \usepackage[margin=20mm,footskip=5mm]{geometry}
 
 \usepackage{amsmath,amssymb,xcolor,pict2e,multienum,amsthm,float}
-\usepackage{booktabs,listings,lltjlisting,showexpl,multicol}
+\usepackage{booktabs,listings,showexpl,multicol}
 \usepackage{luatexja-otf}
 \usepackage{luatexja-fontspec}
 \usepackage[unicode]{hyperref}
@@ -765,7 +765,7 @@ If you want to use these functions, load \Pkg{luatexja-otf} package.
 \CID{7652}飾区の\CID{13706}野家,
 葛飾区の吉野家
 \end{LTXexample}
-%lltjlisting.sty要修正?:↑「森」の直後で改行.
+%lltjp-listings.sty要修正?:↑「森」の直後で改行.
 
 
 %<en>\subsection{Changing Fonts}
@@ -2350,17 +2350,19 @@ At the present version, the lowermost bit of <natural number> indicates
 \item[\Param{yjabaselineshift}\,=<dimen>$^\ast$]\
 \item[\Param{yalbaselineshift}\,=<dimen>$^\ast$] [\verb+\ybaselineshift+]
 
-\item[\Param{jaxspmode}\,=\{<chr\_code>,<mode>\}] [\verb+\inhibitxspcode+]
+\item[\Param{jaxspmode}\,=\{<chr\_code>,<mode>\}]
 
 Setting whether inserting  \Param{xkanjiskip} is allowed before/after a \textbf{JAchar} whose character code is <chr\_code>.
 The followings are allowed for <mode>:
 \begin{description}
 \item[0, \texttt{inhibit}] Insertion of \Param{xkanjiskip} is inhibited before the character, nor after the character.
-\item[2, \texttt{preonly}] Insertion of \Param{xkanjiskip} is allowed before the character, but not after.
-\item[1, \texttt{postonly}] Insertion of \Param{xkanjiskip} is allowed after the character, but not before.
+\item[1, \texttt{preonly}] Insertion of \Param{xkanjiskip} is allowed before the character, but not after.
+\item[2, \texttt{postonly}] Insertion of \Param{xkanjiskip} is allowed after the character, but not before.
 \item[3, \texttt{allow}] Insertion of \Param{xkanjiskip} is allowed before the character and after the character.
 This is the default value.
 \end{description}
+This parameter is similar to the \verb+\inhibitxspcode+ primitive of \pTeX, but not compatible with \verb+\inhibitxspcode+.
+
 
 \item[\Param{alxspmode}\,=\{<chr\_code>,<mode>\}] [\verb+\xspcode+]
 
@@ -2378,7 +2380,7 @@ The followings are allowed for <mode>:
           before the character and after the character.
 This is the default value.
 \end{description}
-Note that parameters \Param{jaxspmode} and \Param{alxspmode} use a common table.
+Note that parameters \Param{jaxspmode} and \Param{alxspmode} use a common table, hence these two parameters are synonyms of each other.
 
 \item[\Param{autospacing}\,=<bool>$^\ast$] [\verb+\autospacing+]
 \item[\Param{autoxspacing}\,=<bool>$^\ast$] [\verb+\autoxspacing+]
similarity index 52%
rename from src/luatexja-fontspec.sty
rename to src/addons/luatexja-fontspec.sty
index 7e5bfd8..3a81907 100644 (file)
@@ -3,82 +3,9 @@
 %
 
 \NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{luatexja-fontspec}[2011/11/16 v0.3]
-
-\def\UTFencname{EU2}\def\XeTeXpicfile{}
-\RequirePackage{xunicode}
-%% Patch for xunicode.sty
-{\catcode`\"=12
-\gdef\check@hexcom@digits@#1#2#3#4#5@!@#6#7#8{%
- \ifx @#4\relax
-  \UTFacc@warning@{insufficient hex digits #7 for #6-\string#8}%
- \else
-  \ifcat \active\noexpand#8%
-   \ifx\add@flag\@ne %
-    \expandafter\def\csname\UTFencname\string#8\endcsname{\ltjalchar"#1#2#3#4\relax}%
-    \ifx\unDeFiNed@#8%
-     \ifx\cf@encoding\UTFencname
-      \DeclareTextCommand{#8}{OT1}{\undefined}%
-     \else
-      \DeclareTextCommand{#8}{\cf@encoding}{\undefined}%
-     \fi
-    \else {% macro #8 exists already ...
-      \let\protect\noexpand
-      \edef\UTF@testi{#8}\def\UTF@testii{#8}%
-      \ifx\UTF@testi\UTF@testii\aftergroup\UTF@ignore
-      \else\aftergroup\UTF@doit\fi
-     }%
-     \iffalse
-      % ... but when it isn't robust, make it so
-      \expandafter\let\csname?-\string#8\endcsname#8\relax
-      \edef\next@UTF@{{\cf@encoding}%
-        {\expandafter\noexpand\csname?-\string#8\endcsname}}%
-      \expandafter\DeclareTextCommand\expandafter
-         {\expandafter#8\expandafter}\next@UTF@
-     \fi
-    \fi %
-   \else % \add@flag \z@
-    \expandafter\global\expandafter
-      \let\csname\UTFencname\string#8\endcsname\relax
-   \fi % end of \add@flag switch
-  \else % not active catcode --- shouldn't happen
-  % \typeout{*** did you really mean #8 ? ***}%
-   \ifx\add@flag\@ne %
-    \edef\tmp@name{\expandafter\string\csname\UTFencname\endcsname
-      \expandafter\string\csname#8\endcsname}%
-    \expandafter\def\csname\tmp@name\endcsname{\ltjalchar"#1#2#3#4\relax}%
-    \ifx\cf@encoding\UTFencname
-     \expandafter\DeclareTextCommand\expandafter
-       {\csname#8\endcsname}{OT1}{\undefined}%
-    \else
-     \expandafter\DeclareTextCommand\expandafter
-       {\csname#8\endcsname}{\cf@encoding}{\undefined}%
-    \fi
-   \else % \add@flag \z@
-    \expandafter\global\expandafter\let\csname#8\endcsname\relax
-   \fi % end of \add@flag switch
-  \fi % end of \ifcat
- \fi}
-\gdef\check@hex@digits@#1#2#3#4#5@!@#6#7#8#9{%
- \ifx @#4\relax
-  \UTFacc@warning@{insufficient hex digits #7 for #6-\string#8#9}%
- \else
-  \def\UTFchar{\ltjalchar"#1#2#3#4\relax}%
-  \expandafter\expandafter\expandafter\declare@utf@composite
-  \expandafter\expandafter\expandafter
-   {\expandafter\csname#6\endcsname}{\UTFchar}{#8}{#9}\relax
- \fi}
-%\gdef\add@UTF@accent#1#2#3{#2\ltjalchar"#1\relax}
-\gdef\add@UTF@accent#1#2#3{\ifx\relax#2\relax\ltjalchar"#3\else
- \ifx\ #2\relax\ltjalchar"#3\else
- \expandafter\ifx\UTF@space#2\relax\ltjalchar"#3\else
- \ifx~#2\ltjalchar"#3\else#2\ltjalchar"#1\fi\fi\fi\fi\relax}
-\gdef\add@UTF@accents#1#2#3{#2\ltjalchar"#1\ltjalchar"#3\relax}
-}
-%% End of patch for xunicode.sty "
+\ProvidesPackage{luatexja-fontspec}[2011/09/23 v0.2]
 
-\RequirePackage{fontspec}
-\RequirePackage{luatexja}
+\RequirePackage{fontspec,luatexja}
 
 \ExplSyntaxOn
 
 
 \cs_set_eq:NN \addjfontfeature \addjfontfeatures
 
-% We reload xunicode package here.
-\ExplSyntaxOff\ReloadXunicode{EU2}
 \endinput
-
-%% the following patch is needed to xunicode.sty:
-%% 
---- /opt/texlive/2011/texmf-dist/tex/xelatex/xunicode/xunicode.sty     2011-09-12 08:31:47.000000000 +0900
-+++ xunicode.sty       2011-11-16 22:06:17.061413113 +0900
-@@ -1475,7 +1475,11 @@
- \newtoks\tipasavetokens
- \newtoks\tipachecktokens
-+
-+\fi
- \newif\iftipaonetoken
-+\expandafter\ifx\csname ReloadXunicode\endcsname\relax
-+
- \def\tipalasttoken{!@! do nothing with this !@!}
- \def\tipacatchonechar#1{\begingroup
-  \def\textipa##1{##1}% prevent recursion
index 673f581..3ebe54b 100644 (file)
@@ -105,7 +105,7 @@ end
 function math.two_add(a,b) return a+b end
 function math.two_average(a,b) return (a+b)/2 end
 
----- table: charprop_stack_table [stack_level][chr_code].{pre|post|xsp}
+---- table: charprop_stack_table [stack_level].{pre|post|xsp}[chr_code]
 
 ------------------------------------------------------------------------
 -- CODE FOR GETTING/SETTING PARAMETERS 
index 666a6fe..dcc3fb4 100644 (file)
 \def\zw{\directlua{luatexja.jfont.load_zw()}\ltj@zw}
 \def\zh{\directlua{luatexja.jfont.load_zh()}\ltj@zh}
 
+
 %%%%%%%% \inhibitglue
+\protected\def\ltj@reset@globaldefs{%
+  \directlua{ltj.global_temp = tex.globaldefs; tex.globaldefs = 0}}
+\protected\def\ltj@restore@globaldefs{\directlua{tex.globaldefs = ltj.global_temp}}
 \let\new@everypar=\everypar
 \protected\def\inhibitglue{\relax%
   \ifvmode
-    \directlua{ltj.global_temp = tex.globaldefs; tex.globaldefs = 0}% trick
+    \ltj@reset@globaldefs
     \xdef\@@tempa{\the\everypar}%
     \xdef\@@tempb{\everypar={\@@tempa}\@@tempa\noexpand\ltj@@ihb}%
     \everypar\expandafter{\@@tempb}%
-    \directlua{tex.globaldefs = ltj.global_temp}% trick
+    \ltj@restore@globaldefs
   \else\ifhmode\ltj@@ihb\fi\fi}
 \def\ltj@@ihb{\directlua{luatexja.jfmglue.create_inhibitglue_node()}}
 
 \define@key[ltj]{japaram}{jascriptscriptfont}{%
   \expandafter\ltj@@set@stackfont#1:{mjss}}
 \def\ltj@@set@stackfont#1,#2:#3{%
-  \directlua{%
-    ltj.global_temp = tex.globaldefs; 
-    tex.globaldefs = 0}%
+  \ltj@reset@globaldefs
   \ltj@tempcnta=\ltj@curjfnt\ltj@curjfnt=-1 #2%
   \ifnum\ltj@curjfnt=-1
     \@PackageError{luatexja-core}%
     \ltj@safe@num@or\ltj@defnum{#1}, \the\ltj@curjfnt)}%
   \fi
   \ltj@curjfnt=\ltj@tempcnta
-  \directlua{tex.globaldefs = ltj.global_temp}%
+  \ltj@restore@globaldefs
   }
 
 % yalbaselineshift = <dimen>
 
 % jaxspmode = {<char_code>, <mode>}
 % mode: inhibit, preonly, postonly, allow
-%    or       0        2         1      3
+%    or       0        1         2      3
 \define@key[ltj]{japaram}{jaxspmode}{%        \inhibitxspcode
   \expandafter\ltj@set@jaxspmode#1:\relax}
 \def\ltj@set@jaxspmode#1,#2:{%
   \lowercase{\edef\ltj@temp{#2}}%
   \def\ltj@tempa{inhibit}\ifx\ltj@temp\ltj@tempa\def\ltj@temp{0}\fi
-  \def\ltj@tempa{preonly}\ifx\ltj@temp\ltj@tempa\def\ltj@temp{2}\fi
-  \def\ltj@tempa{postonly}\ifx\ltj@temp\ltj@tempa\def\ltj@temp{1}\fi
+  \def\ltj@tempa{preonly}\ifx\ltj@temp\ltj@tempa\def\ltj@temp{1}\fi
+  \def\ltj@tempa{postonly}\ifx\ltj@temp\ltj@tempa\def\ltj@temp{2}\fi
   \def\ltj@tempa{allow}\ifx\ltj@temp\ltj@tempa\def\ltj@temp{3}\fi
   \directlua{luatexja.stack.set_stack_table(ltj.isglobal, 'xsp', 
     \ltj@safe@num@or\ltj@defnum{#1},
     \csname ltj@kcat4\endcsname="7FFFFFFF %"
     \csname ltj@kcat5\endcsname="7FFFFFFF %"
     \csname ltj@kcat6\endcsname="7FFFFFFF }%"
-\protected\def\ltj@backup@kcat{\edef\ltj@restore@kcat{%
-    \csname ltj@kcat0\endcsname=\expandafter\the\csname ltj@kcat0\endcsname\relax
-    \csname ltj@kcat1\endcsname=\expandafter\the\csname ltj@kcat1\endcsname\relax
-    \csname ltj@kcat2\endcsname=\expandafter\the\csname ltj@kcat2\endcsname\relax
-    \csname ltj@kcat3\endcsname=\expandafter\the\csname ltj@kcat3\endcsname\relax
-    \csname ltj@kcat4\endcsname=\expandafter\the\csname ltj@kcat4\endcsname\relax
-    \csname ltj@kcat5\endcsname=\expandafter\the\csname ltj@kcat5\endcsname\relax
-    \csname ltj@kcat6\endcsname=\expandafter\the\csname ltj@kcat6\endcsname\relax}}
-\let\ltj@restore@kcat=\relax
-
-\protected\def\ltjjachar{\afterassignment\ltj@@kchar\ltj@tempcnta}
-\def\ltj@@kchar{{\directlua{tex.globaldefs = 0}\ltj@alljachar\ltj@@origchar\ltj@tempcnta}}
-\protected\def\ltjalchar{\afterassignment\ltj@@achar\ltj@tempcnta}
-\def\ltj@@achar{{\directlua{tex.globaldefs = 0}\ltj@allalchar\ltj@@origchar\ltj@tempcnta}}
 
+\protected\def\ltjjachar{\afterassignment\ltj@@jachar\ltj@tempcnta}
+\def\ltj@@jachar{{\directlua{tex.globaldefs = 0}\ltj@alljachar\ltj@@origchar\ltj@tempcnta}}
+\protected\def\ltjalchar{\afterassignment\ltj@@alchar\ltj@tempcnta}
+\def\ltj@@alchar{{\directlua{tex.globaldefs = 0}\ltj@allalchar\ltj@@origchar\ltj@tempcnta}}
 
+%%%%%%%% \ltjsetmathletter<number>, \ltjunsetmathletter<number>
+\def\ltjsetmathletter#1{\directlua{luatexja.math.is_math_letters[#1]=true}}
+\def\ltjunsetmathletter#1{\directlua{luatexja.math.is_math_letters[#1]=false}}
 
 %%------------------ Load module for the format
 
index 5183456..ee41e4b 100644 (file)
 \def\luatexjalatexLoaded{\endinput}
 
 \NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{luatexja-latex}[2011/08/01 v0.1]
+\ProvidesPackage{luatexja-latex}[2011/11/22 LuaLaTeX-ja]
+
+\def\ltj@pkgpatchlist{}
+\def\ltj@pkgpatch#1{
+  \@ifpackageloaded{#1}{\usepackage{lltjp-#1}}{
+    \@ifpackageloaded{filehook}{\AtEndOfPackageFile*{#1}{\usepackage{lltjp-#1}}}{}
+  }
+  \ifx\ltj@pkgpatchlist\@empty
+    \gdef\ltj@pkgpatchlist{#1}
+  \else
+    \xdef\ltj@pkgpatchlist{\ltj@pkgpatchlist, #1}
+  \fi
+}
 
 \endlinechar=13
 
+%%% patch for LaTeX
+\usepackage{lltjfont}
+\usepackage{lltjdefs}
+\usepackage{lltjcore}
 
-%%% patch for LaTeX (similar to plfonts.dtx)
-\input{lltjfont.sty}
-\input{lltjdefs.sty}
-\input{lltjcore.sty}
-
-%%% parameter
-
+%%% default parameters
 \ltjsetparameter{kanjiskip=0pt plus 0.4pt minus 0.4pt, 
   xkanjiskip=.25\zw plus 1pt minus 1pt,
   autospacing, autoxspacing, jacharrange={-1}, 
 }
 
 \input luatexja-kinsoku.tex
+\expandafter\let\csname JY3/mc/m/n/10\endcsname\relax
+
+%%% patch for packages
+\IfFileExists{filehook.sty}{\usepackage{filehook}}{}
+\ltj@pkgpatch{listings}
+\ltj@pkgpatch{unicode-math}
+\ltj@pkgpatch{xunicode}
+\@ifpackageloaded{filehook}{}{%
+  \@PackageWarningNoLine{luatexja-latex}{
+    LuaTeX-ja uses filehook package to apply patches to the following packages:\MessageBreak
+    \ltj@pkgpatchlist.\MessageBreak
+    But your TeX system does not have the filehook package.\MessageBreak
+    Therefore problems may occur if you load the above packages after this message}%
+}
 
 %%------------------ all done
 \ltj@latex@AtEnd
index 0deeae9..c472e83 100644 (file)
@@ -61,6 +61,8 @@
 \ltjdefcharrange{8}{"B4, "A8, "B1, "D7, "F7, "B0, "A7, "B6}
 \ltjsetparameter{jacharrange={-1, +2, +3, -4, -5, +6, +7, +8}}
 
+\directlua{for x=128,255 do luatexja.math.is_math_letters[x] = true end}
+
 %%------------------ all done
 \ltj@plain@AtEnd
 \endinput
index 8aec0fd..5163c91 100644 (file)
@@ -73,6 +73,7 @@ local max_dimen = 1073741823
 
 local ltjs_get_penalty_table = ltjs.get_penalty_table
 local ltjs_get_skip_table = ltjs.get_skip_table
+local ltjf_find_char_class = ltjf.find_char_class
 local ltjf_font_metric_table = ltjf.font_metric_table
 local ltjf_metrics = ltjf.metrics
 local box_stack_level
@@ -81,7 +82,7 @@ local par_indented -- is the paragraph indented?
 -------------------- Helper functions
 
 -- This function is called only for acquiring `special' characters.
-local function find_char_class(c,m)
+local function fast_find_char_class(c,m)
    return m.chars[c] or 0
 end
 
@@ -245,6 +246,106 @@ local function calc_np_pbox()
    check_next_ickern()
 end
 
+local calc_np_auxtable = {
+   [id_glyph] = function() 
+                  Np.first = lp
+                  if lp.font == has_attr(lp, attr_curjfnt) then 
+                     Np.id = id_jglyph 
+                  else 
+                     Np.id = id_glyph 
+                  end
+                  Np.first = lp; Np.nuc = lp; set_attr_icflag_processed(lp)
+                  lp = node_next(lp); check_next_ickern(); return true
+               end,
+   [id_hlist] = function() 
+                  Np.first = lp; Np.last = lp; Np.nuc = lp; 
+                  set_attr_icflag_processed(lp)
+                  if lp.shift~=0 then 
+                     Np.id = id_box_like
+                  else 
+                     Np.id = id_hlist 
+                  end
+                  lp = node_next(lp); return true
+               end,
+   [id_vlist] = function()
+                  Np.first = lp; Np.nuc = lp; Np.last = lp;
+                  Np.id = id_box_like; set_attr_icflag_processed(lp); 
+                  lp = node_next(lp); return true
+               end,
+   [id_rule] = function()
+                 Np.first = lp; Np.nuc = lp; Np.last = lp;
+                 Np.id = id_box_like; set_attr_icflag_processed(lp); 
+                 lp = node_next(lp); return true
+              end,
+   [id_ins] = function() 
+                set_attr_icflag_processed(lp); lp = node_next(lp)
+                return false
+             end,
+   [id_mark] = function() 
+                 set_attr_icflag_processed(lp); lp = node_next(lp)
+                 return false
+              end,
+   [id_adjust] = function() 
+                   set_attr_icflag_processed(lp); lp = node_next(lp)
+                   return false
+                end,
+   [id_disc] = function()
+                 Np.first = lp; Np.nuc = lp; set_attr_icflag_processed(lp); 
+                 Np.last = lp; Np.id = id_disc; lp = node_next(lp); return true
+              end,
+   [id_whatsit] = function() 
+                    if lp.subtype==sid_user and lp.user_id==30111 then
+                       local lq = node_next(lp)
+                       head = node_remove(head, lp); node_free(lp); lp = lq; ihb_flag = true
+                    else
+                       set_attr_icflag_processed(lp); lp = node_next(lp)
+                    end
+                    return false
+                 end,
+   [id_math] = function()
+                 Np.first = lp; Np.nuc = lp; 
+                 set_attr_icflag_processed(lp); lp  = node_next(lp) 
+                 while lp.id~=id_math do 
+                    set_attr_icflag_processed(lp); lp  = node_next(lp) 
+                 end
+                 set_attr_icflag_processed(lp); 
+                 Np.last = lp; Np.id = id_math; lp = node_next(lp); 
+                 return true
+              end,
+   [id_glue] = function()
+                 Np.first = lp; Np.nuc = lp; set_attr_icflag_processed(lp); 
+                 Np.last = lp; Np.id = id_glue; lp = node_next(lp); return true
+              end,
+   [id_kern] = function() 
+                 Np.first = lp
+                 if lp.subtype==2 then
+                    set_attr_icflag_processed(lp); lp = node_next(lp)
+                    set_attr_icflag_processed(lp); lp = node_next(lp)
+                    set_attr_icflag_processed(lp); lp = node_next(lp)
+                    set_attr_icflag_processed(lp); Np.nuc = lp
+                    if lp.font == has_attr(lp, attr_curjfnt) then 
+                       Np.id = id_jglyph 
+                    else
+                       Np.id = id_glyph 
+                    end
+                    lp = node_next(lp); check_next_ickern(); 
+                 else
+                    Np.id = id_kern; set_attr_icflag_processed(lp);
+                    Np.last = lp; lp = node_next(lp)
+                 end
+                 return true
+              end,
+   [id_penalty] = function()
+                    Bp[#Bp+1] = lp; set_attr_icflag_processed(lp); 
+                    lp = node_next(lp); return false
+                 end,
+   [13] = function()
+                 Np.first = lp; Np.nuc = lp; Np.last = lp;
+                 Np.id = id_box_like; set_attr_icflag_processed(lp); 
+                 lp = node_next(lp); return true
+              end,
+}
+
 local function calc_np()
    -- We assume lp = node_next(Np.last)
    local lpi, lpa, Nr
@@ -252,58 +353,16 @@ local function calc_np()
    Nq = Np; Np = Nr
    for k in pairs(Bp) do Bp[k] = nil end
    ihb_flag = false 
-   while true do
-      lpi = lp.id; lpa = has_attr(lp, attr_icflag) or 0
-      if lp==last then Np = nil; return
-      elseif lpa>=PACKED then
+   while lp ~= last do
+      lpa = has_attr(lp, attr_icflag) or 0
+      if lpa>=PACKED then
         if lpa == BOXBDD then
            local lq = node_next(lp)
            head = node_remove(head, lp); node_free(lp); lp = lq
         else calc_np_pbox(); return end -- id_pbox
-      elseif lpi == id_ins or lpi == id_mark or lpi == id_adjust then
-        set_attr_icflag_processed(lp); lp = node_next(lp)
-      elseif lpi == id_penalty then
-        table_insert(Bp, lp); set_attr_icflag_processed(lp); lp = node_next(lp)
-      elseif lpi == id_whatsit then
-        if lp.subtype==sid_user and lp.user_id==30111 then
-           local lq = node_next(lp)
-           head = node_remove(head, lp); node_free(lp); lp = lq; ihb_flag = true
-        else
-           set_attr_icflag_processed(lp); lp = node_next(lp)
-        end
-      else -- a `cluster' is found
-        Np.first = lp
-        if lpi == id_glyph then -- id_[j]glyph
-           if lp.font == has_attr(lp, attr_curjfnt) then Np.id = id_jglyph 
-           else Np.id = id_glyph end
-           Np.nuc = lp; set_attr_icflag_processed(lp)
-           lp = node_next(lp); check_next_ickern(); return
-        elseif lpi == id_hlist then -- hlist
-           Np.last = lp; Np.nuc = lp; set_attr_icflag_processed(lp)
-           if lp.shift~=0 then Np.id = id_box_like
-           else Np.id = lpi end
-           lp = node_next(lp); return
-        elseif lpi == id_vlist or lpi == id_rule then -- id_box_like
-           Np.nuc = lp; Np.last = lp; Np.id = id_box_like; break
-        elseif lpi == id_math then -- id_math
-           Np.nuc = lp; lp  = node_next(lp) 
-           while lp.id~=id_math do 
-              set_attr_icflag_processed(lp); lp  = node_next(lp) 
-           end; break
-        elseif lpi == id_kern and lp.subtype==2 then -- id_kern
-           set_attr_icflag_processed(lp); lp = node_next(lp)
-           set_attr_icflag_processed(lp); lp = node_next(lp)
-           set_attr_icflag_processed(lp); lp = node_next(lp)
-           set_attr_icflag_processed(lp); Np.nuc = lp
-           if lp.font == has_attr(lp, attr_curjfnt) then Np.id = id_jglyph 
-           else Np.id = id_glyph end
-           lp = node_next(lp); check_next_ickern(); return
-        else -- id_disc, id_glue, id_kern
-           Np.nuc = lp; break
-        end
-      end
+      elseif calc_np_auxtable[lp.id]() then return end
    end
-   set_attr_icflag_processed(lp); Np.last = lp; Np.id = lpi; lp = node_next(lp)
+   Np = nil; return
 end
 
 -- extract informations from Np
@@ -312,25 +371,29 @@ end
 --            "Np is not a character" otherwise.
 
 -- 和文文字のデータを取得
-local function set_np_xspc_jachar(c,x)
-   Np.class = has_attr(x, attr_jchar_class)
-   Np.char = c
+local function set_np_xspc_jachar(x)
    local z = ltjf_font_metric_table[x.font]
+   local c = x.char
+   local cls = ltjf_find_char_class(c, z)
+   local m = ltjf_metrics[z.jfm]
+   set_attr(x, attr_jchar_class, cls)
+   Np.class = cls
+   Np.char = c
    Np.size= z.size
-   Np.met = ltjf_metrics[z.jfm]
+   Np.met = m
    Np.var = z.var
    Np.pre = ltjs_get_penalty_table('pre', c, 0, box_stack_level)
    Np.post = ltjs_get_penalty_table('post', c, 0, box_stack_level)
-   z = find_char_class('lineend', Np.met)
-   local y = Np.met.size_cache[Np.size].char_type[Np.class]
+   z = fast_find_char_class('lineend', m)
+   local y = m.size_cache[Np.size].char_type[Np.class]
    if y.kern and y.kern[z] then 
       Np.lend = y.kern[z]
    else 
       Np.lend = 0 
    end
    y = ltjs_get_penalty_table('xsp', c, 3, box_stack_level)
-   Np.xspc_before = (y>=2)
-   Np.xspc_after  = (y%2==1)
+   Np.xspc_before = (y%2==1)
+   Np.xspc_after  = (y>=2)
    Np.auto_kspc = (has_attr(x, attr_autospc)==1)
    Np.auto_xspc = (has_attr(x, attr_autoxspc)==1)
 end
@@ -365,7 +428,7 @@ end
 local function extract_np()
    local x = Np.nuc
    if Np.id ==  id_jglyph then
-      set_np_xspc_jachar(x.char, x)
+      set_np_xspc_jachar(x)
    elseif Np.id == id_glyph then
       set_np_xspc_alchar(x.char, x, ligature_head)
    elseif Np.id == id_hlist then
@@ -373,7 +436,7 @@ local function extract_np()
       if check_box(x.head, nil) then
         if first_char then
            if first_char.font == has_attr(first_char, attr_curjfnt) then 
-              set_np_xspc_jachar(first_char.char,first_char)
+              set_np_xspc_jachar(first_char)
            else
               set_np_xspc_alchar(first_char.char,first_char, ligature_head)
            end
@@ -384,7 +447,7 @@ local function extract_np()
       if check_box(Np.first, node_next(Np.last)) then
         if first_char then
            if first_char.font == has_attr(first_char, attr_curjfnt) then 
-              set_np_xspc_jachar(first_char.char,first_char)
+              set_np_xspc_jachar(first_char)
            else
               set_np_xspc_alchar(first_char.char,first_char, ligature_head)
            end
@@ -395,7 +458,7 @@ local function extract_np()
       if check_box(x.replace, nil) then
         if first_char then
            if first_char.font == has_attr(first_char, attr_curjfnt) then 
-              set_np_xspc_jachar(first_char.char,first_char)
+              set_np_xspc_jachar(first_char)
            else
               set_np_xspc_alchar(first_char.char,first_char, ligature_head)
            end
@@ -411,7 +474,7 @@ end
 local function after_hlist()
    if last_char then
       if last_char.font == has_attr(last_char, attr_curjfnt) then 
-        set_np_xspc_jachar(last_char.char,last_char, ligature_after)
+        set_np_xspc_jachar(last_char, ligature_after)
       else
         set_np_xspc_alchar(last_char.char,last_char, ligature_after)
       end
@@ -452,7 +515,7 @@ local function handle_penalty_normal(post, pre, g)
         if a<-10000 then a = -10000 elseif a>10000 then a = 10000 end
         p.penalty = a
         head = node_insert_before(head, Np.first, p)
-        Bp[1] = p; set_attr(p, attr_icflag, KINSOKU)
+        table_insert(Bp, p); set_attr(p, attr_icflag, KINSOKU)
       end
    else for i, v in pairs(Bp) do add_penalty(v,a) end
    end
@@ -466,7 +529,7 @@ local function handle_penalty_always(post, pre, g)
         if a<-10000 then a = -10000 elseif a>10000 then a = 10000 end
         p.penalty = a
         head = node_insert_before(head, Np.first, p)
-        Bp[1] = p; set_attr(p, attr_icflag, KINSOKU)
+        table_insert(Bp, p); set_attr(p, attr_icflag, KINSOKU)
       end
    else for i, v in pairs(Bp) do add_penalty(v,a) end
    end
@@ -478,7 +541,7 @@ local function handle_penalty_suppress(post, pre, g)
       if g and g.id==id_glue then
         local p = node_new(id_penalty)
         p.penalty = 10000; head = node_insert_before(head, Np.first, p)
-        Bp[1] = p; set_attr(p, attr_icflag, KINSOKU)
+        table_insert(Bp, p); set_attr(p, attr_icflag, KINSOKU)
       end
    else for i, v in pairs(Bp) do add_penalty(v,a) end
    end
@@ -605,8 +668,8 @@ local function calc_ja_ja_glue()
       return new_jfm_glue(Nq, Nq.class, Np.class)
    else
       local g = new_jfm_glue(Nq, Nq.class,
-                            find_char_class('diffmet',Nq.met))
-      local h = new_jfm_glue(Np, find_char_class('diffmet',Np.met),
+                            fast_find_char_class('diffmet',Nq.met))
+      local h = new_jfm_glue(Np, fast_find_char_class('diffmet',Np.met),
                             Np.class)
       return calc_ja_ja_aux(g,h)
    end
@@ -649,7 +712,7 @@ local function get_OA_skip()
    if not ihb_flag then
       local c
       if Nq.id == id_math then c = -1 else c = 'jcharbdd' end
-      return new_jfm_glue(Np, find_char_class(c,Np.met), Np.class)
+      return new_jfm_glue(Np, fast_find_char_class(c,Np.met), Np.class)
    else return nil
    end
 end
@@ -657,7 +720,7 @@ local function get_OB_skip()
    if not ihb_flag then
       local c
       if Np.id == id_math then c = -1 else c = 'jcharbdd' end
-      return new_jfm_glue(Nq, Nq.class, find_char_class(c,Nq.met))
+      return new_jfm_glue(Nq, Nq.class, fast_find_char_class(c,Nq.met))
    else return nil
    end
 end
@@ -755,7 +818,7 @@ local function handle_list_tail()
    else
       -- the current list is the contents of a hbox
       if Np.id == id_jglyph or (Np.id==id_pbox and Np.met) then 
-        local g = new_jfm_glue(Np, Np.class, find_char_class('boxbdd',Np.met))
+        local g = new_jfm_glue(Np, Np.class, fast_find_char_class('boxbdd',Np.met))
         if g then
            set_attr(g, attr_icflag, BOXBDD)
            head = node_insert_after(head, Np.last, g)
@@ -772,9 +835,9 @@ local function handle_list_head()
       if not ihb_flag then
         local g
         if par_indented then
-           g = new_jfm_glue(Np, find_char_class('parbdd',Np.met), Np.class)
+           g = new_jfm_glue(Np, fast_find_char_class('parbdd',Np.met), Np.class)
         else
-           g = new_jfm_glue(Np, find_char_class('boxbdd',Np.met), Np.class)
+           g = new_jfm_glue(Np, fast_find_char_class('boxbdd',Np.met), Np.class)
         end
         if g then
            set_attr(g, attr_icflag, BOXBDD)
@@ -815,7 +878,7 @@ local function init_var()
       last=node.tail(head)
    else 
       -- the current list is the contents of a hbox:
-      -- insert a sentinel
+      -- insert a sentinelEG
       last=node.tail(head); local g = node_new(id_kern)
       node_insert_after(head, last, g); last = g
    end
index 245b024..3354ddd 100644 (file)
@@ -45,6 +45,9 @@ local PROCESSED = 8
 local ltjf_font_metric_table = ltjf.font_metric_table
 local ltjf_find_char_class = ltjf.find_char_class
 
+-- table of mathematical characters
+is_math_letters = {}
+
 local conv_jchar_to_hbox_A
 
 -- sty : 0 (display or text), 1 (script), >=2 (scriptscript)
@@ -57,6 +60,7 @@ local function conv_jchar_to_hbox(head, sty)
         p.sub = conv_jchar_to_hbox_A(p.sub, sty + 1)
         p.sup = conv_jchar_to_hbox_A(p.sup, sty + 1)
       elseif p.id == id_choice then
+        p.display = conv_jchar_to_hbox(p.display, 0)
         p.text = conv_jchar_to_hbox(p.text, 0)
         p.script = conv_jchar_to_hbox(p.script, 1)
         p.scriptscript = conv_jchar_to_hbox(p.scriptscript, 2)
@@ -93,7 +97,7 @@ function (p, sty)
       end
    elseif p.id == id_mchar then
       local fam = has_attr(p, attr_jfam) or -1
-      if ltjc.is_ucs_in_japanese_char(p) and fam>=0 then
+      if (not is_math_letters[p.char]) and ltjc.is_ucs_in_japanese_char(p) and fam>=0 then
         local mode = 'mjss'
         if sty == 0 then mode = 'mjtext'
         elseif sty == 1 then mode = 'mjscr'
@@ -122,4 +126,4 @@ luatexbase.add_to_callback('mlist_to_hlist',
       local head = conv_jchar_to_hbox(n, 0);
       head = node.mlist_to_hlist(head, display_type, penalties)
       return head
-   end,'ltj.mlist_to_hlist', 1)
\ No newline at end of file
+   end,'ltj.mlist_to_hlist', 1)
index 208f4c0..8096145 100644 (file)
@@ -17,22 +17,22 @@ require('luatexja.stack');     local ltjs = luatexja.stack
 local has_attr = node.has_attribute
 local set_attr = node.set_attribute
 local unset_attr = node.unset_attribute
+local node_type = node.type
 local node_remove = node.remove
 local node_next = node.next
 local node_free = node.free
 
 local id_glyph = node.id('glyph')
+local id_math = node.id('math')
 local id_whatsit = node.id('whatsit')
 local sid_user = node.subtype('user_defined')
 
-local attr_jchar_class = luatexbase.attributes['ltj@charclass']
 local attr_curjfnt = luatexbase.attributes['ltj@curjfnt']
 local attr_icflag = luatexbase.attributes['ltj@icflag']
 local attr_yablshift = luatexbase.attributes['ltj@yablshift']
 local attr_ykblshift = luatexbase.attributes['ltj@ykblshift']
 
 local ltjf_font_metric_table = ltjf.font_metric_table
-local ltjf_find_char_class = ltjf.find_char_class
 
 ------------------------------------------------------------------------
 -- MAIN PROCESS STEP 1: replace fonts
@@ -41,23 +41,26 @@ box_stack_level = 0
 -- This is used in jfmglue.lua.
 
 local function suppress_hyphenate_ja(head)
-   for p in node.traverse_id(id_glyph, head) do
-      local i = has_attr(p, attr_icflag) or 0
-      if i==0 and ltjc.is_ucs_in_japanese_char(p) then
-        local v = has_attr(p, attr_curjfnt)
-        if v then 
-           p.font = v 
-           set_attr(p, attr_jchar_class,
-                    ltjf_find_char_class(p.char, ltjf_font_metric_table[v]))
+   local non_math = true
+   for p in node.traverse(head) do
+      if p.id == id_glyph and non_math then
+        local i = has_attr(p, attr_icflag) or 0
+        if i==0 and ltjc.is_ucs_in_japanese_char(p) then
+           local v = has_attr(p, attr_curjfnt)
+           if v then 
+              p.font = v 
+           end
+           v = has_attr(p, attr_ykblshift)
+           if v then 
+              set_attr(p, attr_yablshift, v)
+           else
+              unset_attr(p, attr_yablshift)
+           end
+           if p.subtype%2==1 then p.subtype = p.subtype - 1 end
+           -- p.lang=lang_ja
         end
-        v = has_attr(p, attr_ykblshift)
-        if v then 
-           set_attr(p, attr_yablshift, v)
-        else
-           unset_attr(p, attr_yablshift)
-        end
-         if p.subtype%2==1 then p.subtype = p.subtype - 1 end
-        -- p.lang=lang_ja
+      elseif p.id == id_math then 
+        non_math = (p.subtype ~= 0)
       end
    end
    lang.hyphenate(head)
index a74b37b..a668f0f 100644 (file)
@@ -107,10 +107,14 @@ function set_ja_width(ahead, dir)
    while p do
       if p.id==id_glyph then
         if is_japanese_glyph_node(p) then
-           local met = ltjf.font_metric_table[p.font]
+           local met = ltjf_font_metric_table[p.font]
            local class = has_attr(p, attr_jchar_class)
            char_data = ltjf.metrics[met.jfm].size_cache[met.size].char_type[class]
-           p = capsule_glyph(p, dir, false, met, class)
+            if char_data then
+               p = capsule_glyph(p, dir, false, met, class)
+            else
+               p = node_next(p)
+            end
         else 
            p.yoffset = p.yoffset - (has_attr(p,attr_yablshift) or 0); p = node_next(p)
         end
index 32e6845..4e99176 100644 (file)
@@ -19,6 +19,27 @@ local hmode = 118 -- in luatexref-t.pdf, this must be 127
 
 local charprop_stack_table={}; charprop_stack_table[0]={}
 
+-- modified from table.fastcopy
+local next = next
+local function stack_table_copy_aux(old) 
+   local new = {}
+   for i,v in next, old do
+      new[i] = v
+   end
+   return new
+end
+local function stack_table_copy(old) 
+   if old then 
+      local new = {}
+      for i,v in next, old do
+        new[i] = stack_table_copy_aux(v)
+      end
+      return new
+   else
+      return {}
+   end 
+end
+
 function get_stack_level()
    local i = tex.getcount('ltj@@stack')
    local j = tex.currentgrouplevel
@@ -31,7 +52,7 @@ function get_stack_level()
       for k,v in pairs(charprop_stack_table) do -- clear the stack above i
         if k>=i then charprop_stack_table[k]=nil end
       end
-      charprop_stack_table[i] = table.fastcopy(charprop_stack_table[i-1])
+      charprop_stack_table[i] = stack_table_copy(charprop_stack_table[i-1])
       tex.setcount('ltj@@stack', i)
       if gd>0 then tex.globaldefs = gd end
       if tex.nest[tex.nest.ptr].mode == hmode or
@@ -43,6 +64,21 @@ function get_stack_level()
    return i
 end
 
+-- local function table_to_str(v) 
+--    local s = ''
+--    for i, a in pairs(v) do
+--       s = s .. i .. "=" .. tostring(a) .. ', '
+--    end
+--    return s
+-- end
+-- function print_stack_table(i)
+--    print('\n>>> get_stack_level:')
+--    for k, v in pairs(charprop_stack_table[i]) do
+--       print("  " , k, type(k), table_to_str(v));
+--    end
+-- end
+
+
 -- EXT
 function set_stack_table(g,m,c,p,lb,ub)
    local i = get_stack_level()
@@ -59,14 +95,14 @@ function set_stack_table(g,m,c,p,lb,ub)
                          "(-1 is used for denoting `math boundary')",
                          'So I changed this one to zero.'})
       c=0
-   elseif not charprop_stack_table[i][c] then 
-      charprop_stack_table[i][c] = {} 
+   elseif not charprop_stack_table[i][m] then 
+      charprop_stack_table[i][m] = {} 
    end
-   charprop_stack_table[i][c][m] = p
+   charprop_stack_table[i][m][c] = p
   if g=='global' then
      for j,v in pairs(charprop_stack_table) do 
-       if not charprop_stack_table[j][c] then charprop_stack_table[j][c] = {} end
-       charprop_stack_table[j][c][m] = p
+       if not charprop_stack_table[j][m] then charprop_stack_table[j][m] = {} end
+       charprop_stack_table[j][m][c] = p
      end
   end
 end
@@ -80,38 +116,38 @@ function set_stack_font(g,m,c,p)
                         {"The family number should in the range 0 .. 255.",
                          "I'm going to use 0 instead of that illegal family number."})
       c=0
-   elseif not charprop_stack_table[i][c] then 
-      charprop_stack_table[i][c] = {} 
+   elseif not charprop_stack_table[i][m] then 
+      charprop_stack_table[i][m] = {} 
    end
-   charprop_stack_table[i][c][m] = p
+   charprop_stack_table[i][m][c] = p
   if g=='global' then
      for j,v in pairs(charprop_stack_table) do 
-       if not charprop_stack_table[j][c] then charprop_stack_table[j][c] = {} end
-       charprop_stack_table[j][c][m] = p
+       if not charprop_stack_table[j][m] then charprop_stack_table[j][m] = {} end
+       charprop_stack_table[j][m][c] = p
      end
   end
 end
 
 -- EXT: store \ltj@tempskipa
-function set_stack_skip(g,c,sp)
+function set_stack_skip(g,m,sp)
   local i = get_stack_level()
   if not sp then return end
-  if not charprop_stack_table[i][c] then 
-     charprop_stack_table[i][c] = {} 
+  if not charprop_stack_table[i][m] then 
+     charprop_stack_table[i][m] = {} 
   end
-  charprop_stack_table[i][c].width   = sp.width
-  charprop_stack_table[i][c].stretch = sp.stretch
-  charprop_stack_table[i][c].shrink  = sp.shrink
-  charprop_stack_table[i][c].stretch_order = sp.stretch_order
-  charprop_stack_table[i][c].shrink_order  = sp.shrink_order
+  charprop_stack_table[i][m].width   = sp.width
+  charprop_stack_table[i][m].stretch = sp.stretch
+  charprop_stack_table[i][m].shrink  = sp.shrink
+  charprop_stack_table[i][m].stretch_order = sp.stretch_order
+  charprop_stack_table[i][m].shrink_order  = sp.shrink_order
   if g=='global' then
      for j,v in pairs(charprop_stack_table) do 
-       if not charprop_stack_table[j][c] then charprop_stack_table[j][c] = {} end
-       charprop_stack_table[j][c].width   = sp.width
-       charprop_stack_table[j][c].stretch = sp.stretch
-       charprop_stack_table[j][c].shrink  = sp.shrink
-       charprop_stack_table[j][c].stretch_order = sp.stretch_order
-       charprop_stack_table[j][c].shrink_order  = sp.shrink_order
+       if not charprop_stack_table[j][m] then charprop_stack_table[j][m] = {} end
+       charprop_stack_table[j][m].width   = sp.width
+       charprop_stack_table[j][m].stretch = sp.stretch
+       charprop_stack_table[j][m].shrink  = sp.shrink
+       charprop_stack_table[j][m].stretch_order = sp.stretch_order
+       charprop_stack_table[j][m].shrink_order  = sp.shrink_order
      end
   end
 end
@@ -124,8 +160,8 @@ function get_skip_table(m, idx)
 end
 
 function get_penalty_table(m,c,d, idx)
-   local i = charprop_stack_table[idx][c]
-   if i then i=i[m] end
+   local i = charprop_stack_table[idx][m]
+   if i then i=i[c] end
    return i or d
 end
 
similarity index 95%
rename from src/lltjcore.sty
rename to src/patches/lltjcore.sty
index 98fa932..3dbcc41 100644 (file)
@@ -1,7 +1,11 @@
-%%
-%% lltjcore.sty: derived from plcore.dtx in pLaTeX.
-%% This file does not include the code relating to "tategaki".
-%% 
+%
+% lltjcore.sty: derived from plcore.dtx in pLaTeX.
+% This file does not include the code relating to "tategaki".
+% 
+
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{lltjcore}[2011/11/22 Patch to LaTeX2e Kernel for LuaLaTeX-ja]
+
 \makeatletter
 \newif\iftombow \tombowfalse
 \newif\iftombowdate \tombowdatetrue
similarity index 96%
rename from src/lltjdefs.sty
rename to src/patches/lltjdefs.sty
index 72da6da..a76a24c 100644 (file)
@@ -1,3 +1,10 @@
+%
+% lltjdefs.sty
+% 
+
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{lltjdefs}[2011/11/22 Default font settings for LuaLaTeX-ja]
+
 \DeclareKanjiEncodingDefaults{}{}
 \DeclareErrorKanjiFont{JY3}{mc}{m}{n}{10}
 \DeclareYokoKanjiEncoding{JY3}{}{}
@@ -50,6 +57,8 @@
 \ltjdefcharrange{8}{"A7, "A8, "B0, "B1, "B4, "B6, "D7, "F7}
 \ltjsetparameter{jacharrange={-1, +2, +3, -4, -5, +6, +7, +8}}
 
+\directlua{for x=128,255 do luatexja.math.is_math_letters[x] = true end}
+
 % END OF FILE
 \endinput
 
similarity index 99%
rename from src/lltjfont.sty
rename to src/patches/lltjfont.sty
index 70cace2..a3fec95 100644 (file)
@@ -1,7 +1,10 @@
-%%
-%% lltjfont.sty: derived from plfonts.dtx in pLaTeX.
-%% 
-\makeatletter
+%
+% lltjfont.sty: derived from plfonts.dtx in pLaTeX.
+% 
+
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{lltjfont}[2011/11/22 Patch to NFSS2 for LuaLaTeX-ja]
+
 \let\k@encoding\@empty
 \let\ck@encoding\@empty
 % LuaTeX-ja uses JY3 and JT3 encodings.
similarity index 96%
rename from doc/lltjlisting.sty
rename to src/patches/lltjp-listings.sty
index 2563773..62e2385 100644 (file)
@@ -1,11 +1,14 @@
-% lltjlisting.sty: modified from jlisting.sty (by Thor) for
-% LuaTeX-ja. 
+%
+% lltjp-listings.sty
+%
+% Modified from jlisting.sty (by Thor) for LuaTeX-ja. 
+%
 
 \NeedsTeXFormat{LaTeX2e}
 \def\filedate{2006/02/20}
 \def\fileversion{0.2}
-\ProvidesPackage{lltjlisting}[\filedate\space\fileversion\space(Thor)]
-%
+\ProvidesPackage{lltjp-listings}[\filedate\space\fileversion\space(Thor)]
+\RequirePackage{listings}
 \newcount\lst@nextchar
 \let\lst@@ProcessSpace\lst@ProcessSpace
 \def\lst@ProcessSpace#1{%
diff --git a/src/patches/lltjp-unicode-math.sty b/src/patches/lltjp-unicode-math.sty
new file mode 100644 (file)
index 0000000..104052a
--- /dev/null
@@ -0,0 +1,44 @@
+%
+% lltjp-unicode-math.sty
+%
+
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{lltjp-unicode-math}[2011/11/22 Patch to unicode-math for LuaLaTeX-ja]
+
+\RequirePackage{unicode-math,luatexja}
+
+\ExplSyntaxOn
+
+%%%%%% 以下の3命令の再定義はもはや不要と思われる(北川) 
+% \cs_set:Npn \um_set_mathcode:nnnn #1#2#3#4 {
+%   \Umathcode \int_eval:n {#1} =
+%   \mathchar@type#2 \csname sym#3\endcsname \int_eval:n {#4} \scan_stop:
+%   \ltjsetmathletter{\int_eval:n {#4}}
+% }
+% \cs_set:Npn \um_set_mathcode:nnn #1#2#3 {
+%   \Umathcode \int_eval:n {#1} =
+%   \mathchar@type#2 \csname sym#3\endcsname \int_eval:n {#1} \scan_stop:
+%   \ltjsetmathletter{\int_eval:n {#1}}
+% }
+% \cs_set:Npn \um_set_mathchar:NNnn #1#2#3#4 {
+%   \Umathchardef #1 =
+%   \mathchar@type#2 \csname sym#3\endcsname \int_eval:n {#4} \scan_stop:
+%   \ltjsetmathletter{\int_eval:n {#4}}
+% }
+%%%%%%
+\group_begin:
+  \cs_gset:Npn \um_cs_set_eq_active_char:Nw #1 = "#2 \q_nil {%"
+    \group_begin:
+      %\typeout {um: \string#1, \int_from_hexadecimal:n {#2}} <- for debug
+      \char_set_lccode:nn { `! } { "#2 }
+      \tex_lowercase:D {
+        \tl_set:Nn \l_tmpa_tl {\ifmmode!\else{\directlua{tex.globaldefs = 0}\ltj@allalchar!}\fi}
+        \cs_gset_eq:NN #1 \l_tmpa_tl
+      }
+      \ltjsetmathletter{ \int_from_hexadecimal:n {#2} }
+    \group_end:
+  }
+\group_end:
+
+\ExplSyntaxOff
+\endinput
diff --git a/src/patches/lltjp-xunicode.sty b/src/patches/lltjp-xunicode.sty
new file mode 100644 (file)
index 0000000..4b201d6
--- /dev/null
@@ -0,0 +1,102 @@
+%
+% lltjp-xunicode.sty
+%
+
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{lltjp-xunicode}[2011/11/22 Patch to xunicode for LuaLaTeX-ja]
+
+\def\UTFencname{EU2}\def\XeTeXpicfile{}
+\RequirePackage{xunicode,luatexja}
+{\catcode`\"=12
+\gdef\check@hexcom@digits@#1#2#3#4#5@!@#6#7#8{%
+ \ifx @#4\relax
+  \UTFacc@warning@{insufficient hex digits #7 for #6-\string#8}%
+ \else
+  \ifcat \active\noexpand#8%
+   \ifx\add@flag\@ne %
+    \expandafter\def\csname\UTFencname\string#8\endcsname{\ltjalchar"#1#2#3#4\relax}%
+    \ifx\unDeFiNed@#8%
+     \ifx\cf@encoding\UTFencname
+      \DeclareTextCommand{#8}{OT1}{\undefined}%
+     \else
+      \DeclareTextCommand{#8}{\cf@encoding}{\undefined}%
+     \fi
+    \else {% macro #8 exists already ...
+      \let\protect\noexpand
+      \edef\UTF@testi{#8}\def\UTF@testii{#8}%
+      \ifx\UTF@testi\UTF@testii\aftergroup\UTF@ignore
+      \else\aftergroup\UTF@doit\fi
+     }%
+     \iffalse
+      % ... but when it isn't robust, make it so
+      \expandafter\let\csname?-\string#8\endcsname#8\relax
+      \edef\next@UTF@{{\cf@encoding}%
+        {\expandafter\noexpand\csname?-\string#8\endcsname}}%
+      \expandafter\DeclareTextCommand\expandafter
+         {\expandafter#8\expandafter}\next@UTF@
+     \fi
+    \fi %
+   \else % \add@flag \z@
+    \expandafter\global\expandafter
+      \let\csname\UTFencname\string#8\endcsname\relax
+   \fi % end of \add@flag switch
+  \else % not active catcode --- shouldn't happen
+  % \typeout{*** did you really mean #8 ? ***}%
+   \ifx\add@flag\@ne %
+    \edef\tmp@name{\expandafter\string\csname\UTFencname\endcsname
+      \expandafter\string\csname#8\endcsname}%
+    \expandafter\def\csname\tmp@name\endcsname{\ltjalchar"#1#2#3#4\relax}%
+    \ifx\cf@encoding\UTFencname
+     \expandafter\DeclareTextCommand\expandafter
+       {\csname#8\endcsname}{OT1}{\undefined}%
+    \else
+     \expandafter\DeclareTextCommand\expandafter
+       {\csname#8\endcsname}{\cf@encoding}{\undefined}%
+    \fi
+   \else % \add@flag \z@
+    \expandafter\global\expandafter\let\csname#8\endcsname\relax
+   \fi % end of \add@flag switch
+  \fi % end of \ifcat
+ \fi}
+\gdef\check@hex@digits@#1#2#3#4#5@!@#6#7#8#9{%
+ \ifx @#4\relax
+  \UTFacc@warning@{insufficient hex digits #7 for #6-\string#8#9}%
+ \else
+  \def\UTFchar{\ltjalchar"#1#2#3#4\relax}%
+  \expandafter\expandafter\expandafter\declare@utf@composite
+  \expandafter\expandafter\expandafter
+   {\expandafter\csname#6\endcsname}{\UTFchar}{#8}{#9}\relax
+ \fi}
+\gdef\add@UTF@accent#1#2#3{\ifx\relax#2\relax\ltjalchar"#3\else
+ \ifx\ #2\relax\ltjalchar"#3\else
+ \expandafter\ifx\UTF@space#2\relax\ltjalchar"#3\else
+ \ifx~#2\ltjalchar"#3\else#2\ltjalchar"#1\fi\fi\fi\fi\relax}
+\gdef\add@UTF@accents#1#2#3{#2\ltjalchar"#1\ltjalchar"#3\relax}
+}
+% If unicode-math is already loaded, the following error occurs:
+%    ! Undefined control sequence.
+%    \hbar ->\hslash 
+% Therefore temporarily set \hbar=\relax.
+\let\ltj@tmpa\hbar
+\let\hbar\relax
+\ReloadXunicode{EU2}
+\makeatletter
+\let\hbar\ltj@tmpa
+\endinput
+
+%% the following patch is needed to xunicode.sty:
+%% 
+--- /opt/texlive/2011/texmf-dist/tex/xelatex/xunicode/xunicode.sty     2011-09-12 08:31:47.000000000 +0900
++++ xunicode.sty       2011-11-16 22:06:17.061413113 +0900
+@@ -1475,7 +1475,11 @@
+ \newtoks\tipasavetokens
+ \newtoks\tipachecktokens
++
++\fi
+ \newif\iftipaonetoken
++\expandafter\ifx\csname ReloadXunicode\endcsname\relax
++
+ \def\tipalasttoken{!@! do nothing with this !@!}
+ \def\tipacatchonechar#1{\begingroup
+  \def\textipa##1{##1}% prevent recursion
index ba78cc7..2d76e92 100644 (file)
Binary files a/test/test01-noembed.pdf and b/test/test01-noembed.pdf differ
index 4d6942b..f9e7dad 100644 (file)
 {\tentt jp78} feature: 辻→{\jisse 辻}
 
 {\tentt hwid} feature: アイウエ→{\jishwid アイウエ}\hfil\break
-↑文字クラスが変わらないので幅も変わらない.
 
 {\tentt nalt} feature: 男→{\jisnalt 男}
 
 {\tentt trad} feature: 医学→{\jistrad 医学}
 
 {\tentt sups} feature: 注1注1→{\jissups 注1注1}\hfil\break
-↑文字クラスが変わらないので幅も変わらない.
+↑まだ上付き文字用の文字クラスを作ってない.
 
 {\tentt liga} feature: か゚き゚く゚け゚こ゚→{\jisliga か゚き゚く゚け゚こ゚}\hfil\break
 ↑合字用の半濁点({\tentt U+309A})を用いれば成功する.単体用({\tentt U+309C})では失敗する.%比較:{\tmiliga か゜き゜く゜け゜こ゜}
index 86fda87..49673da 100644 (file)
Binary files a/test/test01.pdf and b/test/test01.pdf differ
index 2217c08..940a876 100644 (file)
 {\tentt jp04} feature: 辻→{\jisfour 辻}
 
 {\tentt hwid} feature: アイウエ→{\jishwid アイウエ}\hfil\break
-↑文字クラスが変わらないので幅も変わらない.
 
 {\tentt nalt} feature: 男→{\jisnalt 男}
 
 {\tentt trad} feature: 医学→{\jistrad 医学}
 
 {\tentt sups} feature: 注1注1→{\jissups 注1注1}\hfil\break
-↑文字クラスが変わらないので幅も変わらない.
+↑まだ上付き文字用の文字クラスを作ってない.
 
 {\tentt liga} feature: か゚き゚く゚け゚こ゚→{\jisliga か゚き゚く゚け゚こ゚}\hfil\break
 ↑合字用の半濁点({\tentt U+309A})を用いれば成功する.単体用({\tentt U+309C})では失敗する.%比較:{\tmiliga か゜き゜く゜け゜こ゜}
index 15c8eab..654ce27 100644 (file)
Binary files a/test/test04-jfm.pdf and b/test/test04-jfm.pdf differ
diff --git a/test/test07-math-unicode.pdf b/test/test07-math-unicode.pdf
new file mode 100644 (file)
index 0000000..c691232
Binary files /dev/null and b/test/test07-math-unicode.pdf differ
diff --git a/test/test07-math-unicode.tex b/test/test07-math-unicode.tex
new file mode 100644 (file)
index 0000000..b617db2
--- /dev/null
@@ -0,0 +1,34 @@
+%#!lualatex
+\documentclass{article}
+\usepackage[a4paper]{geometry}
+
+\usepackage{luatexja-fontspec}
+
+\usepackage{luatexja}
+\makeatletter\ltj@alljachar %←全部の(>=U+0080な)文字を和文文字扱いに!
+
+\usepackage{unicode-math}
+\setmathfont{XITSMath}
+\setmainjfont{IPAGothic}
+
+\begin{document}\makeatletter
+
+\[
+ \frac1{1^2}+\frac1{2^2}+\cdots=
+\sum_{n=1}^\infty \frac1{n^s}=\zeta(2)=\frac{\pi^2}{6}
+=\frac16\cdot \pi\times\pi,\qquad a_1,\dots,a_n.
+\]
+
+$
+ \frac1{1^2}+\frac1{2^2}+\cdots=
+\sum_{n=1}^\infty \frac1{n^s\zeta}=\zeta(2)=\frac{\pi^2}{6}
+=\frac16\cdot \pi\times\pi,\qquad a_1,\dots,a_n. \hbar
+$
+
+{\tt\meaning\sum}
+
+
+○×○漢\ltjjachar`\×漢\ltjalchar`\×漢\times 漢
+え\ltjjachar`\“え\ltjalchar`\“え\textquotedblleft え“え
+←数式外では和文文字扱いのままになっている.
+\end{document}
index dde7ccb..dee24fc 100644 (file)
Binary files a/test/test07-math.pdf and b/test/test07-math.pdf differ
index 55dc9be..e2431db 100644 (file)
@@ -42,6 +42,9 @@ mathgt: $\mathrm{\mathmc{あa}}\mathmc{あb}\mathgt{あa}$
 
 \LaTeX では数式ファミリ番号は欧文と共用→$\the\jfam$
 
+\def\s{\mathchoice{Dあ}{Tあ}{Sあ}{SSあ}}
+\[
+\s {\textstyle \s} {\scriptstyle \s} {\scriptscriptstyle \s}
+\]
 
 \end{document}
-