OSDN Git Service

apply "implicit" vert/vrt2 features just before computing character class
authorHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Wed, 5 Nov 2014 09:05:33 +0000 (18:05 +0900)
committerHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Wed, 5 Nov 2014 09:05:33 +0000 (18:05 +0900)
src/jfm-ujisv.lua
src/ltj-jfmglue.lua
src/ltj-jfont.lua
src/ltj-pretreat.lua
src/ltj-setwidth.lua

index 8b3e692..918f87a 100644 (file)
@@ -169,7 +169,7 @@ luatexja.jfont.define_jfm {
         "AJ1-593", "AJ1-594", "AJ1-595", "AJ1-596", "AJ1-597", "AJ1-598",
       },
       align = 'left', left = 0.0, down = 0.0,
-      width = 0.5, height = 0.50, depth = 0.50, italic=0.0,
+      width = 0.5, height = 0.5, depth = 0.5, italic=0.0,
       glue = {
         [1] = { 0.5 , 0.0, 0.5, 0, 1 },
         [2] = {0, 0, 0},
index 870bab4..106b98d 100644 (file)
@@ -110,7 +110,7 @@ local slow_find_char_class
 do
    local start_time_measure = ltjb.start_time_measure
    local stop_time_measure = ltjb.stop_time_measure
-   slow_find_char_class = function (c, m, oc)
+   slow_find_char_class = function (c, m, oc,t )
       local cls = ltjf_find_char_class(oc, m)
       if oc~=c and cls==0 then
         return ltjf_find_char_class(-c, m), oc
@@ -564,6 +564,7 @@ do
    local attr_jchar_class = luatexbase.attributes['ltj@charclass']
    local attr_autospc = luatexbase.attributes['ltj@autospc']
    local attr_autoxspc = luatexbase.attributes['ltj@autoxspc']
+   local ltjf_get_vert_glyph = ltjf.get_vert_glyph
    function set_np_xspc_jachar_yoko(Nx, x)
       local m = ltjf_font_metric_table[getfont(x)]
       local cls, c = slow_find_char_class(ltjs_orig_char_table[x], m, getchar(x))
@@ -576,12 +577,11 @@ do
       Nx.auto_kspc, Nx.auto_xspc = (has_attr(x, attr_autospc)==1), (has_attr(x, attr_autoxspc)==1)
    end
    function set_np_xspc_jachar_tate(Nx, x)
-      local m = ltjf_font_metric_table[getfont(x)]
-      local cls, c
-      local c1, c2 = getchar(x), ltjs_orig_char_table[x][1]
-      c = ltjs_orig_char_table[x][2] or c1 or c2
-      cls = ltjf_find_char_class(c, m)
-      if cls==0 then cls = slow_find_char_class(c2, m, c1) end
+      local c, c_glyph = ltjs_orig_char_table[x], getchar(x)
+      local xf = getfont(x)
+      local m = ltjf_font_metric_table[xf]
+      local cls = slow_find_char_class(c, m, c_glyph)
+      setfield(x, 'char', ltjf_get_vert_glyph(xf, c_glyph) or c_glyph)
       Nx.met = m; Nx.class = cls;
       if cls~=0 then set_attr(x, attr_jchar_class, cls) end
       Nx.pre  = table_current_stack[PRE + c]  or 0
index 2d1a55e..83abf70 100644 (file)
@@ -750,7 +750,7 @@ end
 
 -- 
 do
-   local cache_ver = 3
+   local cache_ver = 5
    local checksum = file.checksum
 
    local function prepare_extra_data_base(id)
@@ -820,13 +820,19 @@ end
 -- calculate vadvance
 ------------------------------------------------------------------------
 do
-   local function acc_feature(table_vadv, subtables, ft)
+   local function acc_feature(table_vadv, table_vorg, subtables, ft)
       for char_num,v in pairs(ft.shared.rawdata.descriptions) do
         if v.slookups then
            for sn, sv in pairs(v.slookups) do
-              if subtables[sn] and type(sv)=='table' and sv[4]~=0 then
-                 table_vadv[char_num] 
-                    = (table_vadv[char_num] or 0) + sv[4]
+              if subtables[sn] and type(sv)=='table' then
+                 if sv[4]~=0 then 
+                    table_vadv[char_num] 
+                       = (table_vadv[char_num] or 0) + sv[4]
+                 end
+                 if sv[2]~=0 then 
+                    table_vorg[char_num] 
+                       = (table_vorg[char_num] or 0) + sv[2]
+                 end
               end
            end
         end
@@ -837,11 +843,14 @@ luatexbase.add_to_callback(
    "luatexja.define_jfont", 
    function (fmtable, fnum)
       local vadv = {}; fmtable.v_advance = vadv
+      local vorg = {}; fmtable.v_origin = vorg
       local ft = font_getfont(fnum)
       local subtables = {}
       if ft.specification then
+        ft.specification.features.normal.vrt2 = true
+        ft.specification.features.normal.vert = true
         for feat_name,v in pairs(ft.specification.features.normal) do
-           if v then
+           if v==true then
               for _,i in pairs(ft.resources.sequences) do
                  if i.order[1]== feat_name and i.type == 'gpos_single' then
                     for _,st in pairs(i.subtables) do
@@ -851,10 +860,13 @@ luatexbase.add_to_callback(
               end
            end
         end
-        acc_feature(vadv, subtables, ft)
+        acc_feature(vadv, vorg, subtables, ft)
         for i,v in pairs(vadv) do
            vadv[i]=vadv[i]/ft.units_per_em*fmtable.size
         end
+        for i,v in pairs(vorg) do
+           vorg[i]=vorg[i]/ft.units_per_em*fmtable.size
+        end
       end
       return fmtable 
    end, 1, 'ltj.v_advance'
index 14743db..796ad70 100644 (file)
@@ -44,7 +44,6 @@ 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']
 local STCK  = luatexja.userid_table.STCK
@@ -133,11 +132,7 @@ local function set_box_stack_level(head, mode)
          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)
             local pc = ltjs_orig_char_table[p]
-            local pf = ltjf_replace_altfont(pfn, pc)
-           ltjs_orig_char_table[p] = { pc, ltjs_orig_char_table[p] }
-           local xc = ltjf_get_vert_glyph(pf, pc) or pc
-            setfield(p, 'char', xc); setfield(p, 'font', pf);
-           ltjs_orig_char_table[p] = { pc, xc }
+           setfield(p, 'font', ltjf_replace_altfont(pfn, pc))
         end
       end
    end
index d9b903c..f8afa72 100644 (file)
@@ -150,12 +150,13 @@ local function capsule_glyph_tate(p, met, class, head, dir)
    local fwidth, pwidth = char_data.width
    do
       local pf = getfont(p)
-      local pc = getchar(p) -- ltjf_get_vert_glyph(pf, getchar(p))
+      local pc = getchar(p)
       setfield(p, 'char', pc)
       pwidth = ltjf_font_extra_info[pf] and  ltjf_font_extra_info[pf][pc] 
         and ltjf_font_extra_info[pf][pc].vwidth 
         and ltjf_font_extra_info[pf][pc].vwidth * met.size or (ascent+descent)
-      pwidth = pwidth + (met.v_advance and met.v_advance[pc] or 0)
+      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
    fshift.down = char_data.down; fshift.left = char_data.left