OSDN Git Service

Fix: replacement by IVS was overwritten by that by font features.
[luatex-ja/luatexja.git] / test / test19-ivs.tex
1 %#!lualatex
2 \documentclass{ltjsarticle}
3 \usepackage{luatexja-fontspec,luatexja-otf, luacode, booktabs,array}
4 \usepackage[scale=0.80]{geometry}
5
6 \begin{luacode}
7    local attr_curjfnt = luatexbase.attributes['ltj@curjfnt']
8    local ubyte = unicode.utf8.byte
9    local uchar = unicode.utf8.char
10    local sort = table.sort
11    function list_ivs(s)
12       local c = ubyte(s)
13       local pt = luatexja.otf.font_ivs_table[tex.attribute[attr_curjfnt]][c]
14       if pt then
15          local t = {}
16          for i,_ in pairs(pt) do t[1+#t]=i end
17          sort(t)
18          for _,i in ipairs(t) do 
19             tex.sprint('\\oalign{' .. s .. uchar(i+0xE0100)
20                           .. '\\crcr\\hss\\tiny' .. tostring(i) .. '\\hss\\crcr}') 
21          end
22       end
23    end
24 \end{luacode}
25
26 \def\MJI[#1]#2{#2\char\numexpr "E0100+#1\relax}%"
27 \def\IVSL#1{\directlua{list_ivs('#1')}}
28 \begin{document}
29 \jfontspec{ipamjm} % IPA MJ 明朝
30
31 例文はZRさんのブログ記事「ipamjmパッケージでアレしてみた」\footnote{%
32 \verb+http://d.hatena.ne.jp/zrbabbler/20131214/1387029624+}より引用.
33
34 \paragraph{標準状態では……}
35 \begin{quote}
36 \LARGE
37 渡邉󠄏さんとか   % { } の中は U+9089 U+E010F
38 渡𫟪󠄂さんとか。% { } の中は U+2B7EA U+E0102
39 \end{quote}
40
41 \paragraph{IVS処理コードをここで読み込んだ.}\ 
42 \directlua{luatexja.otf.enable_ivs()}
43
44 \begin{quote}
45 \LARGE
46 \MJI[15]{邉}\MJI[25]{邉}\MJI[27]{邉}\MJI[26]{邉}\MJI[26]{邉}\MJI[16]{邊}
47 \MJI[18]{邊}\MJI[2]{𫟪}\MJI[17]{邊}〓\\
48 \MJI[28]{邉}\MJI[29]{邉}\MJI[23]{邉}\MJI[15]{邊}\MJI[8]{邊}\MJI[20]{邉}
49 \MJI[24]{邉}\MJI[19]{邉}\MJI[18]{邉}\MJI[16]{邉}\\
50 \MJI[14]{邊}\MJI[10]{邊}\MJI[12]{邊}\MJI[11]{邊}\MJI[13]{邊}\MJI[9]{邊}
51 \MJI[0]{𫟪}\MJI[1]{𫟪}〓\MJI[21]{邉}
52 \end{quote}
53 「〓」はMJ番号を直接指定していたところなので,とりあえず無視している.
54 なぜか𫟪(U+2B7EA)のIVSが機能していないようだが,フォント側にその記述がない,ということ?
55
56 \begin{quote}
57 \LARGE
58 渡邉󠄏さんとか   % { } の中は U+9089 U+E010F
59 渡𫟪󠄂さんとか。% { } の中は U+2B7EA U+E0102
60 \end{quote}
61
62 \begin{center}
63 IPA MJ 明朝\par\medskip
64 \Large
65 \begin{tabular}{c>{\tt}ll}
66 \toprule
67 文字&Unicode&IVS\\
68 \midrule
69 邉&U+9089&\IVSL{邉}\\
70 邊&U+908A&\IVSL{邊}\\
71 𫟪&U+2B7EA&\IVSL{𫟪}\\
72 \bottomrule
73 \end{tabular}
74 \end{center}
75
76 \jfontspec{kozminpr6n-regular} % 小塚明朝 Pr6N R
77 \begin{center}
78 小塚明朝 Pr6N R\par\medskip
79 \Large
80 \begin{tabular}{c>{\tt}ll}
81 \toprule
82 文字&Unicode&IVS\\
83 \midrule
84 邉&U+9089&\IVSL{邉}\\
85 邊&U+908A&\IVSL{邊}\\
86 𫟪&U+2B7EA&\IVSL{𫟪}\\
87 \bottomrule
88 \end{tabular}
89 \end{center}
90
91
92 \jfontspec{hanamina} % 花園明朝A
93 \begin{center}
94 花園明朝A\par\medskip
95 \Large
96 \begin{tabular}{c>{\tt}ll}
97 \toprule
98 文字&Unicode&IVS\\
99 \midrule
100 邉&U+9089&\IVSL{邉}\\
101 邊&U+908A&\IVSL{邊}\\
102 𫟪&U+2B7EA&\IVSL{𫟪}\\
103 \bottomrule
104 \end{tabular}
105 \end{center}
106
107 \newpage
108 \def\TEST{%
109   奈良県葛󠄀城市と東京都葛󠄁飾区.%
110   江戸川区葛西はどっち?
111 }
112
113
114 \begin{quote}
115  \Large
116  {\jfontspec{KozMinPr6N-Regular}\TEST}\\
117  {\jfontspec[CJKShape=JIS1978]{KozMinPr6N-Regular}\TEST}\\
118  {\jfontspec[CJKShape=JIS1990]{KozMinPr6N-Regular}\TEST}
119 \end{quote}
120 \end{document}