OSDN Git Service

JFM v3: 「仮想的な文字」'alchar', 'nox_alchar', 'glue'
authorHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Sat, 15 Jul 2017 12:14:51 +0000 (21:14 +0900)
committerHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Sat, 15 Jul 2017 12:14:51 +0000 (21:14 +0900)
src/jfm-ujis.lua
src/ltj-jfmglue.lua
src/ltj-jfont.lua
test/test24-jfmv3.pdf [new file with mode: 0644]
test/test24-jfmv3.tex [new file with mode: 0644]

index 925def1..476f063 100644 (file)
@@ -8,6 +8,7 @@
 
 
 local t = {
+   version = 3,
    dir = 'yoko',
    zw = 1.0, zh = 1.0,
    kanjiskip =  { 0.0, 0.25, 0 },
@@ -260,7 +261,7 @@ local t = {
 
 
    [99] = { -- box末尾
-      chars = {'boxbdd', 'parbdd'},
+      chars = {'boxbdd', 'parbdd', 'glue'},
    },
 
 }
@@ -274,4 +275,13 @@ for i=9758,9778 do ht[#ht+1] = 'AJ1-' .. tostring(i) end
 local ht = t[207].chars
 for i=9738,9757 do ht[#ht+1] = 'AJ1-' .. tostring(i) end
 
+t[100]=table.fastcopy(t[0])
+t[100].chars={'nox_alchar'}
+for i,v in pairs(t) do
+  if i~=6 and type(i)=='number' and type(v)=='table' then -- 感嘆符以外
+    if v.glue and v.glue[0] then v.glue[100] = v.glue[0] end
+    if v.kern and v.kern[0] then v.kern[100] = v.kern[0] end
+  end
+end
+
 luatexja.jfont.define_jfm(t)
index a51dacb..3476f5c 100644 (file)
@@ -933,18 +933,40 @@ local function combine_spc(name)
    return (Np[name] or Nq[name]) and ((Np[name]~=0) and (Nq[name]~=0))
 end
 
+-- OAX, OBX: alchar or math
+local function get_OAX_skip()
+   local pm = Np.met
+   local g, _, kn, kp, kh = new_jfm_glue(
+      pm.char_type,
+      fast_find_char_class(
+        (Nq.id == id_math and -1 or (Nq.xspc>=2 and 'alchar' or 'nox_alchar')), pm), 
+      Np.class)
+   local k = ((Nq.xspc>=2) and (Np.xspc%2==1) and combine_spc('auto_xspc'))
+       and get_xkanjiskip_low(false, pm, kn, kp, kh)
+   return g, k
+end
+local function get_OBX_skip()
+   local qm = Nq.met
+   local g, _, kn, kp, kh = new_jfm_glue(
+      qm.char_type, Nq.class,
+      fast_find_char_class(
+        (Np.id == id_math and -1 or (Np.xspc%2==1 and 'alchar' or 'nox_alchar')), qm)
+    )
+   local k = ((Nq.xspc>=2) and (Np.xspc%2==1) and combine_spc('auto_xspc'))
+        and get_xkanjiskip_low(false, qm, kn, kp, kh)
+   return g, k
+end
+
 local function get_OA_skip(is_kanji)
    local pm = Np.met
    local g, _, kn, kp, kh = new_jfm_glue(
       pm.char_type,
-      fast_find_char_class((Nq.id == id_math and -1 or 'jcharbdd'), pm), 
+      fast_find_char_class(
+        (((Nq.id==id_glue)or(Nq.id==id_kern)) and 'glue' or 'jcharbdd'), pm), 
       Np.class)
    local k
    if is_kanji==0 then
       k = combine_spc('auto_kspc') and get_kanjiskip_low(false, pm, kn, kp, kh)
-   elseif is_kanji==1 then
-      k = ((Nq.xspc>=2) and (Np.xspc%2==1) and combine_spc('auto_xspc'))
-        and get_xkanjiskip_low(false, pm, kn, kp, kh)
    end
    return g, k
 end
@@ -952,13 +974,11 @@ local function get_OB_skip(is_kanji)
    local qm = Nq.met
    local g, _, kn, kp, kh = new_jfm_glue(
       qm.char_type, Nq.class,
-      fast_find_char_class((Np.id == id_math and -1 or'jcharbdd'), qm))
+      fast_find_char_class(
+        (((Np.id==id_glue)or(Np.id==id_kern)) and 'glue' or 'jcharbdd'), qm))
    local k
    if is_kanji==0 then
       k = combine_spc('auto_kspc') and get_kanjiskip_low(false, qm, kn, kp, kh)
-   elseif is_kanji==1 then
-      k = ((Nq.xspc>=2) and (Np.xspc%2==1) and combine_spc('auto_xspc'))
-        and get_xkanjiskip_low(false, qm, kn, kp, kh)
    end
    return g, k
 end
@@ -979,7 +999,7 @@ local function handle_np_jachar(mode)
       handle_penalty_normal(0, Np.pre, g); real_insert(g); real_insert(k)
    elseif Nq.pre then
       local g, k
-      if non_ihb_flag then g, k = get_OA_skip(1) end -- O_A->X
+      if non_ihb_flag then g, k = get_OAX_skip() end -- O_A->X
       if not g then g = get_xkanjiskip(Np) end
       handle_penalty_normal((qid==id_hlist and 0 or Nq.post), Np.pre, g); 
       real_insert(g); real_insert(k)
@@ -1000,7 +1020,7 @@ end
 -- jachar .. (anything)
 local function handle_nq_jachar()
     if Np.pre then
-      local g = non_ihb_flag and get_OB_skip(1) or get_xkanjiskip(Nq) -- O_B->X
+      local g = non_ihb_flag and get_OBX_skip() or get_xkanjiskip(Nq) -- O_B->X
       handle_penalty_normal(Nq.post, (Np.id==id_hlist and 0 or Np.pre), g); real_insert(g)
    else
       local g =non_ihb_flag and  (get_OB_skip()) -- O_B
index 52bc6a5..272b03c 100644 (file)
@@ -162,6 +162,15 @@ function define_jfm(t)
         t[i] = nil
       end
    end
+   if t.version<3 then
+      -- In version 3, 'jcharbdd' is divided into 
+      -- 'alchar': ALchar (or math boundary) 
+      -- 'nox_alchar': ALchar (or math boundary), where xkanjiskip won't inserted
+      -- 'glue': glue/kern, 'jcharbdd': other cases (和文B, rule, ...)
+      t.chars.alchar = t.chars.jcharbdd
+      t.chars.nox_alchar = t.chars.jcharbdd
+      t.chars.glue = t.chars.jcharbdd
+   end
    t = luatexbase.call_callback("luatexja.load_jfm", t, jfm_file_name)
    t.size_cache = {}
    defjfm_res = t
diff --git a/test/test24-jfmv3.pdf b/test/test24-jfmv3.pdf
new file mode 100644 (file)
index 0000000..9fc469e
Binary files /dev/null and b/test/test24-jfmv3.pdf differ
diff --git a/test/test24-jfmv3.tex b/test/test24-jfmv3.tex
new file mode 100644 (file)
index 0000000..d0c15e8
--- /dev/null
@@ -0,0 +1,29 @@
+\input luatexja.sty
+
+\tentt
+
+あ!あ
+
+あ!a
+
+あ!)
+
+あ!(
+
+あ!)全角
+
+あ!\kern0ptあ
+
+
+あ(あ
+
+あ\kern0pt(あ
+
+あ・あ
+
+あ・(
+
+あ・)
+
+あ・a
+\end