リビジョン | 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
@@ -22,11 +22,13 @@ | ||
22 | 22 | \maketitle |
23 | 23 | |
24 | 24 | \tableofcontents |
25 | +\bigskip | |
26 | +{\Large\bf This documentation is far from complete. It may have many | |
27 | +grammatical (and contextual) errors.} | |
25 | 28 | |
26 | 29 | \newpage |
27 | 30 | \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. | |
30 | 32 | |
31 | 33 | |
32 | 34 | \section{Introduction} |
@@ -198,7 +200,6 @@ This does the minimal setting (like {\tt ptex.tex}) for typesetting Japanese doc | ||
198 | 200 | Here \verb+\zw+ is a counterpart of \texttt{em} for Japanese fonts, that is, the length of `full-width' in the current Japanese font. |
199 | 201 | \end{itemize} |
200 | 202 | |
201 | - | |
202 | 203 | \subsection{Using in \LaTeX} |
203 | 204 | \paragraph{\LaTeXe} |
204 | 205 | Using in \LaTeXe\ is basically same. To set up the minimal environment |
@@ -244,6 +245,7 @@ $f_{高温}$~($f_{\text{high temperature}}$). | ||
244 | 245 | \[ y=(x-1)^2+2\quad{}よって\quad y>0 \] |
245 | 246 | $5\in{}素:=\{\,p\in\mathbb N:\text{$p$ is a prime}\,\}$. |
246 | 247 | \end{LTXexample} |
248 | + | |
247 | 249 | We (the project members of Lua\TeX-ja) think that using |
248 | 250 | Japanese characters in math mode are allowed if these are used as identifiers. |
249 | 251 | In this point of view, |
@@ -453,7 +455,31 @@ For example, the following sets banner as `{\tt filename (2012-01-01 17:01)}': | ||
453 | 455 | \part{Reference}\label{part-ref} |
454 | 456 | \section{Font Metric and Japanese Font} |
455 | 457 | \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 | + | |
457 | 483 | |
458 | 484 | \subsection{Structure of JFM file} |
459 | 485 | 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 | ||
534 | 560 | it is not uncommon that the \texttt{align} field is \texttt{'middle'} or \texttt{'right'}. |
535 | 561 | For example, setting the \texttt{align} field to \texttt{'right'} is practically needed |
536 | 562 | when the current character class is the class for opening delimiters'. |
537 | -\begin{figure}[htb] | |
563 | +\begin{figure}[tb] | |
538 | 564 | \begin{minipage}{0.4\textwidth}% |
539 | 565 | \begin{center}\unitlength=10pt\small |
540 | 566 | \begin{picture}(15,12)(-1,-4) |
@@ -595,7 +621,9 @@ field is \texttt{'middle'}. | ||
595 | 621 | Its width, height and depth are specified by JFM. |
596 | 622 | \item Since the \texttt{align} field is \texttt{'middle'}, |
597 | 623 | 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. | |
599 | 627 | \end{itemize} |
600 | 628 | \end{minipage} |
601 | 629 | \caption{The position of the `real' glyph} |
@@ -613,6 +641,13 @@ the `real' glyph is centered horizontally (the green rectangle). | ||
613 | 641 | \subsection{{\tt\char92 ltjsetparameter} primitive} |
614 | 642 | |
615 | 643 | \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 | + | |
616 | 651 | \begin{list}{}{\def\makelabel{\ttfamily}\def\{{\char`\{}\def\}{\char`\}}} |
617 | 652 | \item[\textsf{kcatcode}\,=\{<chr\_code>,<value>\}] |
618 | 653 | \item[\textsf{prebreakpenalty}\,=\{<chr\_code>,<penalty>\}] |
@@ -620,19 +655,101 @@ the `real' glyph is centered horizontally (the green rectangle). | ||
620 | 655 | \item[\textsf{jatextfont}\,=\{<jfam>,<jfont\_cs>\}] |
621 | 656 | \item[\textsf{jascriptfont}\,=\{<jfam>,<jfont\_cs>\}] |
622 | 657 | \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$] | |
625 | 660 | \item[\textsf{jaxspmode}\,=\{<chr\_code>,<mode>\}] |
626 | 661 | \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$] | |
629 | 664 | \item[\textsf{kanjiskip}\,=<skip>] |
630 | 665 | \item[\textsf{xkanjiskip}\,=<skip>] |
631 | 666 | \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$] | |
634 | 669 | \end{list} |
635 | 670 | \section{Other Primitives} |
636 | 671 | \section{Control Sequences for \LaTeXe} |
637 | 672 | \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 | + | |
638 | 755 | \end{document} |
\ No newline at end of file |
@@ -253,8 +253,8 @@ | ||
253 | 253 | \define@key[ltj]{japaram}{jascriptscriptfont}{% |
254 | 254 | \expandafter\ltj@@set@stackfont#1:{mjss}} |
255 | 255 | \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}% | |
258 | 258 | \ifnum\ltj@tempcnta=-1 |
259 | 259 | \@PackageError{luatexja-core}% |
260 | 260 | {\string#2 is not a control sequence that represents \MessageBreak |
@@ -357,9 +357,10 @@ | ||
357 | 357 | } |
358 | 358 | |
359 | 359 | \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 | |
361 | 361 | \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 | |
363 | 364 | \setkeys[ltj]{japaram}{#1}\ignorespaces} |
364 | 365 | |
365 | 366 | %%%%%%%% |
@@ -23,12 +23,16 @@ function get_stack_level() | ||
23 | 23 | local j = tex.currentgrouplevel |
24 | 24 | if j > tex.getcount('ltj@@group@level') then |
25 | 25 | 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. | |
26 | 29 | tex.setcount('ltj@@group@level', j) |
27 | 30 | for k,v in pairs(charprop_stack_table) do -- clear the stack above i |
28 | 31 | if k>=i then charprop_stack_table[k]=nil end |
29 | 32 | end |
30 | 33 | charprop_stack_table[i] = table.fastcopy(charprop_stack_table[i-1]) |
31 | 34 | tex.setcount('ltj@@stack', i) |
35 | + if gd>0 then tex.globaldefs = gd end | |
32 | 36 | local g = node_new(id_whatsit, sid_user) |
33 | 37 | g.user_id=30112; g.type=100; g.value=j; node.write(g) |
34 | 38 | end |