OSDN Git Service

ltj-otf.lua: \CID and IVS now work with tate direction.
authorHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Wed, 29 Oct 2014 00:17:41 +0000 (09:17 +0900)
committerHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Wed, 29 Oct 2014 00:17:41 +0000 (09:17 +0900)
src/ltj-direction.lua
src/ltj-jfmglue.lua
src/ltj-otf.lua
src/ltj-pretreat.lua
src/ltj-stack.lua
src/luatexja.lua
test/test19-ivs.pdf
test/test19-ivs.tex

index 9dc8fbf..e29503b 100644 (file)
@@ -1095,7 +1095,6 @@ do
       end
       setfield(shipout_temp, 'head', a)
       finalize_inner(shipout_temp)
-      --luatexja.ext_show_node(to_node(shipout_temp), '> ', print,4)
       setbox('global', "AtBeginShipoutBox", copy(getlist(shipout_temp)))
       setfield(shipout_temp, 'head',nil)
    end
index 195e693..a9d6dae 100644 (file)
@@ -300,7 +300,7 @@ local function calc_np_pbox(lp, last)
    while lp ~=last and (lpa>=PACKED) and (lpa<BOXBDD) do
       if getid(lp)==id_hlist or getid(lp)==id_vlist then
         head, lp, nc = ltjd_make_dir_whatsit(head, lp, list_dir, 'jfm pbox')
-        if first then Np.first = nc end
+        Np.first = first and nc or Np.first
       else
         nc, lp = lp, node_next(lp)
       end
@@ -308,7 +308,9 @@ local function calc_np_pbox(lp, last)
      -- get_attr_icflag() ではいけない!
    end
    Np.nuc = nc
-   return check_next_ickern(lp)
+   lp = check_next_ickern(lp)
+   Np.last_char = check_box_high(Np, Np.first, lp)
+   return lp
 end
 
 local ltjw_apply_ashift_math = ltjw.apply_ashift_math
@@ -484,6 +486,7 @@ local calc_np_auxtable = {
       Np.first, Np.nuc, Np.last = (Np.first or lp), lp, lp;
       Np.id = getid(lp); set_attr(lp, attr_icflag, PROCESSED)
       ltjw_apply_ashift_disc(lp, (list_dir==dir_tate), tex_dir)
+      Np.last_char = check_box_high(Np, getfield(lp, 'replace'), nil)
       return true, node_next(lp)
    end,
    [id_kern] = function(lp)
@@ -611,18 +614,6 @@ do
    end
    local set_np_xspc_alchar = set_np_xspc_alchar
 
--- Np の情報取得メインルーチン
-   extract_np = function ()
-      local x, i = Np.nuc, Np.id;
---      if i ==  id_jglyph then return set_np_xspc_jachar(Np, x)
---      elseif i == id_glyph then return set_np_xspc_alchar(Np, getchar(x), x, 1)
---      if i == id_hlist then Np.last_char = check_box_high(Np, getlist(x), nil)
-      if i == id_pbox then Np.last_char = check_box_high(Np, Np.first, node_next(Np.last))
-      elseif i == id_disc then Np.last_char = check_box_high(Np, getfield(x, 'replace'), nil)
---      elseif i == id_math then return set_np_xspc_alchar(Np, -1, x)
-      end
-   end
-
    -- change the information for the next loop
    -- (will be done if Nx is an alphabetic character or a hlist)
    after_hlist = function (Nx)
@@ -1128,13 +1119,12 @@ function main(ahead, mode, dir)
    local lp, last, par_indented = init_var(mode,dir)
    lp = calc_np(lp, last)
    if Np then
-      extract_np(); handle_list_head(par_indented)
+      handle_list_head(par_indented)
    else
       return cleanup(mode)
    end
    lp = calc_np(lp, last)
    while Np do
-      extract_np();
       adjust_nq();
       local pid, pm = Np.id, Np.met
       -- 挿入部
index 70a946f..991fc4e 100644 (file)
@@ -55,6 +55,7 @@ local ltjf_find_char_class = ltjf.find_char_class
 local ltjr_cidfont_data = ltjr.cidfont_data
 local ltjc_is_ucs_in_japanese_char = ltjc.is_ucs_in_japanese_char
 local ltjd_get_dir_count = ltjd.get_dir_count
+local dir_tate = luatexja.dir_table.dir_tate
 
 luatexja.userid_table.OTF = luatexbase.newuserwhatsitid('char_by_cid',  'luatexja')
 luatexja.userid_table.VSR = luatexbase.newuserwhatsitid('replace_vs',  'luatexja')
@@ -95,7 +96,6 @@ end
 
 local cid
 do
-   local dir_tate = luatexja.dir_table.dir_tate
    local tex_get_attr = tex.getattribute
    cid = function (key)
       if key==0 then return append_jglyph(char) end
@@ -309,6 +309,10 @@ do
    local function do_ivs_repr(head)
       head = to_direct(head)
       local p, r = head
+      local is_dir_tate = ltjs.list_dir == dir_tate
+      local attr_ablshift = is_dir_tate and attr_tablshift or attr_yablshift
+      local attr_kblshift = is_dir_tate and attr_tkblshift or attr_ykblshift
+      local attr_curfnt =   is_dir_tate and attr_curtfnt or attr_curjfnt
       while p do
         local pid = getid(p)
         if pid==id_glyph then
@@ -324,8 +328,13 @@ do
                   head, r = node_remove(head,q)
                  node_free(q)
                   if pt then
+                    local is_jachar = (getfield(p, 'lang')==lang_ja)
                      local np = ivs_jglyph(pt, p, pf,
-                                           (getfield(p, 'lang') or 0)==lang_ja and OTF or VSR)
+                                           is_jachar and OTF or VSR)
+                    if is_jachar then
+                       set_attr(np, attr_curfnt, pf)
+                       set_attr(np, attr_kblshift, has_attr(p, attr_kblshift))
+                    end
                      head = node_insert_after(head, p, np)
                      head = node_remove(head,p)
                     node_free(p)
