OSDN Git Service

Supported Japanese math font families by \DeclareSymbolFont etc.
authorHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Sun, 21 Aug 2011 00:33:32 +0000 (09:33 +0900)
committerHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Sun, 21 Aug 2011 00:35:45 +0000 (09:35 +0900)
src/lltjdefs.sty
src/lltjfont.sty
src/luatexja-core.sty
src/luatexja/math.lua
test/test07-math.pdf [new file with mode: 0644]
test/test07-math.tex [new file with mode: 0644]

index fd28c36..963d35e 100644 (file)
@@ -16,7 +16,7 @@
 \DeclareFontShape{JY3}{mc}{m}{n}{<-> psft:Ryumin-Light:jfm=ujis}{}
 \DeclareKanjiFamily{JY3}{gt}{}
 \DeclareFontShape{JY3}{gt}{m}{n}{<-> psft:GothicBBB-Medium:jfm=ujis}{}
-\DeclareFontShape{JY3}{mc}{bx}{n}{<->ssub*gt/m/n}{}
+\DeclareFontShape{JY3}{mc}{bx}{n}{<-> sub*gt/m/n}{}
 
 %fontencoding{JT3}\selectfont
 \fontencoding{JY3}\selectfont
 \DeclareOldFontCommand{\mc}{\normalfont\mcfamily}{}
 \DeclareOldFontCommand{\gt}{\normalfont\gtfamily}{}
 
+\DeclareSymbolFont{mincho}{JY3}{mc}{m}{n}
+\jfam\symmincho
+\SetSymbolFont{mincho}{bold}{JY3}{gt}{m}{n}
+\DeclareSymbolFontAlphabet{\mathmc}{mincho}
+\DeclareMathAlphabet{\mathgt}{JY3}{gt}{m}{n}
+
 \endinput
index 9f2a0da..a4ad74c 100644 (file)
   %\iftdir\raise-\tbaselineshift\fi
   \vbox{\hrule\@width.3em}}
 
+%%%%%% LuaTeX-ja specific
+
+% #1 の展開結果から encoding 部分をとりだし,それが和文用かどうかの結果を \ifin@ に代入
+\def\ltj@@IsFontJapanese#1{%
+  \expandafter\ltj@@IsFontJapaneseX#1//:%
+  \expandafter\expandafter\expandafter
+  \inlist@\expandafter\tmp@item\expandafter{\kenc@list}}
+\def\ltj@@IsFontJapaneseX#1/#2/:{\edef\tmp@item{{\directlua{tex.print('#1')}}}}
+
+
 \let\extract@afont\extract@font
 \def\pickup@jfont{%
     \expandafter \ifx \font@name \relax
     \csname \f@encoding+\f@family\endcsname
     \csname\curr@fontshape\endcsname}
 
