OSDN Git Service

test: ksp_{natural,stretch,shrink} key in JFM
authorHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Thu, 17 Sep 2015 11:21:09 +0000 (20:21 +0900)
committerHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Thu, 17 Sep 2015 11:21:09 +0000 (20:21 +0900)
If ksp_natural is true, the natural width of a jfm glue is
increased by that of kanjiskip. ksp_stretch and ksp_shrink are similar.
Note that tune of jfm-ujis.lua is not completed.

src/jfm-ujis.lua
src/ltj-jfmglue.lua
src/ltj-jfont.lua

index ced82f6..a69ce5c 100644 (file)
@@ -16,9 +16,10 @@ luatexja.jfont.define_jfm {
       align = 'left', left = 0.0, down = 0.0,
       width = 1.0, height = 0.88, depth = 0.12, italic=0.0,
       glue = {
-        -- [index] = { width, stretch, shrink, [priority, [ratio]] }
-        [1] = { 0.5 , 0.0, 0.5,  0, 1 },
-        [2] = {0, 0, 0},
+        -- [index] = { width, stretch, shrink, [priority, [ratio]],
+         --             ksp_nat=t/f, ksp_stretch=t/f, ksp_shrink=t/f }
+        [1] = { 0.5 , 0.0, 0.5,  0, 1, ksp_stretch=true },
+        [2] = { 0, 0, 0 , ksp_shrink=true },
         [3] = { 0.25, 0.0, 0.25, 1, 1 },
         [4] = {0, 0, 0},
         [6] = {0, 0, 0},
@@ -37,7 +38,7 @@ luatexja.jfont.define_jfm {
       width = 0.5, height = 0.88, depth = 0.12, italic=0.0,
       glue = {
 -- 3 のみ四分,あとは0
-         [0] = {0, 0, 0},
+         [0] = {0, 0, 0, ksp_shrink=true },
          [1] = {0, 0, 0},
         [2] = {0, 0, 0},
         [3] = { 0.25, 0.0, 0.25, 1 },
@@ -59,15 +60,15 @@ luatexja.jfont.define_jfm {
       width = 0.5, height = 0.88, depth = 0.12, italic=0.0,
       glue = {
 -- 3 は四分, 2, 4, 9 は0, あとは0.5
-        [0] = { 0.5 , 0.0, 0.5, 0, -1 },
-        [1] = { 0.5 , 0.0, 0.5, 0, -1 },
+        [0] = { 0.5 , 0.0, 0.5, 0, -1, ksp_stretch=true },
+        [1] = { 0.5 , 0.0, 0.5, 0, -1, ksp_stretch=true },
          [2] = {0, 0, 0},
         [3] = { 0.25, 0.0, 0.25, 1, 1 },
          [4] = {0, 0, 0},
-        [5] = { 0.5 , 0.0, 0.5, 0, -1 },
-        [6] = { 0.5 , 0.0, 0.5, 0, -1 },
-        [7] = { 0.5 , 0.0, 0.5, 0, -1 },
-        [8] = { 0.5 , 0.0, 0.5, 0, -1 },
+        [5] = { 0.5 , 0.0, 0.5, 0, -1, ksp_stretch=true },
+        [6] = { 0.5 , 0.0, 0.5, 0, -1, ksp_stretch=true },
+        [7] = { 0.5 , 0.0, 0.5, 0, -1, ksp_stretch=true },
+        [8] = { 0.5 , 0.0, 0.5, 0, -1, ksp_stretch=true },
          [9] = {0, 0, 0},
       }
    },
@@ -98,14 +99,14 @@ luatexja.jfont.define_jfm {
       width = 0.5, height = 0.88, depth = 0.12, italic=0.0,
       glue = {
 -- 3 は.75, 2, 4 は0, あとは0.5
-        [0] = { 0.5 , 0.0, 0.5, 0, -1 },
-        [1] = { 0.5 , 0.0, 0.5, 0, -1 },
+        [0] = { 0.5 , 0.0, 0.5, 0, -1, ksp_stretch=true },
+        [1] = { 0.5 , 0.0, 0.5, 0, -1, ksp_stretch=true },
         [3] = { 0.75, 0.0, 0.25, 1, -1/3 },
-        [5] = { 0.5 , 0.0, 0.5, 0, -1 },
-        [6] = { 0.5 , 0.0, 0.5, 0, -1 },
-        [7] = { 0.5 , 0.0, 0.5, 0, -1 },
-        [8] = { 0.5 , 0.0, 0.5, 0, -1 },
-         [9] = { 0.5 , 0.0, 0.5, 0, -1 },
+        [5] = { 0.5 , 0.0, 0.5, 0, -1, ksp_stretch=true },
+        [6] = { 0.5 , 0.0, 0.5, 0, -1, ksp_stretch=true },
+        [7] = { 0.5 , 0.0, 0.5, 0, -1, ksp_stretch=true },
+        [8] = { 0.5 , 0.0, 0.5, 0, -1, ksp_stretch=true },
+         [9] = { 0.5 , 0.0, 0.5, 0, -1, ksp_stretch=true },
       }
    },
 
@@ -114,7 +115,7 @@ luatexja.jfont.define_jfm {
       align = 'left', left = 0.0, down = 0.0,
       width = 1.0, height = 0.88, depth = 0.12, italic=0.0,
       glue = {
-        [1] = { 0.5 , 0.0, 0.5, 0, 1 },
+        [1] = { 0.5 , 0.0, 0.5, 0, 1, ksp_stretch=true },
         [2] = {0, 0, 0},
         [3] = { 0.25, 0.0, 0.25, 1, 1 },
         [4] = {0, 0, 0},
@@ -131,13 +132,13 @@ luatexja.jfont.define_jfm {
       align = 'left', left = 0.0, down = 0.0,
       width = 1.0, height = 0.88, depth = 0.12, italic=0.0,
       glue = {
-         [0] = { 0.5 , 0.0, 0.5, 0, 1 },
-        [1] = { 0.5 , 0.0, 0.5, 0, 1 },
+         [0] = { 0.5 , 0.0, 0.5, 0, 1, ksp_stretch=true },
+        [1] = { 0.5 , 0.0, 0.5, 0, 1, ksp_stretch=true },
         [2] = {0, 0, 0},
         [3] = { 0.75, 0.0, 0.25, 1, 1 },
         [4] = {0, 0, 0},
         [6] = {0, 0, 0},
-        [7] = { 0.5 , 0.0, 0.5, 0, 1 },
+        [7] = { 0.5 , 0.0, 0.5, 0, 1, ksp_stretch=true},
         [8] = {0, 0, 0},
         [9] = {0, 0, 0},
       },
@@ -171,7 +172,7 @@ luatexja.jfont.define_jfm {
       align = 'left', left = 0.0, down = 0.0,
       width = 0.5, height = 0.88, depth = 0.12, italic=0.0,
       glue = {
-        [1] = { 0.5 , 0.0, 0.5, 0, 1 },
+        [1] = { 0.5 , 0.0, 0.5, 0, 1, ksp_stretch=true },
         [2] = {0, 0, 0},
         [3] = { 0.25, 0.0, 0.25, 1, 1 },
         [4] = {0, 0, 0},
@@ -204,7 +205,7 @@ luatexja.jfont.define_jfm {
       align = 'left', left = 0.0, down = 0.0,
       width = 1.0, height = 0.88, depth = 0.12, italic=0.0,
       glue = {
-        [1] = { 0.5 , 0.0, 0.5, 0, 1 },
+        [1] = { 0.5 , 0.0, 0.5, 0, 1, ksp_stretch=true },
         [2] = {0, 0, 0},
         [3] = { 0.25, 0.0, 0.25, 1, 1 },
         [4] = {0, 0, 0},
index 3a7101e..5d30dcb 100644 (file)
@@ -682,14 +682,24 @@ local function handle_penalty_suppress(post, pre, g)
 end
 
 -- 和文文字間の JFM glue を node 化
-local function new_jfm_glue(m, bc, ac)
+local function new_jfm_glue(m, bc, ac, ks)
 -- bc, ac: char classes
    local g = m.char_type[bc][ac]
    if g then
       if g[1] then
         local f = node_new(id_glue)
         set_attr(f, attr_icflag, g[4])
-        setfield(f, 'spec', node_copy(g[2]))
+        local fs = node_copy(g[2])
+        if g.ksp_natural then
+           setfield(fs, 'width', getfield(fs,'width')+getfield(ks, 'width'))
+        end
+        if g.ksp_stretch then
+           setfield(fs, 'stretch', getfield(fs,'stretch')+getfield(ks, 'stretch'))
+        end
+        if g.ksp_shrink then
+           setfield(fs, 'shrink', getfield(fs,'shrink')+getfield(ks, 'shrink'))
+        end
+        setfield(f, 'spec', fs)
         return f, g[3]
       else
         return node_copy(g[2]), g[3]
@@ -818,19 +828,20 @@ do
    end
 end
 
-local function calc_ja_ja_glue()
+local function calc_ja_ja_glue(ks)
    local qm, pm = Nq.met, Np.met
+   local ks = getfield(kanji_skip,'spec')
    if (qm.char_type==pm.char_type) and (qm.var==pm.var) then
-      return new_jfm_glue(qm, Nq.class, Np.class)
+      return new_jfm_glue(qm, Nq.class, Np.class, ks)
    else
       local npn, nqn = Np.nuc, Nq.nuc
       local gb, db = new_jfm_glue(qm, Nq.class,
                                  slow_find_char_class(Np.char,
-                                                      qm, getchar(npn)))
+                                                      qm, getchar(npn)), ks)
       local ga, da = new_jfm_glue(pm,
                                  slow_find_char_class(Nq.char,
                                                       pm, getchar(nqn)),
-                                 Np.class)
+                                 Np.class, ks)
       return calc_ja_ja_aux(gb, ga, db, da);
    end
 end
@@ -876,12 +887,14 @@ end
 local function get_OA_skip()
    local pm = Np.met
    return new_jfm_glue(pm,
-                      fast_find_char_class((Nq.id == id_math and -1 or 'jcharbdd'), pm), Np.class)
+                      fast_find_char_class((Nq.id == id_math and -1 or 'jcharbdd'), pm), 
+                      Np.class, getfield(xkanji_skip,'spec'))
 end
 local function get_OB_skip()
    local qm = Nq.met
    return new_jfm_glue(qm, Nq.class,
-                      fast_find_char_class((Np.id == id_math and -1 or'jcharbdd'), qm))
+                      fast_find_char_class((Np.id == id_math and -1 or'jcharbdd'), qm), 
+                      getfield(xkanji_skip,'spec'))
 end
 
 -- (anything) .. jachar
index 62b0e32..6a14283 100644 (file)
@@ -161,7 +161,13 @@ do
         if type(i) == 'number' then -- char_type
            for k,w in pairs(v.glue) do
               local h = node_new(id_glue_spec)
-              v[k] = {true, h, (w[5] and w[5]/sz or 0), FROM_JFM + (w[4] and w[4]/sz or 0)}
+              v[k] = {
+                 true, h, (w[5] and w[5]/sz or 0), 
+                 FROM_JFM + (w[4] and w[4]/sz or 0),
+                 ksp_natural = w.ksp_natural,
+                 ksp_stretch = w.ksp_stretch,
+                 ksp_shrink = w.ksp_shrink,
+              }
               setfield(h, 'width', w[1])
               setfield(h, 'stretch', w[2])
               setfield(h, 'shrink', w[3])