OSDN Git Service

lltjext.sty: platex/#77
[luatex-ja/luatexja.git] / src / ltj-rmlgbm.lua
index 2430ef3..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
@@ -230,10 +231,18 @@ local function read_cid_font()
          if not v.width then v.width = 655360 end
          v.height, v.depth = 576716.8, 78643.2 -- optimized for jfm-ujis.lua
       end
+      return cidfont_data[cid_name]
+   else
+      return nil
    end
 end
 
 -- High-level
+local function prepare_cid_font(reg, ord)
+   cid_reg, cid_order, cid_name, cid_supp = reg, ord, reg .. '-' .. ord
+   return cidfont_data[cid_name] or read_cid_font()
+end
+
 
 local definers = fonts.definers
 local function mk_rml(name, size, id)
@@ -308,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
@@ -320,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)
@@ -345,17 +352,13 @@ local function font_callback(name, size, id, fallback)
       if not cid_reg then
          cid_reg, cid_order = string.match(s, "^(.-)%-(.-)$")
       end
-      cid_name = cid_reg .. '-' .. cid_order
-      if not cidfont_data[cid_name] then
-         read_cid_font()
-         if not cidfont_data[cid_name] then
-            ltjb.package_error('luatexja',
-                               "bad cid key `" .. s .. "'",
-                               "I couldn't find any non-embedded font information for the CID\n" ..
-                                  '`' .. s .. "'. For now, I'll use `Adobe-Japan1-6'.\n"..
-                                  'Please contact the LuaTeX-ja project team.')
-            cid_name = "Adobe-Japan1"
-         end
+      if not prepare_cid_font(cid_reg, cid_order) then
+        ltjb.package_error('luatexja',
+                           "bad cid key `" .. s .. "'",
+                           "I couldn't find any non-embedded font information for the CID\n" ..
+                              '`' .. s .. "'. For now, I'll use `Adobe-Japan1-6'.\n"..
+                              'Please contact the LuaTeX-ja project team.')
+        cid_name = "Adobe-Japan1"
       end
       return mk_rml(basename, size, id)
    else
@@ -368,10 +371,10 @@ local function font_callback(name, size, id, fallback)
 end
 
 luatexja.rmlgbm = {
+   prepare_cid_font = prepare_cid_font,
    cidfont_data = cidfont_data,
    font_callback = font_callback,
    vert_addfunc = function () end, -- dummy, set in ltj-direction.lua
 }
 
-cid_reg, cid_order, cid_name, cid_supp = 'Adobe', 'Japan1', 'Adobe-Japan1'
-read_cid_font()
+prepare_cid_font('Adobe', 'Japan1')