@@ -350,9 +359,13 @@ do
                              'luatexja.otf.enable_ivs() was already called, so this call is ignored', '')
       else
         luatexbase.add_to_callback('hpack_filter',
-                                   do_ivs_repr,'do_ivs', 1)
+                                   do_ivs_repr,'do_ivs', 
+                                   luatexbase.priority_in_callback('hpack_filter',
+                                                                   'ltj.hpack_filter_pre')+1)
         luatexbase.add_to_callback('pre_linebreak_filter',
-                                   do_ivs_repr, 'do_ivs', 1)
+                                   do_ivs_repr, 'do_ivs', 
+                                   luatexbase.priority_in_callback('pre_linebreak_filter',
+                                                                   'ltj.pre_linebreak_filter_pre')+1)
         local ivs_callback = function (name, size, id)
            return font_callback(
               name, size, id,
index 79961cc..00c2ed8 100644 (file)
@@ -43,6 +43,7 @@ local attr_curtfnt = luatexbase.attributes['ltj@curtfnt']
 local attr_icflag = luatexbase.attributes['ltj@icflag']
 
 local is_ucs_in_japanese_char = ltjc.is_ucs_in_japanese_char_direct
+--local ltjs_orig_char_table = ltjs.orig_char_table
 local ltjf_get_vert_glyph = ltjf.get_vert_glyph
 local ltjf_replace_altfont = ltjf.replace_altfont
 local attr_orig_char = luatexbase.attributes['ltj@origchar']
@@ -61,15 +62,14 @@ do
    local start_time_measure, stop_time_measure
       = ltjb.start_time_measure, ltjb.stop_time_measure
    local head
-   local is_dir_tate
    local suppress_hyphenate_ja_aux = {}
    suppress_hyphenate_ja_aux[id_glyph] = function(p)
       if (has_attr(p, attr_icflag) or 0)<=0 and is_ucs_in_japanese_char(p) then
          local pc = getchar(p)
         local pf = ltjf_replace_altfont(has_attr(p, attr_curjfnt) or getfont(p), pc)
-        setfield(p, 'font', pf);  --set_attr(p, attr_curjfnt, pf)
+        setfield(p, 'font', pf)
         setfield(p, 'lang', lang_ja)
-         set_attr(p, attr_orig_char, pc)
+        set_attr(p, attr_orig_char, pc)
       end
       return p
    end
@@ -126,8 +126,7 @@ local function set_box_stack_level(head, mode)
    for _,p  in pairs(wtd) do
       node_free(p)
    end
-   is_dir_tate = ltjs.list_dir == dir_tate
-   if is_dir_tate then
+   if ltjs.list_dir == dir_tate then
       for p in Dnode.traverse_id(id_glyph,to_direct(head)) do
          if (has_attr(p, attr_icflag) or 0)<=0 and getfield(p, 'lang')==lang_ja then
             local pfn = has_attr(p, attr_curtfnt) or getfont(p)
@@ -155,4 +154,5 @@ luatexbase.add_to_callback('pre_linebreak_filter',
 
 luatexja.pretreat = {
    set_box_stack_level = set_box_stack_level,
+   orig_char_table = orig_char_table,
 }
index aec2a7b..7a890e5 100644 (file)
@@ -130,7 +130,6 @@ function get_stack_table(mc, d, idx)
    return i or d
 end
 
-
 --------------------------------------------------------------------------------
 -- nest table (obeys TeX's semantic nest)
 --------------------------------------------------------------------------------
index d404278..1381424 100644 (file)
@@ -413,7 +413,7 @@ local function debug_show_node_X(p,print_fn, limit)
       if (p.shift or 0)~=0 then
          s = s .. ', shifted ' .. print_scaled(p.shift)
       end
-      if p.glue_sign or 0>= 1 then
+      if p.glue_set and p.glue_sign ==2 or ( p.glue_sign==1 and p.glue_set>0) then
          s = s .. ' glue set '
          if p.glue_sign == 2 then s = s .. '-' end
          s = s .. tostring(floor(p.glue_set*10000)/10000)
index f6a822a..f1a181b 100644 (file)
Binary files a/test/test19-ivs.pdf and b/test/test19-ivs.pdf differ
index 6d6e7da..59d8670 100644 (file)
@@ -127,4 +127,18 @@ MJ番号を直接指定していたところは,このソース中では無視
 江戸川区葛西はどっち?
 \end{lstlisting}
 
-\end{document}
\ No newline at end of file
+
+\def\test{あいうえお
+  {\ltjsetparameter{yjabaselineshift=-2pt,tjabaselineshift=2pt}%
+  \vrule 葛葛󠄀城市と葛󠄁飾区\CID{200}}あ}
+\catcode`\@=11
+\ltjsetparameter{kanjiskip=4pt}
+
+\hbox{\jfont\F=KozMinPr6N-Regular:jfm=ujis at 12pt \F\CID{200}\test}
+
+\hrule
+
+\hbox{\tate\tfont\F=KozMinPr6N-Regular:jfm=ujisv at 12pt \F\CID{200}\test}
+
+
+\end{document}