From 5c46359f4fa543e24e5d4a0a327d41bf8a9ff7c8 Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Thu, 22 Mar 2018 19:57:53 +0100 Subject: 2018-03-22 19:49:00 --- tex/context/base/mkii/cont-new.mkii | 2 +- tex/context/base/mkii/context.mkii | 2 +- tex/context/base/mkiv/cont-new.mkiv | 2 +- tex/context/base/mkiv/context.mkiv | 2 +- tex/context/base/mkiv/font-ots.lua | 2 +- tex/context/base/mkiv/l-macro.lua | 72 +++++++++++- tex/context/base/mkiv/l-package.lua | 6 +- tex/context/base/mkiv/lpdf-epd.lua | 2 + tex/context/base/mkiv/lpdf-ini.lua | 30 ++++- tex/context/base/mkiv/lpdf-mis.lua | 32 +++--- tex/context/base/mkiv/lpdf-pda.xml | 9 +- tex/context/base/mkiv/lpdf-pdx.xml | 9 +- tex/context/base/mkiv/lpdf-pua.xml | 9 +- tex/context/base/mkiv/lpdf-xmp.lua | 123 +++++++++++---------- tex/context/base/mkiv/sort-ini.lua | 58 ++++++++-- tex/context/base/mkiv/status-files.pdf | Bin 25801 -> 26081 bytes tex/context/base/mkiv/status-lua.pdf | Bin 254074 -> 254477 bytes tex/context/base/mkiv/trac-log.lua | 11 +- tex/context/base/mkiv/util-lua.lua | 14 +-- tex/context/base/mkiv/util-sql-imp-ffi.lua | 4 +- tex/context/interface/mkiv/i-context.pdf | Bin 848123 -> 848385 bytes tex/context/interface/mkiv/i-readme.pdf | Bin 60776 -> 61034 bytes tex/context/modules/mkiv/s-fonts-shapes.lua | 115 ++++++++++--------- tex/context/modules/mkiv/s-fonts-shapes.mkiv | 6 +- tex/generic/context/luatex/luatex-fonts-merged.lua | 4 +- 25 files changed, 340 insertions(+), 174 deletions(-) (limited to 'tex') diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii index 58823af2c..6603bb01f 100644 --- a/tex/context/base/mkii/cont-new.mkii +++ b/tex/context/base/mkii/cont-new.mkii @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2018.03.21 09:16} +\newcontextversion{2018.03.22 19:41} %D This file is loaded at runtime, thereby providing an %D excellent place for hacks, patches, extensions and new diff --git a/tex/context/base/mkii/context.mkii b/tex/context/base/mkii/context.mkii index 1a4769614..acfda88dc 100644 --- a/tex/context/base/mkii/context.mkii +++ b/tex/context/base/mkii/context.mkii @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2018.03.21 09:16} +\edef\contextversion{2018.03.22 19:41} %D For those who want to use this: diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index cb7607eac..10ae9d1df 100644 --- a/tex/context/base/mkiv/cont-new.mkiv +++ b/tex/context/base/mkiv/cont-new.mkiv @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2018.03.21 09:16} +\newcontextversion{2018.03.22 19:41} %D This file is loaded at runtime, thereby providing an excellent place for %D hacks, patches, extensions and new features. diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv index f786d1d0c..cef988ce7 100644 --- a/tex/context/base/mkiv/context.mkiv +++ b/tex/context/base/mkiv/context.mkiv @@ -42,7 +42,7 @@ %D has to match \type {YYYY.MM.DD HH:MM} format. \edef\contextformat {\jobname} -\edef\contextversion{2018.03.21 09:16} +\edef\contextversion{2018.03.22 19:41} \edef\contextkind {beta} %D For those who want to use this: diff --git a/tex/context/base/mkiv/font-ots.lua b/tex/context/base/mkiv/font-ots.lua index 3e338f614..25083dfce 100644 --- a/tex/context/base/mkiv/font-ots.lua +++ b/tex/context/base/mkiv/font-ots.lua @@ -936,7 +936,7 @@ function handlers.gpos_pair(head,start,dataset,sequence,kerns,rlmode,skiphash,st elseif b then -- #b > 0 local x, y, w, h = setposition(2,snext,factor,rlmode,b,injection) if trace_kerns then - local startchar = getchar(snext) + local startchar = getchar(start) logprocess("%s: shifting second of pair %s and %s by xy (%p,%p) and wh (%p,%p) as %s",pref(dataset,sequence),gref(startchar),gref(nextchar),x,y,w,h,injection or "injections") end start = snext -- cf spec diff --git a/tex/context/base/mkiv/l-macro.lua b/tex/context/base/mkiv/l-macro.lua index d2b8c7ae4..30c7cbec6 100644 --- a/tex/context/base/mkiv/l-macro.lua +++ b/tex/context/base/mkiv/l-macro.lua @@ -14,7 +14,8 @@ if not modules then modules = { } end modules ['l-macros'] = { local S, P, R, V, C, Cs, Cc, Ct, Carg = lpeg.S, lpeg.P, lpeg.R, lpeg.V, lpeg.C, lpeg.Cs, lpeg.Cc, lpeg.Ct, lpeg.Carg local lpegmatch = lpeg.match local concat = table.concat -local next = next +local format, sub = string.format, string.sub +local next, load, type = next, load, type local newline = S("\n\r")^1 local continue = P("\\") * newline @@ -41,6 +42,15 @@ local definitions = { } local resolve local subparser +local report_lua = function(...) + if logs and logs.reporter then + report_lua = logs.reporter("system","lua") + report_lua(...) + else + print(format(...)) + end +end + -- todo: zero case resolve = C(C(name) * arguments^-1) / function(raw,s,a) @@ -160,6 +170,66 @@ function macros.resolving() return next(patterns) end +local function loaded(name,trace,detail) + -- local c = io.loaddata(fullname) -- not yet available + local f = io.open(name,"rb") + if not f then + return false, format("file '%s' not found",name) + end + local c = f:read("*a") + if not c then + return false, format("file '%s' is invalid",name) + end + f:close() + local n = lpegmatch(parser,c) + if trace then + if #n ~= #c then + report_lua("macros expanded in '%s' (%i => %i bytes)",name,#c,#n) + if detail then + report_lua() + report_lua(n) + report_lua() + end + elseif detail then + report_lua("no macros expanded in '%s'",name) + end + end + if #name > 30 then + n = "--[[" .. sub(name,-30) .. "]] " .. n + else + n = "--[[" .. name .. "]] " .. n + end + return load(n) +end + +macros.loaded = loaded + +function required(name,trace) + local filename = file.addsuffix(name,"lua") + local fullname = resolvers and resolvers.find_file(filename) or filename + if not fullname or fullname == "" then + return false + end + local codeblob = package.loaded[fullname] + if codeblob then + return codeblob + end + local code, message = loaded(fullname,macros,trace,trace) + if type(code) == "function" then + code = code() + else + report_lua("error when loading '%s'",fullname) + return false, message + end + if code == nil then + code = false + end + package.loaded[fullname] = code + return code +end + +macros.required = required + -- local str = [[ -- #define check(p,q) (p ~= 0) and (p > q) -- diff --git a/tex/context/base/mkiv/l-package.lua b/tex/context/base/mkiv/l-package.lua index d43c5c5c6..4faee76bf 100644 --- a/tex/context/base/mkiv/l-package.lua +++ b/tex/context/base/mkiv/l-package.lua @@ -18,12 +18,12 @@ if not modules then modules = { } end modules ['l-package'] = { local type = type local gsub, format, find = string.gsub, string.format, string.find +local insert, remove = table.insert, table.remove local P, S, Cs, lpegmatch = lpeg.P, lpeg.S, lpeg.Cs, lpeg.match -local package = package -local searchers = package.searchers or package.loaders -local insert, remove = table.insert, table.remove +local package = package +local searchers = package.searchers or package.loaders -------.loaders = nil -- old stuff that we don't want -------.seeall = nil -- old stuff that we don't want diff --git a/tex/context/base/mkiv/lpdf-epd.lua b/tex/context/base/mkiv/lpdf-epd.lua index 2fcd28473..cf02b5a22 100644 --- a/tex/context/base/mkiv/lpdf-epd.lua +++ b/tex/context/base/mkiv/lpdf-epd.lua @@ -374,6 +374,8 @@ local function get_array(object,document) end end +-- todo: collect chunks + local function streamaccess(s,_,what) if not what or what == "all" or what == "*all" then local t, n = { }, 0 diff --git a/tex/context/base/mkiv/lpdf-ini.lua b/tex/context/base/mkiv/lpdf-ini.lua index f8cff2032..8af1fb409 100644 --- a/tex/context/base/mkiv/lpdf-ini.lua +++ b/tex/context/base/mkiv/lpdf-ini.lua @@ -1082,10 +1082,28 @@ end do + -- It's a bit of a historical mess here. + + local metadata = nil local timestamp = backends.timestamp() - function lpdf.timestamp() - return timestamp + function lpdf.getmetadata() + if not metadata then + local contextversion = environment.version + local luatexversion = format("%1.2f",LUATEXVERSION) + local luatexfunctionality = tostring(LUATEXFUNCTIONALITY) + metadata = { + producer = format("LuaTeX-%s",luatexversion), + creator = format("LuaTeX %s %s + ConTeXt MkIV %s",luatexversion,luatexfunctionality,contextversion), + luatexversion = luatexversion, + contextversion = contextversion, + luatexfunctionality = luatexfunctionality, + luaversion = tostring(LUAVERSION), + platform = os.platform, + time = timestamp, + } + end + return metadata end function lpdf.settime(n) @@ -1096,6 +1114,9 @@ do timestamp = backends.timestamp() end end + if metadata then + metadata.time = timestamp + end return timestamp end @@ -1107,10 +1128,11 @@ do end function lpdf.id(nodate) + local banner = environment.jobname or tex.jobname or "unknown" if nodate then - return tex.jobname + return banner else - return format("%s.%s",tex.jobname,timestamp) + return format("%s.%s",banner,timestamp) end end diff --git a/tex/context/base/mkiv/lpdf-mis.lua b/tex/context/base/mkiv/lpdf-mis.lua index 07dc3dcf1..6d1b09ca0 100644 --- a/tex/context/base/mkiv/lpdf-mis.lua +++ b/tex/context/base/mkiv/lpdf-mis.lua @@ -52,6 +52,8 @@ local addtoinfo = lpdf.addtoinfo local addtopageattributes = lpdf.addtopageattributes local addtonames = lpdf.addtonames +local pdfgetmetadata = lpdf.getmetadata + local variables = interfaces.variables local v_stop = variables.stop @@ -189,6 +191,12 @@ local done = false -- using "setupidentity = function() end" fails as the meani local function setupidentity() if not done then + local metadata = pdfgetmetadata() + local creator = metadata.creator + local version = metadata.contextversion + local time = metadata.time + local jobname = environment.jobname or tex.jobname or "unknown" + -- local title = identity.title if not title or title == "" then title = tex.jobname @@ -202,21 +210,16 @@ local function setupidentity() if author ~= "" then addtoinfo("Author", pdfunicode(author), author) -- '/Author' in /Info, 'Creator' in XMP end - -- local creator = identity.creator or "" - local creator = "LuaTeX + ConTeXt MkIV" -- has to be the same in CreatorTool - if creator ~= "" then - addtoinfo("Creator", pdfunicode(creator), creator) -- '/Creator' in /Info, 'CreatorTool' in XMP - end - local currenttimestamp = lpdf.timestamp() - addtoinfo("CreationDate", pdfstring(formattedtimestamp(currenttimestamp))) + addtoinfo("Creator", pdfunicode(creator), creator) + addtoinfo("CreationDate", pdfstring(formattedtimestamp(time))) local date = identity.date or "" - local pdfdate = formattedtimestamp(date) + local pdfdate = date and formattedtimestamp(date) if pdfdate then addtoinfo("ModDate", pdfstring(pdfdate), date) else -- users should enter the date in 2010-01-19T23:27:50+01:00 format -- and if not provided that way we use the creation time instead - addtoinfo("ModDate", pdfstring(formattedtimestamp(currenttimestamp)), currenttimestamp) + addtoinfo("ModDate", pdfstring(formattedtimestamp(time)),time) end local keywords = identity.keywords or "" if keywords ~= "" then @@ -226,11 +229,12 @@ local function setupidentity() local id = lpdf.id() addtoinfo("ID", pdfstring(id), id) -- needed for pdf/x -- - addtoinfo("ConTeXt.Version", environment.version) - addtoinfo("ConTeXt.Time", os.date("%Y-%m-%d %H:%M")) - addtoinfo("ConTeXt.Jobname", environment.jobname or tex.jobname) - addtoinfo("ConTeXt.Url", "www.pragma-ade.com") - addtoinfo("ConTeXt.Support", "contextgarden.net") + addtoinfo("ConTeXt.Version",version) + addtoinfo("ConTeXt.Time",os.date("%Y-%m-%d %H:%M")) + addtoinfo("ConTeXt.Jobname",jobname) + addtoinfo("ConTeXt.Url","www.pragma-ade.com") + addtoinfo("ConTeXt.Support","contextgarden.net") + addtoinfo("TeX.Support","tug.org") -- done = true else diff --git a/tex/context/base/mkiv/lpdf-pda.xml b/tex/context/base/mkiv/lpdf-pda.xml index 78ad47f21..efdfc4d7d 100644 --- a/tex/context/base/mkiv/lpdf-pda.xml +++ b/tex/context/base/mkiv/lpdf-pda.xml @@ -24,12 +24,17 @@ + + - - + + + + + diff --git a/tex/context/base/mkiv/lpdf-pdx.xml b/tex/context/base/mkiv/lpdf-pdx.xml index d55e1fdf3..889862c76 100644 --- a/tex/context/base/mkiv/lpdf-pdx.xml +++ b/tex/context/base/mkiv/lpdf-pdx.xml @@ -23,12 +23,17 @@ + + - - + + + + + diff --git a/tex/context/base/mkiv/lpdf-pua.xml b/tex/context/base/mkiv/lpdf-pua.xml index c50e1f05b..f985b54d3 100644 --- a/tex/context/base/mkiv/lpdf-pua.xml +++ b/tex/context/base/mkiv/lpdf-pua.xml @@ -23,12 +23,17 @@ + + - - + + + + + diff --git a/tex/context/base/mkiv/lpdf-xmp.lua b/tex/context/base/mkiv/lpdf-xmp.lua index 2eb573acb..eb15a3582 100644 --- a/tex/context/base/mkiv/lpdf-xmp.lua +++ b/tex/context/base/mkiv/lpdf-xmp.lua @@ -27,6 +27,8 @@ local pdfconstant = lpdf.constant local pdfreference = lpdf.reference local pdfflushstreamobject = lpdf.flushstreamobject +local pdfgetmetadata = lpdf.getmetadata + -- The XMP packet wrapper is kind of fixed, see page 10 of XMPSpecificationsPart1.pdf from -- XMP-Toolkit-SDK-CC201607.zip. So we hardcode the id. @@ -39,47 +41,52 @@ local xpacket = format ( [[ local mapping = { -- user defined keys (pdfx:) - ["ConTeXt.Jobname"] = { "context", "rdf:Description/pdfx:ConTeXt.Jobname" }, - ["ConTeXt.Time"] = { "date", "rdf:Description/pdfx:ConTeXt.Time" }, - ["ConTeXt.Url"] = { "context", "rdf:Description/pdfx:ConTeXt.Url" }, - ["ConTeXt.Version"] = { "context", "rdf:Description/pdfx:ConTeXt.Version" }, - ["ID"] = { "id", "rdf:Description/pdfx:ID" }, -- has date - ["PTEX.Fullbanner"] = { "metadata","rdf:Description/pdfx:PTEX.Fullbanner" }, + ["ConTeXt.Jobname"] = { "context", "rdf:Description/pdfx:ConTeXt.Jobname" }, + ["ConTeXt.Time"] = { "date", "rdf:Description/pdfx:ConTeXt.Time" }, + ["ConTeXt.Url"] = { "context", "rdf:Description/pdfx:ConTeXt.Url" }, + ["ConTeXt.Support"] = { "context", "rdf:Description/pdfx:ConTeXt.Support" }, + ["ConTeXt.Version"] = { "context", "rdf:Description/pdfx:ConTeXt.Version" }, + ["TeX.Support"] = { "metadata", "rdf:Description/pdfx:TeX.Support" }, + ["LuaTeX.Version"] = { "metadata","rdf:Description/pdfx:LuaTeX.Version" }, + ["LuaTeX.Functionality"] = { "metadata","rdf:Description/pdfx:LuaTeX.Functionality" }, + ["LuaTeX.LuaVersion"] = { "metadata","rdf:Description/pdfx:LuaTeX.LuaVersion" }, + ["LuaTeX.Platform"] = { "metadata","rdf:Description/pdfx:LuaTeX.Platform" }, + ["ID"] = { "id", "rdf:Description/pdfx:ID" }, -- has date -- Adobe PDF schema - ["Keywords"] = { "metadata","rdf:Description/pdf:Keywords" }, - ["Producer"] = { "metadata","rdf:Description/pdf:Producer" }, - -- ["Trapped"] = { "pdf", "rdf:Description/pdf:Trapped" }, -- '/False' in /Info, but 'False' in XMP + ["Keywords"] = { "metadata","rdf:Description/pdf:Keywords" }, + ["Producer"] = { "metadata","rdf:Description/pdf:Producer" }, + -- ["Trapped"] = { "pdf", "rdf:Description/pdf:Trapped" }, -- '/False' in /Info, but 'False' in XMP -- Dublin Core schema - ["Author"] = { "metadata","rdf:Description/dc:creator/rdf:Seq/rdf:li" }, - ["Format"] = { "metadata","rdf:Description/dc:format" }, -- optional, but nice to have - ["Subject"] = { "metadata","rdf:Description/dc:description/rdf:Alt/rdf:li" }, - ["Title"] = { "metadata","rdf:Description/dc:title/rdf:Alt/rdf:li" }, + ["Author"] = { "metadata","rdf:Description/dc:creator/rdf:Seq/rdf:li" }, + ["Format"] = { "metadata","rdf:Description/dc:format" }, -- optional, but nice to have + ["Subject"] = { "metadata","rdf:Description/dc:description/rdf:Alt/rdf:li" }, + ["Title"] = { "metadata","rdf:Description/dc:title/rdf:Alt/rdf:li" }, -- XMP Basic schema - ["CreateDate"] = { "date", "rdf:Description/xmp:CreateDate" }, - ["CreationDate"] = { "date", "rdf:Description/xmp:CreationDate" }, -- dummy - ["Creator"] = { "metadata","rdf:Description/xmp:CreatorTool" }, - ["MetadataDate"] = { "date", "rdf:Description/xmp:MetadataDate" }, - ["ModDate"] = { "date", "rdf:Description/xmp:ModDate" }, -- dummy - ["ModifyDate"] = { "date", "rdf:Description/xmp:ModifyDate" }, + ["CreateDate"] = { "date", "rdf:Description/xmp:CreateDate" }, + ["CreationDate"] = { "date", "rdf:Description/xmp:CreationDate" }, -- dummy + ["Creator"] = { "metadata","rdf:Description/xmp:CreatorTool" }, + ["MetadataDate"] = { "date", "rdf:Description/xmp:MetadataDate" }, + ["ModDate"] = { "date", "rdf:Description/xmp:ModDate" }, -- dummy + ["ModifyDate"] = { "date", "rdf:Description/xmp:ModifyDate" }, -- XMP Media Management schema - ["DocumentID"] = { "id", "rdf:Description/xmpMM:DocumentID" }, -- uuid - ["InstanceID"] = { "id", "rdf:Description/xmpMM:InstanceID" }, -- uuid - ["RenditionClass"] = { "pdf", "rdf:Description/xmpMM:RenditionClass" }, -- PDF/X-4 - ["VersionID"] = { "pdf", "rdf:Description/xmpMM:VersionID" }, -- PDF/X-4 + ["DocumentID"] = { "id", "rdf:Description/xmpMM:DocumentID" }, -- uuid + ["InstanceID"] = { "id", "rdf:Description/xmpMM:InstanceID" }, -- uuid + ["RenditionClass"] = { "pdf", "rdf:Description/xmpMM:RenditionClass" }, -- PDF/X-4 + ["VersionID"] = { "pdf", "rdf:Description/xmpMM:VersionID" }, -- PDF/X-4 -- additional entries -- PDF/X - ["GTS_PDFXVersion"] = { "pdf", "rdf:Description/pdfxid:GTS_PDFXVersion" }, + ["GTS_PDFXVersion"] = { "pdf", "rdf:Description/pdfxid:GTS_PDFXVersion" }, -- optional entries -- all what is visible in the 'document properties --> additional metadata' window -- XMP Rights Management schema (optional) - ["Marked"] = { "pdf", "rdf:Description/xmpRights:Marked" }, - -- ["Owner"] = { "metadata", "rdf:Description/xmpRights:Owner/rdf:Bag/rdf:li" }, -- maybe useful (not visible) - -- ["UsageTerms"] = { "metadata", "rdf:Description/xmpRights:UsageTerms" }, -- maybe useful (not visible) - ["WebStatement"] = { "metadata", "rdf:Description/xmpRights:WebStatement" }, + ["Marked"] = { "pdf", "rdf:Description/xmpRights:Marked" }, + -- ["Owner"] = { "metadata", "rdf:Description/xmpRights:Owner/rdf:Bag/rdf:li" }, -- maybe useful (not visible) + -- ["UsageTerms"] = { "metadata", "rdf:Description/xmpRights:UsageTerms" }, -- maybe useful (not visible) + ["WebStatement"] = { "metadata", "rdf:Description/xmpRights:WebStatement" }, -- Photoshop PDF schema (optional) - ["AuthorsPosition"] = { "metadata", "rdf:Description/photoshop:AuthorsPosition" }, - ["Copyright"] = { "metadata", "rdf:Description/photoshop:Copyright" }, - ["CaptionWriter"] = { "metadata", "rdf:Description/photoshop:CaptionWriter" }, + ["AuthorsPosition"] = { "metadata", "rdf:Description/photoshop:AuthorsPosition" }, + ["Copyright"] = { "metadata", "rdf:Description/photoshop:Copyright" }, + ["CaptionWriter"] = { "metadata", "rdf:Description/photoshop:CaptionWriter" }, } pdf.setsuppressoptionalinfo( @@ -100,6 +107,12 @@ local included = backends.included local pdfsettrailerid = pdf.settrailerid +local lpdfid = lpdf.id + +function lpdf.id() -- overload of ini + return lpdfid(included.date) +end + pdf.disablecommand("settrailerid") function lpdf.settrailerid(v) @@ -144,14 +157,6 @@ function lpdf.setdates(v) end end -function lpdf.id() -- overload of ini - local banner = tex.jobname - if included.date then - return format("%s.%s",banner,lpdf.timestamp()) - else - return banner - end -end directives.register("backend.trailerid", lpdf.settrailerid) directives.register("backend.date", lpdf.setdates) @@ -251,38 +256,36 @@ local function flushxmpinfo() commands.pushrandomseed() commands.setrandomseed(os.time()) - local version = status.luatex_version - local revision = status.luatex_revision - local documentid = "no unique document id here" local instanceid = "no unique instance id here" - -- local producer = format("LuaTeX-%i.%02i.%s",math.div(version,100),math.mod(version,100),revision) - local producer = format("LuaTeX-%0.2f.%s",version/100,revision) - local creator = "LuaTeX + ConTeXt MkIV" - local time = lpdf.timestamp() - local fullbanner = status.banner + local metadata = pdfgetmetadata() + local time = metadata.time + local producer = metadata.producer + local creator = metadata.creator if included.id ~= "fake" then documentid = "uuid:" .. os.uuid() instanceid = "uuid:" .. os.uuid() end - pdfaddtoinfo("Producer", producer) - pdfaddtoinfo("Creator", creator) - pdfaddtoinfo("CreationDate", time) - pdfaddtoinfo("ModDate", time) - -- pdfaddtoinfo("PTEX.Fullbanner", fullbanner) -- no checking done on existence + pdfaddtoinfo("Producer",producer) + pdfaddtoinfo("Creator",creator) + pdfaddtoinfo("CreationDate",time) + pdfaddtoinfo("ModDate",time) if add_xmp_blob then - pdfaddxmpinfo("DocumentID", documentid) - pdfaddxmpinfo("InstanceID", instanceid) - pdfaddxmpinfo("Producer", producer) - pdfaddxmpinfo("CreatorTool", creator) - pdfaddxmpinfo("CreateDate", time) - pdfaddxmpinfo("ModifyDate", time) - pdfaddxmpinfo("MetadataDate", time) - pdfaddxmpinfo("PTEX.Fullbanner", fullbanner) + pdfaddxmpinfo("DocumentID",documentid) + pdfaddxmpinfo("InstanceID",instanceid) + pdfaddxmpinfo("Producer",producer) + pdfaddxmpinfo("CreatorTool",creator) + pdfaddxmpinfo("CreateDate",time) + pdfaddxmpinfo("ModifyDate",time) + pdfaddxmpinfo("MetadataDate",time) + pdfaddxmpinfo("LuaTeX.Version",metadata.luatexversion) + pdfaddxmpinfo("LuaTeX.Functionality",metadata.luatexfunctionality) + pdfaddxmpinfo("LuaTeX.LuaVersion",metadata.luaversion) + pdfaddxmpinfo("LuaTeX.Platform",metadata.platform) local blob = xml.tostring(xml.first(xmp or valid_xmp(),"/x:xmpmeta")) local md = pdfdictionary { diff --git a/tex/context/base/mkiv/sort-ini.lua b/tex/context/base/mkiv/sort-ini.lua index 7cd28d08f..f90b70be5 100644 --- a/tex/context/base/mkiv/sort-ini.lua +++ b/tex/context/base/mkiv/sort-ini.lua @@ -53,14 +53,15 @@ have language etc properties that then can be used.

local gsub, find, rep, sub, sort, concat, tohash, format = string.gsub, string.find, string.rep, string.sub, table.sort, table.concat, table.tohash, string.format local utfbyte, utfchar, utfcharacters, utfvalues = utf.byte, utf.char, utf.characters, utf.values local next, type, tonumber, rawget, rawset = next, type, tonumber, rawget, rawset -local P, Cs, R, S, lpegmatch = lpeg.P, lpeg.Cs, lpeg.R, lpeg.S, lpeg.match +local P, Cs, R, S, lpegmatch, lpegpatterns = lpeg.P, lpeg.Cs, lpeg.R, lpeg.S, lpeg.match, lpeg.patterns local allocate = utilities.storage.allocate local setmetatableindex = table.setmetatableindex -local trace_tests = false trackers.register("sorters.tests", function(v) trace_tests = v end) -local trace_methods = false trackers.register("sorters.methods", function(v) trace_methods = v end) -local trace_orders = false trackers.register("sorters.orders", function(v) trace_orders = v end) +local trace_tests = false trackers.register("sorters.tests", function(v) trace_tests = v end) +local trace_methods = false trackers.register("sorters.methods", function(v) trace_methods = v end) +local trace_orders = false trackers.register("sorters.orders", function(v) trace_orders = v end) +local trace_replacements= false trackers.register("sorters.replacements", function(v) trace_replacements = v end) local report_sorters = logs.reporter("languages","sorters") @@ -523,7 +524,7 @@ local function prepare() -- todo: test \Ux{hex} return pattern end -function sorters.strip(str) -- todo: only letters and such +local function strip(str) -- todo: only letters and such if str and str ~= "" then return lpegmatch(pattern or prepare(),str) else @@ -531,6 +532,8 @@ function sorters.strip(str) -- todo: only letters and such end end +sorters.strip = strip + local function firstofsplit(entry) -- numbers are left padded by spaces local split = entry.split @@ -553,15 +556,35 @@ sorters.firstofsplit = firstofsplit -- we know what combinations make sense we can optimize this function splitters.utf(str,checked) -- we could append m and u but this is cleaner, s is for tracing - if #replacements > 0 then + local nofreplacements = #replacements + if nofreplacements > 0 then -- todo make an lpeg for this - for k=1,#replacements do - local v = replacements[k] - local s = v[1] - if find(str,s) then - str = gsub(str,s,v[2]) + local replacer = replacements.replacer + if not replacer then + local rep = { } + for i=1,nofreplacements do + local r = replacements[i] + rep[strip(r[1])] = strip(r[2]) + end + replacer = lpeg.utfchartabletopattern(rep) + replacer = Cs((replacer/rep + lpegpatterns.utf8character)^0) + replacements.replacer = replacer + end + local rep = lpegmatch(replacer,str) + if rep and rep ~= str then + if trace_replacements then + report_sorters("original : %s",str) + report_sorters("replacement: %s",rep) end + str = rep end + -- for k=1,#replacements do + -- local v = replacements[k] + -- local s = v[1] + -- if find(str,s) then + -- str = gsub(str,s,v[2]) + -- end + -- end end local m_case, z_case, p_case, m_mapping, z_mapping, p_mapping, char, byte, n = { }, { }, { }, { }, { }, { }, { }, { }, 0 local nm, nz, np = 0, 0, 0 @@ -797,3 +820,16 @@ function sorters.sort(entries,cmp) end) end end + +-- helper + +function sorters.replacementlist(list) + local replacements = { } + for i=1,#list do + replacements[i] = { + list[i], + utfchar(replacementoffset+i), + } + end + return replacements +end diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf index 4bb82edcf..6e2441929 100644 Binary files a/tex/context/base/mkiv/status-files.pdf and b/tex/context/base/mkiv/status-files.pdf differ diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf index 8deebb2ec..13610af00 100644 Binary files a/tex/context/base/mkiv/status-lua.pdf and b/tex/context/base/mkiv/status-lua.pdf differ diff --git a/tex/context/base/mkiv/trac-log.lua b/tex/context/base/mkiv/trac-log.lua index c7b6f6d2d..b0da12715 100644 --- a/tex/context/base/mkiv/trac-log.lua +++ b/tex/context/base/mkiv/trac-log.lua @@ -10,7 +10,6 @@ if not modules then modules = { } end modules ['trac-log'] = { -- terminal handler in lua then. Ok, maybe it's slower then, so a no-go. local next, type, select, print = next, type, select, print -local write_nl, write = texio and texio.write_nl or print, texio and texio.write or io.write local format, gmatch, find = string.format, string.gmatch, string.find local concat, insert, remove = table.concat, table.insert, table.remove local topattern = string.topattern @@ -18,6 +17,14 @@ local utfchar = utf.char local datetime = os.date local openfile = io.open +local runningtex = tex and (tex.jobname or tex.formatname) + +-- local write_nl = texio and texio.write_nl or print +-- local write = texio and texio.write or io.write + +local write_nl = runningtex and texio and texio.write_nl or print +local write = runningtex and texio and texio.write or io.write + local setmetatableindex = table.setmetatableindex local formatters = string.formatters local settings_to_hash = utilities.parsers.settings_to_hash @@ -108,7 +115,7 @@ local direct, subdirect, writer, pushtarget, poptarget, setlogfile, settimedlog, -- we don't want this overhead for single messages (not that there are that -- many; we could have a special weak table) -if tex and (tex.jobname or tex.formatname) then +if runningtex then if texio.setescape then texio.setescape(0) -- or (false) diff --git a/tex/context/base/mkiv/util-lua.lua b/tex/context/base/mkiv/util-lua.lua index bd74d0843..b7de11936 100644 --- a/tex/context/base/mkiv/util-lua.lua +++ b/tex/context/base/mkiv/util-lua.lua @@ -42,7 +42,7 @@ luautilities.suffixes = { -- environment.loadpreprocessedfile can be set to a preprocessor -local function register(name) +local function register(name) -- makes no sense runtime if tracestripping then report_lua("stripped bytecode from %a",name or "unknown") end @@ -75,18 +75,12 @@ end function luautilities.loadedluacode(fullname,forcestrip,name,macros) -- quite subtle ... doing this wrong incidentally can give more bytes name = name or fullname - local code, message if macros then macros = lua.macros end - if macros and macros.enabled then - -- local c = io.loaddata(fullname) -- not yet available - local f = io.open(fullname,"rb") local c = f:read("*a") f:close() - local n = c and macros.resolvestring("--[["..fullname.."]] "..c) - if n and #n ~= #c then - report_lua("preprocessed file %a: %i => %i bytes",fullname,#c,#n) - end - code, message = load(n or c) + local code, message + if macros then + code, message = macros.loaded(fullname,true,false) else code, message = loadfile(fullname) end diff --git a/tex/context/base/mkiv/util-sql-imp-ffi.lua b/tex/context/base/mkiv/util-sql-imp-ffi.lua index 07c4752cd..2a2bc6569 100644 --- a/tex/context/base/mkiv/util-sql-imp-ffi.lua +++ b/tex/context/base/mkiv/util-sql-imp-ffi.lua @@ -365,10 +365,10 @@ local function connect(session,specification) end local function error_in_connection(specification,action) - report_state("error in connection: [%s] %s@%s to %s:%s", + report_state("error in connection: [%s] user %s into %s at %s:%s", action or "unknown", - specification.database or "no database", specification.username or "no username", + specification.database or "no database", specification.host or "no host", specification.port or "no port" ) diff --git a/tex/context/interface/mkiv/i-context.pdf b/tex/context/interface/mkiv/i-context.pdf index bdcfefbb0..97254d3ef 100644 Binary files a/tex/context/interface/mkiv/i-context.pdf and b/tex/context/interface/mkiv/i-context.pdf differ diff --git a/tex/context/interface/mkiv/i-readme.pdf b/tex/context/interface/mkiv/i-readme.pdf index 644b9336e..1a8314fe2 100644 Binary files a/tex/context/interface/mkiv/i-readme.pdf and b/tex/context/interface/mkiv/i-readme.pdf differ diff --git a/tex/context/modules/mkiv/s-fonts-shapes.lua b/tex/context/modules/mkiv/s-fonts-shapes.lua index ebdf04c22..748c5a92a 100644 --- a/tex/context/modules/mkiv/s-fonts-shapes.lua +++ b/tex/context/modules/mkiv/s-fonts-shapes.lua @@ -109,12 +109,9 @@ local characters = nil local function showglyphshape(specification) specification = interfaces.checkedspecification(specification) - local id, cs = fonts.definers.internal(specification,"") + local id, cs = fonts.definers.internal(specification,"") local tfmdata = fontdata[id] - local charnum = tonumber(specification.character) - if not charnum then - charnum = fonts.helpers.nametoslot(specification.character) - end + local charnum = tonumber(specification.character) or fonts.helpers.nametoslot(specification.character) local characters = tfmdata.characters local descriptions = tfmdata.descriptions local parameters = tfmdata.parameters @@ -133,64 +130,75 @@ local function showglyphshape(specification) context.startMPcode() context("numeric lw ; lw := .125bp ;") context("pickup pencircle scaled lw ;") - context('picture p ; p := image(draw textext.drt("\\getuvalue{%s}\\gray\\char%s");); draw p ;',cs,charnum) + if width < 0.01 then + -- catches zero width marks + context('picture p ; p := textext.drt("\\hskip5sp\\getuvalue{%s}\\gray\\char%s"); draw p ;',cs,charnum) + else + context('picture p ; p := textext.drt("\\getuvalue{%s}\\gray\\char%s"); draw p ;',cs,charnum) + end context('draw (%s,%s)--(%s,%s)--(%s,%s)--(%s,%s)--cycle withcolor green ;',llx,lly,urx,lly,urx,ury,llx,ury) context('draw (%s,%s)--(%s,%s) withcolor green ;',llx,0,urx,0) context('draw boundingbox p withcolor .2white withpen pencircle scaled .065bp ;') context("defaultscale := 0.05 ; ") -- inefficient but non critical - local function slant_1(v,dx,dy,txt,xsign,ysign,loc,labloc) - if #v > 0 then - local l = { } - for kk, vv in ipairs(v) do - local h, k = vv.height or 0, vv.kern or 0 - if h and k then - l[#l+1] = formatters["((%s,%s) shifted (%s,%s))"](xsign*k*factor,ysign*h*factor,dx,dy) + local slant = { + function(v,dx,dy,txt,xsign,ysign,loc,labloc) + local n = #v + if n > 0 then + local l = { } + for i=1,n do + local c = v[i] + local h = c.height or 0 + local k = c.kern or 0 + l[i] = formatters["((%s,%s) shifted (%s,%s))"](xsign*k*factor,ysign*h*factor,dx,dy) end - end - context("draw ((%s,%s) shifted (%s,%s))--%s dashed (evenly scaled 1/16) withcolor .5white;", xsign*v[1].kern*factor,lly,dx,dy,l[1]) - context("draw laddered (%s) withcolor .5white ;",table.concat(l,"..")) - context("draw ((%s,%s) shifted (%s,%s))--%s dashed (evenly scaled 1/16) withcolor .5white;", xsign*v[#v].kern*factor,ury,dx,dy,l[#l]) - for k, v in ipairs(l) do - context("draw %s withcolor blue withpen pencircle scaled 2lw ;",v) - end - end - end - local function slant_2(v,dx,dy,txt,xsign,ysign,loc,labloc) - if #v > 0 then - local l = { } - for kk, vv in ipairs(v) do - local h, k = vv.height or 0, vv.kern or 0 - if h and k then - l[#l+1] = formatters["((%s,%s) shifted (%s,%s))"](xsign*k*factor,ysign*h*factor,dx,dy) + context("draw ((%s,%s) shifted (%s,%s))--%s dashed (evenly scaled 1/16) withcolor .5white;", xsign*v[1].kern*factor,lly,dx,dy,l[1]) +-- context("draw laddered (%s) withcolor .5white ;",table.concat(l,"..")) + context("draw laddered (%..t) withcolor .5white ;",l) + context("draw ((%s,%s) shifted (%s,%s))--%s dashed (evenly scaled 1/16) withcolor .5white;", xsign*v[#v].kern*factor,ury,dx,dy,l[#l]) + for i=1,n do + context("draw %s withcolor blue withpen pencircle scaled 2lw ;",l[i]) end end - if loc == "top" then - context('label.%s("\\type{%s}",%s shifted (0,-1bp)) ;',loc,txt,l[#l]) - else - context('label.%s("\\type{%s}",%s shifted (0,2bp)) ;',loc,txt,l[1]) - end - for kk, vv in ipairs(v) do - local h, k = vv.height or 0, vv.kern or 0 - if h and k then - context('label.top("(%s,%s)",%s shifted (0,-2bp));',k,h,l[kk]) + end, + function(v,dx,dy,txt,xsign,ysign,loc,labloc) + local n = #v + if n > 0 then + local l = { } + for i=1,n do + local c = v[i] + local h = c.height or 0 + local k = c.kern or 0 + l[i] = formatters["((%s,%s) shifted (%s,%s))"](xsign*k*factor,ysign*h*factor,dx,dy) + end + if loc == "top" then + context('label.%s("\\type{%s}",%s shifted (0,-1bp)) ;',loc,txt,l[n]) + else + context('label.%s("\\type{%s}",%s shifted (0,2bp)) ;',loc,txt,l[1]) + end + for i=1,n do + local c = v[i] + local h = c.height or 0 + local k = c.kern or 0 + context('label.top("(%s,%s)",%s shifted (0,-2bp));',k,h,l[i]) end end - end - end + end, + } if math then local kerns = math.kerns if kerns then - for _, slant in ipairs { slant_1, slant_2 } do - for k,v in pairs(kerns) do + for i=1,#slant do + local s = slant[i] + for k, v in next, kerns do if k == "topright" then - slant(v,width+italic,0,k,1,1,"top","ulft") + s(v,width+italic,0,k,1,1,"top","ulft") elseif k == "bottomright" then - slant(v,width,0,k,1,1,"bot","lrt") + s(v,width,0,k,1,1,"bot","lrt") elseif k == "topleft" then - slant(v,0,0,k,-1,1,"top","ulft") + s(v,0,0,k,-1,1,"top","ulft") elseif k == "bottomleft" then - slant(v,0,0,k,-1,1,"bot","lrt") + s(v,0,0,k,-1,1,"bot","lrt") end end end @@ -205,33 +213,34 @@ local function showglyphshape(specification) if anchors then local a = anchors.baselig if a then - for k, v in pairs(a) do - for kk, vv in ipairs(v) do - show(vv[1],vv[2],k .. ":" .. kk) + for k, v in next, a do + for i=1,#v do + local p = v[i] + show(p[1],p[2],k .. ":" .. i) end end end local a = anchors.mark if a then - for k, v in pairs(a) do + for k, v in next, a do show(v[1],v[2],k) end end local a = anchors.basechar if a then - for k, v in pairs(a) do + for k, v in next, a do show(v[1],v[2],k) end end local ba = anchors.centry if a then - for k, v in pairs(a) do + for k, v in next, a do show(v[1],v[2],k) end end local a = anchors.cexit if a then - for k, v in pairs(a) do + for k, v in next, a do show(v[1],v[2],k) end end diff --git a/tex/context/modules/mkiv/s-fonts-shapes.mkiv b/tex/context/modules/mkiv/s-fonts-shapes.mkiv index 4a0377ada..53ed1b426 100644 --- a/tex/context/modules/mkiv/s-fonts-shapes.mkiv +++ b/tex/context/modules/mkiv/s-fonts-shapes.mkiv @@ -109,7 +109,11 @@ % \startTEXpage[offset=0pt]\ShowGlyphShape{name:cambria-math}{50bp}{0x1D45D}\stopTEXpage % \page -\showallglyphshapes[name=name:cambria-math,size=100bp] +\startTEXpage[offset=0pt]\ShowGlyphShape{file:husayninotebold.ttf}{50bp}{0xF034A}\stopTEXpage +\startTEXpage[offset=0pt]\ShowGlyphShape{file:husayninotebold.ttf}{50bp}{0x006DD}\stopTEXpage + +% \showallglyphshapes[name=name:cambria-math,size=100bp] +% \showallglyphshapes[name=file:husayninotebold.ttf,size=100bp] % \showallglyphshapes[name=name:dejavuserif,size=100bp] % \showallglyphshapes[name=file:brill.otf,size=100bp] diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index de4458dda..5e9caf71e 100644 --- a/tex/generic/context/luatex/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : c:/data/develop/context/sources/luatex-fonts-merged.lua -- parent file : c:/data/develop/context/sources/luatex-fonts.lua --- merge date : 03/21/18 09:16:30 +-- merge date : 03/22/18 19:41:33 do -- begin closure to overcome local limits and interference @@ -23720,7 +23720,7 @@ function handlers.gpos_pair(head,start,dataset,sequence,kerns,rlmode,skiphash,st elseif b then local x,y,w,h=setposition(2,snext,factor,rlmode,b,injection) if trace_kerns then - local startchar=getchar(snext) + local startchar=getchar(start) logprocess("%s: shifting second of pair %s and %s by xy (%p,%p) and wh (%p,%p) as %s",pref(dataset,sequence),gref(startchar),gref(nextchar),x,y,w,h,injection or "injections") end start=snext -- cgit v1.2.3