OSDN Git Service

lltjfont.sty: fix \bfseries and \mdseries
[luatex-ja/luatexja.git] / src / ltj-compat.lua
index a4c1d68..c8e046c 100644 (file)
@@ -1,5 +1,5 @@
 --
--- luatexja/ltj-compat.lua
+-- ltj-compat.lua
 --
 
 luatexja.load_module('base');   local ltjb = luatexja.base
@@ -7,7 +7,7 @@ luatexja.load_module('stack');  local ltjs = luatexja.stack
 local stack_table_index = luatexja.stack_table_index
 
 -- load jisx0208 table
-local cache_ver = 2
+local cache_ver = 3
 
 local cache_outdate_fn = function (t) return t.version~=cache_ver end
 local jisx0208 = ltjb.load_cache('ltj-jisx0208',cache_outdate_fn)
@@ -18,6 +18,7 @@ end
 
 
 -- \kuten, \jis, \euc, \sjis, \ucs, \kansuji
+local utfchar=utf.char
 local function to_kansuji(num)
    if not num then num=0; return
    elseif num<0 then
@@ -25,7 +26,7 @@ local function to_kansuji(num)
    end
    local s = ""
    while num~=0 do
-      s = utf.char(
+      s = utfchar(
         ltjs.get_stack_table(luatexja.stack_table_index.KSJ + num%10,
                                '', tex.getcount('ltj@@stack'))) .. s
       num=math.floor(num/10)
@@ -52,7 +53,11 @@ local function from_kuten(i)
                         "I'm going to use 0 instead of that illegal character code.")
       i=0
    end
-   tex.write(tostring(jisx0208.table_jisx0208_uptex[i] or 0))
+   if (i%256==0)or(i%256>94) then
+     tex.write('0')
+   else 
+     tex.write(tostring(jisx0208.table_jisx0208_uptex[math.floor(i/256)*94+(i%256)-94] or 0))
+   end
 end
 
 -- \euc: EUC-JP による符号位置 => Unicode 符号位置