OSDN Git Service

JFM: allow non-number value in height/depth fields
authorHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Fri, 16 Oct 2015 23:38:11 +0000 (08:38 +0900)
committerHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Fri, 16 Oct 2015 23:38:11 +0000 (08:38 +0900)
src/jfm-prop.lua
src/ltj-jfmglue.lua
src/ltj-jfont.lua
src/ltj-setwidth.lua
src/luatexja.sty

index af1c12e..71dc1ae 100644 (file)
@@ -6,4 +6,4 @@ luatexja.jfont.define_jfm {
       align = 'left', left = 0.0, down = 0.0,
       width = 'prop', height = 0.88, depth = 0.12, italic=0.0,
    }
-}
\ No newline at end of file
+}
index 11f648b..7c5ba86 100644 (file)
@@ -296,9 +296,13 @@ local function calc_np_pbox(lp, last)
    Np.first = Np.first or lp; Np.id = id_pbox
    set_attr(lp, attr_icflag, get_attr_icflag(lp));
    while lp ~=last and (lpa>=PACKED) and (lpa<BOXBDD) do
-      if getid(lp)==id_hlist or getid(lp)==id_vlist then
+      local lpi = getid(lp)
+      if lpi==id_hlist or lpi==id_vlist then
         head, lp, nc = ltjd_make_dir_whatsit(head, lp, list_dir, 'jfm pbox')
         Np.first = first and nc or Np.first
+      elseif (lpi==id_rule) and (lpa==PACKED) then
+         lp = node_next(lp)
+        nc, lp = lp, node_next(lp)
       else
         nc, lp = lp, node_next(lp)
       end
index 12d6dd9..3e4e0b1 100644 (file)
@@ -62,7 +62,6 @@ local function norm_val(a)
    end
 end
 
-
 function define_jfm(t)
    local real_char -- Does current character class have the 'real' character?
    if t.dir~=jfm_dir then
@@ -75,16 +74,13 @@ function define_jfm(t)
       if type(i) == 'number' then -- char_type
         if not v.chars then
            if i ~= 0 then defjfm_res= nil; return  end
-           real_char = true
         else
-           real_char = false
            for j,w in pairs(v.chars) do
               if type(w) == 'number' and w~=-1 then
-                 real_char = true;
               elseif type(w) == 'string' and utf.len(w)==1 then
-                 real_char = true; w = utf.byte(w)
+                 w = utf.byte(w)
               elseif type(w) == 'string' and utf.len(w)==2 and utf.sub(w,2) == '*' then
-                 real_char = true; w = utf.byte(utf.sub(w,1,1))
+                 w = utf.byte(utf.sub(w,1,1))
               end
               if not t.chars[w] then
                  t.chars[w] = i
@@ -92,35 +88,29 @@ function define_jfm(t)
                  defjfm_res= nil; return
               end
            end
-            if type(v.align)~='string' then
-               v.align = 'left' -- left
-            end
-           if real_char then
-              if type(v.width)~='number' and v.width~='prop' then
-                 defjfm_res= nil; return
-              else
-                 if v.width=='prop' and jfm_dir=='tate' then
-                    v.width = 1.0
-                 end
-                 if type(v.height)~='number' then
-                    v.height = 0.0
-                 end
-                 if type(v.depth)~='number' then
-                    v.depth = 0.0
-                 end
-                 if type(v.italic)~='number' then
-                    v.italic = 0.0
-                 end
-                 if type(v.left)~='number' then
-                    v.left = 0.0
-                 end
-                 if type(v.down)~='number' then
-                    v.down = 0.0
-                 end
-              end
-           end
            v.chars = nil
         end
+        if type(v.align)~='string' then
+           v.align = 'left' -- left
+        end
+        if type(v.width)~='number' then
+           v.width = (jfm_dir=='tate') and  1.0
+        end
+        if type(v.height)~='number' then
+           v.height = (jfm_dir=='tate') and  0.0
+        end
+        if type(v.depth)~='number' then
+           v.depth =  (jfm_dir=='tate') and  0.0
+        end
+        if type(v.italic)~='number' then
+           v.italic = 0.0
+        end
+        if type(v.left)~='number' then
+           v.left = 0.0
+        end
+        if type(v.down)~='number' then
+           v.down = 0.0
+        end
         v.kern = v.kern or {}; v.glue = v.glue or {}
         for j,x in pairs(v.glue) do
            if v.kern[j] then defjfm_res= nil; return end
index 390b1ca..acbe754 100644 (file)
@@ -77,19 +77,22 @@ local min, max = math.min, math.max
 -- 和文文字の位置補正(横)
 local function capsule_glyph_yoko(p, met, char_data, head, dir)
    if not char_data then return node_next(p), head, p end
-   -- f*: whd specified in JFM
-   local fwidth, pwidth = char_data.width, getfield(p, 'width')
-   fwidth = (fwidth ~= 'prop') and fwidth or pwidth
    fshift.down = char_data.down; fshift.left = char_data.left
    fshift = call_callback("luatexja.set_width", fshift, met, char_data)
-   local fheight, fdepth = char_data.height, char_data.depth
    local kbl = has_attr(p, attr_ykblshift) or 0
    --
+   -- f*: whd specified in JFM
+   local fwidth, pwidth = char_data.width, getfield(p, 'width')
+   fwidth = fwidth or pwidth
+   local fheight, pheight = char_data.height, getfield(p, 'height')
+   fheight = fheight or pheight
+   local fdepth, pdepth =  char_data.depth,getfield(p, 'depth')
+   fdepth = fdepth or pdepth
    if pwidth==fwidth then
       -- 補正後glyph node は ht: p.height - kbl - down, dp: p.depth + min(0, kbl+down) を持つ
       -- 設定されるべき寸法: ht: fheight - kbl, dp: fdepth + kbl
-      local ht_diff = fheight + fshift.down - getfield(p, 'height')
-      local dp_diff = fdepth  + kbl - getfield(p, 'depth') - min(kbl + fshift.down, 0)
+      local ht_diff = fheight + fshift.down - pheight
+      local dp_diff = fdepth  + kbl - pdepth - min(kbl + fshift.down, 0)
       if ht_diff == 0 and dp_diff ==0 then -- offset only
         set_attr(p, attr_icflag, PROCESSED)
         setfield(p, 'xoffset', getfield(p, 'xoffset') - fshift.left)
@@ -103,7 +106,7 @@ local function capsule_glyph_yoko(p, met, char_data, head, dir)
         setfield(box, 'depth', fdepth + kbl)
         setfield(box, 'dir', dir)
         set_attr(box, attr_icflag, PACKED)
-        set_attr(p, attr_icflag, PACKED)
+        --set_attr(p, attr_icflag, PACKED)
         head = p and node_insert_before(head, p, box)
            or node_insert_after(head, node_tail(head), box)
         return node_next(p), head, p, box
@@ -146,11 +149,11 @@ local function capsule_glyph_tate(p, met, char_data, head, dir)
       pwidth = pwidth + (met.v_advance[pc] or 0)
       ascent = met.v_origin[pc] and ascent - met.v_origin[pc] or ascent
    end
-   fwidth = (fwidth ~= 'prop') and fwidth or pwidth
+   fwidth = fwidth or pwidth
    fshift.down = char_data.down; fshift.left = char_data.left
    fshift = call_callback("luatexja.set_width", fshift, met, char_data)
-   local fheight, fdepth = char_data.height, char_data.depth
-
+   local fheight = char_data.height or 0
+   local fdepth  = char_data.depth or 0
    local y_shift
       = getfield(p, 'xoffset') + (has_attr(p,attr_tkblshift) or 0)
    local q
index 7a16149..80437db 100644 (file)
@@ -41,7 +41,7 @@
 
 %% Load all sub-packages.
 \ifltj@in@latex                 %<*LaTeX>
-  \RequirePackage{expl3}
+  %% \RequirePackage{expl3} needed if the version of l3kernel is v6111
   \RequirePackage{luatexja-core}  [2015/10/12]
   \RequirePackage{luatexja-compat}[2013/05/14]
 \else                           %<*!LaTeX>