diff options
| -rw-r--r-- | otfl-font-otc.lua | 2 | ||||
| -rw-r--r-- | otfl-font-otf.lua | 2 | ||||
| -rw-r--r-- | otfl-font-tfm.lua | 23 | ||||
| -rw-r--r-- | otfl-luat-dum.lua | 5 | ||||
| -rw-r--r-- | otfl-node-res.lua | 19 | 
5 files changed, 40 insertions, 11 deletions
| diff --git a/otfl-font-otc.lua b/otfl-font-otc.lua index 059748d..64e09f8 100644 --- a/otfl-font-otc.lua +++ b/otfl-font-otc.lua @@ -21,6 +21,8 @@ local tfm = fonts.tfm  -- instead of "script = "DFLT", langs = { 'dflt' }" we now use wildcards (we used to  -- have always); some day we can write a "force always when true" trick for other  -- features as well +-- +-- we could have a tnum variant as well  local extra_lists = {      tlig = { diff --git a/otfl-font-otf.lua b/otfl-font-otf.lua index 75eb361..efe1319 100644 --- a/otfl-font-otf.lua +++ b/otfl-font-otf.lua @@ -1818,7 +1818,7 @@ function tfm.read_from_open_type(specification)                  end              end          end -        tfmtable = tfm.scale(tfmtable,s) +        tfmtable = tfm.scale(tfmtable,s,specification.relativeid)       -- here we resolve the name; file can be relocated, so this info is not in the cache          local filename = (otfdata and otfdata.luatex and otfdata.luatex.filename) or specification.filename          if not filename then diff --git a/otfl-font-tfm.lua b/otfl-font-tfm.lua index c5140ff..2f96de4 100644 --- a/otfl-font-tfm.lua +++ b/otfl-font-tfm.lua @@ -228,12 +228,27 @@ local charactercache = { }  -- a virtual font has italic correction make sure to set the  -- has_italic flag. Some more flags will be added in the future. -function tfm.do_scale(tfmtable, scaledpoints) - -- tfm.prepare_base_kerns(tfmtable) -- optimalization + +function tfm.calculate_scale(tfmtable, scaledpoints, relativeid)      if scaledpoints < 0 then          scaledpoints = (- scaledpoints/1000) * tfmtable.designsize -- already in sp      end      local delta = scaledpoints/(tfmtable.units or 1000) -- brr, some open type fonts have 2048 +    return scaledpoints, delta +end + +function tfm.do_scale(tfmtable, scaledpoints, relativeid) + -- tfm.prepare_base_kerns(tfmtable) -- optimalization +    local scaledpoints, delta = tfm.calculate_scale(tfmtable, scaledpoints, relativeid) +    if enable_auto_r_scale and relativeid then -- for the moment this is rather context specific +        local relativedata = fontdata[relativeid] +        local id_x_height = relativedata and relativedata.parameters and relativedata.parameters.x_height +        local tf_x_height = id_x_height and tfmtable.parameters and tfmtable.parameters.x_height * delta +        if tf_x_height then +            scaledpoints = (id_x_height/tf_x_height) * scaledpoints +            delta = scaledpoints/(tfmtable.units or 1000) +        end +    end      local hdelta, vdelta = delta, delta      local t = { }      -- unicoded unique descriptions shared cidinfo characters changed parameters indices @@ -628,8 +643,8 @@ end  function tfm.cleanup(tfmdata) -- we need a cleanup callback, now we miss the last one  end -function tfm.scale(tfmtable, scaledpoints) -    local t, factor = tfm.do_scale(tfmtable, scaledpoints) +function tfm.scale(tfmtable, scaledpoints, relativeid) +    local t, factor = tfm.do_scale(tfmtable, scaledpoints, relativeid)      t.factor    = factor      t.ascender  = factor*(tfmtable.ascender  or 0)      t.descender = factor*(tfmtable.descender or 0) diff --git a/otfl-luat-dum.lua b/otfl-luat-dum.lua index 4c55d37..2b818ce 100644 --- a/otfl-luat-dum.lua +++ b/otfl-luat-dum.lua @@ -23,6 +23,11 @@ trackers = {      enable        = dummyfunction,      disable       = dummyfunction,  } +experiments = { +    register      = dummyfunction, +    enable        = dummyfunction, +    disable       = dummyfunction, +}  storage = {      register      = dummyfunction,      shared        = { }, diff --git a/otfl-node-res.lua b/otfl-node-res.lua index 49a1297..5398d84 100644 --- a/otfl-node-res.lua +++ b/otfl-node-res.lua @@ -16,7 +16,14 @@ for debugging <l n='luatex'/> node management.</p>  nodes = nodes or { } +nodes.whatsits = { } -- table.swapped(node.whatsits()) +  local reserved = { } +local whatsits = nodes.whatsits + +for k, v in pairs(node.whatsits()) do +    whatsits[k], whatsits[v] = v, k -- two way +end  function nodes.register(n)      reserved[#reserved+1] = n @@ -57,13 +64,13 @@ local penalty    = nodes.register(new_node("penalty"))  local glue       = nodes.register(new_node("glue"))  local glue_spec  = nodes.register(new_node("glue_spec"))  local glyph      = nodes.register(new_node("glyph",0)) -local textdir    = nodes.register(new_node("whatsit",7)) +local textdir    = nodes.register(new_node("whatsit",whatsits.dir)) -- 7  local rule       = nodes.register(new_node("rule")) -local latelua    = nodes.register(new_node("whatsit",35)) -local user_n     = nodes.register(new_node("whatsit",44)) user_n.type = 100 -local user_l     = nodes.register(new_node("whatsit",44)) user_l.type = 110 -local user_s     = nodes.register(new_node("whatsit",44)) user_s.type = 115 -local user_t     = nodes.register(new_node("whatsit",44)) user_t.type = 116 +local latelua    = nodes.register(new_node("whatsit",whatsits.late_lua)) -- 35 +local user_n     = nodes.register(new_node("whatsit",whatsits.user_defined)) user_n.type = 100 -- 44 +local user_l     = nodes.register(new_node("whatsit",whatsits.user_defined)) user_l.type = 110 -- 44 +local user_s     = nodes.register(new_node("whatsit",whatsits.user_defined)) user_s.type = 115 -- 44 +local user_t     = nodes.register(new_node("whatsit",whatsits.user_defined)) user_t.type = 116 -- 44  function nodes.glyph(fnt,chr)      local n = copy_node(glyph) | 
