OSDN Git Service

Merged test/ivs.lua into ltj-otf.lua
[luatex-ja/luatexja.git] / test / test19-ivs.tex
1 %#!lualatex
2 \documentclass{ltjsarticle}
3 \usepackage{luatexja-fontspec,luatexja-otf, luacode, booktabs,array}
4
5 \begin{luacode}
6    local attr_curjfnt = luatexbase.attributes['ltj@curjfnt']
7    local identifiers = fonts.hashes.identifiers
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 = identifiers[tex.attribute[attr_curjfnt]]
14       pt = pt and pt.resources; pt = pt and pt.variants
15       if pt then
16          local t = {}
17          for i,v in pairs(pt) do
18             if v[c] then t[1+#t]=i end
19          end
20          sort(t)
21          for _,v in ipairs(t) do 
22             tex.sprint('\\oalign{' .. s .. uchar(v) 
23                           .. '\\crcr\\hss\\tiny' .. tostring(v-0xE0100) .. '\\hss\\crcr}') 
24          end
25       end
26    end
27 \end{luacode}
28
29 \def\MJI[#1]#2{#2\char\numexpr "E0100+#1\relax}%"
30 \def\IVSL#1{\directlua{list_ivs('#1')}}
31 \begin{document}
32 \jfontspec{ipamjm.ttf} % IPA MJ 明朝
33
34 例文はZRさんのブログ記事「ipamjmパッケージでアレしてみた」\footnote{%
35 \verb+http://d.hatena.ne.jp/zrbabbler/20131214/1387029624+}より引用.
36
37 \paragraph{標準状態では……}
38 \begin{quote}
39 \LARGE
40 渡邉󠄏さんとか   % { } の中は U+9089 U+E010F
41 渡𫟪󠄂さんとか。% { } の中は U+2B7EA U+E0102
42 \end{quote}
43
44 \paragraph{IVS処理コードをここで読み込んだ.}\ 
45 \directlua{luatexja.otf.enable_ivs()}
46
47 \begin{quote}
48 \LARGE
49 \MJI[15]{邉}\MJI[25]{邉}\MJI[27]{邉}\MJI[26]{邉}\MJI[26]{邉}\MJI[16]{邊}
50 \MJI[18]{邊}\MJI[2]{𫟪}\MJI[17]{邊}〓\\
51 \MJI[28]{邉}\MJI[29]{邉}\MJI[23]{邉}\MJI[15]{邊}\MJI[8]{邊}\MJI[20]{邉}
52 \MJI[24]{邉}\MJI[19]{邉}\MJI[18]{邉}\MJI[16]{邉}\\
53 \MJI[14]{邊}\MJI[10]{邊}\MJI[12]{邊}\MJI[11]{邊}\MJI[13]{邊}\MJI[9]{邊}
54 \MJI[0]{𫟪}\MJI[1]{𫟪}〓\MJI[21]{邉}
55 \end{quote}
56 「〓」はMJ番号を直接指定していたところなので,とりあえず無視している.
57 なぜか𫟪(U+2B7EA)のIVSが機能していないようだが,フォント側にその記述がない,ということ?
58
59 \begin{quote}
60 \LARGE
61 渡邉󠄏さんとか   % { } の中は U+9089 U+E010F
62 渡𫟪󠄂さんとか。% { } の中は U+2B7EA U+E0102
63 \end{quote}
64
65 \begin{center}
66 \Large
67 \begin{tabular}{c>{\tt}ll}
68 \toprule
69 文字&Unicode&IVS\\
70 \midrule
71 邉&U+9089&\IVSL{邉}\\
72 邊&U+908A&\IVSL{邊}\\
73 𫟪&U+2B7EA&\IVSL{𫟪}\\
74 \bottomrule
75 \end{tabular}
76 \end{center}
77 \end{document}