OSDN Git Service

lltjp-listings.sty: support IVS (ugly hack)
[luatex-ja/luatexja.git] / test / test13-listings.tex
1 %#!lualatex
2 \documentclass{article}
3
4 \usepackage{luatexja-fontspec}
5 \usepackage{listings,color,showexpl,comment}
6 \usepackage{luatexja-otf}
7 \directlua{luatexja.otf.enable_ivs()}
8 \usepackage
9 [
10         papersize={100mm,100mm},
11         hmargin={5mm,5mm},
12         vmargin={5mm,5mm}
13 ]{geometry}
14 \pagestyle{empty}
15
16 \lstset
17 {
18         language=sh, extendedchars=false,
19         backgroundcolor=\color[gray]{.75},
20         breaklines=true,
21     basewidth={0.55\zw, 0.45em},
22         numbers=left,numberstyle=\tiny, numbersep=2pt,
23 }
24
25 \lstnewenvironment{env}[1]
26 {
27         \ifx\relax#1\else
28         \renewcommand{\lstlistingname}{ex}
29         \lstset
30         {
31                 caption=#1,
32         }
33         \fi
34 }{}
35 \DeclareKanjiFamily{JY3}{koz}{}
36 \DeclareFontShape{JY3}{koz}{m}{n}{<-> s * [0.92489] KozMinPr6N-Regular:jfm=ujis}{}
37 \DeclareFontShape{JY3}{koz}{m}{sl}{<-> s * [0.92489] psft:Ryumin-Light:jfm=ujis;slant=0.167}{}
38 \DeclareFontShape{JY3}{koz}{m}{it}{<-> ssub* koz/m/sl}{}
39 \def\mcdefault{koz}
40
41 \setmainfont{TeX Gyre Pagella}
42 \setmonofont{TeX Gyre Cursor}
43 \begin{document}
44
45 This test file is based on a.tex\footnote{This can be downloaded from {\tt https://gist.github.com/1574793}.} by x19290.
46
47
48 \textbf{SOLVED}: bad folding and not slanted problems are common in pLaTeX and LuaTeX-ja.
49
50 The cause of the latter problem is that Japanese fonts don't have italic shape by default.
51 In this document, we define them by
52 \begin{lstlisting}[language={[AlLaTeX]TeX}, basicstyle=\ttfamily]
53 \DeclareFontShape{JY3}{mc}{m}{sl}{<-> s * [0.92489] psft:Ryumin-Light:jfm=ujis;slant=0.167}{}
54 \DeclareFontShape{JY3}{mc}{m}{it}{<-> ssub* mc/m/sl}{}
55 \end{lstlisting}
56 \newpage
57
58 We also avoid white band problem, by setting both the height and the depth of each 
59 letter/word to 0\,pt. 
60
61 \begin{env}{\relax}
62 #!/bin/sh
63 #長い長い長い長い長い長い長い長い長い長い長い長い長い長い長い長い
64 長い長い長い長い長い長い長い長い長い長い長い長い,長い長い長い長い長い長い
65 #長い長い長い長い長い長い長い長い長い長い長い長い,長い長い長い長い長い長い
66 #I.長い長い長い長い長い長い長い長い長い長い長い長い長い長い長い長いI
67 長い長い長い長い長い長い長い長い長い長い長い長い長い長い長い長い
68 #IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII
69 IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII
70 \end{env}
71
72 \newpage
73
74 \textbf{SOLVED}: LuaTeX-ja specific problem:
75 when the \emph{begin} line of a listings environment ends with JAchar,
76 the first line of the listing is not rendered.
77
78 \begin{env}{problem; shebang not rendered --- 問題}
79 #!/bin/bash
80 :
81 \end{env}
82
83 \begin{LTXexample}[language=TeX]
84 え!1あ,い・あ)う(え
85 え!2あ
86 \end{LTXexample}
87
88 \lstinputlisting{test13-listings.tmp}
89
90 \begin{lstlisting}
91 え!1あアイウエオ
92 え!2あ
93 \end{lstlisting}
94 \newpage
95 \textbf{Ticket \#29311}
96
97 \begin{env}{\relax}
98 長い長い長い長い長い長い長い長い長い長い長い長い#い長い
99 長い長い長い長い長い長い長い長い長い長い長い長aaaa#::い長い
100 長い長い長い長い長い長い長い長い長い長い長い長い,長い長い
101 長い長い長い長い長い長い長い長い長い長い長い長aa,::い長い
102 長い長い長い長い長い長い長い長い長い長い長い長,,::い長い
103 長い長い長い長い長い長い長い長い長い長い長い長(い長い
104 長い長い長い長い長い長い長い長い長い長い長いaa(い長い
105 長い長い長い長い長い長い長い長い長い長い長い長(aa長い
106 長い長い長い長い長い長い長い長い長い長い長い長い)(長い
107 \end{env}
108
109 \newpage
110 \textbf{Ticket \#29604}
111
112 \setmonofont{DejaVu Sans Mono}
113 \ltjsetparameter{jacharrange={-2,-3,-8}}
114 ギリシャ文字欧文扱い
115
116 \begin{lstlisting}[basewidth=.5em,basicstyle=\tt, emph={TeX}, emphstyle=\color{red}]
117 01234567890123456789
118 !あ!漢!α!×!
119 \TeX はギリシャ文字のΤ-Ε-Χ(タウ・イプシロン・カイ)であるから、……
120 \TeX is an abbreviation of τέχνη (ΤΕΧΝΗ – technē).
121 \end{lstlisting}
122
123 \ltjsetparameter{jacharrange={+2,+8,+3}}
124 ギリシャ文字和文扱い
125
126 \begin{lstlisting}[basewidth=.5em,basicstyle=\tt, emph={TeX}, emphstyle=\color{red}]
127 01234567890123456789
128 !あ!漢!α!×!
129 \TeX はギリシャ文字のΤ-Ε-Χ(タウ・イプシロン・カイ)であるから、……
130 \TeX is an abbreviation of τέχνη (ΤΕΧΝΗ – technē).
131 \end{lstlisting}
132
133 \newpage
134 IVS対応
135
136 \begin{lstlisting}[escapechar=\%,basicstyle=\tt]
137 1234567890
138 1葛󠄀城,葛󠄁飾
139 \end{lstlisting}
140 \end{document}