From 90491494c53879d563f695cafdb68c6aea2c2c16 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sun, 29 Nov 2009 00:33:48 +0000 Subject: luaotfload update (28nov09) git-svn-id: svn://tug.org/texlive/trunk@16232 c570f23f-e606-0410-a88d-b1316a301751 --- .../tex/luatex/luaotfload/luaotfload.lua | 2 +- .../tex/luatex/luaotfload/luaotfload.sty | 2 +- .../tex/luatex/luaotfload/otfl-data-con.lua | 4 +- .../tex/luatex/luaotfload/otfl-font-cid.lua | 9 +- .../tex/luatex/luaotfload/otfl-font-def.lua | 128 +++++++--- .../tex/luatex/luaotfload/otfl-font-dum.lua | 31 +-- .../tex/luatex/luaotfload/otfl-font-ini.lua | 24 +- .../tex/luatex/luaotfload/otfl-font-map.lua | 13 +- .../tex/luatex/luaotfload/otfl-font-ota.lua | 3 +- .../tex/luatex/luaotfload/otfl-font-otb.lua | 8 +- .../tex/luatex/luaotfload/otfl-font-otc.lua | 4 +- .../tex/luatex/luaotfload/otfl-font-otd.lua | 2 +- .../tex/luatex/luaotfload/otfl-font-otf.lua | 72 ++++-- .../tex/luatex/luaotfload/otfl-font-oti.lua | 2 +- .../tex/luatex/luaotfload/otfl-font-otn.lua | 279 ++++++++++++++------- .../tex/luatex/luaotfload/otfl-font-ott.lua | 3 +- .../tex/luatex/luaotfload/otfl-font-tfm.lua | 49 ++-- .../tex/luatex/luaotfload/otfl-font-xtx.lua | 2 +- .../tex/luatex/luaotfload/otfl-luat-dum.lua | 14 +- .../tex/luatex/luaotfload/otfl-node-fnt.lua | 3 +- .../tex/luatex/luaotfload/otfl-node-ini.lua | 2 +- .../tex/luatex/luaotfload/otfl-node-inj.lua | 132 ++++++---- .../tex/luatex/luaotfload/otfl-node-res.lua | 45 +++- 23 files changed, 588 insertions(+), 245 deletions(-) (limited to 'Master/texmf-dist/tex/luatex') diff --git a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload.lua b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload.lua index 4aeb50b8fd3..674dd1799e5 100644 --- a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload.lua +++ b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload.lua @@ -20,7 +20,7 @@ luaotfload = { } luaotfload.module = { name = "luaotfload", version = 1.04, - date = "2009/09/22", + date = "2009/11/15", description = "ConTeXt font loading system.", author = "Elie Roux & Hans Hagen", copyright = "Elie Roux", diff --git a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload.sty b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload.sty index e39288fdc67..c1b749459cd 100644 --- a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload.sty +++ b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload.sty @@ -23,7 +23,7 @@ \else \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{luaotfload}% - [2009/09/22 v1.04 ConTeXt font loading system] + [2009/11/15 v1.05 ConTeXt font loading system] \RequirePackage{luatextra} \fi diff --git a/Master/texmf-dist/tex/luatex/luaotfload/otfl-data-con.lua b/Master/texmf-dist/tex/luatex/luaotfload/otfl-data-con.lua index 02ee9eeddd9..f06dba5b5e5 100644 --- a/Master/texmf-dist/tex/luatex/luaotfload/otfl-data-con.lua +++ b/Master/texmf-dist/tex/luatex/luaotfload/otfl-data-con.lua @@ -1,6 +1,6 @@ if not modules then modules = { } end modules ['data-con'] = { version = 1.001, - comment = "companion to luat-lib.tex", + comment = "companion to luat-lib.mkiv", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright = "PRAGMA ADE / ConTeXt Development Team", license = "see context related readme files" @@ -11,8 +11,6 @@ local format, lower, gsub = string.format, string.lower, string.gsub local trace_cache = false trackers.register("resolvers.cache", function(v) trace_cache = v end) local trace_containers = false trackers.register("resolvers.containers", function(v) trace_containers = v end) local trace_storage = false trackers.register("resolvers.storage", function(v) trace_storage = v end) -local trace_verbose = false trackers.register("resolvers.verbose", function(v) trace_verbose = v end) -local trace_locating = false trackers.register("resolvers.locating", function(v) trace_locating = v trackers.enable("resolvers.verbose") end) --[[ldx--

