OSDN Git Service

update documents
[luatex-ja/luatexja.git] / src / ltj-jfont.lua
index cfd544c..9c53425 100644 (file)
@@ -167,8 +167,8 @@ do
            for k,w in pairs(v.glue) do
               local h = node_new(id_glue_spec)
               v[k] = {
-                 true, h, 
-                 ratio=w.ratio/sz, 
+                 true, h,
+                 ratio=w.ratio/sz,
                  priority=FROM_JFM + w.priority/sz,
                  kanjiskip_natural = w.kanjiskip_natural and w.kanjiskip_natural/sz,
                  kanjiskip_stretch = w.kanjiskip_stretch and w.kanjiskip_stretch/sz,
@@ -260,7 +260,7 @@ do
       cstemp = csname:sub( (utf8.byte(csname,1,1) == tex.escapechar) and 2 or 1, -1)
       cstemp = cstemp:sub(1, ((cstemp:sub(-1,-1)==' ') and (cstemp:len()>=2)) and -2 or -1)
       global_flag = g and '\\global' or ''
-      tex.sprint(cat_lp, '\\expandafter\\font\\csname ', 
+      tex.sprint(cat_lp, '\\expandafter\\font\\csname ',
                 (cstemp==' ') and '\\space' or cstemp, '\\endcsname')
    end
 
@@ -277,7 +277,7 @@ do
                            "bad JFM `" .. jfm_file_name .. "'",
                            'The JFM file you specified is not valid JFM file.\n'..
                               'So defining Japanese font is cancelled.')
-        tex.sprint(cat_lp, global_flag, '\\expandafter\\let\\csname ', 
+        tex.sprint(cat_lp, global_flag, '\\expandafter\\let\\csname ',
                    (cstemp==' ') and '\\space' or cstemp,
                       '\\endcsname=\\relax')
         return
@@ -286,7 +286,7 @@ do
       local ad = identifiers[fn].parameters
       local sz = metrics[j].size_cache[f.size]
       local fmtable = { jfm = j, size = f.size, var = jfm_var,
-                       with_kanjiskip = jfm_ksp, 
+                       with_kanjiskip = jfm_ksp,
                        zw = sz.zw, zh = sz.zh,
                        ascent = ad.ascender,
                        descent = ad.descender,
@@ -371,7 +371,7 @@ do
       if jfm_dir == 'tate' then
         is_vert_enabled = (not name:match('[:;]%-vert')) and (not  name:match('[:;]%-vrt2'))
          if not name:match('vert') and not name:match('vrt2') then
-            name = name .. ';vert;vrt2'
+            name = name .. ';+vert;+vrt2'
          end
       else
         is_vert_enabled = nil
@@ -420,9 +420,9 @@ do
       kfam_list[fam]=true
    end
    function search_kfam(fam, use_fd)
-      if kfam_list[fam] then 
+      if kfam_list[fam] then
         tex.sprint(cat_lp, '\\let\\ifin@\\iftrue '); return
-      elseif Nkfam_list[fam] then 
+      elseif Nkfam_list[fam] then
         tex.sprint(cat_lp, '\\let\\ifin@\\iffalse '); return
       elseif use_fd then
         for i,_ in pairs(kyenc_list) do
@@ -455,7 +455,7 @@ do
      tex.sprint(cat_lp, s)
    end
    function search_ffam_fd(fam)
-      if Nffam_list[fam] then 
+      if Nffam_list[fam] then
         tex.sprint(cat_lp, '\\let\\ifin@\\iffalse '); return
       else
         for i,_ in pairs(fenc_list) do
@@ -699,7 +699,7 @@ do
    local function add_fl_table(dest, glyphs, unitable, asc_des, units)
       local tg, glyphmin, glyphmax = glyphs.glyphs, 0, glyphs.glyphmax
       for _,v in pairs(fields(glyphs)) do
-        if v=='glyphmin' then glyphmin = glyphs.glyphmin; break end
+        if v=='glyphmin' then glyphmin, glyphmax = glyphs.glyphmin, glyphmax+1; break end
       end
       for i = glyphmin, glyphmax-1 do
         local gv = tg[i]
@@ -765,7 +765,7 @@ do
       end
       if fl.subfonts then
          for _,v in pairs(fl.subfonts) do
-            dest = add_fl_table(dest, v, unicodes, 
+            dest = add_fl_table(dest, v, unicodes,
                                fl.ascent + fl.descent, fl.units_per_em)
          end
       end
@@ -935,7 +935,7 @@ do
 
        return tfmdata
      end,
-     'ltj.supply_tounicode', 1)  
+     'ltj.supply_tounicode', 1)
 end
 
 
@@ -950,7 +950,17 @@ do
    local ensure_tex_attr = ltjb.ensure_tex_attr
    local node_write = Dnode.write
    local font = font
-   local ITALIC       = luatexja.icflag_table.ITALIC
+   local new_ic_kern
+   if status.luatex_version>=89 then
+       new_ic_kern = function(g)  return node_new(id_kern,3) end
+   else
+       local ITALIC       = luatexja.icflag_table.ITALIC
+       new_ic_kern = function()
+         local g = node_new(id_kern)
+         setfield(g, 'subtype', 1); set_attr(g, attr_icflag, ITALIC)
+        return g
+       end
+   end
    -- EXT: italic correction
    function append_italic()
       local p = to_direct(tex.nest[tex.nest.ptr].tail)
@@ -960,18 +970,18 @@ do
            local j = font_metric_table[
               has_attr(p, (get_dir_count()==dir_tate) and attr_curtfnt or attr_curjfnt)
               ]
-           local g = node_new(id_kern)
-           setfield(g, 'subtype', 1); set_attr(g, attr_icflag, ITALIC)
+           local g = new_ic_kern()
            setfield(g, 'kern', j.char_type[find_char_class(getchar(p), j)].italic)
            node_write(g); ensure_tex_attr(attr_icflag, 0)
         else
            local f = getfont(p)
            local h = font_getfont(f) or font.fonts[f]
            if h then
-              local g = node_new(id_kern)
-              setfield(g, 'subtype', 1); set_attr(g, attr_icflag, ITALIC)
-              setfield(g, 'kern', h.characters[getchar(p)].italic)
-              node_write(g); ensure_tex_attr(attr_icflag, 0)
+              local g = new_ic_kern()
+              if h.characters[getchar(p)] and h.characters[getchar(p)].italic then
+                 setfield(g, 'kern', h.characters[getchar(p)].italic)
+                 node_write(g); ensure_tex_attr(attr_icflag, 0)
+              end
            end
         end
       end
@@ -991,4 +1001,3 @@ vert_form_table = {
    [0xFF3B]=0xFE47, [0xFF3D]=0xFE48, [0xFF3F]=0xFE33,
 }
 setmetatable(vert_form_table, {__index=function(t,k) return k end});
-