OSDN Git Service

updated documents
[luatex-ja/luatexja.git] / src / ltj-lotf_aux.lua
index 92ffa72..bd3a602 100644 (file)
@@ -40,8 +40,7 @@ do
 local nulltable = {}
 local function get_cidinfo(id) -- table
   local t = getfont(id)
-  local a = t and (t.cidinfo or (t.resources and t.resources and t.resources.cidinfo)) or nulltable
-  return a
+  return (t and (t.resources and t.resources.cidinfo or t.cidinfo)) or nulltable
 end
 aux.get_cidinfo = get_cidinfo
 end
@@ -49,14 +48,18 @@ end
 local function get_asc_des(id)
   local t, v = getfont(id), font_metric_table[id]
   local a, d
-  if t and t.shared then
+  if t and t.shared and t.shared.rawdata then
     local u = t.units
     local t2 = t.shared.rawdata.metadata
     if t2 then
       a, d = t2.ascender and t2.ascender/u, t2.descender and -t2.descender/u
     end
-  -- HARF h_extents() returns "too large" value...?
-  -- rawdata.metadata.horizontalmetrics is same
+  elseif t.hb then -- HARF
+    local hbfont, u = t.hb.shared.font, t.hb.shared.upem
+    local h = hbfont:get_h_extents()
+    if h and u then 
+       a, d = h.ascender and h.ascender/u, h.descender and -h.descender/u
+    end
   end
   v.ascender, v.descender =  (a or 0.88)*t.size, (d or 0.12)*t.size
 end
@@ -76,9 +79,10 @@ local dummy_vht, dummy_vorg = {}, {}
 setmetatable(dummy_vht, {__index = function () return 1 end } )
 setmetatable(dummy_vorg, {__index = function () return 0.88 end } )
 local function get_vmet_table(tfmdata, dest)
-   if (not tfmdata) or (not tfmdata.shared) then
+   if (not tfmdata) or (not tfmdata.shared) or (not tfmdata.shared.rawdata) then
      dest = dest or {}
      dest.vorigin, dest.vheight = dummy_vorg, dummy_vht
+     dest.ind_to_uni = {}
      return dest
    end
    local rawdata = tfmdata.shared.rawdata
@@ -98,8 +102,11 @@ local function get_vmet_table(tfmdata, dest)
        if v.vheight~=default_vheight then t_vheight[i] = v.vheight / units end
      end
    end
-   setmetatable(t_vheight, {__index = function () return default_vheight / units end } )
-   setmetatable(t_vorigin, {__index = function () return ascender / units end } )
+   local vhd, vod = default_vheight / units, ascender/units
+   t_vheight.default = vhd
+   t_vorigin.default = vod
+   setmetatable(t_vheight, {__index = function () return vhd end } )
+   setmetatable(t_vorigin, {__index = function () return vod end } )
    dest = dest or {}
    dest.ind_to_uni = t_ind_to_uni
    dest.vorigin = t_vorigin -- designed size = 1.0