diff options
| author | Elie Roux <elie.roux@telecom-bretagne.eu> | 2009-04-12 21:17:28 +0200 | 
|---|---|---|
| committer | Elie Roux <elie.roux@telecom-bretagne.eu> | 2009-04-12 21:17:28 +0200 | 
| commit | e86146694fb4159c4ae2ad9969c6c992a19e9c09 (patch) | |
| tree | c85077dc4545f5df461e5e21bcf1c3897c42fbeb | |
| parent | 5a642e00686d0a9354480fea2aced3d1c4fc47a8 (diff) | |
| download | luaotfload-e86146694fb4159c4ae2ad9969c6c992a19e9c09.tar.gz | |
syncronizing with the latest ConTeXt beta, fixing bugs
| -rw-r--r-- | luaotfload.lua | 26 | ||||
| -rw-r--r-- | otfl-font-def.lua | 2 | ||||
| -rw-r--r-- | otfl-font-otc.lua | 4 | ||||
| -rw-r--r-- | otfl-font-tfm.lua | 43 | ||||
| -rw-r--r-- | otfl-luat-dum.lua | 4 | ||||
| -rw-r--r-- | otfl-node-ini.lua | 23 | ||||
| -rw-r--r-- | otfl-node-res.lua | 110 | 
7 files changed, 186 insertions, 26 deletions
| diff --git a/luaotfload.lua b/luaotfload.lua index 24e9530..80e1ae2 100644 --- a/luaotfload.lua +++ b/luaotfload.lua @@ -15,7 +15,7 @@ luatextra.provides_module(luaotfload.module)  function luaotfload.loadmodule(name)      local foundname = kpse.find_file('otfl-'..name,"tex")      if not foundname then -      luatextra.module_error('luaotfload', string.format('file otf-%s not found.', name)) +      luatextra.module_error('luaotfload', string.format('file otfl-%s not found.', name))        return       end      dofile(foundname) @@ -109,7 +109,7 @@ luaotfload.loadmodule('node-dum.lua')  luaotfload.loadmodule('font-ini.lua')  luaotfload.loadmodule('font-tfm.lua') -- will be split (we may need font-log) ---loadmodule('font-ott.lua') -- might be split +--luaotfload.loadmodule('font-ott.lua') -- might be split  luaotfload.loadmodule('font-otf.lua')  luaotfload.loadmodule('font-otb.lua')  luaotfload.loadmodule('font-cid.lua') @@ -128,20 +128,18 @@ luaotfload.loadmodule('font-xtx.lua')  luaotfload.loadmodule('font-dum.lua')  function luaotfload.register_callbacks() -    callback.add('ligaturing',           nodes.simple_font_dummy, 'nodes.simple_font_dummy') -    callback.add('kerning',              nodes.simple_font_dummy, 'nodes.simple_font_dummy') -    callback.add('pre_linebreak_filter', nodes.simple_font_handler, 'nodes.simple_font_handler') -    callback.add('hpack_filter',         nodes.simple_font_handler, 'nodes.simple_font_handler') +    callback.add('ligaturing',           nodes.simple_font_dummy, 'luaotfload.ligaturing') +    callback.add('kerning',              nodes.simple_font_dummy, 'luaotfload.kerning') +    callback.add('pre_linebreak_filter', nodes.simple_font_handler, 'luaotfload.pre_linebreak_filter') +    callback.add('hpack_filter',         nodes.simple_font_handler, 'luaotfload.hpack_filter')      callback.reset('define_font') -    callback.add('define_font' ,         fonts.define.read, 'fonts.define.read', 1) -    callback.add('find_vf_file',         fonts.vf.find, 'fonts.vf.find') +    callback.add('define_font' ,         fonts.define.read, 'luaotfload.define_font', 1)  end  function luaotfload.unregister_callbacks() -    callback.remove('ligaturing', 'nodes.simple_font_dummy') -    callback.remove('kerning', 'nodes.simple_font_dummy') -    callback.remove('pre_linebreak_filter', 'nodes.simple_font_handler') -    callback.remove('hpack_filter', 'nodes.simple_font_handler') -    callback.reset('define_font') -    callback.remove('find_vf_file', 'fonts.vf.find') +    callback.remove('ligaturing', 'luaotfload.ligaturing') +    callback.remove('kerning', 'luaotfload.kerning') +    callback.remove('pre_linebreak_filter', 'luaotfload.pre_linebreak_filter') +    callback.remove('hpack_filter', 'luaotfload.hpack_filter') +    callback.remove('define_font', 'luaotfload.define_font')  end diff --git a/otfl-font-def.lua b/otfl-font-def.lua index a437ef8..f6bcb54 100644 --- a/otfl-font-def.lua +++ b/otfl-font-def.lua @@ -323,7 +323,7 @@ evolved. Each one has its own way of dealing with its format.</p>  local function check_tfm(specification,fullname)      -- ofm directive blocks local path search unless set -    fullname = input.findbinfile(fullname, 'ofm') or "" -- just to be sure +    fullname = input.findbinfile(fullname, 'tfm') or "" -- just to be sure      if fullname ~= "" then          specification.filename, specification.format = fullname, "ofm"          return tfm.read_from_tfm(specification) diff --git a/otfl-font-otc.lua b/otfl-font-otc.lua index 840d4a9..40631fb 100644 --- a/otfl-font-otc.lua +++ b/otfl-font-otc.lua @@ -9,6 +9,8 @@ if not modules then modules = { } end modules ['font-otc'] = {  local format, insert = string.format, table.insert  local type, next = type, next +local ctxcatcodes = tex.ctxcatcodes +  -- we assume that the other otf stuff is loaded already  local trace_loading = false  trackers.register("otf.loading", function(v) trace_loading = v end) @@ -122,6 +124,6 @@ function otf.char(n) -- todo: afm en tfm          n = otf.name_to_slot(n)      end      if n then -        tex.sprint(tex.ctxcatcodes,format("\\char%s ",n)) +        tex.sprint(ctxcatcodes,format("\\char%s ",n))      end  end diff --git a/otfl-font-tfm.lua b/otfl-font-tfm.lua index 9d5a774..1d81602 100644 --- a/otfl-font-tfm.lua +++ b/otfl-font-tfm.lua @@ -290,6 +290,7 @@ function tfm.do_scale(tfmtable, scaledpoints)      local scaledwidth  = defaultwidth  * delta      local scaledheight = defaultheight * delta      local scaleddepth  = defaultdepth  * delta +    local stackmath = tfmtable.ignore_stack_math ~= true      for k,v in next, characters do          local chr, description, index          if ischanged then @@ -376,8 +377,10 @@ function tfm.do_scale(tfmtable, scaledpoints)          if vi then              chr.italic = vi*delta          end -        -- note needed if no math: todo: hasmath ---~ if hasmath then +        -- to be tested +if hasmath then + +        -- todo, just operate on descriptions.math          local vn = v.next          if vn then              chr.next = vn @@ -418,7 +421,34 @@ function tfm.do_scale(tfmtable, scaledpoints)          if vt then              chr.top_accent = delta*vt          end ---~ end +        if stackmath then +            local mk = v.mathkerns +            if mk then +                local kerns = { } +             -- for k, v in next, mk do +             --     local kk = { } +              --     for i=1,#v do +             --         local vi = v[i] +             --         kk[i] = { height = delta*vi.height, kern = delta*vi.kern } +             --     end +             --     kerns[k] = kk +             -- end +                local v = mk.top_right    if v then local k = { } for i=1,#v do local vi = v[i] +                    k[i] = { height = delta*vi.height, kern = delta*vi.kern } +                end     kerns.top_right    = k end +                local v = mk.top_left     if v then local k = { } for i=1,#v do local vi = v[i] +                    k[i] = { height = delta*vi.height, kern = delta*vi.kern } +                end     kerns.top_left     = k end +                local v = mk.bottom_left  if v then local k = { } for i=1,#v do local vi = v[i] +                    k[i] = { height = delta*vi.height, kern = delta*vi.kern } +                end     kerns.bottom_left  = k end +                local v = mk.bottom_right if v then local k = { } for i=1,#v do local vi = v[i] +                    k[i] = { height = delta*vi.height, kern = delta*vi.kern } +                end     kerns.bottom_right = k end +                chr.mathkern = kerns -- singular +            end +        end +end          if not nodemode then              local vk = v.kerns              if vk then @@ -502,8 +532,11 @@ function tfm.do_scale(tfmtable, scaledpoints)      if not tp[17] then tp[17] = .48*tpx end  -- mathsubcombined      if not tp[22] then tp[22] =   0     end  -- mathaxisheight      if t.MathConstants then t.MathConstants.AccentBaseHeight = nil end -- safeguard ---~ print(t.fullname,table.serialize(t.MathConstants),t.parameters.x_height) -t.tounicode = 1 +    t.tounicode = 1 +    -- we have t.name=metricfile and t.fullname=RealName and t.filename=diskfilename +    -- when collapsing fonts, luatex looks as both t.name and t.fullname as ttc files +    -- can have multiple subfonts +--~ collectgarbage("collect")      return t, delta  end diff --git a/otfl-luat-dum.lua b/otfl-luat-dum.lua index 7b959ca..5c53115 100644 --- a/otfl-luat-dum.lua +++ b/otfl-luat-dum.lua @@ -52,7 +52,7 @@ end  function input.findbinfile(name,kind)      if not kind or kind == "" then -        kind = string.match(name,"%.(.-)$") +        kind = file.extname(name) -- string.match(name,"%.([^%.]-)$")      end -    return input.find_file(name,kind and remapper[kind]) +    return input.find_file(name,(kind and remapper[kind]) or kind)  end diff --git a/otfl-node-ini.lua b/otfl-node-ini.lua index 563260d..aeeb689 100644 --- a/otfl-node-ini.lua +++ b/otfl-node-ini.lua @@ -31,9 +31,9 @@ attributes.numbers    = attributes.numbers or { }  attributes.list       = attributes.list    or { }  attributes.unsetvalue = -0x7FFFFFFF -storage.register(false, "attributes/names",   attributes.names,   "attributes.names") -storage.register(false, "attributes/numbers", attributes.numbers, "attributes.numbers") -storage.register(false, "attributes/list",    attributes.list,    "attributes.list") +storage.register("attributes/names",   attributes.names,   "attributes.names") +storage.register("attributes/numbers", attributes.numbers, "attributes.numbers") +storage.register("attributes/list",    attributes.list,    "attributes.list")  local names, numbers, list = attributes.names, attributes.numbers, attributes.list @@ -171,6 +171,23 @@ function nodes.after(h,c,n)      return n, n  end +function nodes.replace(head,current,new) +    if current and next then +        local p, n = current.prev, current.next +        new.prev, new.next = p, n +        if p then +            p.next = new +        else +            head = new +        end +        if n then +            n.prev = new +        end +        free_node(current) +    end +    return head, current +end +  -- will move  local function count(stack,flat) diff --git a/otfl-node-res.lua b/otfl-node-res.lua new file mode 100644 index 0000000..c8d815b --- /dev/null +++ b/otfl-node-res.lua @@ -0,0 +1,110 @@ +if not modules then modules = { } end modules ['node-res'] = { +    version   = 1.001, +    comment   = "companion to node-ini.tex", +    author    = "Hans Hagen, PRAGMA-ADE, Hasselt NL", +    copyright = "PRAGMA ADE / ConTeXt Development Team", +    license   = "see context related readme files" +} + +local gmatch, format = string.gmatch, string.format +local copy_node, free_node, new_node = node.copy, node.free, node.new + +--[[ldx-- +<p>The next function is not that much needed but in <l n='context'/> we use +for debugging <l n='luatex'/> node management.</p> +--ldx]]-- + +nodes = nodes or { } + +local reserved = { } + +function nodes.register(n) +    reserved[#reserved+1] = n +    return n +end + +function nodes.cleanup_reserved(nofboxes) -- todo +    nodes.tracers.steppers.reset() -- todo: make a registration subsystem +    local nr, nl = #reserved, 0 +    for i=1,nr do +        free_node(reserved[i]) +    end +    if nofboxes then +        local tb = tex.box +        for i=0,nofboxes do +            local l = tb[i] +            if l then +                free_node(tb[i]) +                nl = nl + 1 +            end +        end +    end +    reserved = { } +    return nr, nl, nofboxes -- can be nil +end + +function nodes.usage() +    local t = { } +    for n, tag in gmatch(status.node_mem_usage,"(%d+) ([a-z_]+)") do +        t[tag] = n +    end +    return t +end + +local pdfliteral = nodes.register(new_node("whatsit",8))   pdfliteral.mode = 1 +local disc       = nodes.register(new_node("disc")) +local kern       = nodes.register(new_node("kern",1)) +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)) + +function nodes.glyph(fnt,chr) +    local n = copy_node(glyph) +    if fnt then n.font = fnt end +    if chr then n.char = chr end +    return n +end +function nodes.penalty(p) +    local n = copy_node(penalty) +    n.penalty = p +    return n +end +function nodes.kern(k) +    local n = copy_node(kern) +    n.kern = k +    return n +end +function nodes.glue(width,stretch,shrink) +    local n, s = copy_node(glue), copy_node(glue_spec) +    s.width, s.stretch, s.shrink = width, stretch, shrink +    n.spec = s +    return n +end +function nodes.glue_spec(width,stretch,shrink) +    local s = copy_node(glue_spec) +    s.width, s.stretch, s.shrink = width, stretch, shrink +    return s +end +function nodes.disc() +    return copy_node(disc) +end +function nodes.pdfliteral(str) +    local t = copy_node(pdfliteral) +    t.data = str +    return t +end +function nodes.textdir(dir) +    local t = copy_node(textdir) +    t.dir = dir +    return t +end + +statistics.register("cleaned up reserved nodes", function() +    return format("%s nodes, %s lists of %s", nodes.cleanup_reserved(tex.count["lastallocatedbox"])) +end) -- \topofboxstack + +statistics.register("node memory usage", function() -- comes after cleanup ! +    return status.node_mem_usage +end) | 