Once we found ourselves defining similar cache constructs diff --git a/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-cid.lua b/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-cid.lua index 13e9cce8949..7165288cfa1 100644 --- a/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-cid.lua +++ b/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-cid.lua @@ -6,7 +6,7 @@ if not modules then modules = { } end modules ['font-cid'] = { license = "see context related readme files" } -local format, match = string.format, string.match +local format, match, lower = string.format, string.match, string.lower local tonumber = tonumber local trace_loading = false trackers.register("otf.loading", function(v) trace_loading = v end) @@ -79,8 +79,9 @@ end local template = "%s-%s-%s.cidmap" local function locate(registry,ordering,supplement) - local filename = string.lower(format(template,registry,ordering,supplement)) - local cidmap = fonts.cid.map[filename] + local filename = format(template,registry,ordering,supplement) + local hashname = lower(filename) + local cidmap = fonts.cid.map[hasnname] if not cidmap then if trace_loading then logs.report("load otf","checking cidmap, registry: %s, ordering: %s, supplement: %s, filename: %s",registry,ordering,supplement,filename) @@ -92,7 +93,7 @@ local function locate(registry,ordering,supplement) if trace_loading then logs.report("load otf","using cidmap file %s",filename) end - fonts.cid.map[filename] = cidmap + fonts.cid.map[hashname] = cidmap cidmap.usedname = file.basename(filename) return cidmap end diff --git a/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-def.lua b/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-def.lua index 3301c39f2ce..65c74d48fd2 100644 --- a/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-def.lua +++ b/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-def.lua @@ -1,6 +1,6 @@ if not modules then modules = { } end modules ['font-def'] = { version = 1.001, - comment = "companion to font-ini.tex", + comment = "companion to font-ini.mkiv", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright = "PRAGMA ADE / ConTeXt Development Team", license = "see context related readme files" @@ -9,7 +9,8 @@ if not modules then modules = { } end modules ['font-def'] = { local format, concat, gmatch, match, find, lower = string.format, table.concat, string.gmatch, string.match, string.find, string.lower local tostring, next = tostring, next -local trace_defining = false trackers.register("fonts.defining", function(v) trace_defining = v end) +local trace_defining = false trackers .register("fonts.defining", function(v) trace_defining = v end) +local directive_embedall = false directives.register("fonts.embedall", function(v) directive_embedall = v end) trackers.register("fonts.loading", "fonts.defining", "otf.loading", "afm.loading", "tfm.loading") trackers.register("fonts.all", "fonts.*", "otf.*", "afm.*", "tfm.*") @@ -77,20 +78,35 @@ and prepares a table that will move along as we proceed.

local splitter, specifiers = nil, "" +local P, C, S, Cc = lpeg.P, lpeg.C, lpeg.S, lpeg.Cc + +local left = P("(") +local right = P(")") +local colon = P(":") +local space = P(" ") + +define.defaultlookup = "file" + +local prefixpattern = P(false) + function define.add_specifier(symbol) specifiers = specifiers .. symbol - local left = lpeg.P("(") - local right = lpeg.P(")") - local colon = lpeg.P(":") - local method = lpeg.S(specifiers) - local lookup = lpeg.C(lpeg.P("file")+lpeg.P("name")) * colon -- hard test, else problems with : method - local sub = left * lpeg.C(lpeg.P(1-left-right-method)^1) * right ---~ local specification = lpeg.C(method) * lpeg.C(lpeg.P(1-method)^1) - local specification = lpeg.C(method) * lpeg.C(lpeg.P(1)^1) - local name = lpeg.C((1-sub-specification)^1) - splitter = lpeg.P((lookup + lpeg.Cc("")) * name * (sub + lpeg.Cc("")) * (specification + lpeg.Cc(""))) + local method = S(specifiers) + local lookup = C(prefixpattern) * colon + local sub = left * C(P(1-left-right-method)^1) * right + local specification = C(method) * C(P(1)^1) + local name = C((1-sub-specification)^1) + splitter = P((lookup + Cc("")) * name * (sub + Cc("")) * (specification + Cc(""))) +end + +function define.add_lookup(str,default) + prefixpattern = prefixpattern + P(str) end +define.add_lookup("file") +define.add_lookup("name") +define.add_lookup("spec") + function define.get_specification(str) return splitter:match(str) end @@ -111,8 +127,8 @@ function define.makespecification(specification, lookup, name, sub, method, deta --~ lookup = specification.lookup -- can come from xetex [] syntax --~ specification.lookup = nil --~ end - if lookup ~= 'name' then -- for the moment only two lookups, maybe some day also system: - lookup = 'file' + if not lookup or lookup == "" then + lookup = define.defaultlookup end local t = { lookup = lookup, -- forced type @@ -132,7 +148,7 @@ end function define.analyze(specification, size) -- can be optimized with locals local lookup, name, sub, method, detail = define.get_specification(specification or "") - return define.makespecification(specification,lookup, name, sub, method, detail, size) + return define.makespecification(specification, lookup, name, sub, method, detail, size) end --[[ldx-- @@ -214,17 +230,44 @@ end

We can resolve the filename using the next function:

--ldx]]-- +define.resolvers = resolvers + +function define.resolvers.file(specification) + specification.forced = file.extname(specification.name) + specification.name = file.removesuffix(specification.name) +end + +function define.resolvers.name(specification) + local resolve = fonts.names.resolve + if resolve then + specification.resolved, specification.sub = fonts.names.resolve(specification.name,specification.sub) + if specification.resolved then + specification.forced = file.extname(specification.resolved) + specification.name = file.removesuffix(specification.resolved) + end + else + define.resolvers.file(specification) + end +end + +function define.resolvers.spec(specification) + local resolvespec = fonts.names.resolvespec + if resolvespec then + specification.resolved, specification.sub = fonts.names.resolvespec(specification.name,specification.sub) + if specification.resolved then + specification.forced = file.extname(specification.resolved) + specification.name = file.removesuffix(specification.resolved) + end + else + define.resolvers.name(specification) + end +end + function define.resolve(specification) if not specification.resolved or specification.resolved == "" then -- resolved itself not per se in mapping hash - if specification.lookup == 'name' then - specification.resolved, specification.sub = fonts.names.resolve(specification.name,specification.sub) - if specification.resolved then - specification.forced = file.extname(specification.resolved) - specification.name = file.removesuffix(specification.resolved) - end - elseif specification.lookup == 'file' then - specification.forced = file.extname(specification.name) - specification.name = file.removesuffix(specification.name) + local r = define.resolvers[specification.lookup] + if r then + r(specification) end end if specification.forced == "" then @@ -232,7 +275,6 @@ function define.resolve(specification) else specification.forced = specification.forced end ---~ specification.hash = specification.name .. ' @ ' .. tfm.hash_features(specification) specification.hash = lower(specification.name .. ' @ ' .. tfm.hash_features(specification)) if specification.sub and specification.sub ~= "" then specification.hash = specification.sub .. ' @ ' .. specification.hash @@ -271,15 +313,21 @@ function tfm.read(specification) local reader = sequence[s] if readers[reader] then -- not really needed if trace_defining then - logs.report("define font","trying type %s for %s with file %s",reader,specification.name,specification.filename or "unknown") + logs.report("define font","trying (sequence driven) type %s for %s with file %s",reader,specification.name,specification.filename or "unknown") end tfmtable = readers[reader](specification) - if tfmtable then break end + if tfmtable then + break + else + specification.filename = nil + end end end end if tfmtable then - if tfmtable.filename and fonts.dontembed[tfmtable.filename] then + if directive_embedall then + tfmtable.embedding = "full" + elseif tfmtable.filename and fonts.dontembed[tfmtable.filename] then tfmtable.embedding = "no" else tfmtable.embedding = "subset" @@ -402,16 +450,22 @@ function readers.afm(specification,method) return tfmtable end -local function check_otf(specification,suffix,what) - local fullname, tfmtable = resolvers.findbinfile(specification.name,suffix) or "", nil +-- maybe some day a set of names + +local function check_otf(forced,specification,suffix,what) + local name = specification.name + if forced then + name = file.addsuffix(name,suffix) + end + local fullname, tfmtable = resolvers.findbinfile(name,suffix) or "", nil -- one shot if fullname == "" then - local fb = fonts.names.old_to_new[specification.name] + local fb = fonts.names.old_to_new[name] if fb then fullname = resolvers.findbinfile(fb,suffix) or "" end end if fullname == "" then - local fb = fonts.names.new_to_old[specification.name] + local fb = fonts.names.new_to_old[name] if fb then fullname = resolvers.findbinfile(fb,suffix) or "" end @@ -426,13 +480,11 @@ end function readers.opentype(specification,suffix,what) local forced = specification.forced or "" if forced == "otf" then - return check_otf(specification,forced,"opentype") - elseif forced == "ttf" then - return check_otf(specification,forced,"truetype") - elseif forced == "ttf" then - return check_otf(specification,forced,"truetype") + return check_otf(true,specification,forced,"opentype") + elseif forced == "ttf" or forced == "ttc" or forced == "dfont" then + return check_otf(true,specification,forced,"truetype") else - return check_otf(specification,suffix,what) + return check_otf(false,specification,suffix,what) end end diff --git a/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-dum.lua b/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-dum.lua index ef267a42c14..e13f8a25536 100644 --- a/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-dum.lua +++ b/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-dum.lua @@ -39,9 +39,15 @@ function fonts.logger.save() end -- names +-- +-- Watch out, the version number is the same as the one used in +-- the mtx-fonts.lua function scripts.fonts.names as we use a +-- simplified font database in the plain solution and by using +-- a different number we're less dependent on context. fonts.names = fonts.names or { } +fonts.names.version = 1.001 -- not the same as in context fonts.names.basename = "luatex-fonts-names.lua" fonts.names.new_to_old = { } fonts.names.old_to_new = { } @@ -56,35 +62,30 @@ function fonts.names.resolve(name,sub) local foundname = resolvers.find_file(basename,format) or "" if foundname ~= "" then data = dofile(foundname) - if data then - local d = { } - for k, v in pairs(data.mapping) do - local t = v[1] - if t == "ttf" or t == "otf" or t == "ttc" or t == "dfont" then - d[k] = v - end - end - data.mapping = d - end break end end end loaded = true end - if type(data) == "table" and data.version == 1.08 then + if type(data) == "table" and data.version == fonts.names.version then local condensed = string.gsub(string.lower(name),"[^%a%d]","") - local found = data.mapping and data.mapping[condensed] + local found = data.mappings and data.mappings[condensed] if found then - local filename, is_sub = found[3], found[4] - if is_sub then is_sub = found[2] end - return filename, is_sub + local fontname, filename, subfont = found[1], found[2], found[3] + if subfont then + return filename, fontname + else + return filename, false + end else return name, false -- fallback to filename end end end +fonts.names.resolvespec = fonts.names.resolve -- only supported in mkiv + -- For the moment we put this (adapted) pseudo feature here. table.insert(fonts.triggers,"itlc") diff --git a/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-ini.lua b/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-ini.lua index 4005726a59a..5cff22760cc 100644 --- a/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-ini.lua +++ b/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-ini.lua @@ -1,6 +1,6 @@ if not modules then modules = { } end modules ['font-ini'] = { version = 1.001, - comment = "companion to font-ini.tex", + comment = "companion to font-ini.mkiv", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright = "PRAGMA ADE / ConTeXt Development Team", license = "see context related readme files" @@ -11,6 +11,8 @@ if not modules then modules = { } end modules ['font-ini'] = { --ldx]]-- local utf = unicode.utf8 +local format, serialize = string.format, table.serialize +local write_nl = texio.write_nl if not fontloader then fontloader = fontforge end @@ -30,6 +32,7 @@ fonts.verbose = false -- more verbose cache tables fonts.ids[0] = { -- nullfont characters = { }, descriptions = { }, + name = "nullfont", } fonts.methods = fonts.methods or { @@ -91,7 +94,24 @@ function fonts.show_char_data(n) end local chr = tfmdata.characters[n] if chr then - texio.write_nl(table.serialize(chr,string.format("U_%04X",n))) + write_nl(format("%s @ %s => U%04X => %s => ",tfmdata.fullname,tfmdata.size,n,utf.char(n)) .. serialize(chr,false)) + end + end +end + +function fonts.show_font_parameters() + local tfmdata = fonts.ids[font.current()] + if tfmdata then + local parameters, mathconstants = tfmdata.parameters, tfmdata.MathConstants + local hasparameters, hasmathconstants = parameters and next(parameters), mathconstants and next(mathconstants) + if hasparameters then + write_nl(format("%s @ %s => parameters => ",tfmdata.fullname,tfmdata.size) .. serialize(parameters,false)) + end + if hasmathconstants then + write_nl(format("%s @ %s => math constants => ",tfmdata.fullname,tfmdata.size) .. serialize(mathconstants,false)) + end + if not hasparameters and not hasmathconstants then + write_nl(format("%s @ %s => no parameters and/or mathconstants",tfmdata.fullname,tfmdata.size)) end end end diff --git a/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-map.lua b/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-map.lua index c597d48552b..0dc4eca5b86 100644 --- a/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-map.lua +++ b/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-map.lua @@ -1,6 +1,6 @@ if not modules then modules = { } end modules ['font-map'] = { version = 1.001, - comment = "companion to font-ini.tex", + comment = "companion to font-ini.mkiv", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright = "PRAGMA ADE / ConTeXt Development Team", license = "see context related readme files" @@ -10,7 +10,7 @@ local match, format, find, concat = string.match, string.format, string.find, ta local trace_loading = false trackers.register("otf.loading", function(v) trace_loading = v end) -local ctxcatcodes = tex.ctxcatcodes +local ctxcatcodes = tex and tex.ctxcatcodes --[[ldx--

Eventually this code will disappear because map files are kind @@ -141,13 +141,15 @@ end local hex = lpeg.R("AF","09") local hexfour = (hex*hex*hex*hex) / function(s) return tonumber(s,16) end -local dec = (lpeg.R("09")^1) / tonumber +local hexsix = (hex^1) / function(s) return tonumber(s,16) end +local dec = (lpeg.R("09")^1) / tonumber local period = lpeg.P(".") local unicode = lpeg.P("uni") * (hexfour * (period + lpeg.P(-1)) * lpeg.Cc(false) + lpeg.Ct(hexfour^1) * lpeg.Cc(true)) +local ucode = lpeg.P("u") * (hexsix * (period + lpeg.P(-1)) * lpeg.Cc(false) + lpeg.Ct(hexsix ^1) * lpeg.Cc(true)) local index = lpeg.P("index") * dec * lpeg.Cc(false) -local parser = unicode + index +local parser = unicode + ucode + index local parsers = { } @@ -165,10 +167,13 @@ function fonts.map.make_name_parser(str) end --~ local parser = fonts.map.make_name_parser("Japan1") +--~ local parser = fonts.map.make_name_parser() --~ local function test(str) --~ local b, a = parser:match(str) --~ print((a and table.serialize(b)) or b) --~ end +--~ test("a.sc") +--~ test("a") --~ test("uni1234") --~ test("uni1234.xx") --~ test("uni12349876") diff --git a/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-ota.lua b/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-ota.lua index 72e7414c8af..e2fa3f290da 100644 --- a/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-ota.lua +++ b/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-ota.lua @@ -131,7 +131,8 @@ local isol_fina = { [0x06D3] = true, [0x06D5] = true, [0x06EE] = true, [0x06EF] = true, [0x0759] = true, [0x075A] = true, [0x075B] = true, [0x076B] = true, [0x076C] = true, [0x0771] = true, [0x0773] = true, [0x0774] = true, - [0x0778] = true, [0x0779] = true, + [0x0778] = true, [0x0779] = true, [0xFEF5] = true, [0xFEF7] = true, + [0xFEF9] = true, [0xFEFB] = true, } local isol_fina_medi_init = { diff --git a/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-otb.lua b/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-otb.lua index 5ef44a0110a..127d4c21896 100644 --- a/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-otb.lua +++ b/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-otb.lua @@ -1,6 +1,6 @@ if not modules then modules = { } end modules ['font-otb'] = { version = 1.001, - comment = "companion to font-ini.tex", + comment = "companion to font-ini.mkiv", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright = "PRAGMA ADE / ConTeXt Development Team", license = "see context related readme files" @@ -309,7 +309,7 @@ local supported_gsub = { 'zero', 'smcp','cpsp','c2sc','ornm','aalt', 'hwid','fwid', - 'ssty', -- math + 'ssty', 'rtlm', -- math } local supported_gpos = { @@ -361,8 +361,8 @@ function fonts.initializers.base.otf.features(tfmdata,value) -- eventually (and subset later on). If needed we can use a more -- verbose name as long as we don't use <()<>[]{}/%> and the length -- is < 128. - tfmdata.fullname = tfmdata.fullname .. "-" .. base ---~ logs.report("otf define","fullname base hash: '%s', featureset '%s'",tfmdata.fullname,hash) + tfmdata.fullname = tfmdata.fullname .. "-" .. base -- tfmdata.psname is the original + --~ logs.report("otf define","fullname base hash: '%s', featureset '%s'",tfmdata.fullname,hash) end if trace_preparing then logs.report("otf define","preparation time is %0.3f seconds for %s",os.clock()-t,tfmdata.fullname or "?") diff --git a/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-otc.lua b/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-otc.lua index f75da39cdab..1fc1f228930 100644 --- a/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-otc.lua +++ b/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-otc.lua @@ -219,7 +219,9 @@ function otf.name_to_slot(name) -- todo: afm en tfm if tfmdata and tfmdata.shared then local otfdata = tfmdata.shared.otfdata local unicode = otfdata.luatex.unicodes[name] - if type(unicode) == "number" then + if not unicode then + return string.byte("?") -- nil + elseif type(unicode) == "number" then return unicode else return unicode[1] diff --git a/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-otd.lua b/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-otd.lua index 78a82814654..41e8853316c 100644 --- a/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-otd.lua +++ b/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-otd.lua @@ -1,6 +1,6 @@ if not modules then modules = { } end modules ['font-otd'] = { version = 1.001, - comment = "companion to font-ini.tex", + comment = "companion to font-ini.mkiv", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright = "PRAGMA ADE / ConTeXt Development Team", license = "see context related readme files" diff --git a/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-otf.lua b/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-otf.lua index f3b3f5481eb..6900b844591 100644 --- a/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-otf.lua +++ b/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-otf.lua @@ -1,6 +1,6 @@ if not modules then modules = { } end modules ['font-otf'] = { version = 1.001, - comment = "companion to font-ini.tex", + comment = "companion to font-ini.mkiv", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright = "PRAGMA ADE / ConTeXt Development Team", license = "see context related readme files" @@ -19,6 +19,7 @@ local trace_dynamics = false trackers.register("otf.dynamics", function(v local trace_sequences = false trackers.register("otf.sequences", function(v) trace_sequences = v end) local trace_math = false trackers.register("otf.math", function(v) trace_math = v end) local trace_unimapping = false trackers.register("otf.unimapping", function(v) trace_unimapping = v end) +local trace_defining = false trackers.register("fonts.defining", function(v) trace_defining = v end) --~ trackers.enable("otf.loading") @@ -82,7 +83,7 @@ otf.features.default = otf.features.default or { } otf.enhancers = otf.enhancers or { } otf.glists = { "gsub", "gpos" } -otf.version = 2.628 -- beware: also sync font-mis.lua +otf.version = 2.636 -- beware: also sync font-mis.lua otf.pack = true -- beware: also sync font-mis.lua otf.syncspace = true otf.notdef = false @@ -104,6 +105,7 @@ otf.tables.global_fields = table.tohash { "names", "unicodes", "names", +--~ "math", "anchor_classes", "kern_classes", "gpos", @@ -202,6 +204,7 @@ local enhancers = { "patch bugs", "merge cid fonts", "prepare unicode", "cleanup ttf tables", "compact glyphs", "reverse coverage", "cleanup aat", "enrich with features", "add some missing characters", + "reorganize mark classes", "reorganize kerns", -- moved here "flatten glyph lookups", "flatten anchor tables", "flatten feature tables", "prepare luatex tables", @@ -227,7 +230,7 @@ function otf.load(filename,format,sub,featurefile) local data = containers.read(otf.cache(), hash) local size = lfs.attributes(filename,"size") or 0 if not data or data.verbose ~= fonts.verbose or data.size ~= size then - logs.report("load otf","loading: %s",filename) + logs.report("load otf","loading: %s (hash: %s)",filename,hash) local ff, messages if sub then ff, messages = fontloader.open(filename,sub) @@ -267,6 +270,9 @@ function otf.load(filename,format,sub,featurefile) end end if data then + if trace_defining then + logs.report("define font","loading from cache: %s",hash) + end otf.enhance("unpack",data,filename,false) -- no message here otf.add_dimensions(data) if trace_sequences then @@ -354,6 +360,29 @@ end -- todo: normalize, design_size => designsize +otf.enhancers["reorganize mark classes"] = function(data,filename) + if data.mark_classes then + local unicodes = data.luatex.unicodes + local reverse = { } + for name, class in next, data.mark_classes do + local t = { } + for s in gmatch(class,"[^ ]+") do + local us = unicodes[s] + if type(us) == "table" then + for u=1,#us do + t[us[u]] = true + end + else + t[us] = true + end + end + reverse[name] = t + end + data.luatex.markclasses = reverse + data.mark_classes = nil + end +end + otf.enhancers["prepare luatex tables"] = function(data,filename) data.luatex = data.luatex or { } local luatex = data.luatex @@ -500,6 +529,7 @@ otf.enhancers["analyse unicodes"] = function(data,filename) cidcodes = usedmap.unicodes end uparser = fonts.map.make_name_parser() + local aglmap = fonts.map and fonts.map.agl_to_unicode for index, glyph in next, data.glyphs do local name, unic = glyph.name, glyph.unicode or -1 -- play safe if unic == -1 or unic >= private or (unic >= 0xE000 and unic <= 0xF8FF) or unic == 0xFFFE or unic == 0xFFFF then @@ -509,7 +539,7 @@ otf.enhancers["analyse unicodes"] = function(data,filename) end -- cidmap heuristics, beware, there is no guarantee for a match unless -- the chain resolves - if not unicode and usedmap then + if (not unicode) and usedmap then local foundindex = oparser:match(name) if foundindex then unicode = cidcodes[foundindex] -- name to number @@ -544,7 +574,8 @@ otf.enhancers["analyse unicodes"] = function(data,filename) if nplit == 0 then -- skip elseif nplit == 1 then - unicode = unicodes[split[1]] + local base = split[1] + unicode = unicodes[base] or (agl and agl[base]) if unicode then if type(unicode) == "table" then unicode = unicode[1] @@ -552,20 +583,20 @@ otf.enhancers["analyse unicodes"] = function(data,filename) originals[index], tounicode[index], ns = unicode, tounicode16(unicode), ns + 1 end else - local done = true + local t = { } for l=1,nplit do - local u = unicodes[split[l]] + local base = split[l] + local u = unicodes[base] or (agl and agl[base]) if not u then - done = false break elseif type(u) == "table" then - split[l] = u[1] + t[#t+1] = u[1] else - split[l] = u + t[#t+1] = u end end - if done then - originals[index], tounicode[index], nl, unicode = split, tounicode16sequence(split), nl + 1, true + if #t > 0 then -- done then + originals[index], tounicode[index], nl, unicode = t, tounicode16sequence(t), nl + 1, true end end end @@ -658,8 +689,11 @@ otf.enhancers["analyse subtables"] = function(data,filename) (flags.ignorecombiningmarks and "mark") or false, (flags.ignoreligatures and "ligature") or false, (flags.ignorebaseglyphs and "base") or false, - flags.r2l or false + flags.r2l or false, } + if flags.mark_class then + gk.markclass = luatex.markclasses[flags.mark_class] + end end end end @@ -756,7 +790,7 @@ otf.enhancers["prepare unicode"] = function(data,filename) end end end - -- beware: the indeces table is used to initialize the tfm table + -- beware: the indices table is used to initialize the tfm table for unicode, index in next, mapmap do if not internals[index] then local name = glyphs[index].name @@ -1445,6 +1479,7 @@ function otf.copy_to_tfm(data,cache_id) -- we can save a copy when we reorder th end end c.vert_variants = m.vert_parts + c.vert_italic_correction = m.vert_italic_correction end end local kerns = m.kerns @@ -1463,7 +1498,9 @@ function otf.copy_to_tfm(data,cache_id) -- we can save a copy when we reorder th tfm.units = metadata.units_per_em or 1000 -- we need a runtime lookup because of running from cdrom or zip, brrr tfm.filename = resolvers.findbinfile(luatex.filename,"") or luatex.filename - tfm.fullname = metadata.fontname or metadata.fullname + tfm.fullname = metadata.fullname + tfm.fontname = metadata.fontname + tfm.psname = tfm.fontname or tfm.fullname tfm.encodingbytes = 2 tfm.cidinfo = data.cidinfo tfm.cidinfo.registry = tfm.cidinfo.registry or "" @@ -1587,7 +1624,8 @@ function tfm.read_from_open_type(specification) if filename then tfmtable.encodingbytes = 2 tfmtable.filename = resolvers.findbinfile(filename,"") or filename - tfmtable.fullname = tfmtable.fullname or otfdata.metadata.fontname or otfdata.metadata.fullname + tfmtable.fontname = tfmtable.fontname or otfdata.metadata.fontname + tfmtable.fullname = tfmtable.fullname or otfdata.metadata.fullname or tfmtable.fontname local order = otfdata and otfdata.metadata.order2 if order == 0 then tfmtable.format = 'opentype' @@ -1596,7 +1634,7 @@ function tfm.read_from_open_type(specification) else tfmtable.format = specification.format end - tfmtable.name = tfmtable.filename or tfmtable.fullname + tfmtable.name = tfmtable.filename or tfmtable.fullname or tfmtable.fontname end fonts.logger.save(tfmtable,file.extname(specification.filename),specification) end diff --git a/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-oti.lua b/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-oti.lua index cbac6d36a84..4cb27062623 100644 --- a/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-oti.lua +++ b/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-oti.lua @@ -1,6 +1,6 @@ if not modules then modules = { } end modules ['font-oti'] = { version = 1.001, - comment = "companion to font-ini.tex", + comment = "companion to font-ini.mkiv", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright = "PRAGMA ADE / ConTeXt Development Team", license = "see context related readme files" diff --git a/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-otn.lua b/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-otn.lua index 3c11b84f1b4..fb04b367ea0 100644 --- a/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-otn.lua +++ b/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-otn.lua @@ -1,6 +1,6 @@ if not modules then modules = { } end modules ['font-otn'] = { version = 1.001, - comment = "companion to font-ini.tex", + comment = "companion to font-ini.mkiv", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright = "PRAGMA ADE / ConTeXt Development Team", license = "see context related readme files" @@ -10,6 +10,8 @@ if not modules then modules = { } end modules ['font-otn'] = { -- much functionality could only be implemented thanks to the husayni font -- of Idris Samawi Hamid to who we dedicate this module. +-- some day when we can jit this, we can use more functions + -- we can use more lpegs when lpeg is extended with function args and so -- resolving to unicode does not gain much @@ -115,7 +117,7 @@ results in different tables.

-- remark: the 'not implemented yet' variants will be done when we have fonts that use them -- remark: we need to check what to do with discretionaries -local concat = table.concat +local concat, insert, remove = table.concat, table.insert, table.remove local format, gmatch, gsub, find, match, lower, strip = string.format, string.gmatch, string.gsub, string.find, string.match, string.lower, string.strip local type, next, tonumber, tostring = type, next, tonumber, tostring @@ -136,6 +138,8 @@ local trace_bugs = false trackers.register("otf.bugs", function local trace_details = false trackers.register("otf.details", function(v) trace_details = v end) local trace_applied = false trackers.register("otf.applied", function(v) trace_applied = v end) local trace_steps = false trackers.register("otf.steps", function(v) trace_steps = v end) +local trace_skips = false trackers.register("otf.skips", function(v) trace_skips = v end) +local trace_directions = false trackers.register("otf.directions", function(v) trace_directions = v end) trackers.register("otf.verbose_chain", function(v) otf.setcontextchain(v and "verbose") end) trackers.register("otf.normal_chain", function(v) otf.setcontextchain(v and "normal") end) @@ -301,16 +305,29 @@ end local function toligature(kind,lookupname,start,stop,char,markflag,discfound) -- brr head if start ~= stop then +--~ if discfound then +--~ local lignode = copy_node(start) +--~ lignode.font = start.font +--~ lignode.char = char +--~ lignode.subtype = 2 +--~ start = node.do_ligature_n(start, stop, lignode) +--~ if start.id == disc then +--~ local prev = start.prev +--~ start = start.next +--~ end if discfound then + -- print("start->stop",nodes.tosequence(start,stop)) local lignode = copy_node(start) - lignode.font = start.font - lignode.char = char - lignode.subtype = 2 - start = node.do_ligature_n(start, stop, lignode) - if start.id == disc then - local prev = start.prev - start = start.next + lignode.font, lignode.char, lignode.subtype = start.font, char, 2 + local next, prev = stop.next, start.prev + stop.next = nil + lignode = node.do_ligature_n(start, stop, lignode) + prev.next = lignode + if next then + next.prev = lignode end + lignode.next, lignode.prev = next, prev + -- print("start->end",nodes.tosequence(start)) else -- start is the ligature local deletemarks = markflag ~= "mark" local n = copy_node(start) @@ -385,16 +402,19 @@ local function alternative_glyph(start,alternatives,kind,chainname,chainlookupna value, choice = format("first, choice %s",1), alternatives[1] elseif value == "last" then value, choice = format("last, choice %s",n), alternatives[n] - elseif type(value) ~= "number" then - value, choice = "default, choice 1", alternatives[1] - elseif value > n then - value, choice = format("no %s variants, taking %s",value,n), alternatives[n] - elseif value == 0 then - value, choice = format("choice %s (no change)",value), start.char - elseif value < 1 then - value, choice = format("no %s variants, taking %s",value,1), alternatives[1] else - value, choice = format("choice %s",value), alternatives[value] + value = tonumber(value) + if type(value) ~= "number" then + value, choice = "default, choice 1", alternatives[1] + elseif value > n then + value, choice = format("no %s variants, taking %s",value,n), alternatives[n] + elseif value == 0 then + value, choice = format("choice %s (no change)",value), start.char + elseif value < 1 then + value, choice = format("no %s variants, taking %s",value,1), alternatives[1] + else + value, choice = format("choice %s",value), alternatives[value] + end end if not choice then logwarning("%s: no variant %s for %s",cref(kind,chainname,chainlookupname,lookupname),value,gref(start.char)) @@ -724,7 +744,7 @@ function handlers.gpos_cursive(start,kind,lookupname,exitanchors,sequence) -- to if exit then local dx, dy, bound = set_cursive(start,nxt,tfmdata.factor,rlmode,exit,entry,characters[startchar],characters[nextchar]) if trace_cursive then - logprocess("%s: moving %s to %s cursive (%s,%s) using anchor %s and bound %s",pref(kind,lookupname),gref(startchar),gref(nextchar),dx,dy,anchor,bound) + logprocess("%s: moving %s to %s cursive (%s,%s) using anchor %s and bound %s in rlmode %s",pref(kind,lookupname),gref(startchar),gref(nextchar),dx,dy,anchor,bound,rlmode) end done = true break @@ -752,9 +772,9 @@ end function handlers.gpos_single(start,kind,lookupname,kerns,sequence) local startchar = start.char - local dx, dy = set_pair(start,tfmdata.factor,rlmode,kerns,characters[startchar]) + local dx, dy, w, h = set_pair(start,tfmdata.factor,rlmode,sequence.flags[4],kerns,characters[startchar]) if trace_kerns then - logprocess("%s: shifting single %s by (%s,%s)",pref(kind,lookupname),gref(startchar),dx,dy) + logprocess("%s: shifting single %s by (%s,%s) and correction (%s,%s)",pref(kind,lookupname),gref(startchar),dx,dy,w,h) end return start, false end @@ -783,14 +803,14 @@ local krn = kerns[nextchar] local a, b = krn[3], krn[4] if a and #a > 0 then local startchar = start.char - local x, y, w, h = set_pair(start,factor,rlmode,a,characters[startchar]) + local x, y, w, h = set_pair(start,factor,rlmode,sequence.flags[4],a,characters[startchar]) if trace_kerns then logprocess("%s: shifting first of pair %s and %s by (%s,%s) and correction (%s,%s)",pref(kind,lookupname),gref(startchar),gref(nextchar),x,y,w,h) end end if b and #b > 0 then local startchar = start.char - local x, y, w, h = set_pair(snext,factor,rlmode,b,characters[nextchar]) + local x, y, w, h = set_pair(snext,factor,rlmode,sequence.flags[4],b,characters[nextchar]) if trace_kerns then logprocess("%s: shifting second of pair %s and %s by (%s,%s) and correction (%s,%s)",pref(kind,lookupname),gref(startchar),gref(nextchar),x,y,w,h) end @@ -1376,7 +1396,7 @@ function chainprocs.gpos_cursive(start,stop,kind,chainname,currentcontext,cache, if exit then local dx, dy, bound = set_cursive(start,nxt,tfmdata.factor,rlmode,exit,entry,characters[startchar],characters[nextchar]) if trace_cursive then - logprocess("%s: moving %s to %s cursive (%s,%s) using anchor %s and bound %s",pref(kind,lookupname),gref(startchar),gref(nextchar),dx,dy,anchor,bound) + logprocess("%s: moving %s to %s cursive (%s,%s) using anchor %s and bound %s in rlmode %s",pref(kind,lookupname),gref(startchar),gref(nextchar),dx,dy,anchor,bound,rlmode) end done = true break @@ -1404,7 +1424,7 @@ function chainprocs.gpos_cursive(start,stop,kind,chainname,currentcontext,cache, return start, false end -function chainprocs.gpos_single(start,stop,kind,chainname,currentcontext,cache,currentlookup,chainlookupname) +function chainprocs.gpos_single(start,stop,kind,chainname,currentcontext,cache,currentlookup,chainlookupname,chainindex,sequence) -- untested local startchar = start.char local subtables = currentlookup.subtables @@ -1413,9 +1433,9 @@ function chainprocs.gpos_single(start,stop,kind,chainname,currentcontext,cache,c if kerns then kerns = kerns[startchar] if kerns then - local dx, dy = set_pair(start,tfmdata.factor,rlmode,kerns,characters[startchar]) + local dx, dy, w, h = set_pair(start,tfmdata.factor,rlmode,sequence.flags[4],kerns,characters[startchar]) if trace_kerns then - logprocess("%s: shifting single %s by (%s,%s)",cref(kind,chainname,chainlookupname),gref(startchar),dx,dy) + logprocess("%s: shifting single %s by (%s,%s) and correction (%s,%s)",cref(kind,chainname,chainlookupname),gref(startchar),dx,dy,w,h) end end end @@ -1424,7 +1444,7 @@ end -- when machines become faster i will make a shared function -function chainprocs.gpos_pair(start,stop,kind,chainname,currentcontext,cache,currentlookup,chainlookupname) +function chainprocs.gpos_pair(start,stop,kind,chainname,currentcontext,cache,currentlookup,chainlookupname,chainindex,sequence) -- logwarning("%s: gpos_pair not yet supported",cref(kind,chainname,chainlookupname)) local snext = start.next if snext then @@ -1439,12 +1459,11 @@ function chainprocs.gpos_pair(start,stop,kind,chainname,currentcontext,cache,cur local factor = tfmdata.factor while snext and snext.id == glyph and snext.subtype<256 and snext.font == currentfont do local nextchar = snext.char -local krn = kerns[nextchar] + local krn = kerns[nextchar] if not krn and marks[nextchar] then prev = snext snext = snext.next else ---~ local krn = kerns[nextchar] if not krn then -- skip elseif type(krn) == "table" then @@ -1452,14 +1471,14 @@ local krn = kerns[nextchar] local a, b = krn[3], krn[4] if a and #a > 0 then local startchar = start.char - local x, y, w, h = set_pair(start,factor,rlmode,a,characters[startchar]) + local x, y, w, h = set_pair(start,factor,rlmode,sequence.flags[4],a,characters[startchar]) if trace_kerns then logprocess("%s: shifting first of pair %s and %s by (%s,%s) and correction (%s,%s)",cref(kind,chainname,chainlookupname),gref(startchar),gref(nextchar),x,y,w,h) end end if b and #b > 0 then local startchar = start.char - local x, y, w, h = set_pair(snext,factor,rlmode,b,characters[nextchar]) + local x, y, w, h = set_pair(snext,factor,rlmode,sequence.flags[4],b,characters[nextchar]) if trace_kerns then logprocess("%s: shifting second of pair %s and %s by (%s,%s) and correction (%s,%s)",cref(kind,chainname,chainlookupname),gref(startchar),gref(nextchar),x,y,w,h) end @@ -1503,19 +1522,29 @@ end -- we don't need to pass the currentcontext, saves a bit -- make a slow variant then can be activated but with more tracing +local function show_skip(kind,chainname,char,ck,class) + if ck[9] then + logwarning("%s: skipping char %s (%s) in rule %s, lookuptype %s (%s=>%s)",cref(kind,chainname),gref(char),class,ck[1],ck[2],ck[9],ck[10]) + else + logwarning("%s: skipping char %s (%s) in rule %s, lookuptype %s",cref(kind,chainname),gref(char),class,ck[1],ck[2]) + end +end + local function normal_handle_contextchain(start,kind,chainname,contexts,sequence,cache) -- local rule, lookuptype, sequence, f, l, lookups = ck[1], ck[2] ,ck[3], ck[4], ck[5], ck[6] local flags, done = sequence.flags, false local skipmark, skipligature, skipbase = flags[1], flags[2], flags[3] local someskip = skipmark or skipligature or skipbase -- could be stored in flags for a fast test (hm, flags could be false !) + local markclass = sequence.markclass -- todo, first we need a proper test for k=1,#contexts do local match, current, last = true, start, start local ck = contexts[k] - local sequence = ck[3] - local s = #sequence + local seq = ck[3] + local s = #seq + -- f..l = mid string if s == 1 then -- never happens - match = current.id == glyph and current.subtype<256 and current.font == currentfont and sequence[1][current.char] + match = current.id == glyph and current.subtype<256 and current.font == currentfont and seq[1][current.char] else -- todo: better space check (maybe check for glue) local f, l = ck[4], ck[5] @@ -1529,7 +1558,7 @@ local function normal_handle_contextchain(start,kind,chainname,contexts,sequence -- we cannot optimize for n=2 because there can be disc nodes -- if not someskip and n == l then -- -- n=2 and no skips then faster loop - -- match = last and last.id == glyph and last.subtype<256 and last.font == currentfont and sequence[n][last.char] + -- match = last and last.id == glyph and last.subtype<256 and last.font == currentfont and seq[n][last.char] -- else while n <= l do if last then @@ -1540,11 +1569,12 @@ local function normal_handle_contextchain(start,kind,chainname,contexts,sequence local ccd = descriptions[char] if ccd then local class = ccd.class - if class == skipmark or class == skipligature or class == skipbase then ---~ if someskip and class == skipmark or class == skipligature or class == skipbase then - -- skip 'm + if class == skipmark or class == skipligature or class == skipbase or (markclass and class == "mark" and not markclass[char]) then + if trace_skips then + show_skip(kind,chainname,char,ck,class) + end last = last.next - elseif sequence[n][char] then + elseif seq[n][char] then if n < l then last = last.next end @@ -1570,6 +1600,7 @@ local function normal_handle_contextchain(start,kind,chainname,contexts,sequence -- end end if match and f > 1 then + -- before local prev = start.prev if prev then local n = f-1 @@ -1582,10 +1613,11 @@ local function normal_handle_contextchain(start,kind,chainname,contexts,sequence local ccd = descriptions[char] if ccd then local class = ccd.class - if class == skipmark or class == skipligature or class == skipbase then ---~ if someskip and class == skipmark or class == skipligature or class == skipbase then - -- skip 'm - elseif sequence[n][char] then + if class == skipmark or class == skipligature or class == skipbase or (markclass and class == "mark" and not markclass[char]) then + if trace_skips then + show_skip(kind,chainname,char,ck,class) + end + elseif seq[n][char] then n = n -1 else match = false break @@ -1598,32 +1630,33 @@ local function normal_handle_contextchain(start,kind,chainname,contexts,sequence end elseif id == disc then -- skip 'm - elseif sequence[n][32] then + elseif seq[n][32] then n = n -1 else match = false break end prev = prev.prev - elseif sequence[n][32] then + elseif seq[n][32] then n = n -1 else match = false break end end elseif f == 2 then - match = sequence[1][32] + match = seq[1][32] else for n=f-1,1 do - if not sequence[n][32] then + if not seq[n][32] then match = false break end end end end if match and s > l then + -- after local current = last.next if current then - -- removed optimiziation for s-l == 1, we have to deal with marks anyway + -- removed optimization for s-l == 1, we have to deal with marks anyway local n = l + 1 while n <= s do if current then @@ -1634,10 +1667,11 @@ local function normal_handle_contextchain(start,kind,chainname,contexts,sequence local ccd = descriptions[char] if ccd then local class = ccd.class - if class == skipmark or class == skipligature or class == skipbase then ---~ if someskip and class == skipmark or class == skipligature or class == skipbase then - -- skip 'm - elseif sequence[n][char] then + if class == skipmark or class == skipligature or class == skipbase or (markclass and class == "mark" and not markclass[char]) then + if trace_skips then + show_skip(kind,chainname,char,ck,class) + end + elseif seq[n][char] then n = n + 1 else match = false break @@ -1650,23 +1684,23 @@ local function normal_handle_contextchain(start,kind,chainname,contexts,sequence end elseif id == disc then -- skip 'm - elseif sequence[n][32] then -- brrr + elseif seq[n][32] then -- brrr n = n + 1 else match = false break end current = current.next - elseif sequence[n][32] then + elseif seq[n][32] then n = n + 1 else match = false break end end elseif s-l == 1 then - match = sequence[s][32] + match = seq[s][32] else for n=l+1,s do - if not sequence[n][32] then + if not seq[n][32] then match = false break end end @@ -1676,7 +1710,7 @@ local function normal_handle_contextchain(start,kind,chainname,contexts,sequence if match then -- ck == currentcontext if trace_contexts then - local rule, lookuptype, sequence, f, l = ck[1], ck[2] ,ck[3], ck[4], ck[5] + local rule, lookuptype, f, l = ck[1], ck[2], ck[4], ck[5] local char = start.char if ck[9] then logwarning("%s: rule %s matches at char %s for (%s,%s,%s) chars, lookuptype %s (%s=>%s)",cref(kind,chainname),rule,gref(char),f-1,l-f+1,s-l,lookuptype,ck[9],ck[10]) @@ -1693,7 +1727,7 @@ local function normal_handle_contextchain(start,kind,chainname,contexts,sequence local chainlookup = lookuptable[chainlookupname] local cp = chainprocs[chainlookup.type] if cp then - start, done = cp(start,last,kind,chainname,ck,cache,chainlookup,chainlookupname) + start, done = cp(start,last,kind,chainname,ck,cache,chainlookup,chainlookupname,nil,sequence) else logprocess("%s: %s is not yet supported",cref(kind,chainname,chainlookupname),chainlookup.type) end @@ -1706,7 +1740,7 @@ local function normal_handle_contextchain(start,kind,chainname,contexts,sequence local cp = chainmores[chainlookup.type] if cp then local ok, n - start, ok, n = cp(start,last,kind,chainname,ck,cache,chainlookup,chainlookupname,i) + start, ok, n = cp(start,last,kind,chainname,ck,cache,chainlookup,chainlookupname,i,sequence) -- messy since last can be changed ! if ok then done = true @@ -1725,7 +1759,7 @@ local function normal_handle_contextchain(start,kind,chainname,contexts,sequence else local replacements = ck[7] if replacements then - start, done = chainprocs.reversesub(start,last,kind,chainname,ck,cache,replacements) + start, done = chainprocs.reversesub(start,last,kind,chainname,ck,cache,replacements) -- sequence else done = true -- can be meant to be skipped if trace_contexts then @@ -1797,6 +1831,11 @@ end local resolved = { } -- we only resolve a font,script,language pair once +-- todo: pass all these 'locals' in a table + +-- maybe some day i'll make an alternative that works on 'sub direction runs' which might be +-- more efficient for arabic but it has quite some consequences + function fonts.methods.node.otf.features(head,font,attr) if trace_steps then checkstep(head) @@ -1840,6 +1879,7 @@ function fonts.methods.node.otf.features(head,font,attr) local ra = rl [attr] if ra == nil then ra = { } rl [attr] = ra end -- attr can be false -- sequences always > 1 so no need for optimization for s=1,#sequences do + local pardir, txtdir = 0, { } local success = false local sequence = sequences[s] local r = ra[s] -- cache @@ -1939,7 +1979,7 @@ function fonts.methods.node.otf.features(head,font,attr) local ns = #subtables local thecache = featuredata[typ] or { } start = head -- local ? - rlmode = 0 + rlmode = 0 -- to be checked ? if ns == 1 then local lookupname = subtables[1] local lookupcache = thecache[lookupname] @@ -1956,6 +1996,7 @@ function fonts.methods.node.otf.features(head,font,attr) -- sequence kan weg local ok start, ok = handler(start,r[4],lookupname,lookupmatch,sequence,featuredata,1) +--~ texio.write_nl(tostring(lookupname),tostring(lookupmatch),tostring(ok)) if ok then success = true end @@ -1980,24 +2021,57 @@ function fonts.methods.node.otf.features(head,font,attr) -- start = start.next -- end elseif id == whatsit then +--~ if subtype == 7 then +--~ local dir = start.dir +--~ if dir == "+TRT" then +--~ rlmode = -1 +--~ elseif dir == "+TLT" then +--~ rlmode = 1 +--~ else +--~ rlmode = 0 +--~ end +--~ elseif subtype == 6 then +--~ local dir = start.dir +--~ if dir == "TRT" then +--~ rlmode = -1 +--~ elseif dir == "TLT" then +--~ rlmode = 1 +--~ else +--~ rlmode = 0 +--~ end +--~ end local subtype = start.subtype if subtype == 7 then local dir = start.dir - if dir == "+TRT" then + if dir == "+TRT" or dir == "+TLT" then + insert(txtdir,dir) + elseif dir == "-TRT" or dir == "-TLT" then + remove(txtdir) + end + local d = txtdir[#txtdir] + if d == "+TRT" then rlmode = -1 - elseif dir == "+TLT" then + elseif d == "+TLT" then rlmode = 1 else - rlmode = 0 + rlmode = pardir + end + if trace_directions then + logs.report("fonts","directions after textdir %s: pardir=%s, txtdir=%s:%s, rlmode=%s",dir,pardir,#txtdir,txtdir[#txtdir] or "unset",rlmode) end elseif subtype == 6 then local dir = start.dir if dir == "TRT" then - rlmode = -1 + pardir = -1 elseif dir == "TLT" then - rlmode = 1 + pardir = 1 else - rlmode = 0 + pardir = 0 + end + rlmode = pardir + --~ txtdir = { } + if trace_directions then + logs.report("fonts","directions after pardir %s: pardir=%s, txtdir=%s:%s, rlmode=%s",dir,pardir,#txtdir,txtdir[#txtdir] or "unset",rlmode) end end start = start.next @@ -2005,7 +2079,6 @@ function fonts.methods.node.otf.features(head,font,attr) start = start.next end end - end else while start do @@ -2052,25 +2125,59 @@ function fonts.methods.node.otf.features(head,font,attr) -- end elseif id == whatsit then local subtype = start.subtype - if subtype == 7 then - local dir = start.dir - if dir == "+TRT" then - rlmode = -1 - elseif dir == "+TLT" then - rlmode = 1 - else - rlmode = 0 +--~ if subtype == 7 then +--~ local dir = start.dir +--~ if dir == "+TRT" then +--~ rlmode = -1 +--~ elseif dir == "+TLT" then +--~ rlmode = 1 +--~ else +--~ rlmode = 0 +--~ end +--~ elseif subtype == 6 then +--~ local dir = start.dir +--~ if dir == "TRT" then +--~ rlmode = -1 +--~ elseif dir == "TLT" then +--~ rlmode = 1 +--~ else +--~ rlmode = 0 +--~ end +--~ end + local subtype = start.subtype + if subtype == 7 then + local dir = start.dir + if dir == "+TRT" or dir == "+TLT" then + insert(txtdir,dir) + elseif dir == "-TRT" or dir == "-TLT" then + remove(txtdir) + end + local d = txtdir[#txtdir] + if d == "+TRT" then + rlmode = -1 + elseif d == "+TLT" then + rlmode = 1 + else + rlmode = pardir + end + if trace_directions then + logs.report("fonts","directions after textdir %s: pardir=%s, txtdir=%s:%s, rlmode=%s",dir,pardir,#txtdir,txtdir[#txtdir] or "unset",rlmode) + end + elseif subtype == 6 then + local dir = start.dir + if dir == "TRT" then + pardir = -1 + elseif dir == "TLT" then + pardir = 1 + else + pardir = 0 + end + rlmode = pardir + --~ txtdir = { } + if trace_directions then + logs.report("fonts","directions after pardir %s: pardir=%s, txtdir=%s:%s, rlmode=%s",dir,pardir,#txtdir,txtdir[#txtdir] or "unset",rlmode) end - elseif subtype == 6 then - local dir = start.dir - if dir == "TRT" then - rlmode = -1 - elseif dir == "TLT" then - rlmode = 1 - else - rlmode = 0 end - end start = start.next else start = start.next diff --git a/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-ott.lua b/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-ott.lua index 47c2e0e9fe0..55cb734d675 100644 --- a/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-ott.lua +++ b/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-ott.lua @@ -87,7 +87,7 @@ otf.tables.scripts = { ['ugar'] = 'Ugaritic Cuneiform', ['xpeo'] = 'Old Persian Cuneiform', ['xsux'] = 'Sumero-Akkadian Cuneiform', - ['yi' ] = 'Yi' + ['yi' ] = 'Yi', } otf.tables.languages = { @@ -569,6 +569,7 @@ otf.tables.features = { ['rphf'] = 'Reph Form', ['rtbd'] = 'Right Bounds', ['rtla'] = 'Right-To-Left Alternates', + ['rtlm'] = 'Right To Left Math', -- math ['ruby'] = 'Ruby Notation Forms', ['salt'] = 'Stylistic Alternates', ['sinf'] = 'Scientific Inferiors', diff --git a/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-tfm.lua b/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-tfm.lua index 8b799df5aa0..efea9def3f9 100644 --- a/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-tfm.lua +++ b/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-tfm.lua @@ -1,6 +1,6 @@ if not modules then modules = { } end modules ['font-tfm'] = { version = 1.001, - comment = "companion to font-ini.tex", + comment = "companion to font-ini.mkiv", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright = "PRAGMA ADE / ConTeXt Development Team", license = "see context related readme files" @@ -8,7 +8,7 @@ if not modules then modules = { } end modules ['font-tfm'] = { local utf = unicode.utf8 -local next, format, match, lower = next, string.format, string.match, string.lower +local next, format, match, lower, gsub = next, string.format, string.match, string.lower, string.gsub local concat, sortedkeys, utfbyte, serialize = table.concat, table.sortedkeys, utf.byte, table.serialize local trace_defining = false trackers.register("fonts.defining", function(v) trace_defining = v end) @@ -225,7 +225,7 @@ end local charactercache = { } -- The scaler is only used for otf and afm and virtual fonts. If --- a virtual font has italic correction make sur eto set the +-- 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) @@ -258,6 +258,9 @@ function tfm.do_scale(tfmtable, scaledpoints) t.unicodes = tfmtable.unicodes t.indices = tfmtable.indices t.marks = tfmtable.marks +t.goodies = tfmtable.goodies +t.colorscheme = tfmtable.colorscheme +--~ t.embedding = tfmtable.embedding t.descriptions = descriptions if tfmtable.fonts then t.fonts = table.fastcopy(tfmtable.fonts) -- hm also at the end @@ -362,6 +365,7 @@ local private = fonts.private end end if hasquality then + -- we could move these calculations elsewhere (saves calculations) local ve = v.expansion_factor if ve then chr.expansion_factor = ve*1000 -- expansionfactor, hm, can happen elsewhere @@ -403,6 +407,11 @@ local private = fonts.private } end chr.vert_variants = t +--~ local ic = v.vert_italic_correction +--~ if ic then +--~ chr.italic = ic * delta +--~ print(format("0x%05X -> %s",k,chr.italic)) +--~ end else local hv = v.horiz_variants if hv then @@ -513,6 +522,9 @@ local private = fonts.private end end tc[k] = chr +--~ if k == 0x222B then +--~ print(t.fontname,table.serialize(chr)) +--~ end end -- t.encodingbytes, t.filename, t.fullname, t.name: elsewhere t.size = scaledpoints @@ -529,15 +541,15 @@ local private = fonts.private end -- needed for \high cum suis local tpx = tp.x_height -if hasmath then - if not tp[13] then tp[13] = .86*tpx end -- mathsupdisplay - if not tp[14] then tp[14] = .86*tpx end -- mathsupnormal - if not tp[15] then tp[15] = .86*tpx end -- mathsupcramped - if not tp[16] then tp[16] = .48*tpx end -- mathsubnormal - 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 -end + if hasmath then + if not tp[13] then tp[13] = .86*tpx end -- mathsupdisplay + if not tp[14] then tp[14] = .86*tpx end -- mathsupnormal + if not tp[15] then tp[15] = .86*tpx end -- mathsupcramped + if not tp[16] then tp[16] = .48*tpx end -- mathsubnormal + 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 + end t.tounicode = 1 t.cidinfo = tfmtable.cidinfo -- we have t.name=metricfile and t.fullname=RealName and t.filename=diskfilename @@ -545,14 +557,23 @@ end -- can have multiple subfonts if hasmath then if trace_defining then - logs.report("define font","math enabled for: %s %s %s",t.name or "noname",t.fullname or "nofullname",t.filename or "nofilename") + logs.report("define font","math enabled for: name '%s', fullname: '%s', filename: '%s'",t.name or "noname",t.fullname or "nofullname",t.filename or "nofilename") end else if trace_defining then - logs.report("define font","math disabled for: %s %s %s",t.name or "noname",t.fullname or "nofullname",t.filename or "nofilename") + logs.report("define font","math disabled for: name '%s', fullname: '%s', filename: '%s'",t.name or "noname",t.fullname or "nofullname",t.filename or "nofilename") end t.nomath, t.MathConstants = true, nil end + if not t.psname then + -- name used in pdf file as well as for selecting subfont in ttc/dfont + t.psname = t.fontname or (t.fullname and fonts.names.cleanname(t.fullname)) + end + if trace_defining then + logs.report("define font","used for accesing subfont: '%s'",t.psname or "nopsname") + logs.report("define font","used for subsetting: '%s'",t.fontname or "nofontname") + end +--~ print(t.fontname,table.serialize(t.MathConstants)) return t, delta end diff --git a/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-xtx.lua b/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-xtx.lua index 7b3f1ec8196..8aecae8d920 100644 --- a/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-xtx.lua +++ b/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-xtx.lua @@ -1,6 +1,6 @@ if not modules then modules = { } end modules ['font-xtx'] = { version = 1.001, - comment = "companion to font-ini.tex", + comment = "companion to font-ini.mkiv", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright = "PRAGMA ADE / ConTeXt Development Team", license = "see context related readme files" diff --git a/Master/texmf-dist/tex/luatex/luaotfload/otfl-luat-dum.lua b/Master/texmf-dist/tex/luatex/luaotfload/otfl-luat-dum.lua index f2ff50577a4..dd5ade7a9b4 100644 --- a/Master/texmf-dist/tex/luatex/luaotfload/otfl-luat-dum.lua +++ b/Master/texmf-dist/tex/luatex/luaotfload/otfl-luat-dum.lua @@ -13,6 +13,11 @@ statistics = { starttiming = dummyfunction, stoptiming = dummyfunction, } +directives = { + register = dummyfunction, + enable = dummyfunction, + disable = dummyfunction, +} trackers = { register = dummyfunction, enable = dummyfunction, @@ -40,10 +45,11 @@ texconfig.kpse_init = true resolvers = resolvers or { } -- no fancy file helpers used local remapper = { - otf = "opentype fonts", - ttf = "truetype fonts", - ttc = "truetype fonts", - cid = "other text files", -- will become "cid files" + otf = "opentype fonts", + ttf = "truetype fonts", + ttc = "truetype fonts", + dfont = "truetype dictionary", + cid = "other text files", -- will become "cid files" } function resolvers.find_file(name,kind) diff --git a/Master/texmf-dist/tex/luatex/luaotfload/otfl-node-fnt.lua b/Master/texmf-dist/tex/luatex/luaotfload/otfl-node-fnt.lua index 3ad9060c307..72bb140ca3e 100644 --- a/Master/texmf-dist/tex/luatex/luaotfload/otfl-node-fnt.lua +++ b/Master/texmf-dist/tex/luatex/luaotfload/otfl-node-fnt.lua @@ -1,6 +1,6 @@ if not modules then modules = { } end modules ['node-fnt'] = { version = 1.001, - comment = "companion to font-ini.tex", + comment = "companion to font-ini.mkiv", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright = "PRAGMA ADE / ConTeXt Development Team", license = "see context related readme files" @@ -178,7 +178,6 @@ else do -- X000 1100 = 12 = 0x1C = leftghost -- X001 0100 = 20 = 0x14 = rightghost - function nodes.protect_glyphs(head) local done = false for g in traverse_id(glyph,head) do diff --git a/Master/texmf-dist/tex/luatex/luaotfload/otfl-node-ini.lua b/Master/texmf-dist/tex/luatex/luaotfload/otfl-node-ini.lua index 3ff73c62f16..741e53d6bfd 100644 --- a/Master/texmf-dist/tex/luatex/luaotfload/otfl-node-ini.lua +++ b/Master/texmf-dist/tex/luatex/luaotfload/otfl-node-ini.lua @@ -1,6 +1,6 @@ if not modules then modules = { } end modules ['node-ini'] = { version = 1.001, - comment = "companion to node-ini.tex", + comment = "companion to node-ini.mkiv", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright = "PRAGMA ADE / ConTeXt Development Team", license = "see context related readme files" diff --git a/Master/texmf-dist/tex/luatex/luaotfload/otfl-node-inj.lua b/Master/texmf-dist/tex/luatex/luaotfload/otfl-node-inj.lua index dc676a412ed..4c5840978c1 100644 --- a/Master/texmf-dist/tex/luatex/luaotfload/otfl-node-inj.lua +++ b/Master/texmf-dist/tex/luatex/luaotfload/otfl-node-inj.lua @@ -1,6 +1,6 @@ if not modules then modules = { } end modules ['node-inj'] = { version = 1.001, - comment = "companion to node-ini.tex", + comment = "companion to node-ini.mkiv", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright = "PRAGMA ADE / ConTeXt Development Team", license = "see context related readme files" @@ -10,7 +10,8 @@ if not modules then modules = { } end modules ['node-inj'] = { -- This is very experimental (this will change when we have luatex > .50 and -- a few pending thingies are available. Also, Idris needs to make a few more --- test fonts. +-- test fonts. Btw, future versions of luatex will have extended glyph properties +-- that can be of help. local next = next @@ -50,6 +51,8 @@ local kerns = { } -- explicitly i will provide an alternative; also, we can share -- tables +-- for the moment we pass the r2l key ... volt/arabtype tests + function nodes.set_cursive(start,nxt,factor,rlmode,exit,entry,tfmstart,tfmnext) local dx, dy = factor*(exit[1]-entry[1]), factor*(exit[2]-entry[2]) local ws, wn = tfmstart.width, tfmnext.width @@ -60,7 +63,7 @@ function nodes.set_cursive(start,nxt,factor,rlmode,exit,entry,tfmstart,tfmnext) return dx, dy, bound end -function nodes.set_pair(current,factor,rlmode,spec,tfmchr) +function nodes.set_pair(current,factor,rlmode,r2lflag,spec,tfmchr) local x, y, w, h = factor*spec[1], factor*spec[2], factor*spec[3], factor*spec[4] -- dy = y - h if x ~= 0 or w ~= 0 or y ~= 0 or h ~= 0 then @@ -71,7 +74,7 @@ function nodes.set_pair(current,factor,rlmode,spec,tfmchr) else bound = #kerns + 1 set_attribute(current,kernpair,bound) - kerns[bound] = { rlmode, x, y, w, h } + kerns[bound] = { rlmode, x, y, w, h, r2lflag, tfmchr.width } end return x, y, w, h, bound end @@ -171,6 +174,7 @@ end function nodes.inject_kerns(head,where,keep) local has_marks, has_cursives, has_kerns = next(marks), next(cursives), next(kerns) if has_marks or has_cursives then +--~ if has_marks or has_cursives or has_kerns then if trace_injections then nodes.trace_injection(head) end @@ -190,7 +194,7 @@ function nodes.inject_kerns(head,where,keep) if k then local kk = kerns[k] if kk then - local x, y, w, h = kk[2], kk[3], kk[4], kk[5] + local x, y, w, h = kk[2] or 0, kk[3] or 0, kk[4] or 0, kk[5] or 0 local dy = y - h if dy ~= 0 then ky[n] = dy @@ -305,14 +309,15 @@ function nodes.inject_kerns(head,where,keep) local d = mrks[index] if d then -- local rlmode = d[3] -- not used - -- if rlmode and rlmode < 0 then - -- n.xoffset = p.xoffset + d[1] + -- if rlmode and rlmode > 0 then + -- todo -- else - n.xoffset = p.xoffset - d[1] ---~ local k = wx[p] ---~ if k then ---~ wx[n] = k ---~ end + local k = wx[p] + if k then + n.xoffset = p.xoffset - d[1] - k[2] + else + n.xoffset = p.xoffset - d[1] + end -- end if mk[p] then n.yoffset = p.yoffset + d[2] @@ -334,23 +339,41 @@ function nodes.inject_kerns(head,where,keep) if next(wx) then for n, k in next, wx do -- only w can be nil, can be sped up when w == nil - local rl, x, w = k[1], k[2] or 0, k[4] or 0 + local rl, x, w, r2l = k[1], k[2] or 0, k[4] or 0, k[6] local wx = w - x - if rl < 0 then - if wx ~= 0 then - insert_node_before(head,n,newkern(wx)) - end - if x ~= 0 then - insert_node_after (head,n,newkern(x)) - end - else - -- if wx ~= 0 then - -- insert_node_after(head,n,newkern(wx)) - -- end - if x ~= 0 then - insert_node_before(head,n,newkern(x)) +--~ if rl < 0 then +--~ if r2l then +--~ if wx ~= 0 then +--~ insert_node_before(head,n,newkern(wx)) +--~ end +--~ if x ~= 0 then +--~ insert_node_after (head,n,newkern(x)) +--~ end +--~ else +--~ if x ~= 0 then +--~ insert_node_before(head,n,newkern(x)) +--~ end +--~ if wx ~= 0 then +--~ insert_node_after(head,n,newkern(wx)) +--~ end +--~ end +--~ else + if r2l then + if wx ~= 0 then + insert_node_before(head,n,newkern(wx)) + end + if x ~= 0 then + insert_node_after (head,n,newkern(x)) + end + else + if x ~= 0 then + insert_node_before(head,n,newkern(x)) + end + if wx ~= 0 then + insert_node_after(head,n,newkern(wx)) + end end - end +--~ end end end if next(cx) then @@ -376,29 +399,54 @@ function nodes.inject_kerns(head,where,keep) if trace_injections then nodes.trace_injection(head) end - -- we assume done is true because there are kerns for n in traverse_id(glyph,head) do local k = has_attribute(n,kernpair) if k then local kk = kerns[k] if kk then - -- only w can be nil, can be sped up when w == nil - local rl, x, y, w = kk[1], kk[2] or 0, kk[3] or 0, kk[4] or 0 - if y ~= 0 then + local rl, x, y, w = kk[1], kk[2] or 0, kk[3], kk[4] + if y and y ~= 0 then n.yoffset = y -- todo: h ? end - local wx = w - x - if rl < 0 then - if wx ~= 0 then - insert_node_before(head,n,newkern(wx)) - end - if x ~= 0 then - insert_node_after (head,n,newkern(x)) - end + if w then + -- copied from above + local r2l = kk[6] + local wx = w - x +--~ if rl < 0 then +--~ if r2l then +--~ if x ~= 0 then +--~ insert_node_before(head,n,newkern(x)) +--~ end +--~ if wx ~= 0 then +--~ insert_node_after(head,n,newkern(wx)) +--~ end +--~ else +--~ if wx ~= 0 then +--~ insert_node_before(head,n,newkern(wx)) +--~ end +--~ if x ~= 0 then +--~ insert_node_after (head,n,newkern(x)) +--~ end +--~ end +--~ else + if r2l then + if wx ~= 0 then + insert_node_before(head,n,newkern(wx)) + end + if x ~= 0 then + insert_node_after (head,n,newkern(x)) + end + else + if x ~= 0 then + insert_node_before(head,n,newkern(x)) + end + if wx ~= 0 then + insert_node_after(head,n,newkern(wx)) + end + end +--~ end else - -- if wx ~= 0 then - -- insert_node_after(head,n,newkern(wx)) - -- end + -- simple (e.g. kernclass kerns) if x ~= 0 then insert_node_before(head,n,newkern(x)) end diff --git a/Master/texmf-dist/tex/luatex/luaotfload/otfl-node-res.lua b/Master/texmf-dist/tex/luatex/luaotfload/otfl-node-res.lua index 4f2cf5a0509..49a1297eb9e 100644 --- a/Master/texmf-dist/tex/luatex/luaotfload/otfl-node-res.lua +++ b/Master/texmf-dist/tex/luatex/luaotfload/otfl-node-res.lua @@ -1,6 +1,6 @@ if not modules then modules = { } end modules ['node-res'] = { version = 1.001, - comment = "companion to node-ini.tex", + comment = "companion to node-ini.mkiv", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright = "PRAGMA ADE / ConTeXt Development Team", license = "see context related readme files" @@ -60,6 +60,10 @@ local glyph = nodes.register(new_node("glyph",0)) local textdir = nodes.register(new_node("whatsit",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 function nodes.glyph(fnt,chr) local n = copy_node(glyph) @@ -109,6 +113,45 @@ function nodes.latelua(code) return n end +local cache = { } + +function nodes.usernumber(num) + local n = cache[num] + if n then + return copy_node(n) + else + local n = copy_node(user_n) + if num then n.value = num end + return n + end +end + +function nodes.userlist(list) + local n = copy_node(user_l) + if list then n.value = list end + return n +end + +local cache = { } -- we could use the same cache + +function nodes.userstring(str) + local n = cache[str] + if n then + return copy_node(n) + else + local n = copy_node(user_s) + n.type = 115 + if str then n.value = str end + return n + end +end + +function nodes.usertokens(tokens) + local n = copy_node(user_t) + if tokens then n.value = tokens 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"])) end) -- \topofboxstack -- cgit v1.2.3