最近這幾天玩了一下 ConTeXt,搭配最近開始 beta 的 LuaTeX,想辦法設定中文,有了小小的成果……
因為急著要跟大家分享,所以可能寫的不是很清楚或有所遺漏,還請不吝指教 😀
持續測試、改版中。
PS. 文中不能複製貼上的部份放在下面
$ export TEXMFCNF=/usr/share/texmf/web2c
$ export TEXMF='{/usr/share/texmf,/usr/share/texmf-texlive,/home/kanru/texmf}'
$ export TEXMFCACHE=/tmp
$ export OSFONTDIR='{/usr/share/fonts/truetype,/home/kanru/.fonts}'
\enableregime[utf]
\usemodule[chi-00]
\directlua0{
function wrap(str)
rt = ''
for u in string.utfvalues(str) do
up = math.ceil(u / 0x100)
low = u - math.ceil(u / 0x100) * 0x100
if u < 127 then % need to be replace by cjk range
rt = rt .. unicode.utf8.char(u)
else
rt = rt .. '\\lookaheaduchar{' .. up ..'}{' .. low ..'}'
end
end
return rt
end
callback.register('process_input_buffer', wrap)
}
\beginLUATEX\insertunicodeglyph
\unexpanded\def\insertunicodeglyph
{\doinsertunicodeglyph\unicodeone\unicodetwo}
\unexpanded\def\doinsertunicodeglyph#1#2%
{\char\numexpr(#2+(#1*256))\relax}
\endLUATEX
\def\en#1{%
\hskip\chinesesurroundskip
\hskip\chineseinterglyphskip\relax
#1%
\hskip\chineseinterglyphskip\relax
\hskip\chinesesurroundskip
\hskip\chinesesurroundskip
\hskip\chinesesurroundskip
\hskip\chinesesurroundskip
\hskip\chinesesurroundskip
\hskip\chinesesurroundskip
\hskip\chinesesurroundskip
\ignorespaces
}
\starttypescript [sans] [cwheib] [name]
\definefontsynonym [Sans] [cwheib]
\definefontsynonym [SansItalic] [cwheib]
\definefontsynonym [SansSlanted] [cwheib]
\definefontsynonym [SansBold] [cwheib]
\definefontsynonym [SansBoldSlanted] [cwheib]
\definefontsynonym [SansBoldItalic] [cwheib]
\stoptypescript
\starttypescript [my] [cwheib]
\definetypeface [cwheib][ss][sans][cwheib][default]
\stoptypescript
\usetypescript[my][cwheib]
\setupbodyfont[cwheib,ss,10pt]