From f9a875c39c19e25a6744db40c39935c880a95cc0 Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Wed, 10 Jun 2009 23:24:34 +0300 Subject: Sync with ConTeXt 2009.06.10 20:06, fixes bug with undefined fonts.register_message function that would crash luatex with certain fonts, pluse more. --- otfl-font-def.lua | 32 ++++++++++++++++++++++++++++---- otfl-font-dum.lua | 3 +++ otfl-font-otf.lua | 3 ++- otfl-font-otn.lua | 2 +- otfl-font-tfm.lua | 6 +----- otfl-node-inj.lua | 17 ++++++++++++----- otfl-node-res.lua | 8 ++++++++ 7 files changed, 55 insertions(+), 16 deletions(-) diff --git a/otfl-font-def.lua b/otfl-font-def.lua index f91575a..eca6311 100644 --- a/otfl-font-def.lua +++ b/otfl-font-def.lua @@ -43,6 +43,8 @@ tfm.internalized = tfm.internalized or { } -- internal tex numbers tfm.readers.sequence = { 'otf', 'ttf', 'afm', 'tfm' } +tfm.auto_afm = true + local readers = tfm.readers local sequence = readers.sequence @@ -334,10 +336,31 @@ local function check_tfm(specification,fullname) end end +--~ local function check_afm(specification,fullname) +--~ fullname = resolvers.findbinfile(fullname, 'afm') or "" -- just to be sure +--~ if fullname ~= "" then +--~ specification.filename, specification.format = fullname, "afm" +--~ return tfm.read_from_afm(specification) +--~ end +--~ end + local function check_afm(specification,fullname) - fullname = resolvers.findbinfile(fullname, 'afm') or "" -- just to be sure - if fullname ~= "" then - specification.filename, specification.format = fullname, "afm" + local foundname = resolvers.findbinfile(fullname, 'afm') or "" -- just to be sure + if foundname == "" and tfm.auto_afm then + local encoding, shortname = match(fullname,"^(.-)%-(.*)$") -- context: encoding-name.* + if encoding and shortname and fonts.enc.known[encoding] then + shortname = resolvers.findbinfile(shortname,'afm') or "" -- just to be sure + if shortname ~= "" then + foundname = shortname + -- tfm.set_normal_feature(specification,'encoding',encoding) -- will go away + if trace_loading then + logs.report("load afm","stripping encoding prefix from filename %s",afmname) + end + end + end + end + if foundname ~= "" then + specification.filename, specification.format = foundname, "afm" return tfm.read_from_afm(specification) end end @@ -529,7 +552,7 @@ function define.read(specification,size,id) -- id can be optional, name can alre if not fontdata then logs.report("define font", "unknown font %s, loading aborted",specification.name) elseif trace_defining and type(fontdata) == "table" then - logs.report("define font","using %s font with id %s, n:%s s:%s b:%s e:%s p:%s f:%s", + logs.report("define font","using %s font with id %s, name:%s size:%s bytes:%s encoding:%s fullname:%s filename:%s", fontdata.type or "unknown", id or "?", fontdata.name or "?", @@ -538,6 +561,7 @@ function define.read(specification,size,id) -- id can be optional, name can alre fontdata.encodingname or "unicode", fontdata.fullname or "?", file.basename(fontdata.filename or "?")) + end statistics.stoptiming(fonts) return fontdata diff --git a/otfl-font-dum.lua b/otfl-font-dum.lua index 0d28128..5ae53d0 100644 --- a/otfl-font-dum.lua +++ b/otfl-font-dum.lua @@ -111,3 +111,6 @@ end fonts.initializers.base.otf.itlc = itlc fonts.initializers.node.otf.itlc = itlc + +function fonts.register_message() +end diff --git a/otfl-font-otf.lua b/otfl-font-otf.lua index 20273f8..00ac596 100644 --- a/otfl-font-otf.lua +++ b/otfl-font-otf.lua @@ -1524,7 +1524,7 @@ function tfm.read_from_open_type(specification) if filename then tfmtable.encodingbytes = 2 tfmtable.filename = resolvers.findbinfile(filename,"") or filename - tfmtable.fullname = otfdata.metadata.fontname or otfdata.metadata.fullname + tfmtable.fullname = tfmtable.fullname or otfdata.metadata.fontname or otfdata.metadata.fullname local order = otfdata and otfdata.metadata.order2 if order == 0 then tfmtable.format = 'opentype' @@ -1537,5 +1537,6 @@ function tfm.read_from_open_type(specification) end fonts.logger.save(tfmtable,file.extname(specification.filename),specification) end +--~ print(tfmtable.fullname) return tfmtable end diff --git a/otfl-font-otn.lua b/otfl-font-otn.lua index d23a8a0..719c0ca 100644 --- a/otfl-font-otn.lua +++ b/otfl-font-otn.lua @@ -1762,7 +1762,7 @@ function otf.setcontextchain(method) logwarning("installing contextchain handler '%s'",method) local handler = otf.chainhandlers[method] handlers.contextchain = function(...) - return handler(currentfont,...) + return handler(currentfont,...) -- hm, get rid of ... end end handlers.gsub_context = handlers.contextchain diff --git a/otfl-font-tfm.lua b/otfl-font-tfm.lua index 9210fee..472f69c 100644 --- a/otfl-font-tfm.lua +++ b/otfl-font-tfm.lua @@ -540,10 +540,6 @@ function tfm.do_scale(tfmtable, scaledpoints) -- 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") ---~ t.fontname = t.fontname or t.fullname ---~ t.name = t.name or t.fontname ---~ print(t.fullname,table.serialize(characters[string.byte('W')].kerns)) return t, delta end @@ -691,7 +687,7 @@ function tfm.enhance(tfmdata,specification) tfmdata.shared = tfmdata.shared or { } tfmdata.shared.features = features -- tfmdata.shared.tfmdata = tfmdata -- circular -tfmdata.filename = specification.name + tfmdata.filename = specification.name if not features.encoding then local name, size = specification.name, specification.size local encoding, filename = match(name,"^(.-)%-(.*)$") -- context: encoding-name.* diff --git a/otfl-node-inj.lua b/otfl-node-inj.lua index 6ba21b3..2e8b5ae 100644 --- a/otfl-node-inj.lua +++ b/otfl-node-inj.lua @@ -168,7 +168,7 @@ end -- todo: reuse tables (i.e. no collection), but will be extra fields anyway -function nodes.inject_kerns(head,tail,keep) +function nodes.inject_kerns(head,tail,where,keep) if trace_injections then nodes.trace_injection(head) end @@ -176,10 +176,10 @@ function nodes.inject_kerns(head,tail,keep) if has_marks or has_cursives then -- in the future variant we will not copy items but refs to tables local done, ky, rl, valid, cx, wx = false, { }, { }, { }, { }, { } - for n in traverse_id(glyph,head) do - if n.subtype < 256 then - valid[#valid+1] = n - if has_kerns then -- move outside loop + if has_kerns then -- move outside loop + for n in traverse_id(glyph,head) do + if n.subtype < 256 then + valid[#valid+1] = n local k = has_attribute(n,kernpair) if k then local kk = kerns[k] @@ -197,6 +197,12 @@ function nodes.inject_kerns(head,tail,keep) end end end + else + for n in traverse_id(glyph,head) do + if n.subtype < 256 then + valid[#valid+1] = n + end + end end if #valid > 0 then -- we can assume done == true because we have cursives and marks @@ -215,6 +221,7 @@ function nodes.inject_kerns(head,tail,keep) n = valid[i] if n.font ~= nf then nf = n.font +--~ print(n.font,nf,fontdata[nf]) tm = fontdata[nf].marks -- maybe flush maxt = 0 diff --git a/otfl-node-res.lua b/otfl-node-res.lua index c8d815b..b84e5b1 100644 --- a/otfl-node-res.lua +++ b/otfl-node-res.lua @@ -59,6 +59,7 @@ 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 rule = nodes.register(new_node("rule")) function nodes.glyph(fnt,chr) local n = copy_node(glyph) @@ -100,6 +101,13 @@ function nodes.textdir(dir) t.dir = dir return t end +function nodes.rule(w,h,d) + local n = copy_node(rule) + if w then n.width = w end + if h then n.height = h end + if d then n.depth = d end + return n +end statistics.register("cleaned up reserved nodes", function() return format("%s nodes, %s lists of %s", nodes.cleanup_reserved(tex.count["lastallocatedbox"])) -- cgit v1.2.3