OSDN Git Service

more
authorHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Wed, 11 Sep 2019 20:26:02 +0000 (05:26 +0900)
committerHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Wed, 11 Sep 2019 20:26:02 +0000 (05:26 +0900)
src/ltj-lotf_aux.lua
src/ltj-otf.lua

index 44b56f3..f7ca60a 100644 (file)
@@ -48,6 +48,29 @@ function aux.get_vheight(id, c) -- scaled points
   end
 end
 
+function aux.replace_vert_variant(id, c)
+  local t = getfont(id)
+  if t and t.resources and t.resources.sequences then
+    for _,i in pairs(t.resources.sequences) do
+      if (i.order[1]=='vert' or i.order[1]=='vrt2')
+          and i.type == 'gsub_single' and i.steps then
+        for _,j in pairs(i.steps) do
+          if type(j)=='table' then 
+            if type(j.coverage)=='table' then
+              for i,k in pairs(j.coverage) do
+                if i==c then return k end
+              end
+            end
+          end
+        end
+      end
+    end
+  end
+  return c
+end
+
+
+
 local search
 search = function (t, key, prefix)
   if type(t)=="table" then
index 225d729..0bdad6b 100644 (file)
@@ -10,6 +10,7 @@ luatexja.load_module('rmlgbm');    local ltjr = luatexja.rmlgbm
 luatexja.load_module('charrange'); local ltjc = luatexja.charrange
 luatexja.load_module('direction'); local ltjd = luatexja.direction
 luatexja.load_module('stack');     local ltjs = luatexja.stack
+luatexja.load_module('lotf_aux');  local ltju = luatexja.lotf_aux
 
 local id_glyph = node.id('glyph')
 local id_whatsit = node.id('whatsit')
@@ -104,25 +105,9 @@ local function get_ucs_from_rmlgbm(c)
       end
       if aj.shared.ltj_vert_table[r] then
          -- CID が縦組用字形だった場合
-         local curjfnt_num = tex_get_attr((ltjd_get_dir_count()==dir_tate)
-                                        and attr_curtfnt or attr_curjfnt)
-         local t = font_getfont(curjfnt_num)
-         if t.resources.sequences then
-            for _,i in pairs(t.resources.sequences) do
-               if (i.order[1]=='vert' or i.order[1]=='vrt2')
-                  and i.type == 'gsub_single' and i.steps then
-                  for _,j in pairs(i.steps) do
-                     if type(j)=='table' then 
-                        if type(j.coverage)=='table' then
-                           for i,k in pairs(j.coverage) do
-                              if i==r then return k end
-                           end
-                        end
-                     end
-                  end
-               end
-            end
-         end
+         return ltju.replace_vert_variant(
+            tex_get_attr((ltjd_get_dir_count()==dir_tate) and attr_curtfnt or attr_curjfnt),
+           r)
       end
       return r
    end
@@ -141,29 +126,12 @@ end
 local utf
 do
    utf = function (ucs)
-      local char = ucs
       if ltjd_get_dir_count()==dir_tate then
-         local curjfnt_num = tex_get_attr((ltjd_get_dir_count()==dir_tate)
-                                        and attr_curtfnt or attr_curjfnt)
-         local t = font_getfont(curjfnt_num)
-         if t.resources.sequences then
-            for _,i in pairs(t.resources.sequences) do
-               if (i.order[1]=='vert' or i.order[1]=='vrt2')
-                  and i.type == 'gsub_single' and i.steps then
-                  for _,j in pairs(i.steps) do
-                     if type(j)=='table' then 
-                        if type(j.coverage)=='table' then
-                           for i,k in pairs(j.coverage) do
-                              if i==char then return append_jglyph(k) end
-                           end
-                        end
-                     end
-                  end
-               end
-            end
-         end
+         ucs = ltju.replace_vert_variant(
+            tex_get_attr((ltjd_get_dir_count()==dir_tate) and attr_curtfnt or attr_curjfnt),
+           ucs)
       end
-      return append_jglyph(char)
+      return append_jglyph(ucs)
    end
 end