リビジョン | 35aea5dd86ff987611642f5186399927b759b57e (tree) |
---|---|
日時 | 2011-09-09 03:19:48 |
作者 | Kazuki Maeda <kmaeda@user...> |
コミッター | Kazuki Maeda |
Test: Added luatexja-otf.sty (\CID and \UTF).
@@ -0,0 +1,96 @@ | ||
1 | +% | |
2 | +% luatexja-otf.sty | |
3 | +% | |
4 | + | |
5 | +%% Avoid multiple loading. | |
6 | +\csname\if11luatexjaotfLoaded\fi\endcsname | |
7 | +\edef\x{% | |
8 | +\catcode32=\the\catcode32% | |
9 | +\catcode33=\the\catcode33% | |
10 | +\catcode35=\the\catcode35% | |
11 | +\catcode40=\the\catcode40% | |
12 | +\catcode41=\the\catcode41% | |
13 | +\catcode42=\the\catcode42% | |
14 | +\catcode43=\the\catcode43% | |
15 | +\catcode44=\the\catcode44% | |
16 | +\catcode45=\the\catcode45% | |
17 | +\catcode46=\the\catcode46% | |
18 | +\catcode58=\the\catcode58% | |
19 | +\catcode59=\the\catcode59% | |
20 | +\catcode60=\the\catcode60% | |
21 | +\catcode61=\the\catcode61% | |
22 | +\catcode62=\the\catcode62% | |
23 | +\catcode64=\the\catcode64% | |
24 | +\catcode91=\the\catcode91% | |
25 | +\catcode93=\the\catcode93% | |
26 | +\catcode94=\the\catcode94% | |
27 | +\catcode95=\the\catcode95% | |
28 | +\catcode126=\the\catcode126% | |
29 | +\endlinechar=\the\endlinechar | |
30 | +\relax} | |
31 | +\catcode32=10 %< > | |
32 | +\catcode33=12 %<"> | |
33 | +\catcode35=6 %<#> | |
34 | +\catcode40=12 %<(> | |
35 | +\catcode41=12 %<)> | |
36 | +\catcode42=12 %<*> | |
37 | +\catcode43=12 %<+> | |
38 | +\catcode44=12 %<,> | |
39 | +\catcode45=12 %<-> | |
40 | +\catcode46=12 %<.> | |
41 | +\catcode58=12 %<:> | |
42 | +\catcode59=12 %<;> | |
43 | +\catcode60=12 %<<> | |
44 | +\catcode61=12 %<=> | |
45 | +\catcode62=12 %<>> | |
46 | +\catcode64=11 %<@> | |
47 | +\catcode91=12 %<[> | |
48 | +\catcode93=12 %<]> | |
49 | +\catcode94=7 %<^> | |
50 | +\catcode95=8 %<_> | |
51 | +\catcode126=13 %<~> | |
52 | +\endlinechar=-1 % | |
53 | + | |
54 | +\edef\ltj@otf@AtEnd{\x | |
55 | + \noexpand\let\noexpand\ltj@otf@AtEnd\relax} | |
56 | +\def\luatexjaotfLoaded{\endinput} | |
57 | + | |
58 | +%% Check if LaTeX is used. | |
59 | +\begingroup\expandafter\expandafter\expandafter\endgroup | |
60 | +\expandafter\ifx\csname RequirePackage\endcsname\relax %<*!LaTeX> | |
61 | + \expandafter\let\csname ifltj@in@latex\expandafter\endcsname | |
62 | + \csname iffalse\endcsname | |
63 | +\else %<*LaTeX> | |
64 | + \expandafter\let\csname ifltj@in@latex\expandafter\endcsname | |
65 | + \csname iftrue\endcsname | |
66 | + \NeedsTeXFormat{LaTeX2e} | |
67 | + \ProvidesPackage{luatexja-otf}[2011/09/09 v0.1] | |
68 | +\fi %</LaTeX> | |
69 | + | |
70 | +% Load core module if not yet. | |
71 | +\ifx\luatexjacoreLoaded\@undefined | |
72 | + \ifltj@in@latex %<*LaTeX> | |
73 | + \RequirePackage{luatexja-core}[2011/04/01] | |
74 | + \else %<*!LaTeX> | |
75 | + \input luatexja-core.sty % | |
76 | + \fi %</LaTeX> | |
77 | +\fi | |
78 | + | |
79 | +%% When environment check fails, exit now. | |
80 | +\ifx\LuaTeXjaAvailable\@undefined | |
81 | + \ltj@otf@AtEnd | |
82 | +\expandafter\endinput\fi\relax | |
83 | + | |
84 | +%%------------------ | |
85 | +%! Main part of luatexja-otf | |
86 | +\RequireLuaModule{luatexja.otf} | |
87 | + | |
88 | +\protected\def\CID#1{\directlua{luatexja.otf.cid(#1)}} | |
89 | + | |
90 | +%% \UTF being compatible with the OTF package for pLaTeX | |
91 | +\protected\def\UTF#1{\char"#1} | |
92 | + | |
93 | +%%------------------ all done | |
94 | +\ltj@otf@AtEnd | |
95 | +\endinput | |
96 | +%% EOF |
@@ -0,0 +1,36 @@ | ||
1 | +-- | |
2 | +-- luatexja/otf.lua | |
3 | +-- | |
4 | +luatexbase.provides_module({ | |
5 | + name = 'luatexja.otf', | |
6 | + date = '2011/09/09', | |
7 | + version = '0.1', | |
8 | + description = 'The OTF Lua module for LuaTeX-ja', | |
9 | +}) | |
10 | +module('luatexja.otf', package.seeall) | |
11 | + | |
12 | +require('luatexja.base'); local ltjb = luatexja.base | |
13 | +require('luatexja.jfont'); local ltjf = luatexja.jfont | |
14 | + | |
15 | +local attr_curjfnt = luatexbase.attributes['ltj@curjfnt'] | |
16 | + | |
17 | +function cid(key) | |
18 | + local curjfnt = fonts.ids[tex.attribute[attr_curjfnt]] | |
19 | + if curjfnt.cidinfo.ordering ~= "Japan1" then | |
20 | + ltjb.package_error('luatexja-otf', | |
21 | + 'Current Japanese font "'..curjfnt.psname..'" is not a CID-Keyed font (Adobe-Japan1)', | |
22 | + 'Select a CID-Keyed font using \jfont.') | |
23 | + return | |
24 | + end | |
25 | + local char = curjfnt.unicodes['Japan1.'..tostring(key)] | |
26 | + if not char then | |
27 | + ltjb.package_error('luatexja-otf', | |
28 | + 'Current Japanese font "'..curjfnt.psname..'" does not include the specified CID character ('..tostring(key)..')', | |
29 | + 'Use a font including the specified CID character.') | |
30 | + return | |
31 | + end | |
32 | + tex.print("\\char"..tostring(char).."\\relax") | |
33 | +end | |
34 | + | |
35 | +-------------------- all done | |
36 | +-- EOF |
@@ -0,0 +1,32 @@ | ||
1 | +%#! lualatex | |
2 | +\documentclass{bxjsarticle} | |
3 | +\usepackage{luatexja} | |
4 | +\usepackage{luatexja-otf} | |
5 | +\begin{document} | |
6 | + | |
7 | +※このファイルはフォントを埋め込んでいないため,代替されるフォントによっては正しく | |
8 | +表示されないでしょう. | |
9 | + | |
10 | +森\UTF{9DD7}外と内田百\UTF{9592}とが\UTF{9AD9}島屋に行くところを想像した。 | |
11 | + | |
12 | +\CID{7652}飾区の\CID{13706}野屋 | |
13 | + | |
14 | +\section*{Adobe-Japan1-5で追加された文字を使った例} | |
15 | +\begin{itemize} | |
16 | + %% \item 「\゜か」,「\゜き」,「\゜く」,「\゜け」,「\゜こ」, | |
17 | + %% 「\゜カ」,「\゜キ」,「\゜ク」,「\゜ケ」,「\゜コ」は鼻濁音を表す。 | |
18 | + \item Macintosh用キーボードの\UTF{2318}(Command key)を押す。 | |
19 | + \item \UTF{2672}を心がけよう。 | |
20 | +\end{itemize} | |
21 | + | |
22 | +\section*{Adobe-Japan1-6で追加された文字を使った例} | |
23 | +\begin{itemize} | |
24 | + \item ほげほげ番組\CID{20556} | |
25 | + \item ほげほげフェスティバル\CID{20656} | |
26 | + \item \CID{20939}(Bq: becquerel)は放射能の強さを表す単位である。 | |
27 | + \item フラーレン(fullerene) C$_{60}$は | |
28 | + サッカーボール状(\CID{20957})の構造をしている。 | |
29 | + \item \UTF{9B87}とは岩魚(イワナ)のことであり,嘉魚とも書く。 | |
30 | +\end{itemize} | |
31 | + | |
32 | +\end{document} |