• R/O
  • HTTP
  • SSH
  • HTTPS

luatexja: コミット

ソースコードの管理場所


コミットメタ情報

リビジョン82465c582e5844dab501a4bb4a2fa28baca3d8da (tree)
日時2011-09-07 15:51:09
作者Hironori Kitagawa <h_kitagawa2001@yaho...>
コミッターHironori Kitagawa

ログメッセージ

Updated the manual, and ad hoc fix of the stack system around \globaldefs

変更サマリ

差分

Binary files a/doc/man-en.pdf and b/doc/man-en.pdf differ
--- a/doc/man-en.tex
+++ b/doc/man-en.tex
@@ -22,11 +22,13 @@
2222 \maketitle
2323
2424 \tableofcontents
25+\bigskip
26+{\Large\bf This documentation is far from complete. It may have many
27+grammatical (and contextual) errors.}
2528
2629 \newpage
2730 \part{User's manual}
28-{\Large\bf This documentation is far from complete. It may have many
29-grammatical errors.}
31+\makeatletter\the\ltj@@stack,\the\ltj@@group@level,\the\currentgrouplevel.
3032
3133
3234 \section{Introduction}
@@ -198,7 +200,6 @@ This does the minimal setting (like {\tt ptex.tex}) for typesetting Japanese doc
198200 Here \verb+\zw+ is a counterpart of \texttt{em} for Japanese fonts, that is, the length of `full-width' in the current Japanese font.
199201 \end{itemize}
200202
201-
202203 \subsection{Using in \LaTeX}
203204 \paragraph{\LaTeXe}
204205 Using in \LaTeXe\ is basically same. To set up the minimal environment
@@ -244,6 +245,7 @@ $f_{高温}$~($f_{\text{high temperature}}$).
244245 \[ y=(x-1)^2+2\quad{}よって\quad y>0 \]
245246 $5\in{}素:=\{\,p\in\mathbb N:\text{$p$ is a prime}\,\}$.
246247 \end{LTXexample}
248+
247249 We (the project members of Lua\TeX-ja) think that using
248250 Japanese characters in math mode are allowed if these are used as identifiers.
249251 In this point of view,
@@ -453,7 +455,31 @@ For example, the following sets banner as `{\tt filename (2012-01-01 17:01)}':
453455 \part{Reference}\label{part-ref}
454456 \section{Font Metric and Japanese Font}
455457 \subsection{\texttt{\char92jfont} primitive}
456-Caution: 10pt
458+To load a font as a Japanese font, you must use the
459+\verb+\jfont+ primitive instead of~\verb+\font+, while
460+\verb+\jfont+ admits the same syntax used in~\verb+\font+.
461+Lua\TeX-ja automatically loads \texttt{luaotfload} package,
462+so TrueType/OpenType fonts with features can be used for Japanese fonts:
463+\begin{LTXexample}
464+\jfont\tradgt={file:ipaexg.ttf:script=latn;%
465+ +trad;jfm=ujis} at 14pt
466+\tradgt{}当/体/医/区
467+\end{LTXexample}
468+
469+Note that the defined control sequence (\verb+\tradgt+ in the example above) using \verb+\jfont+ is not a \textit{font\_def} token.
470+
471+\paragraph{Prefix}
472+Besides \texttt{file:} and \texttt{name:} prefixes, \texttt{psft:} can
473+be used a prefix in \verb+\jfont+ (and~\verb+\font+) primitive.. Using
474+this prefix, you can specify a font that has its name only and is not
475+related to any real font.
476+
477+The typical use of this \texttt{psft:} prefix is ...
478+
479+\paragraph{Features}
480+
481+
482+
457483
458484 \subsection{Structure of JFM file}
459485 A JFM file is a Lua script which has only one function call:
@@ -534,7 +560,7 @@ In most cases, \texttt{left} and \texttt{down} fields are~0, while
534560 it is not uncommon that the \texttt{align} field is \texttt{'middle'} or \texttt{'right'}.
535561 For example, setting the \texttt{align} field to \texttt{'right'} is practically needed
536562 when the current character class is the class for opening delimiters'.
537-\begin{figure}[htb]
563+\begin{figure}[tb]
538564 \begin{minipage}{0.4\textwidth}%
539565 \begin{center}\unitlength=10pt\small
540566 \begin{picture}(15,12)(-1,-4)
@@ -595,7 +621,9 @@ field is \texttt{'middle'}.
595621 Its width, height and depth are specified by JFM.
596622 \item Since the \texttt{align} field is \texttt{'middle'},
597623 the `real' glyph is centered horizontally (the green rectangle).
598-\item Furthermore, the glyph is shifted according to values of fields \texttt{left} and \texttt{down}. The ultimate position of the real glyph is the red rectangle.
624+\item Furthermore, the glyph is shifted according to values of fields
625+ \texttt{left} and \texttt{down}. The ultimate position of the real
626+ glyph is indicated by the red rectangle.
599627 \end{itemize}
600628 \end{minipage}
601629 \caption{The position of the `real' glyph}
@@ -613,6 +641,13 @@ the `real' glyph is centered horizontally (the green rectangle).
613641 \subsection{{\tt\char92 ltjsetparameter} primitive}
614642
615643 \subsection{List of Parameters}
644+In the following list of parameters,
645+\begin{itemize}
646+\item `\ast' : local
647+\item `\dagger' always global
648+\item No mark: the last of paragraph
649+\end{itemize}
650+
616651 \begin{list}{}{\def\makelabel{\ttfamily}\def\{{\char`\{}\def\}{\char`\}}}
617652 \item[\textsf{kcatcode}\,=\{<chr\_code>,<value>\}]
618653 \item[\textsf{prebreakpenalty}\,=\{<chr\_code>,<penalty>\}]
@@ -620,19 +655,101 @@ the `real' glyph is centered horizontally (the green rectangle).
620655 \item[\textsf{jatextfont}\,=\{<jfam>,<jfont\_cs>\}]
621656 \item[\textsf{jascriptfont}\,=\{<jfam>,<jfont\_cs>\}]
622657 \item[\textsf{jascriptscriptfont}\,=\{<jfam>,<jfont\_cs>\}]
623-\item[\textsf{yjabaselineshift}\,=<dimen>]
624-\item[\textsf{yalbaselineshift}\,=<dimen>]
658+\item[\textsf{yjabaselineshift}\,=<dimen>$^\ast$]
659+\item[\textsf{yalbaselineshift}\,=<dimen>$^\ast$]
625660 \item[\textsf{jaxspmode}\,=\{<chr\_code>,<mode>\}]
626661 \item[\textsf{alxspmode}\,=\{<chr\_code>,<mode>\}]
627-\item[\textsf{autospacing}\,=<bool>]
628-\item[\textsf{autoxspacing}\,=<bool>]
662+\item[\textsf{autospacing}\,=<bool>$^\ast$]
663+\item[\textsf{autoxspacing}\,=<bool>$^\ast$]
629664 \item[\textsf{kanjiskip}\,=<skip>]
630665 \item[\textsf{xkanjiskip}\,=<skip>]
631666 \item[\textsf{jcharwidowpenalty}\,=<penalty>]
632-\item[\textsf{differentjfm}\,=<mode>]
633-\item[\textsf{jacharrange}\,=<ranges>]
667+\item[\textsf{differentjfm}\,=<mode>$^\dagger$]
668+\item[\textsf{jacharrange}\,=<ranges>$^\ast$]
634669 \end{list}
635670 \section{Other Primitives}
636671 \section{Control Sequences for \LaTeXe}
637672 \part{Implementations}\label{part-imp}
673+\section{Storing Parameters}
674+\subsection{Used Dimensions and Attributes}
675+Here the following is the list of dimension and attributes which are used in Lua\TeX-ja.
676+\begin{list}{}{%
677+\def\makelabel{\ttfamily}
678+\def\dim#1{\item[\char92 #1\ \textrm{(dimension)}]}
679+\def\attr#1{\item[\char92 #1\ \textrm{(attribute)}]}
680+}
681+
682+\dim{jQ}
683+\dim{jH}
684+\dim{ltj@zw}
685+\dim{ltj@zh}
686+\attr{jfam}
687+\attr{ltj@curjfnt} The font index of current Japanese font.
688+\attr{ltj@charclass} The character class of Japanese \textit{glyph\_node}.
689+\attr{ltj@yablshift} The amount of shifting the baseline of alphabetic
690+ fonts in scaled point ($2^{-16}\,\textrm{pt}$).
691+\attr{ltj@ykblshift} The amount of shifting the baseline of Japanese
692+ fonts in scaled point ($2^{-16}\,\textrm{pt}$).
693+\attr{ltj@autospc} Whether the auto insertion of \textsf{kanjiskip} is allowed at the node.
694+\attr{ltj@autoxspc} Whether the auto insertion of \textsf{xkanjiskip} is allowed at the node.
695+\attr{ltj@icflag} For distinguishing `kinds' of the node. To this
696+ attribute, one of the following value is
697+ assigned:
698+\begin{description}
699+\item[ITALIC (1)]
700+\item[PACKED (2)]
701+\item[KINSOKU (3)]
702+\item[FROM\_JFM (4)]
703+\item[LINE\_END (5)]
704+\item[KANJI\_SKIP (6)]
705+\item[XKANJI\_SKIP (7)]
706+\item[PROCESSED (8)]
707+\item[IC\_PROCESSED (9)]
708+\item[BOXBDD (15)]
709+\end{description}
710+\attr{ltj@kcat$i$} Where $i$~is a natural number which is less than~8.
711+These 8~attributes store bit~vectors indicating ...
712+\end{list}
713+
714+\subsection{Stack System of Lua\TeX-ja}
715+\paragraph{Overview}
716+Lua\TeX-ja has its own stack system, and most parameters of Lua\TeX-ja
717+are stored in it. To clarify the reason, imagine the parameter
718+\textsf{kanjiskip} is stored by a skip, and consider the following
719+source:
720+\begin{LTXexample}
721+\ltjsetparameter{kanjiskip=0pt}ふがふが.%
722+\setbox0=\hbox{\ltjsetparameter{kanjiskip=5pt}ほげほげ}
723+\box0.ぴよぴよ\par
724+\end{LTXexample}
725+
726+As described in Part~\ref{part-ref}, the only effective value of
727+\textsf{kanjiskip} in an hbox is the latest value, so the value of
728+\textsf{kanjiskip} which applied in the entire hbox should be 5\,pt.
729+However, by the implementation method of Lua\TeX, this `5\,pt' cannot be
730+known from any callbacks. In the \texttt{tex/packaging.w} (which is a
731+file in the source of Lua\TeX), there are the following codes:
732+\begin{lstlisting}
733+void package(int c)
734+{
735+ scaled h; /* height of box */
736+ halfword p; /* first node in a box */
737+ scaled d; /* max depth */
738+ int grp;
739+ grp = cur_group;
740+ d = box_max_depth;
741+ unsave();
742+ save_ptr -= 4;
743+ if (cur_list.mode_field == -hmode) {
744+ cur_box = filtered_hpack(cur_list.head_field,
745+ cur_list.tail_field, saved_value(1),
746+ saved_level(1), grp, saved_level(2));
747+ subtype(cur_box) = HLIST_SUBTYPE_HBOX;
748+\end{lstlisting}
749+Notice that \verb+unsave+ is executed \emph{before}
750+\verb+filtered_hpack+ (this is where \verb+hpack_filter+ callback is
751+executed): so `5\,pt' in the above source is orphaned at
752+\texttt+unsave+, and hence it can't be accessed from \verb+hpack_filter+
753+callback.
754+
638755 \end{document}
\ No newline at end of file
--- a/src/luatexja-core.sty
+++ b/src/luatexja-core.sty
@@ -253,8 +253,8 @@
253253 \define@key[ltj]{japaram}{jascriptscriptfont}{%
254254 \expandafter\ltj@@set@stackfont#1:{mjss}}
255255 \def\ltj@@set@stackfont#1,#2:#3{%
256- \ltj@tempcntb=\globaldefs{\globaldefs0 \ltj@curjfnt=-1 #2%
257- \global\ltj@tempcnta=\ltj@curjfnt}\globaldefs\ltj@tempcntb%
256+ {\directlua{tex.globaldefs=0}\ltj@curjfnt=-1 #2%
257+ \global\ltj@tempcnta=\ltj@curjfnt}%
258258 \ifnum\ltj@tempcnta=-1
259259 \@PackageError{luatexja-core}%
260260 {\string#2 is not a control sequence that represents \MessageBreak
@@ -357,9 +357,10 @@
357357 }
358358
359359 \protected\def\ltjsetparameter#1{%
360- \ifnum\globaldefs=0\directlua{ltj.isglobal=''}\else\directlua{ltj.isglobal='global'}\fi
360+ \ifnum\globaldefs>0\directlua{ltj.isglobal='global'}\else\directlua{ltj.isglobal=''}\fi
361361 \setkeys[ltj]{japaram}{#1}\ignorespaces}
362-\protected\def\ltjglobalsetparameter#1{\directlua{ltj.isglobal='global'}%
362+\protected\def\ltjglobalsetparameter#1{%
363+ \ifnum\globaldefs<0\directlua{ltj.isglobal=''}\else\directlua{ltj.isglobal='global'}\fi
363364 \setkeys[ltj]{japaram}{#1}\ignorespaces}
364365
365366 %%%%%%%%
--- a/src/luatexja/stack.lua
+++ b/src/luatexja/stack.lua
@@ -23,12 +23,16 @@ function get_stack_level()
2323 local j = tex.currentgrouplevel
2424 if j > tex.getcount('ltj@@group@level') then
2525 i = i+1 -- new stack level
26+ local gd = tex.globaldefs
27+ if gd>0 then tex.globaldefs = 0 end
28+ -- 'tex.globaldefs = 0' is local even if \globaldefs > 0.
2629 tex.setcount('ltj@@group@level', j)
2730 for k,v in pairs(charprop_stack_table) do -- clear the stack above i
2831 if k>=i then charprop_stack_table[k]=nil end
2932 end
3033 charprop_stack_table[i] = table.fastcopy(charprop_stack_table[i-1])
3134 tex.setcount('ltj@@stack', i)
35+ if gd>0 then tex.globaldefs = gd end
3236 local g = node_new(id_whatsit, sid_user)
3337 g.user_id=30112; g.type=100; g.value=j; node.write(g)
3438 end
旧リポジトリブラウザで表示