OSDN Git Service

ltj-base.{sty,lua}: cleanup
[luatex-ja/luatexja.git] / test / test13-listings.tex
index 9930294..0274061 100644 (file)
@@ -1,8 +1,9 @@
 %#!lualatex
 \documentclass{article}
 
-\usepackage{luatexja}
-\usepackage{palatino,listings,color,showexpl}
+\usepackage{luatexja-fontspec,amsmath}
+\usepackage{listings,color,showexpl,comment}
+\usepackage{luatexja-otf}\directlua{luatexja.otf.enable_ivs()}
 \usepackage
 [
        papersize={100mm,100mm},
 
 \lstset
 {
-       language=sh,
+       language=sh, extendedchars=false,
        backgroundcolor=\color[gray]{.75},
        breaklines=true,
-    basewidth={0.55\zw, 0.45em},
+        explpreset={columns=fixed},
+    basewidth={0.5\zw, 0.45em},
        numbers=left,numberstyle=\tiny, numbersep=2pt,
 }
 
        }
        \fi
 }{}
-\DeclareFontShape{JY3}{mc}{m}{sl}{<-> s * [0.92489] psft:Ryumin-Light:jfm=ujis;slant=0.167}{}
-\DeclareFontShape{JY3}{mc}{m}{it}{<-> ssub* mc/m/sl}{}
+\DeclareKanjiFamily{JY3}{koz}{}
+\DeclareFontShape{JY3}{koz}{m}{n}{<-> s * [1.2] KozMinPr6N-Regular:jfm=ujis}{}
+\DeclareFontShape{JY3}{koz}{m}{sl}{<-> s * [1.2] psft:Ryumin-Light:jfm=ujis;slant=0.167}{}
+\DeclareFontShape{JY3}{koz}{m}{it}{<-> ssub* koz/m/sl}{}
+\def\mcdefault{koz}
+
+\setmainfont{TeX Gyre Pagella}
+\setmonofont{TeX Gyre Cursor}
+\def\cs#1{\hbox{\texttt{\textbackslash #1}}}
 \begin{document}
