OSDN Git Service

use pre_shipout_filter hook if available
[luatex-ja/luatexja.git] / src / luatexja.lua
index 5c3b58e..8c01db1 100644 (file)
@@ -42,6 +42,9 @@ icflag_table.LINEEND         = 72
 icflag_table.PROCESSED       = 73
 icflag_table.IC_PROCESSED    = 74
 icflag_table.BOXBDD          = 75
+icflag_table.SPECIAL_JAGLUE  = 76
+-- 段落組版中のノードリストでは通常のノード (not whatsit) だが
+-- 和文処理グルー挿入プロセスで長さが決定されるもの
 icflag_table.PROCESSED_BEGIN_FLAG = 4096 -- sufficiently large power of 2
 
 local stack_ind = {}
@@ -83,6 +86,11 @@ dir_table.dir_utod = dir_table.dir_tate + dir_table.dir_math_mod
 
 local load_module = luatexja.load_module
 load_module 'base';      local ltjb = luatexja.base
+if tex.outputmode==0 then
+    ltjb.package_error('luatexja',
+      'DVI output is not supported in LuaTeX-ja',
+      'Use lua*tex instead dvilua*tex.')
+end
 load_module 'rmlgbm';    local ltjr = luatexja.rmlgbm -- must be 1st
 if luatexja_debug then load_module('debug') end
 load_module 'lotf_aux';  local ltju = luatexja.lotf_aux
@@ -324,11 +332,6 @@ do
    ltjb.add_to_callback('hpack_filter', adjust_icflag, 'ltj.adjust_icflag', 1)
 end
 
--- cleanup process
-function luatexja.ext_cleanup()
-   ltjf.cleanup_size_cache(); ltjd.remove_end_whatsit()
-end
-
 -- lastnodechar
 do
    local id_glyph = node.id('glyph')
@@ -343,10 +346,26 @@ do
             r = tostring(n.char)
          end
       end
-      tex.sprint(r)
+      tex.sprint(-2, r)
    end
 end
 
+do
+    local cache_ver = 3 -- must be same as ltj-kinsoku.tex
+    local cache_outdate_fn = function (t) return t.version~=cache_ver end
+    local t = ltjs.charprop_stack_table
+    function luatexja.load_kinsoku()
+        for i,_ in pairs(t) do t[i]=nil end
+        local kinsoku = ltjb.load_cache('ltj-kinsoku_default',cache_outdate_fn)
+        if kinsoku and kinsoku[1] then
+            t[0] = kinsoku[1]
+        else
+            t[0] = {}; tex.print(cat_lp, '\\input ltj-kinsoku.tex\\relax')
+        end
+        luatexja.load_kinsoku=nil
+    end
+end
+
 -- debug
 
 do