+\let\ltj@@al@do@subst@correction=\do@subst@correction
+\def\ltj@@ja@do@subst@correction{%
+    \xdef\subst@correction{%
+      \font@name
+      \global\expandafter\let\csname \curr@fontshape/\f@size\endcsname\font@name%
+      \relax}%
+    \aftergroup\subst@correction
+}
+\def\do@subst@correction{%
+   \ltj@@IsFontJapanese{\curr@fontshape}\ifin@
+     \ltj@@ja@do@subst@correction
+   \else
+     \ltj@@al@do@subst@correction
+   \fi
+}
+
+
+%%%%%% Japanese font for math mode
+
+% \M@<enc> から その <enc> が和文用か調べる
+{\catcode`M=12%
+\gdef\ltj@@mathJapaneseFonts#1M#2#3\relax{\ltj@@IsFontJapanese{#3}}}
+
+\let\ltj@@al@getanddefine@fonts=\getanddefine@fonts
+\def\ltj@@ja@getanddefine@fonts#1#2{%
+  \xdef\font@name{\csname \string#2/\tf@size\endcsname}%
+  \pickup@jfont \let\textfont@name\font@name
+  \xdef\font@name{\csname \string#2/\sf@size\endcsname}%
+  \pickup@jfont \let\scriptfont@name\font@name
+  \xdef\font@name{\csname \string#2/\ssf@size\endcsname}%
+  \pickup@jfont
+  \edef\math@fonts{\math@fonts\ltjsetparameter{%
+    jatextfont={#1,\textfont@name},%
+    jascriptfont={#1,\scriptfont@name},%
+    jascriptscriptfont={#1,\font@name}}}
+}
+
+\def\getanddefine@fonts#1#2{%
+  \ltj@tempcnta=#1 \ltj@@IsFontJapanese{\string#2}%
+  \ifin@\ltj@@ja@getanddefine@fonts{#1}{#2}%
+  \else \ltj@@al@getanddefine@fonts{#1}{#2}%
+  \fi
+}
+\def\use@mathgroup#1#2{\relax\ifmmode
+  \math@bgroup
+    \expandafter\ifx\csname M@\f@encoding\endcsname#1\else
+    #1\fi \ltj@tempcnta=#2 \expandafter\ltj@@mathJapaneseFonts\string#1\relax%
+    \ifin@\jfam#2\relax\else\mathgroup#2\relax\fi
+  \expandafter\math@egroup\fi}%
+
 \endinput
index a857aad..21bfe8a 100644 (file)
 \define@key[ltj]{japaram}{jascriptscriptfont}{%
   \expandafter\ltj@@set@stackfont#1:{mjss}}
 \def\ltj@@set@stackfont#1,#2:#3{%
-  {\ltj@curjfnt=-1 #2\global\ltj@tempcnta=\ltj@curjfnt}%
+  {\ltj@tempcntb=\ltj@curjfnt\ltj@curjfnt=-1 #2%
+   \global\ltj@tempcnta=\ltj@curjfnt\global\ltj@curjfnt=\ltj@tempcntb}%
   \ifnum\ltj@tempcnta=-1
     \@PackageError{luatexja-core}
     {\string#2 is not a control sequence that represents \MessageBreak
index 930699a..6014e15 100644 (file)
@@ -82,7 +82,6 @@ end
 
 conv_jchar_to_hbox_A = 
 function (p, sty)
-   print ("  Pa: ",p);
    if not p then return nil
    elseif p.id == id_sub_mlist then
       if p.head then
@@ -115,11 +114,7 @@ end
 
 luatexbase.add_to_callback('mlist_to_hlist', 
    function (n, display_type, penalties)
-      ltj.ext_show_node_list(n, '  ', print)
       local head = conv_jchar_to_hbox(n, 0);
       head = node.mlist_to_hlist(head, display_type, penalties)
-      print("--------");
-      ltj.ext_show_node_list(head, '  ', print)
-      print("--------");
       return head
    end,'ltj.mlist_to_hlist', 1)
\ No newline at end of file
diff --git a/test/test07-math.pdf b/test/test07-math.pdf
new file mode 100644 (file)
index 0000000..6190d1a
Binary files /dev/null and b/test/test07-math.pdf differ
diff --git a/test/test07-math.tex b/test/test07-math.tex
new file mode 100644 (file)
index 0000000..9c62440
--- /dev/null
@@ -0,0 +1,47 @@
+%#!lualatex
+\documentclass{article}
+\usepackage[a4paper]{geometry}
+\usepackage{luatexja}
+\usepackage{unicode-math}
+\setmathfont{XITSMath}
+
+% only for testing
+\SetMathAlphabet{\mathgt}{bold}{JY3}{mc}{m}{n} 
+
+\begin{document}\makeatletter
+\paragraph{Unicodeの数式領域}\
+
+標準 $a_i=i,\ i=1, 2, \dots, n$. 
+\ltjdefcharrange{2}{"10000-"1FFFF}% 第1面を欧文扱いに
+\ltjsetparameter{jacharrange={-2}}%
+第1面を欧文扱いに $a_i=i,\ i=1, 2, \dots, n$.
+
+\paragraph{和文数式 on \LaTeX}
+数式フォント関連のコマンドは一緒.e.g.\ in \verb+lltjdefs.sty+,
+\begin{verbatim}
+\DeclareSymbolFont{mincho}{JY3}{mc}{m}{n}
+\jfam\symmincho
+\SetSymbolFont{mincho}{bold}{JY3}{gt}{m}{n}
+\DeclareSymbolFontAlphabet{\mathmc}{mincho}
+\DeclareMathAlphabet{\mathgt}{JY3}{gt}{m}{n}
+\end{verbatim}
+
+添字:${あz}^{いy}_{うu\mathgt{え}}$
+
+数式内の空白処理:$a()a\hbox{a()a}a$
+
+mathgt: $\mathrm{\mathmc{あa}}\mathmc{あb}\mathgt{あa}$
+\begin{itemize}
+\item 和文数式フォント選択命令は,和文文字しか影響しない
+\item 欧文数式フォント選択命令は,欧文文字しか影響しない
+\end{itemize}
+
+\bf mathversion bold: {\mathversion{bold}$aあa\mathgt{あa}\vrule$\vrule}\vrule←
+この空白は何?\\
+二つ目の「あ」は\verb+\mathgt+下だが,明朝なのは本文書の設定通り.
+
+\LaTeX では数式ファミリ番号は欧文と共用→$\the\jfam$
+
+
+\end{document}
+