+
 This test file is based on a.tex\footnote{This can be downloaded from {\tt https://gist.github.com/1574793}.} by x19290.
 
 
@@ -46,21 +56,25 @@ In this document, we define them by
 \end{lstlisting}
 \newpage
 
-We also avoid white band problem, by setting both the height and the depth of each 
-letter/word to 0\,pt. 
+We also avoid white band problem, by setting the value of \cs{lineskiplimit} to
+\begin{multline}
+ -\min(\cs{cht}-\cs{ht}\cs{strutbox}, 0)\\
+ -\min(\cs{cdp}-\cs{dp}\cs{strutbox}, 0).
+\end{multline}
+
+Note: we still have a white band if the first line is line-broken.
 
 \begin{env}{\relax}
 #!/bin/sh
 #長い長い長い長い長い長い長い長い長い長い長い長い長い長い長い長い
 長い長い長い長い長い長い長い長い長い長い長い長い,長い長い長い長い長い長い
+#長い長い長い長い長い長い長い長い長い長い長い長い,長い長い長い長い長い長い
 #I.長い長い長い長い長い長い長い長い長い長い長い長い長い長い長い長いI
 長い長い長い長い長い長い長い長い長い長い長い長い長い長い長い長い
 #IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII
 IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII
 \end{env}
 
-Note that any \emph{kinsoku shori} is not performed inside \textsf{lstlisting} environment,
-as the line~3 in output above. We leave it to further development.
 \newpage
 
 \textbf{SOLVED}: LuaTeX-ja specific problem:
@@ -83,4 +97,116 @@ the first line of the listing is not rendered.
 え!1あアイウエオ
 え!2あ
 \end{lstlisting}
+\newpage
+\textbf{Ticket \#29311}
+
+\begin{env}{\relax}
+長い長い長い長い長い長い長い長い長い長い長い長aaa長い::い長い
+長い長い長い長い長い長い長い長い長い長い長い長aaaa長い::い長い
+長い長い長い長い長い長い長い長い長い長い長い長い長い,長い長い
+あ長い長い長い長い長い長い長い長い長い長い長い長い長い,長い長い
+長い長い長い長い長い長い長い長い長い長い長い長い長a,::い長い
+長い長い長い長い長い長い長い長い長い長い長い長い長aa,::い長い
+長い長い長い長い長い長い長い長い長い長い長い長い長aaa,::い長い
+長い長い長い長い長い長い長い長い長い長い長い長い長aaaa,::い長い
+長い長い長い長い長い長い長い長い長い長い長い長い長い,,::い長い
+長い長い長い長い長い長い長い長い長い長い長い長(い長い
+長い長い長い長い長い長い長い長い長い長い長いaa(い長い
+長い長い長い長い長い長い長い長い長い長い長い長(aa長い
+長い長い長い長い長い長い長い長い長い長い長い長い)(長い
+あ長い長い長い長い長い長い長い長い長い長い長い長い)(長い
+\end{env}
+
+\newpage
+\textbf{Ticket \#29604}
+
+\setmonofont{DejaVu Sans Mono}
+\ltjsetparameter{jacharrange={-2,-3,-8}}
+ギリシャ文字欧文扱い
+
+\begin{lstlisting}[basewidth=.5em,basicstyle=\tt, emph={TeX}, emphstyle=\color{red}]
+01234567890123456789
+!あ!漢!α!×!
+\TeX はギリシャ文字のΤ-Ε-Χ(タウ・イプシロン・カイ)であるから、……
+\TeX is an abbreviation of τέχνη (ΤΕΧΝΗ – technē).
+\end{lstlisting}
+
+\ltjsetparameter{jacharrange={+2,+8,+3}}
+ギリシャ文字和文扱い
+
+\begin{lstlisting}[basewidth=.5em,basicstyle=\tt, emph={TeX}, emphstyle=\color{red}]
+01234567890123456789
+!あ!漢!α!×!
+\TeX はギリシャ文字のΤ-Ε-Χ(タウ・イプシロン・カイ)であるから、……
+\TeX is an abbreviation of τέχνη (ΤΕΧΝΗ – technē).
+\end{lstlisting}
+
+\newpage
+IVS対応1: \texttt{vsraw=false} (default)
+
+\begin{LTXexample}[escapechar=\%, basicstyle=\tt]
+1234567890
+1葛󠄀城,葛󠄁飾
+󠄀a
+\end{LTXexample}
+
+IVS対応2: \texttt{vsraw=true}
+
+\begin{LTXexample}[escapechar=\%,vsraw, basicstyle=\tt]
+1234567890
+1葛󠄀城,葛󠄁飾アイウ
+\end{LTXexample}
+
+\newpage
+
+下の行において,最初の「1」の場所がずれてしまうのは半ば仕方がないとも言える.
+1行目では,「1234567890」が前後・文字間に計11箇所の等量の空白を入れて10全角の領域に
+出力されているのに対し,2,~3行目では「1」が全角幅に左右中央で出力されているからである.
+\begin{lstlisting}[escapechar=\%,vsraw, basewidth=1\zw, basicstyle=\tt]
+1234567890
+1あ,23
+1あ2,3
+1234567890
+\end{lstlisting}
+
+\texttt{doubleletterspace}オプションを指定すると,出力単位中の文字と文字の間隔を2倍にするため,
+下の例の「1」のように,各文字の垂直位置が揃いやすくなる.
+\begin{lstlisting}[escapechar=\%,doubleletterspace, basewidth=1\zw, basicstyle=\tt]
+1234567890
+1あ,23
+1あ2,3
+1)2,3
+1234567890
+\end{lstlisting}
+
+
+\newpage
+\textbf{Ticket \#34786}
+\ltjsetparameter{autoxspacing=false}
+
+foo \lstinline[basicstyle=\tt]!ba{}#shr! baz あ
+
+あ\lstinline[basicstyle=\tt]{bar  s}hoge
+
+あ\lstinline[basicstyle=\tt]{bar..{a}hoge
+
+foo \lstinline[basicstyle=\tt\gtfamily]!あexit 0; #shbar! baz あ
+
+あ\lstinline[basicstyle=\tt]{いbexit #sh$ar}hoge
+
+\bigskip
+\textbf{Ticket \#35484}
+
+\colorbox{red}{\lstinline!aiu#sheoxyz!}
+\colorbox{red}{\lstinline!あいexit 0;#shうえお!}
+
+
+\colorbox{red}{\lstinline{aiu#sheoxyz}}
+\colorbox{red}{\lstinline{あいexit 0;#shうえお}}
+
+あおいうえお
+\begin{lstlisting}[frame=single]
+aiu
+\end{lstlisting}
+あいうえお
 \end{document}