ConTeXt + LuaTeX + Chinese

最近這幾天玩了一下 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}'

#62a35c;">\enableregime[utf]
#62a35c;">\usemodule[chi-00]
#62a35c;">\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 .. '#0086b3;">\\lookaheaduchar{' .. up ..'}{' .. low ..'}'
            end
        end
        return rt
    end
    callback.register('process_input_buffer', wrap)
}
#62a35c;">\beginLUATEX\insertunicodeglyph
    #62a35c;">\unexpanded\def\insertunicodeglyph
    {#62a35c;">\doinsertunicodeglyph\unicodeone\unicodetwo}
    #62a35c;">\unexpanded\def\doinsertunicodeglyph#1#2%
    {#62a35c;">\char\numexpr(#2+(#1*256))#62a35c;">\relax}
#62a35c;">\endLUATEX
#a71d5d;">\def#62a35c;">\en#1{%
    #62a35c;">\hskip\chinesesurroundskip
    #62a35c;">\hskip\chineseinterglyphskip\relax
    #1%
    #62a35c;">\hskip\chineseinterglyphskip\relax
    #62a35c;">\hskip\chinesesurroundskip
    #62a35c;">\hskip\chinesesurroundskip
    #62a35c;">\hskip\chinesesurroundskip
    #62a35c;">\hskip\chinesesurroundskip
    #62a35c;">\hskip\chinesesurroundskip
    #62a35c;">\hskip\chinesesurroundskip
    #62a35c;">\hskip\chinesesurroundskip
    #62a35c;">\ignorespaces
}
#62a35c;">\starttypescript [sans] [cwheib] [name]
    #62a35c;">\definefontsynonym [Sans]              [cwheib]
    #62a35c;">\definefontsynonym [SansItalic]        [cwheib]
    #62a35c;">\definefontsynonym [SansSlanted]       [cwheib]
    #62a35c;">\definefontsynonym [SansBold]          [cwheib]
    #62a35c;">\definefontsynonym [SansBoldSlanted]   [cwheib]
    #62a35c;">\definefontsynonym [SansBoldItalic]    [cwheib]
#62a35c;">\stoptypescript
#62a35c;">\starttypescript [my] [cwheib]
    #62a35c;">\definetypeface [cwheib][ss][sans][cwheib][default]
#62a35c;">\stoptypescript
#62a35c;">\usetypescript[my][cwheib]
#62a35c;">\setupbodyfont[cwheib,ss,10pt]

已發佈

分類:

,

作者:

標籤: