From: Kazuki Maeda Date: Thu, 8 Sep 2011 18:19:48 +0000 (+0900) Subject: Test: Added luatexja-otf.sty (\CID and \UTF). X-Git-Tag: 20120419.0~82^2~1^2~3 X-Git-Url: http://git.osdn.net/view?p=luatex-ja%2Fluatexja.git;a=commitdiff_plain;h=35aea5dd86ff987611642f5186399927b759b57e Test: Added luatexja-otf.sty (\CID and \UTF). --- diff --git a/src/luatexja-otf.sty b/src/luatexja-otf.sty new file mode 100644 index 0000000..6bd3d78 --- /dev/null +++ b/src/luatexja-otf.sty @@ -0,0 +1,96 @@ +% +% luatexja-otf.sty +% + +%% Avoid multiple loading. +\csname\if11luatexjaotfLoaded\fi\endcsname +\edef\x{% +\catcode32=\the\catcode32% +\catcode33=\the\catcode33% +\catcode35=\the\catcode35% +\catcode40=\the\catcode40% +\catcode41=\the\catcode41% +\catcode42=\the\catcode42% +\catcode43=\the\catcode43% +\catcode44=\the\catcode44% +\catcode45=\the\catcode45% +\catcode46=\the\catcode46% +\catcode58=\the\catcode58% +\catcode59=\the\catcode59% +\catcode60=\the\catcode60% +\catcode61=\the\catcode61% +\catcode62=\the\catcode62% +\catcode64=\the\catcode64% +\catcode91=\the\catcode91% +\catcode93=\the\catcode93% +\catcode94=\the\catcode94% +\catcode95=\the\catcode95% +\catcode126=\the\catcode126% +\endlinechar=\the\endlinechar +\relax} +\catcode32=10 %< > +\catcode33=12 %<"> +\catcode35=6 %<#> +\catcode40=12 %<(> +\catcode41=12 %<)> +\catcode42=12 %<*> +\catcode43=12 %<+> +\catcode44=12 %<,> +\catcode45=12 %<-> +\catcode46=12 %<.> +\catcode58=12 %<:> +\catcode59=12 %<;> +\catcode60=12 %<<> +\catcode61=12 %<=> +\catcode62=12 %<>> +\catcode64=11 %<@> +\catcode91=12 %<[> +\catcode93=12 %<]> +\catcode94=7 %<^> +\catcode95=8 %<_> +\catcode126=13 %<~> +\endlinechar=-1 % + +\edef\ltj@otf@AtEnd{\x + \noexpand\let\noexpand\ltj@otf@AtEnd\relax} +\def\luatexjaotfLoaded{\endinput} + +%% Check if LaTeX is used. +\begingroup\expandafter\expandafter\expandafter\endgroup +\expandafter\ifx\csname RequirePackage\endcsname\relax %<*!LaTeX> + \expandafter\let\csname ifltj@in@latex\expandafter\endcsname + \csname iffalse\endcsname +\else %<*LaTeX> + \expandafter\let\csname ifltj@in@latex\expandafter\endcsname + \csname iftrue\endcsname + \NeedsTeXFormat{LaTeX2e} + \ProvidesPackage{luatexja-otf}[2011/09/09 v0.1] +\fi % + +% Load core module if not yet. +\ifx\luatexjacoreLoaded\@undefined + \ifltj@in@latex %<*LaTeX> + \RequirePackage{luatexja-core}[2011/04/01] + \else %<*!LaTeX> + \input luatexja-core.sty % + \fi % +\fi + +%% When environment check fails, exit now. +\ifx\LuaTeXjaAvailable\@undefined + \ltj@otf@AtEnd +\expandafter\endinput\fi\relax + +%%------------------ +%! Main part of luatexja-otf +\RequireLuaModule{luatexja.otf} + +\protected\def\CID#1{\directlua{luatexja.otf.cid(#1)}} + +%% \UTF being compatible with the OTF package for pLaTeX +\protected\def\UTF#1{\char"#1} + +%%------------------ all done +\ltj@otf@AtEnd +\endinput +%% EOF diff --git a/src/luatexja/otf.lua b/src/luatexja/otf.lua new file mode 100644 index 0000000..15e9312 --- /dev/null +++ b/src/luatexja/otf.lua @@ -0,0 +1,36 @@ +-- +-- luatexja/otf.lua +-- +luatexbase.provides_module({ + name = 'luatexja.otf', + date = '2011/09/09', + version = '0.1', + description = 'The OTF Lua module for LuaTeX-ja', +}) +module('luatexja.otf', package.seeall) + +require('luatexja.base'); local ltjb = luatexja.base +require('luatexja.jfont'); local ltjf = luatexja.jfont + +local attr_curjfnt = luatexbase.attributes['ltj@curjfnt'] + +function cid(key) + local curjfnt = fonts.ids[tex.attribute[attr_curjfnt]] + if curjfnt.cidinfo.ordering ~= "Japan1" then + ltjb.package_error('luatexja-otf', + 'Current Japanese font "'..curjfnt.psname..'" is not a CID-Keyed font (Adobe-Japan1)', + 'Select a CID-Keyed font using \jfont.') + return + end + local char = curjfnt.unicodes['Japan1.'..tostring(key)] + if not char then + ltjb.package_error('luatexja-otf', + 'Current Japanese font "'..curjfnt.psname..'" does not include the specified CID character ('..tostring(key)..')', + 'Use a font including the specified CID character.') + return + end + tex.print("\\char"..tostring(char).."\\relax") +end + +-------------------- all done +-- EOF diff --git a/test/test10-otf.pdf b/test/test10-otf.pdf new file mode 100644 index 0000000..db8283e Binary files /dev/null and b/test/test10-otf.pdf differ diff --git a/test/test10-otf.tex b/test/test10-otf.tex new file mode 100644 index 0000000..e95b783 --- /dev/null +++ b/test/test10-otf.tex @@ -0,0 +1,32 @@ +%#! lualatex +\documentclass{bxjsarticle} +\usepackage{luatexja} +\usepackage{luatexja-otf} +\begin{document} + +※このファイルはフォントを埋め込んでいないため,代替されるフォントによっては正しく +表示されないでしょう. + +森\UTF{9DD7}外と内田百\UTF{9592}とが\UTF{9AD9}島屋に行くところを想像した。 + +\CID{7652}飾区の\CID{13706}野屋 + +\section*{Adobe-Japan1-5で追加された文字を使った例} +\begin{itemize} + %% \item 「\゜か」,「\゜き」,「\゜く」,「\゜け」,「\゜こ」, + %% 「\゜カ」,「\゜キ」,「\゜ク」,「\゜ケ」,「\゜コ」は鼻濁音を表す。 + \item Macintosh用キーボードの\UTF{2318}(Command key)を押す。 + \item \UTF{2672}を心がけよう。 +\end{itemize} + +\section*{Adobe-Japan1-6で追加された文字を使った例} +\begin{itemize} + \item ほげほげ番組\CID{20556} + \item ほげほげフェスティバル\CID{20656} + \item \CID{20939}(Bq: becquerel)は放射能の強さを表す単位である。 + \item フラーレン(fullerene) C$_{60}$は + サッカーボール状(\CID{20957})の構造をしている。 + \item \UTF{9B87}とは岩魚(イワナ)のことであり,嘉魚とも書く。 +\end{itemize} + +\end{document}