»
S
I
D
E
B
A
R
«
ConTeXt + LuaTeX + Chinese
August 26th, 2007 by kanru

最近這幾天玩了一下 ConTeXt,搭配最近開始 beta 的 LuaTeX,想辦法設定中文,有了小小的成果……

請參考這個文件原始檔

因為急著要跟大家分享,所以可能寫的不是很清楚或有所遺漏,還請不吝指教 :D

持續測試、改版中。

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]


One Response  
  • ConTeXt 學習筆記, Using MkIV at Kanru’s 探險日誌 writes:
    September 16th, 2008 at 10:07 pm

    [...] 一年前(時間過的好快!)稍稍研究了 ConTeXt 與 LuaTeX 的搭配,如今 ConTeXt MkIV 已經比當時更加的成熟,要使用多國語言簡單得多了。Li Yanrui 整理了一份 ConTeXt 的學習筆記,裡面包括了 TeX 與 ConTeXt 的簡介、ConTeXt MkIV 的安裝、ConTeXt 的文檔架構與基本命令,想要一窺究竟 ConTeXt 是在做甚麼,可以參考看看。 [...]


»  Substance: WordPress   »  Style: Ahren Ahimsa
© Copyright 2004-2009 Kan-Ru Chen