OSDN Git Service

more replacement to vertical forms
authorHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Wed, 16 Aug 2017 02:41:14 +0000 (11:41 +0900)
committerHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Wed, 16 Aug 2017 02:41:14 +0000 (11:41 +0900)
src/ltj-jfont.lua
src/ltj-pretreat.lua
src/ltj-rmlgbm.lua

index 3bd4322..3b217a6 100644 (file)
@@ -1039,6 +1039,7 @@ do
 ------------------------------------------------------------------------
 -- VERT VARIANT TABLE
 ------------------------------------------------------------------------
+  local provides_feature = luaotfload.aux.provides_feature
   local vert_form_table = {
      [0x3001]=0xFE11, [0x3002]=0xFE12, [0x3016]=0xFE17, [0x3017]=0xFE18,
      [0x2026]=0xFE19,
@@ -1049,27 +1050,34 @@ do
      [0x300C]=0xFE41, [0x300D]=0xFE42, [0x300E]=0xFE43, [0x300F]=0xFE44,
      [0xFF3B]=0xFE47, [0xFF3D]=0xFE48, 
   }
-  local function add_vform(coverage, vform, ft)
+  local function add_vform(coverage, vform, ft, add_vert)
      if type(coverage)~='table' then return end
      for i,v in pairs(vert_form_table) do
-        if (not coverage[i]) and ft.characters[v] then
+        if not coverage[i] and ft.characters[v] then
             vform[i] = v
         end
      end
+     if add_vert then -- vert feature が有効にならない場合
+       for i,v in pairs(coverage) do vform[i] = vform[i] or v end
+     end
   end
 
 luatexbase.add_to_callback(
    "luatexja.define_jfont",
    function (fmtable, fnum)
       local vform = {}; fmtable.vform = vform
-      local ft = font_getfont(fnum)
-      if ft.specification and ft.resources then
-         for _,i in pairs(ft.resources.sequences) do
-             if i.order[1]== 'vert' and i.type == 'gsub_single' and i.steps then
-                 for _,j in pairs(i.steps) do
-                    if type(j)=='table' then add_vform(j.coverage,vform, ft) end
-                 end
-             end
+      local t = font_getfont(fnum)
+      if t.specification and t.resources then
+        local add_vert  
+          = not (provides_feature(fnum, t.properties.script, t.properties.language, 'vert'))
+            and not (provides_feature(fnum, t.properties.script, t.properties.language, 'vrt2'))
+         -- 現在の language, script で vert もvrt2 も有効にできない場合,強制的に vert 適用
+        for _,i in pairs(t.resources.sequences) do
+           if i.order[1]== 'vert' and i.type == 'gsub_single' and i.steps then
+              for _,j in pairs(i.steps) do
+                 if type(j)=='table' then add_vform(j.coverage,vform, t, add_vert) end
+              end
+           end
          end
       end
       return fmtable
index 88aad54..3186ca6 100644 (file)
@@ -149,7 +149,7 @@ local function set_box_stack_level(head, mode)
            if ltjf_font_metric_table[nf].vert_activated then
               local pc = getchar(p)
               pc = ltjf_font_metric_table[nf].vform[pc]
-               if pc then setchar(p,  pc) end
+               if pc then print('Replace ', getchar(p) , pc); setchar(p,  pc) end
            end
         end
       end
index a4a06c7..a0505c5 100644 (file)
@@ -5,7 +5,7 @@ luatexja.load_module('base');      local ltjb = luatexja.base
 
 local cidfont_data = {}
 local cache_chars = {}
-local cache_ver = 5
+local cache_ver = 6
 local identifiers = fonts.hashes.identifiers
 
 local cid_reg, cid_order, cid_supp, cid_name
@@ -118,6 +118,7 @@ do
         },
         embedding = "no", cache = "yes", factor = 0, hfactor = 0, vfactor = 0,
         tounicode = 1,
+        properties = { language = "dflt", script = "dflt" },
       }
       cidfont_data[cid_name] = k
 
@@ -200,7 +201,7 @@ do
    cidf_vert_processor = {
       function (head, fnum)
          local fontdata = identifiers[fnum]
-         if fontdata.is_ltj_vert then
+         if luatexja.jfont.font_metric_table[fnum].vert_activated then
             local vt = fontdata.shared.ltj_vert_table
             for n in traverse_id(id_glyph, head) do
                if n.font==fnum then
@@ -316,9 +317,6 @@ local function mk_rml(name, size, id)
       e = e * 1000
       var, fontdata.extend  = var .. 'x' .. tostring(e), e
    end
-   if string.match(specification.detail, '(%+?vert)') then
-      cachedata.is_ltj_vert = true
-   end
    fontdata.name = specification.name .. size .. var; cachedata.name = fontdata.name
    fontdata.fullname = specification.name .. var; cachedata.fullname = fontdata.fullname
    fontdata.psname = specification.name; cachedata.psname = fontdata.psname
@@ -328,7 +326,8 @@ local function mk_rml(name, size, id)
 end
 
 local function font_callback(name, size, id, fallback)
-   local p = name:find(":") or name:len()+1
+   if name:sub(1,1)=="{" and name:sub(-1)=="}" then name = name:sub(2,-2) end
+   local p = name:find(":") or 0
    if name:sub(1, p-1) == 'psft' then
       local s = "Adobe-Japan1-6"
       local basename = name:sub(p+1)