From 99dc1cd9bb77ac9fa68b0584f58f57749994fdba Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Thu, 7 Feb 2019 19:16:06 +0100 Subject: 2019-02-07 18:55:00 --- tex/context/base/mkii/cont-new.mkii | 2 +- tex/context/base/mkii/context.mkii | 2 +- tex/context/base/mkii/mult-it.mkii | 1 + tex/context/base/mkii/syst-rtp.mkiv | 18 -- tex/context/base/mkiv/cldf-ini.lua | 26 +++ tex/context/base/mkiv/cont-new.mkiv | 2 +- tex/context/base/mkiv/cont-run.lua | 2 +- tex/context/base/mkiv/context.mkiv | 2 +- tex/context/base/mkiv/font-con.lua | 22 ++- tex/context/base/mkiv/font-nod.lua | 3 - tex/context/base/mkiv/lpdf-ini.lua | 4 +- tex/context/base/mkiv/lpdf-nod.lua | 129 +++++++++---- tex/context/base/mkiv/luat-cod.lua | 4 + tex/context/base/mkiv/luat-ini.lua | 2 + tex/context/base/mkiv/luat-run.lua | 66 ++++--- tex/context/base/mkiv/metatex.tex | 30 --- tex/context/base/mkiv/mult-def.lua | 3 + tex/context/base/mkiv/node-ini.lua | 28 +-- tex/context/base/mkiv/node-nut.lua | 12 +- tex/context/base/mkiv/node-res.lua | 24 ++- tex/context/base/mkiv/page-run.mkiv | 1 + tex/context/base/mkiv/spac-ver.mkiv | 6 +- tex/context/base/mkiv/status-files.pdf | Bin 26072 -> 26075 bytes tex/context/base/mkiv/status-lua.pdf | Bin 269360 -> 269440 bytes tex/context/base/mkiv/syst-rtp.mkiv | 18 ++ tex/context/base/mkiv/typo-dha.lua | 2 +- tex/context/base/mkiv/typo-dir.mkiv | 10 +- tex/context/base/mkiv/typo-dua.lua | 74 ++++---- tex/context/base/mkiv/typo-dub.lua | 201 +++++++-------------- tex/context/base/mkiv/typo-duc.lua | 59 +++--- tex/context/base/mkiv/util-str.lua | 13 ++ tex/context/interface/mkii/keys-it.xml | 1 + tex/context/interface/mkiv/context-en.xml | 5 +- tex/context/interface/mkiv/i-columns.xml | 6 +- tex/context/interface/mkiv/i-context.pdf | Bin 864662 -> 864764 bytes tex/context/interface/mkiv/i-grid.xml | 3 +- tex/context/interface/mkiv/i-readme.pdf | Bin 60777 -> 60778 bytes tex/generic/context/luatex/luatex-basics-nod.lua | 7 +- tex/generic/context/luatex/luatex-fonts-merged.lua | 27 ++- 39 files changed, 424 insertions(+), 391 deletions(-) delete mode 100644 tex/context/base/mkii/syst-rtp.mkiv delete mode 100644 tex/context/base/mkiv/metatex.tex create mode 100644 tex/context/base/mkiv/syst-rtp.mkiv (limited to 'tex') diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii index b67ac9678..5fefb3bd0 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{2019.01.28 16:58} +\newcontextversion{2019.02.07 18:46} %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 44e420c5d..7d6fc66d4 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{2019.01.28 16:58} +\edef\contextversion{2019.02.07 18:46} %D For those who want to use this: diff --git a/tex/context/base/mkii/mult-it.mkii b/tex/context/base/mkii/mult-it.mkii index 0b5ab2382..d83672d38 100644 --- a/tex/context/base/mkii/mult-it.mkii +++ b/tex/context/base/mkii/mult-it.mkii @@ -587,6 +587,7 @@ \setinterfacevariable{understrike}{understrike} \setinterfacevariable{understrikes}{understrikes} \setinterfacevariable{unframed}{unframed} +\setinterfacevariable{unicode}{unicode} \setinterfacevariable{unit}{unita} \setinterfacevariable{units}{unita} \setinterfacevariable{unknown}{ignoto} diff --git a/tex/context/base/mkii/syst-rtp.mkiv b/tex/context/base/mkii/syst-rtp.mkiv deleted file mode 100644 index 82c0778b4..000000000 --- a/tex/context/base/mkii/syst-rtp.mkiv +++ /dev/null @@ -1,18 +0,0 @@ -%D \module -%D [ file=syst-rtp, -%D version=2006.10.13, -%D title=\CONTEXT\ Core Macros, -%D subtitle=Run Time Processes, -%D author=Hans Hagen, -%D date=\currentdate, -%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] -%C -%C This module is part of the \CONTEXT\ macro||package and is -%C therefore copyrighted by \PRAGMA. See mreadme.pdf for -%C details. - -\unprotect - -\let\executesystemcommand\clf_execute - -\protect \endinput diff --git a/tex/context/base/mkiv/cldf-ini.lua b/tex/context/base/mkiv/cldf-ini.lua index 0f90f058e..489ed1158 100644 --- a/tex/context/base/mkiv/cldf-ini.lua +++ b/tex/context/base/mkiv/cldf-ini.lua @@ -6,6 +6,8 @@ if not modules then modules = { } end modules ['cldf-ini'] = { license = "see context related readme files" } +-- todo: {token} -> 3 tokens + -- This started as an experiment: generating context code at the lua end. After all -- it is surprisingly simple to implement due to metatables. I was wondering if -- there was a more natural way to deal with commands at the lua end. Of course it's @@ -899,6 +901,30 @@ if tokenflushmode then -- combine them return f end) +-- core = setmetatableindex(function(parent,k) +-- local t +-- local f = function(first,...) +-- if not t then +-- t = toks[k] +-- end +-- local f = function(first,...) +-- if first == nil then +-- flush(t) +-- else +-- return writer(context,t,first,...) +-- end +-- end +-- parent[k] = f +-- if first == nil then +-- flush(t) +-- else +-- return writer(context,t,first,...) +-- end +-- end +-- parent[k] = f +-- return f +-- end) + core.cs = setmetatableindex(function(parent,k) local t local f = function() diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index 898068167..e2844174a 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{2019.01.28 16:58} +\newcontextversion{2019.02.07 18:46} %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/cont-run.lua b/tex/context/base/mkiv/cont-run.lua index c8030bf39..2ffbd24dd 100644 --- a/tex/context/base/mkiv/cont-run.lua +++ b/tex/context/base/mkiv/cont-run.lua @@ -197,7 +197,7 @@ local preparejob preparejob = function() -- tricky: we need a hook for this local arguments = environment.arguments - if arguments.lmtx or not status.obj_ptr then + if arguments.lmtx or CONTEXTLMTXMODE then report("enabling lmtx mode") context.enablelmtx() environment.lmtxmode = true diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv index b146002d0..13b91f50b 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{2019.01.28 16:58} +\edef\contextversion{2019.02.07 18:46} \edef\contextkind {beta} %D For those who want to use this: diff --git a/tex/context/base/mkiv/font-con.lua b/tex/context/base/mkiv/font-con.lua index 81ea7c859..9f85ee208 100644 --- a/tex/context/base/mkiv/font-con.lua +++ b/tex/context/base/mkiv/font-con.lua @@ -49,6 +49,8 @@ constructors.cache = containers.define("fonts", "constructors", constr constructors.privateoffset = fonts.privateoffsets.textbase or 0xF0000 constructors.cacheintex = true -- so we see the original table in fonts.font +constructors.addtounicode = true + -- This might become an interface: local designsizes = allocate() @@ -424,6 +426,8 @@ function constructors.scale(tfmdata,specification) targetparameters.forcedsize = forcedsize -- context specific targetparameters.extrafactor = extrafactor -- context specific -- + local addtounicode = constructors.addtounicode + -- local tounicode = fonts.mappings.tounicode local unknowncode = tounicode(0xFFFD) -- @@ -736,13 +740,19 @@ function constructors.scale(tfmdata,specification) end end local isunicode = description.unicode - if isunicode then - chr.unicode = isunicode - chr.tounicode = tounicode(isunicode) - -- in luatex > 0.85 we can do this: - -- chr.tounicode = isunicode + if addtounicode then + if isunicode then + chr.unicode = isunicode + chr.tounicode = tounicode(isunicode) + -- in luatex > 0.85 we can do this: + -- chr.tounicode = isunicode + else + chr.tounicode = unknowncode + end else - chr.tounicode = unknowncode + if isunicode then + chr.unicode = isunicode + end end if hasquality then -- we could move these calculations elsewhere (saves calculations) diff --git a/tex/context/base/mkiv/font-nod.lua b/tex/context/base/mkiv/font-nod.lua index f878f1e50..6beaef469 100644 --- a/tex/context/base/mkiv/font-nod.lua +++ b/tex/context/base/mkiv/font-nod.lua @@ -97,9 +97,6 @@ local fontparameters = hashes.parameters local properties = nodes.properties.data --- direct.set_properties_mode(true,false) --- direct.set_properties_mode(true,true) -- default - local function freeze(h,where) for n in nextnode, h do -- todo: disc but not traced anyway local p = properties[n] diff --git a/tex/context/base/mkiv/lpdf-ini.lua b/tex/context/base/mkiv/lpdf-ini.lua index 055356a4b..c502f3f72 100644 --- a/tex/context/base/mkiv/lpdf-ini.lua +++ b/tex/context/base/mkiv/lpdf-ini.lua @@ -535,7 +535,9 @@ do r[n] = k end end - sort(r) + if n > 1 then + sort(r) + end for i=1,n do local k = r[i] local v = t[k] diff --git a/tex/context/base/mkiv/lpdf-nod.lua b/tex/context/base/mkiv/lpdf-nod.lua index 05736a79f..9d4bf9270 100644 --- a/tex/context/base/mkiv/lpdf-nod.lua +++ b/tex/context/base/mkiv/lpdf-nod.lua @@ -81,45 +81,83 @@ local function tomatrix(rx,sx,sy,ry,tx,ty) -- todo: tx ty end end -local pdforiginliteral = register(new_node(whatsit_code, literalwhatsit_code)) setfield(pdforiginliteral,"mode",originliteral_code) -local pdfpageliteral = register(new_node(whatsit_code, literalwhatsit_code)) setfield(pdfpageliteral, "mode",pageliteral_code) -local pdfdirectliteral = register(new_node(whatsit_code, literalwhatsit_code)) setfield(pdfdirectliteral,"mode",directliteral_code) -local pdfrawliteral = register(new_node(whatsit_code, literalwhatsit_code)) setfield(pdfrawliteral, "mode",rawliteral_code) - -local pdfsave = register(new_node(whatsit_code, savewhatsit_code)) -local pdfrestore = register(new_node(whatsit_code, restorewhatsit_code)) -local pdfsetmatrix = register(new_node(whatsit_code, setmatrixwhatsit_code)) - -function nodepool.pdforiginliteral(str) local t = copy_node(pdforiginliteral) setdata(t,str) return t end -function nodepool.pdfpageliteral (str) local t = copy_node(pdfpageliteral ) setdata(t,str) return t end -function nodepool.pdfdirectliteral(str) local t = copy_node(pdfdirectliteral) setdata(t,str) return t end -function nodepool.pdfrawliteral (str) local t = copy_node(pdfrawliteral ) setdata(t,str) return t end - -local pdfliterals = { - -- by number - [originliteral_code] = pdforiginliteral, - [pageliteral_code] = pdfpageliteral, - [directliteral_code] = pdfdirectliteral, - [rawliteral_code] = pdfrawliteral, - -- by name - [literalvalues[originliteral_code]] = pdforiginliteral, - [literalvalues[pageliteral_code]] = pdfpageliteral, - [literalvalues[directliteral_code]] = pdfdirectliteral, - [literalvalues[rawliteral_code]] = pdfrawliteral, -} +if CONTEXTLMTXMODE then -function nodepool.pdfliteral(mode,str) - if str then - local t = copy_node(pdfliterals[mode] or pdfpageliteral) - setdata(t,str) - return t - else - local t = copy_node(pdfpageliteral) - setdata(t,mode) + local nodeproperties = nodes.properties.data + + local pdfliteral = register(new_node(whatsit_code,literalwhatsit_code)) + + function nodepool.pdforiginliteral(str) local t = copy_node(pdfliteral) nodeproperties[t] = { data = str, mode = originliteral_code } return t end + function nodepool.pdfpageliteral (str) local t = copy_node(pdfliteral) nodeproperties[t] = { data = str, mode = pageliteral_code } return t end + function nodepool.pdfdirectliteral(str) local t = copy_node(pdfliteral) nodeproperties[t] = { data = str, mode = directliteral_code } return t end + function nodepool.pdfrawliteral (str) local t = copy_node(pdfliteral) nodeproperties[t] = { data = str, mode = rawliteral_code } return t end + + local pdfliterals = { + -- by number + [originliteral_code] = originliteral_code, + [pageliteral_code] = pageliteral_code, + [directliteral_code] = directliteral_code, + [rawliteral_code] = rawliteral_code, + -- by name + [literalvalues[originliteral_code]] = originliteral_code, + [literalvalues[pageliteral_code]] = pageliteral_code, + [literalvalues[directliteral_code]] = directliteral_code, + [literalvalues[rawliteral_code]] = rawliteral_code, + } + + function nodepool.pdfliteral(mode,str) + local t = copy_node(pdfliteral) + if str then + nodeproperties[t] = { data = str, mode = pdfliterals[mode] or pageliteral_code } + else + nodeproperties[t] = { data = mode, mode = pageliteral_code } + end return t end + +else + + local pdforiginliteral = register(new_node(whatsit_code, literalwhatsit_code)) setfield(pdforiginliteral,"mode",originliteral_code) + local pdfpageliteral = register(new_node(whatsit_code, literalwhatsit_code)) setfield(pdfpageliteral, "mode",pageliteral_code) + local pdfdirectliteral = register(new_node(whatsit_code, literalwhatsit_code)) setfield(pdfdirectliteral,"mode",directliteral_code) + local pdfrawliteral = register(new_node(whatsit_code, literalwhatsit_code)) setfield(pdfrawliteral, "mode",rawliteral_code) + + function nodepool.pdforiginliteral(str) local t = copy_node(pdforiginliteral) setdata(t,str) return t end + function nodepool.pdfpageliteral (str) local t = copy_node(pdfpageliteral ) setdata(t,str) return t end + function nodepool.pdfdirectliteral(str) local t = copy_node(pdfdirectliteral) setdata(t,str) return t end + function nodepool.pdfrawliteral (str) local t = copy_node(pdfrawliteral ) setdata(t,str) return t end + + local pdfliterals = { + -- by number + [originliteral_code] = pdforiginliteral, + [pageliteral_code] = pdfpageliteral, + [directliteral_code] = pdfdirectliteral, + [rawliteral_code] = pdfrawliteral, + -- by name + [literalvalues[originliteral_code]] = pdforiginliteral, + [literalvalues[pageliteral_code]] = pdfpageliteral, + [literalvalues[directliteral_code]] = pdfdirectliteral, + [literalvalues[rawliteral_code]] = pdfrawliteral, + } + + function nodepool.pdfliteral(mode,str) + if str then + local t = copy_node(pdfliterals[mode] or pdfpageliteral) + setdata(t,str) + return t + else + local t = copy_node(pdfpageliteral) + setdata(t,mode) + return t + end + end + end +local pdfsave = register(new_node(whatsit_code, savewhatsit_code)) +local pdfrestore = register(new_node(whatsit_code, restorewhatsit_code)) +local pdfsetmatrix = register(new_node(whatsit_code, setmatrixwhatsit_code)) + function nodepool.pdfsave() return copy_node(pdfsave) end @@ -128,12 +166,25 @@ function nodepool.pdfrestore() return copy_node(pdfrestore) end -function nodepool.pdfsetmatrix(rx,sx,sy,ry,tx,ty) - local t = copy_node(pdfsetmatrix) - setdata(t,tomatrix(rx,sx,sy,ry,tx,ty)) - return t -end +if CONTEXTLMTXMODE then + + local nodeproperties = nodes.properties.data + + function nodepool.pdfsetmatrix(rx,sx,sy,ry,tx,ty) + local t = copy_node(pdfsetmatrix) + nodeproperties[t] = { matrix = tomatrix(rx,sx,sy,ry,tx,ty) } + return t + end +else + + function nodepool.pdfsetmatrix(rx,sx,sy,ry,tx,ty) + local t = copy_node(pdfsetmatrix) + setdata(t,tomatrix(rx,sx,sy,ry,tx,ty)) + return t + end + +end -- best is to use a specific one: origin | page | direct | raw diff --git a/tex/context/base/mkiv/luat-cod.lua b/tex/context/base/mkiv/luat-cod.lua index 9f8bbb544..849530f72 100644 --- a/tex/context/base/mkiv/luat-cod.lua +++ b/tex/context/base/mkiv/luat-cod.lua @@ -141,6 +141,10 @@ if LUATEXVERION == nil then + (tonumber(LUATEXVERSION) or (string.byte(LUATEXVERSION)-string.byte("a")+10))/1000 end +if CONTEXTLMTXMODE == nil then + CONTEXTLMTXMODE = status.obj_ptr == nil and true or false +end + if LUATEXFUNCTIONALITY == nil then LUATEXFUNCTIONALITY = status.development_id or 6346 end diff --git a/tex/context/base/mkiv/luat-ini.lua b/tex/context/base/mkiv/luat-ini.lua index 487e92cfd..87883b55d 100644 --- a/tex/context/base/mkiv/luat-ini.lua +++ b/tex/context/base/mkiv/luat-ini.lua @@ -37,6 +37,8 @@ JITSUPPORTED = LUATEXENGINE == "luajittex" or jit INITEXMODE = status.ini_version +CONTEXTLMTXMODE = status.obj_ptr == nil and true or false + function os.setlocale() -- no need for a message end diff --git a/tex/context/base/mkiv/luat-run.lua b/tex/context/base/mkiv/luat-run.lua index 5d7026eb7..3939504a2 100644 --- a/tex/context/base/mkiv/luat-run.lua +++ b/tex/context/base/mkiv/luat-run.lua @@ -202,14 +202,6 @@ luatex.registerstopactions(luatex.cleanuptempfiles) -- filenames -local types = { - "data", - "font map", - "image", - "font subset", - "full font", -} - local report_open = logs.reporter("open source") local report_close = logs.reporter("close source") local report_load = logs.reporter("load resource") @@ -225,15 +217,8 @@ function luatex.currentfile() return stack[#stack] or tex.jobname end -local function report_start(left,name) - if not left then - -- skip - elseif left ~= 1 then - if all then - -- report_load("%s > %s",types[left],name or "?") - report_load("type %a, name %a",types[left],name or "?") - end - elseif find(name,"virtual://",1,true) then +local function report_start(name) + if find(name,"virtual://",1,true) then insert(stack,false) else insert(stack,name) @@ -245,16 +230,47 @@ local function report_start(left,name) end end -local function report_stop(right) - if level == 1 or not right or right == 1 then - local name = remove(stack) - if name then - -- report_close("%i > %i > %s",level,total,name or "?") - report_close("level %i, order %i, name %a",level,total,name or "?") - level = level - 1 - synctex.setfilename(stack[#stack] or tex.jobname) +local function report_stop() + local name = remove(stack) + if name then + -- report_close("%i > %i > %s",level,total,name or "?") + report_close("level %i, order %i, name %a",level,total,name or "?") + level = level - 1 + synctex.setfilename(stack[#stack] or tex.jobname) + end +end + +if not CONTEXTLMTXMODE then + + local types = { + "data", + "font map", + "image", + "font subset", + "full font", + } + + local do_report_start = report_start + local do_report_stop = report_stop + + report_start = function(left,name) + if not left then + -- skip + elseif left ~= 1 then + if all then + report_load("type %a, name %a",types[left],name or "?") + end + else + do_report_start(name) + end + end + + report_stop = function(right) + if level == 1 or not right or right == 1 then + do_report_stop() end end + end local function report_none() diff --git a/tex/context/base/mkiv/metatex.tex b/tex/context/base/mkiv/metatex.tex deleted file mode 100644 index 7c8a7ff01..000000000 --- a/tex/context/base/mkiv/metatex.tex +++ /dev/null @@ -1,30 +0,0 @@ -%D \module -%D [ file=metatex, -%D version=2008.10.10, -%D title=\METATEX, -%D subtitle=\METATEX\ Format Generation, -%D author=Hans Hagen, -%D date=\currentdate, -%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] -%C -%C This module is part of the \CONTEXT\ macro||package and is -%C therefore copyrighted by \PRAGMA. See mreadme.pdf for -%C details. - -%D We can experiment here with runtime loading, i.e. no longer -%D use a format. However, we still need a stub then but it could -%D as well be luatools (mtxrun) itself then. - -%D This format is just a minimal layer on top of the \LUATEX\ -%D engine and will not provide high level functionality. It can -%D be used as basis for dedicated (specialized) macro packages. -%D -%D A format is generated with the command; -%D -%D \starttyping -%D mtxrun --script metatex --make -%D \stoptyping -%D -%D For the moment this is a placeholder. Maybe some day ... the old -%D file history/metatex/metatex.tex so I can pick up from there if -%D needed. diff --git a/tex/context/base/mkiv/mult-def.lua b/tex/context/base/mkiv/mult-def.lua index 20f7ab040..e03a82a76 100644 --- a/tex/context/base/mkiv/mult-def.lua +++ b/tex/context/base/mkiv/mult-def.lua @@ -17075,6 +17075,9 @@ return { ["unframed"]={ ["en"]="unframed", }, + ["unicode"]={ + ["en"]="unicode", + }, ["unit"]={ ["cs"]="jednotka", ["de"]="einheit", diff --git a/tex/context/base/mkiv/node-ini.lua b/tex/context/base/mkiv/node-ini.lua index 4aa18ee48..5ed270140 100644 --- a/tex/context/base/mkiv/node-ini.lua +++ b/tex/context/base/mkiv/node-ini.lua @@ -291,6 +291,7 @@ local whatcodes = simplified(node.whatsits()) local usercodes = allocate { [ 97] = "attribute", -- a [100] = "number", -- d + [102] = "float", -- f [108] = "lua", -- l [110] = "node", -- n [115] = "string", -- s @@ -363,6 +364,20 @@ dirvalues = allocate(swapped(dirvalues,dirvalues)) gluevalues = allocate(swapped(gluevalues,gluevalues)) literalvalues = allocate(swapped(literalvalues,literalvalues)) +if CONTEXTLMTXMODE then + whatcodes.literal = 0x1000 whatcodes[0x1000] = whatcodes.literal + whatcodes.savepos = 0x1001 whatcodes[0x1001] = whatcodes.savepos + whatcodes.save = 0x1002 whatcodes[0x1002] = whatcodes.save + whatcodes.restore = 0x1003 whatcodes[0x1003] = whatcodes.restore + whatcodes.setmatrix = 0x1004 whatcodes[0x1004] = whatcodes.setmatrix + whatcodes.lua = 0x1005 whatcodes[0x1005] = whatcodes.lua +elseif not whatcodes.literal then + whatcodes.literal = whatcodes.pdfliteral + whatcodes.save = whatcodes.pdfsave + whatcodes.restore = whatcodes.pdfrestore + whatcodes.setmatrix = whatcodes.pdfsetmatrix +end + nodes.gluecodes = gluecodes nodes.dircodes = dircodes nodes.boundarycodes = boundarycodes @@ -388,19 +403,6 @@ nodes.dirvalues = dirvalues nodes.gluevalues = gluevalues nodes.literalvalues = literalvalues -if whatcodes.literal then - -- temporary hack - whatcodes.pdfliteral = whatcodes.literal - whatcodes.pdfsave = whatcodes.save - whatcodes.pdfrestore = whatcodes.restore - whatcodes.pdfsetmatrix = whatcodes.setmatrix -else - whatcodes.literal = whatcodes.pdfliteral - whatcodes.save = whatcodes.pdfsave - whatcodes.restore = whatcodes.pdfrestore - whatcodes.setmatrix = whatcodes.pdfsetmatrix -end - dirvalues.lefttoright = 0 dirvalues.righttoleft = 1 diff --git a/tex/context/base/mkiv/node-nut.lua b/tex/context/base/mkiv/node-nut.lua index f23a0cfc5..85220e25b 100644 --- a/tex/context/base/mkiv/node-nut.lua +++ b/tex/context/base/mkiv/node-nut.lua @@ -707,14 +707,10 @@ nodes.properties = { data = propertydata, } -------.set_properties_mode(true,false) -- shallow copy ... problem: in fonts we then affect the originals too -direct.set_properties_mode(true,true) -- create metatable, slower but needed for font-otj.lua (unless we use an intermediate table) - --- todo: --- --- function direct.set_properties_mode() --- -- we really need the set modes --- end +if direct.set_properties_mode then + direct.set_properties_mode(true,true) -- create metatable, slower but needed for font-otj.lua (unless we use an intermediate table) + function direct.set_properties_mode() end +end -- experimental code with respect to copying attributes has been removed -- as it doesn't pay of (most attributes are only accessed once anyway) diff --git a/tex/context/base/mkiv/node-res.lua b/tex/context/base/mkiv/node-res.lua index da5dca9f3..596d2861f 100644 --- a/tex/context/base/mkiv/node-res.lua +++ b/tex/context/base/mkiv/node-res.lua @@ -178,7 +178,7 @@ local user_number = register_nut(copy_nut(user_node)) setfield(user_number local user_nodes = register_nut(copy_nut(user_node)) setfield(user_nodes, "type",usercodes.node) local user_string = register_nut(copy_nut(user_node)) setfield(user_string, "type",usercodes.string) local user_tokens = register_nut(copy_nut(user_node)) setfield(user_tokens, "type",usercodes.token) ------ user_lua = register_nut(copy_nut(user_node)) setfield(user_lua, "type",usercodes.lua) -- in > 0.95 +local user_lua = register_nut(copy_nut(user_node)) setfield(user_lua, "type",usercodes.lua) -- in > 0.95 local user_attributes = register_nut(copy_nut(user_node)) setfield(user_attributes,"type",usercodes.attribute) local left_margin_kern = register_nut(new_nut(nodecodes.marginkern,0)) @@ -437,6 +437,20 @@ function nutpool.latelua(code) return n end +if CONTEXTLMTXMODE then + + local properties = nodes.properties.data + + local justlua = register_nut(new_nut(whatsit_code,whatsitcodes.lua)) + + function nutpool.lua(code) + local n = copy_nut(justlua) + properties[n] = { data = code } + return n + end + +end + nutpool.lateluafunction = nutpool.latelua function nutpool.leftmarginkern(glyph,width) @@ -559,10 +573,8 @@ function nutpool.userstring(id,str) local n = copy_nut(user_string) if str then setfield(n,"user_id",id) - -- setfield(n,"value",str) setvalue(n,str) else - -- setfield(n,"value",id) setvalue(n,id) end return n @@ -572,10 +584,8 @@ function nutpool.usertokens(id,tokens) local n = copy_nut(user_tokens) if tokens then setfield(n,"user_id",id) - -- setfield(n,"value",tokens) setvalue(n,tokens) else - -- setfield(n,"value",id) setvalue(n,id) end return n @@ -585,10 +595,8 @@ function nutpool.userlua(id,code) local n = copy_nut(user_lua) if code then setfield(n,"user_id",id) - -- setfield(n,"value",code) setvalue(n,code) else - -- setfield(n,"value",id) setvalue(n,id) end return n @@ -598,10 +606,8 @@ function nutpool.userattributes(id,attr) local n = copy_nut(user_attributes) if attr then setfield(n,"user_id",id) - -- setfield(n,"value",attr) setvalue(n,attr) else - -- setfield(n,"value",id) setvalue(n,id) end return n diff --git a/tex/context/base/mkiv/page-run.mkiv b/tex/context/base/mkiv/page-run.mkiv index 847e82996..85da8d9e5 100644 --- a/tex/context/base/mkiv/page-run.mkiv +++ b/tex/context/base/mkiv/page-run.mkiv @@ -153,6 +153,7 @@ \v!right=>\c_page_grids_lineno_mode \plusone, \v!left=>\c_page_grids_lineno_mode \plustwo, \v!outer=>\c_page_grids_lineno_mode \plusthree, + \v!inner=>\c_page_grids_lineno_mode \plusfour, \v!columns=>\c_page_grids_columns_mode\plusone]% new option \ifcase\c_page_grids_location \let\page_grids_add_to_box\gobbleoneargument diff --git a/tex/context/base/mkiv/spac-ver.mkiv b/tex/context/base/mkiv/spac-ver.mkiv index ef33652f1..7b36f9a5b 100644 --- a/tex/context/base/mkiv/spac-ver.mkiv +++ b/tex/context/base/mkiv/spac-ver.mkiv @@ -1876,8 +1876,10 @@ \resetteststrut \offinterlineskip \hsize#2% - \ifnum\gridboxlinenomode=\plusthree - \gridboxlinenomode\ifodd\realpageno\plusone\else\plustwo\fi + \ifcase\gridboxlinenomode\or\or\or + \gridboxlinenomode\doifoddpageelse\plusone\plustwo % 3: outer + \or + \gridboxlinenomode\doifoddpageelse\plustwo\plusone % 4: inner \fi \topskipcorrection \gridboxvbox % calculated size diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf index 1dfc57e96..6a3114d13 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 e797a2484..da58f3011 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/syst-rtp.mkiv b/tex/context/base/mkiv/syst-rtp.mkiv new file mode 100644 index 000000000..82c0778b4 --- /dev/null +++ b/tex/context/base/mkiv/syst-rtp.mkiv @@ -0,0 +1,18 @@ +%D \module +%D [ file=syst-rtp, +%D version=2006.10.13, +%D title=\CONTEXT\ Core Macros, +%D subtitle=Run Time Processes, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\unprotect + +\let\executesystemcommand\clf_execute + +\protect \endinput diff --git a/tex/context/base/mkiv/typo-dha.lua b/tex/context/base/mkiv/typo-dha.lua index c7c34d379..c0bbdc396 100644 --- a/tex/context/base/mkiv/typo-dha.lua +++ b/tex/context/base/mkiv/typo-dha.lua @@ -41,7 +41,7 @@ if not modules then modules = { } end modules ['typo-dha'] = { local nodes, node = nodes, node -local trace_directions = false trackers.register("typesetters.directions.default", function(v) trace_directions = v end) +local trace_directions = false trackers.register("typesetters.directions", function(v) trace_directions = v end) local report_directions = logs.reporter("typesetting","text directions") diff --git a/tex/context/base/mkiv/typo-dir.mkiv b/tex/context/base/mkiv/typo-dir.mkiv index 25ff94626..7449a7053 100644 --- a/tex/context/base/mkiv/typo-dir.mkiv +++ b/tex/context/base/mkiv/typo-dir.mkiv @@ -20,13 +20,9 @@ \registerctxluafile{typo-dir}{optimize} \registerctxluafile{typo-dha}{} -\registerctxluafile{typo-dua}{} -\registerctxluafile{typo-dub}{} -\doifelsefileexists{typo-duc-new.lua} { - \registerctxluafile{typo-duc-new}{} -} { - \registerctxluafile{typo-duc}{} -} +%registerctxluafile{typo-dua}{} +%registerctxluafile{typo-dub}{} +\registerctxluafile{typo-duc}{} \definesystemattribute[directions][public,pickup] diff --git a/tex/context/base/mkiv/typo-dua.lua b/tex/context/base/mkiv/typo-dua.lua index 095d66eae..3db5f510a 100644 --- a/tex/context/base/mkiv/typo-dua.lua +++ b/tex/context/base/mkiv/typo-dua.lua @@ -106,21 +106,21 @@ local dirvalues = nodes.dirvalues local lefttoright_code = dirvalues.lefttoright local righttoleft_code = dirvalues.righttoleft ------ object_replacement = 0xFFFC -- object replacement character -local maximum_stack = 60 -- probably spec but not needed +local maximum_stack = 60 local directions = typesetters.directions local setcolor = directions.setcolor ------ a_directions = attributes.private('directions') - local remove_controls = true directives.register("typesetters.directions.one.removecontrols",function(v) remove_controls = v end) -local trace_directions = false trackers .register("typesetters.directions.one", function(v) trace_directions = v end) -local trace_details = false trackers .register("typesetters.directions.one.details", function(v) trace_details = v end) - local report_directions = logs.reporter("typesetting","directions one") +local trace_directions = false trackers .register("typesetters.directions", function(v) trace_directions = v end) +local trace_details = false trackers .register("typesetters.directions.details", function(v) trace_details = v end) + + + + local whitespace = { lre = true, rle = true, @@ -332,28 +332,33 @@ local function find_run_limit_b_s_ws_on(list,start,limit) return start end -local function get_baselevel(head,list,size) -- todo: skip if first is object (or pass head and test for localpar) - local id = getid(head) - if id == localpar_code and getsubtype(head) == 0 then - local direction = getdirection(head) - if direction == righttoleft_code or direction == "TRT" then -- for old times sake we we handle strings too - return 1, righttoleft_code, true - else - return 0, lefttoright_code, true +local function get_baselevel(head,list,size,direction) + -- This is an adapted version: + if direction == lefttoright_code or direction == righttoleft_code then + return direction, true + elseif getid(head) == localpar_code and getsubtype(head) == 0 then + direction = getdirection(head) + if direction == lefttoright_code or direction == righttoleft_code then + return direction, true end - else - -- P2, P3 - for i=1,size do - local entry = list[i] - local direction = entry.direction - if direction == "r" or direction == "al" then - return 1, righttoleft_code, true - elseif direction == "l" then - return 0, lefttoright_code, true - end + end + -- for old times sake we we handle strings too + if direction == "TLT" then + return lefttoright_code, true + elseif direction == "TRT" then + return righttoleft_code, true + end + -- P2, P3 + for i=1,size do + local entry = list[i] + local direction = entry.direction + if direction == "r" or direction == "al" then + return righttoleft_code, true + elseif direction == "l" then + return lefttoright_code, true end - return 0, lefttoright_code, false end + return lefttoright_code, false end local function resolve_explicit(list,size,baselevel) @@ -689,8 +694,6 @@ local function resolve_levels(list,size,baselevel) end end --- This is not ok but we keep it as-is: - local function insert_dir_points(list,size) -- L2, but no actual reversion is done, we simply annotate where -- begindir/endddir node will be inserted. @@ -765,7 +768,7 @@ local function apply_to_list(list,size,head,pardir) if enddir and getsubtype(current) == parfillskip_code then -- insert the last enddir before \parfillskip glue local d = new_direction(enddir,true) - setprop(d,"directions",true) + -- setprop(d,"directions",true) -- setattrlist(d,current) head = insert_node_before(head,current,d) enddir = false @@ -774,7 +777,7 @@ local function apply_to_list(list,size,head,pardir) if id == localpar_code and getsubtype(current) == 0 then -- localpar should always be the 1st node local d = new_direction(begindir) - setprop(d,"directions",true) + -- setprop(d,"directions",true) -- setattrlist(d,current) head, current = insert_node_after(head,current,d) begindir = nil @@ -782,7 +785,7 @@ local function apply_to_list(list,size,head,pardir) end if begindir then local d = new_direction(begindir) - setprop(d,"directions",true) + -- setprop(d,"directions",true) -- setattrlist(d,current) head = insert_node_before(head,current,d) end @@ -795,7 +798,7 @@ local function apply_to_list(list,size,head,pardir) end if enddir then local d = new_direction(enddir,true) - setprop(d,"directions",true) + -- setprop(d,"directions",true) -- setattrlist(d,current) head, current = insert_node_after(head,current,d) end @@ -812,9 +815,10 @@ local function apply_to_list(list,size,head,pardir) return head end -local function process(head) +local function process(head,direction,only_one,where) + -- This is an adapted version: local list, size = build_list(head) - local baselevel, pardir, dirfound = get_baselevel(head,list,size) -- we always have an inline dir node in context + local baselevel, dirfound = get_baselevel(head,list,size,direction) if not dirfound and trace_details then report_directions("no initial direction found, gambling") end @@ -828,7 +832,7 @@ local function process(head) report_directions("after : %s",show_list(list,size,"direction")) report_directions("result : %s",show_done(list,size)) end - return apply_to_list(list,size,head,pardir) + return apply_to_list(list,size,head,baselevel) end directions.installhandler(interfaces.variables.one,process) diff --git a/tex/context/base/mkiv/typo-dub.lua b/tex/context/base/mkiv/typo-dub.lua index fde31ca93..f27e40476 100644 --- a/tex/context/base/mkiv/typo-dub.lua +++ b/tex/context/base/mkiv/typo-dub.lua @@ -94,22 +94,22 @@ local dirvalues = nodes.dirvalues local lefttoright_code = dirvalues.lefttoright local righttoleft_code = dirvalues.righttoleft -local maximum_stack = 0xFF -- unicode: 60, will be jumped to 125, we don't care too much +local maximum_stack = 0xFF + +local a_directions = attributes.private('directions') local directions = typesetters.directions local setcolor = directions.setcolor local getfences = directions.getfences -local a_directions = attributes.private('directions') - local remove_controls = true directives.register("typesetters.directions.removecontrols",function(v) remove_controls = v end) ----- analyze_fences = true directives.register("typesetters.directions.analyzefences", function(v) analyze_fences = v end) -local trace_directions = false trackers .register("typesetters.directions.two", function(v) trace_directions = v end) -local trace_details = false trackers .register("typesetters.directions.two.details", function(v) trace_details = v end) -local trace_list = false trackers .register("typesetters.directions.two.list", function(v) trace_list = v end) +local report_directions = logs.reporter("typesetting","directions three") -local report_directions = logs.reporter("typesetting","directions two") +local trace_directions = false trackers.register("typesetters.directions", function(v) trace_directions = v end) +local trace_details = false trackers.register("typesetters.directions.details", function(v) trace_details = v end) +local trace_list = false trackers.register("typesetters.directions.list", function(v) trace_list = v end) -- strong (old): -- @@ -120,7 +120,7 @@ local report_directions = logs.reporter("typesetting","directions two") -- lre : left to right embedding -- rle : left to left embedding -- al : right to legt arabic (esp punctuation issues) - +-- -- weak: -- -- en : english number @@ -130,23 +130,23 @@ local report_directions = logs.reporter("typesetting","directions two") -- cs : common number separator -- nsm : nonspacing mark -- bn : boundary neutral - +-- -- neutral: -- -- b : paragraph separator -- s : segment separator -- ws : whitespace -- on : other neutrals - +-- -- interesting: this is indeed better (and more what we expect i.e. we already use this split -- in the old original (also these isolates) - +-- -- strong (new): -- -- l : left to right -- r : right to left -- al : right to left arabic (esp punctuation issues) - +-- -- explicit: (new) -- -- lro : left to right override @@ -209,27 +209,28 @@ end local function show_done(list,size) local joiner = utfchar(0x200C) local result = { } + local format = formatters["<%s>"] for i=1,size do local entry = list[i] local character = entry.char local begindir = entry.begindir local enddir = entry.enddir if begindir then - result[#result+1] = formatters["<%s>"](begindir) + result[#result+1] = format(begindir) end if entry.remove then -- continue elseif character == 0xFFFC then - result[#result+1] = formatters["<%s>"]("?") + result[#result+1] = format("?") elseif character == 0x0020 then - result[#result+1] = formatters["<%s>"](" ") + result[#result+1] = format(" ") elseif character >= 0x202A and character <= 0x202C then - result[#result+1] = formatters["<%s>"](entry.original) + result[#result+1] = format(entry.original) else result[#result+1] = utfchar(character) end if enddir then - result[#result+1] = formatters["<%s>"](enddir) + result[#result+1] = format(enddir) end end return concat(result,joiner) @@ -239,17 +240,7 @@ end -- char is only used for mirror, so in fact we can as well only store it for -- glyphs only --- using metatable is slightly faster so maybe some day ... - --- local space = { char = 0x0020, direction = "ws", original = "ws" } --- local lre = { char = 0x202A, direction = "lre", original = "lre" } --- local rle = { char = 0x202B, direction = "rle", original = "rle" } --- local pdf = { char = 0x202C, direction = "pdf", original = "pdf" } --- local object = { char = 0xFFFC, direction = "on", original = "on" } --- --- local t = { level = 0 } setmetatable(t,space) list[size] = t - -local function build_list(head) -- todo: store node pointer ... saves loop +local function build_list(head) -- P1 local current = head local list = { } @@ -352,8 +343,8 @@ end local function resolve_fences(list,size,start,limit) -- N0: funny effects, not always better, so it's an option - local stack = { } - local top = 0 + local stack = { } + local nofstack = 0 for i=start,limit do local entry = list[i] if entry.direction == "on" then @@ -364,15 +355,15 @@ local function resolve_fences(list,size,start,limit) entry.mirror = mirror entry.class = class if class == "open" then - top = top + 1 - stack[top] = { mirror, i, false } - elseif top == 0 then + nofstack = nofstack + 1 + stack[nofstack] = { mirror, i, false } + elseif nofstack == 0 then -- skip elseif class == "close" then - while top > 0 do - local s = stack[top] - if s[1] == char then - local open = s[2] + while nofstack > 0 do + local stacktop = stack[nofstack] + if stacktop[1] == char then + local open = stacktop[2] local close = i list[open ].paired = close list[close].paired = open @@ -380,7 +371,7 @@ local function resolve_fences(list,size,start,limit) else -- do we mirror or not end - top = top - 1 + nofstack = nofstack - 1 end end end @@ -403,28 +394,32 @@ end -- the action -local function get_baselevel(head,list,size) -- todo: skip if first is object (or pass head and test for localpar) - local id = getid(head) - if id == localpar_code and getsubtype(head) == 0 then - local direction = getdirection(head) - if direction == righttoleft_code or direction == "TRT" then -- for old times sake we we handle strings too - return 1, righttoleft_code, true - else - return 0, lefttoright_code, true +local function get_baselevel(head,list,size,direction) + if direction == lefttoright_code or direction == righttoleft_code then + return direction, true + elseif getid(head) == localpar_code and getsubtype(head) == 0 then + direction = getdirection(head) + if direction == lefttoright_code or direction == righttoleft_code then + return direction, true end - else - -- P2, P3 - for i=1,size do - local entry = list[i] - local direction = entry.direction - if direction == "r" or direction == "al" then -- and an ? - return 1, righttoleft_code, true - elseif direction == "l" then - return 0, lefttoright_code, true - end + end + -- for old times sake we we handle strings too + if direction == "TLT" then + return lefttoright_code, true + elseif direction == "TRT" then + return righttoleft_code, true + end + -- P2, P3 + for i=1,size do + local entry = list[i] + local direction = entry.direction + if direction == "r" or direction == "al" then -- and an ? + return righttoleft_code, true + elseif direction == "l" then + return lefttoright_code, true end - return 0, lefttoright_code, false end + return lefttoright_code, false end local function resolve_explicit(list,size,baselevel) @@ -492,14 +487,15 @@ local function resolve_explicit(list,size,baselevel) elseif direction == "pdf" then if nofstack > 0 then local stacktop = stack[nofstack] - nofstack = nofstack - 1 level = stacktop[1] override = stacktop[2] + nofstack = nofstack - 1 entry.level = level entry.direction = "bn" entry.remove = true elseif trace_directions then - report_directions("stack underflow at position %a with direction %a",i,direction) + report_directions("stack underflow at position %a with direction %a", + i, direction) end -- X6 else @@ -698,33 +694,6 @@ local function resolve_neutral(list,size,start,limit,orderbefore,orderafter) end end --- local function resolve_implicit(list,size,start,limit,orderbefore,orderafter) --- -- I1 --- for i=start,limit do --- local entry = list[i] --- local level = entry.level --- if level % 2 ~= 1 then -- not odd(level) --- local direction = entry.direction --- if direction == "r" then --- entry.level = level + 1 --- elseif direction == "an" or direction == "en" then --- entry.level = level + 2 --- end --- end --- end --- -- I2 --- for i=start,limit do --- local entry = list[i] --- local level = entry.level --- if level % 2 == 1 then -- odd(level) --- local direction = entry.direction --- if direction == "l" or direction == "en" or direction == "an" then --- entry.level = level + 1 --- end --- end --- end --- end - local function resolve_implicit(list,size,start,limit,orderbefore,orderafter,baselevel) for i=start,limit do local entry = list[i] @@ -824,52 +793,6 @@ local function resolve_levels(list,size,baselevel,analyze_fences) end end --- local function insert_dir_points(list,size) --- -- L2, but no actual reversion is done, we simply annotate where --- -- begindir/endddir node will be inserted. --- local maxlevel = 0 --- local finaldir = false --- for i=1,size do --- local level = list[i].level --- if level > maxlevel then --- maxlevel = level --- end --- end --- for level=0,maxlevel do --- local started = false --- local begindir = nil --- local enddir = nil --- if level % 2 == 1 then --- begindir = righttoleft_code --- enddir = righttoleft_code --- else --- begindir = lefttoright_code --- enddir = lefttoright_code --- end --- for i=1,size do --- local entry = list[i] --- if entry.level >= level then --- if not started then --- entry.begindir = begindir --- started = true --- end --- else --- if started then --- list[i-1].enddir = enddir --- started = false --- end --- end --- end --- -- make sure to close the run at end of line --- if started then --- finaldir = enddir --- end --- end --- if finaldir then --- list[size].enddir = finaldir --- end --- end - local function insert_dir_points(list,size) -- L2, but no actual reversion is done, we simply annotate where -- begindir/endddir node will be inserted. @@ -978,7 +901,7 @@ local function apply_to_list(list,size,head,pardir) if enddir and getsubtype(current) == parfillskip_code then -- insert the last enddir before \parfillskip glue local d = new_direction(enddir,true) - setprop(d,"directions",true) + -- setprop(d,"directions",true) -- setattrlist(d,current) head = insert_node_before(head,current,d) enddir = false @@ -987,7 +910,7 @@ local function apply_to_list(list,size,head,pardir) if id == localpar_code and getsubtype(current) == 0 then -- localpar should always be the 1st node local d = new_direction(begindir) - setprop(d,"directions",true) + -- setprop(d,"directions",true) -- setattrlist(d,current) head, current = insert_node_after(head,current,d) begindir = nil @@ -995,7 +918,7 @@ local function apply_to_list(list,size,head,pardir) end if begindir then local d = new_direction(begindir) - setprop(d,"directions",true) + -- setprop(d,"directions",true) -- setattrlist(d,current) head = insert_node_before(head,current,d) end @@ -1008,7 +931,7 @@ local function apply_to_list(list,size,head,pardir) end if enddir then local d = new_direction(enddir,true) - setprop(d,"directions",true) + -- setprop(d,"directions",true) -- setattrlist(d,current) head, current = insert_node_after(head,current,d) end @@ -1028,13 +951,13 @@ local function apply_to_list(list,size,head,pardir) return head end -local function process(head) +local function process(head,direction,only_one,where) -- for the moment a whole paragraph property local attr = getattr(head,a_directions) local analyze_fences = getfences(attr) -- local list, size = build_list(head) - local baselevel, pardir, dirfound = get_baselevel(head,list,size) -- we always have an inline dir node in context + local baselevel, dirfound = get_baselevel(head,list,size,direction) if not dirfound and trace_details then report_directions("no initial direction found, gambling") end @@ -1048,7 +971,7 @@ local function process(head) report_directions("after : %s",show_list(list,size,"direction")) report_directions("result : %s",show_done(list,size)) end - return apply_to_list(list,size,head,pardir) + return apply_to_list(list,size,head,baselevel) end directions.installhandler(interfaces.variables.two,process) diff --git a/tex/context/base/mkiv/typo-duc.lua b/tex/context/base/mkiv/typo-duc.lua index c1338d0d1..f91fc4d64 100644 --- a/tex/context/base/mkiv/typo-duc.lua +++ b/tex/context/base/mkiv/typo-duc.lua @@ -56,7 +56,6 @@ local mirrordata = characters.mirrors local textclassdata = characters.textclasses local nuts = nodes.nuts -local tonut = nuts.tonut local getnext = nuts.getnext local getid = nuts.getid @@ -99,23 +98,23 @@ local dirvalues = nodes.dirvalues local lefttoright_code = dirvalues.lefttoright local righttoleft_code = dirvalues.righttoleft -local maximum_stack = 0xFF -- unicode: 60, will be jumped to 125, we don't care too much +local maximum_stack = 0xFF + +local a_directions = attributes.private('directions') local directions = typesetters.directions local setcolor = directions.setcolor local getfences = directions.getfences -local a_directions = attributes.private('directions') - local remove_controls = true directives.register("typesetters.directions.removecontrols",function(v) remove_controls = v end) ----- analyze_fences = true directives.register("typesetters.directions.analyzefences", function(v) analyze_fences = v end) -local trace_directions = false trackers.register("typesetters.directions.three", function(v) trace_directions = v end) -local trace_details = false trackers.register("typesetters.directions.three.details", function(v) trace_details = v end) -local trace_list = false trackers.register("typesetters.directions.three.list", function(v) trace_list = v end) - local report_directions = logs.reporter("typesetting","directions three") +local trace_directions = false trackers.register("typesetters.directions", function(v) trace_directions = v end) +local trace_details = false trackers.register("typesetters.directions.details", function(v) trace_details = v end) +local trace_list = false trackers.register("typesetters.directions.list", function(v) trace_list = v end) + -- strong (old): -- -- l : left to right @@ -125,7 +124,7 @@ local report_directions = logs.reporter("typesetting","directions three") -- lre : left to right embedding -- rle : left to left embedding -- al : right to legt arabic (esp punctuation issues) - +-- -- weak: -- -- en : english number @@ -135,23 +134,23 @@ local report_directions = logs.reporter("typesetting","directions three") -- cs : common number separator -- nsm : nonspacing mark -- bn : boundary neutral - +-- -- neutral: -- -- b : paragraph separator -- s : segment separator -- ws : whitespace -- on : other neutrals - +-- -- interesting: this is indeed better (and more what we expect i.e. we already use this split -- in the old original (also these isolates) - +-- -- strong (new): -- -- l : left to right -- r : right to left -- al : right to left arabic (esp punctuation issues) - +-- -- explicit: (new) -- -- lro : left to right override @@ -244,7 +243,7 @@ end -- keeping the list and overwriting doesn't save much runtime, only a few percent -- char is only used for mirror, so in fact we can as well only store it for -- glyphs only - +-- -- tracking what direction is used and skipping tests is not faster (extra kind of -- compensates gain) @@ -257,7 +256,7 @@ local mt_object = { __index = { char = 0xFFFC, direction = "on", original = "on local stack = table.setmetatableindex("table") -- shared local list = { } -- shared -local function build_list(head,where) -- todo: store node pointer ... saves loop +local function build_list(head,where) -- P1 local current = head local size = 0 @@ -354,9 +353,10 @@ end -- ש ( ל ( א ) כ ) 2-8,4-6 -- ש ( ל [ א ] כ ) 2-8,4-6 +local fencestack = table.setmetatableindex("table") + local function resolve_fences(list,size,start,limit) -- N0: funny effects, not always better, so it's an option - local stack = { } local nofstack = 0 for i=start,limit do local entry = list[i] @@ -369,14 +369,14 @@ local function resolve_fences(list,size,start,limit) entry.class = class if class == "open" then nofstack = nofstack + 1 - local stacktop = stack[nofstack] + local stacktop = fencestack[nofstack] stacktop[1] = mirror stacktop[2] = i elseif nofstack == 0 then -- skip elseif class == "close" then while nofstack > 0 do - local stacktop = stack[nofstack] + local stacktop = fencestack[nofstack] if stacktop[1] == char then local open = stacktop[2] local close = i @@ -424,7 +424,7 @@ local function get_baselevel(head,list,size,direction) elseif direction == "TRT" then return righttoleft_code, true end - -- P2, P3: + -- P2, P3 for i=1,size do local entry = list[i] local direction = entry.direction @@ -531,11 +531,6 @@ local function resolve_explicit(list,size,baselevel) end end end --- else --- for i=1,size do --- list[i].level = baselevel --- end --- end -- X8 (reset states and overrides after paragraph) end @@ -1006,19 +1001,12 @@ end -- do have a glyph! local function process(head,direction,only_one,where) - --- print("START") --- for n in nodes.traverse(nodes.tonode(head)) do --- print(" "..tostring(n)) --- end --- print("STOP") - -- for the moment a whole paragraph property local attr = getattr(head,a_directions) local analyze_fences = getfences(attr) -- local list, size = build_list(head,where) - local baselevel, dirfound = get_baselevel(head,list,size,direction) -- we always have an inline dir node in context + local baselevel, dirfound = get_baselevel(head,list,size,direction) if trace_details then report_directions("analyze: baselevel %a",baselevel == righttoleft_code and "r2l" or "l2r") report_directions("before : %s",show_list(list,size,"original")) @@ -1033,4 +1021,9 @@ local function process(head,direction,only_one,where) return apply_to_list(list,size,head,baselevel) end -directions.installhandler(interfaces.variables.three,process) +local variables = interfaces.variables + +directions.installhandler(variables.one, process) -- for old times sake +directions.installhandler(variables.two, process) -- for old times sake +directions.installhandler(variables.three, process) -- for old times sake +directions.installhandler(variables.unicode,process) diff --git a/tex/context/base/mkiv/util-str.lua b/tex/context/base/mkiv/util-str.lua index 410a4a547..713c294eb 100644 --- a/tex/context/base/mkiv/util-str.lua +++ b/tex/context/base/mkiv/util-str.lua @@ -612,6 +612,8 @@ local environment = { formattedfloat = number.formattedfloat, stripzero = lpeg.patterns.stripzero, stripzeros = lpeg.patterns.stripzeros, + + FORMAT = string.f9, } -- -- -- @@ -730,6 +732,17 @@ local format_F = function(f) -- beware, no cast to number end end +-- if string.f9 then +-- format_F = function(f) -- beware, no cast to number +-- n = n + 1 +-- if not f or f == "" then +-- return format("(((a%s > -0.0000000005 and a%s < 0.0000000005) and '0') or FORMAT(a%s))",n,n,n,n,n) +-- else +-- return format("((a%s %% 1 == 0) and format('%%i',a%s) or FORMAT(a%s,'%%%sf'))",n,n,n,f) +-- end +-- end +-- end + local format_k = function(b,a) -- slow n = n + 1 return format("formattedfloat(a%s,%i,%i)",n,b or 0, a or 0) diff --git a/tex/context/interface/mkii/keys-it.xml b/tex/context/interface/mkii/keys-it.xml index 47880bd63..2ebcb4a9d 100644 --- a/tex/context/interface/mkii/keys-it.xml +++ b/tex/context/interface/mkii/keys-it.xml @@ -590,6 +590,7 @@ + diff --git a/tex/context/interface/mkiv/context-en.xml b/tex/context/interface/mkiv/context-en.xml index acd8ba5cb..73af42a96 100644 --- a/tex/context/interface/mkiv/context-en.xml +++ b/tex/context/interface/mkiv/context-en.xml @@ -5221,10 +5221,10 @@ - + - + @@ -15044,6 +15044,7 @@ + diff --git a/tex/context/interface/mkiv/i-columns.xml b/tex/context/interface/mkiv/i-columns.xml index b89bd5845..bbc022ac6 100644 --- a/tex/context/interface/mkiv/i-columns.xml +++ b/tex/context/interface/mkiv/i-columns.xml @@ -34,10 +34,10 @@ - + - + @@ -108,4 +108,4 @@ - \ No newline at end of file + diff --git a/tex/context/interface/mkiv/i-context.pdf b/tex/context/interface/mkiv/i-context.pdf index 2996163ad..d181f8a6b 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-grid.xml b/tex/context/interface/mkiv/i-grid.xml index cb70fa416..9b072127b 100644 --- a/tex/context/interface/mkiv/i-grid.xml +++ b/tex/context/interface/mkiv/i-grid.xml @@ -18,6 +18,7 @@ + @@ -192,4 +193,4 @@ - \ No newline at end of file + diff --git a/tex/context/interface/mkiv/i-readme.pdf b/tex/context/interface/mkiv/i-readme.pdf index 7fc07ede0..fba78c447 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/generic/context/luatex/luatex-basics-nod.lua b/tex/generic/context/luatex/luatex-basics-nod.lua index 276c7efa5..e22f170ef 100644 --- a/tex/generic/context/luatex/luatex-basics-nod.lua +++ b/tex/generic/context/luatex/luatex-basics-nod.lua @@ -259,9 +259,10 @@ end local propertydata = direct.get_properties_table() nodes.properties = { data = propertydata } -direct.set_properties_mode(true,true) -- needed for injection - -function direct.set_properties_mode() end -- we really need the set modes +if direct.set_properties_mode then + direct.set_properties_mode(true,true) + function direct.set_properties_mode() end +end nuts.getprop = function(n,k) local p = propertydata[n] diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 89ae7d64d..679efbd87 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 : 01/28/19 16:58:09 +-- merge date : 02/07/19 18:46:18 do -- begin closure to overcome local limits and interference @@ -3386,6 +3386,7 @@ local environment={ formattedfloat=number.formattedfloat, stripzero=lpeg.patterns.stripzero, stripzeros=lpeg.patterns.stripzeros, + FORMAT=string.f9, } local arguments={ "a1" } setmetatable(arguments,{ __index=function(t,k) @@ -4855,8 +4856,10 @@ if not nuts.getdirection then end local propertydata=direct.get_properties_table() nodes.properties={ data=propertydata } -direct.set_properties_mode(true,true) -function direct.set_properties_mode() end +if direct.set_properties_mode then + direct.set_properties_mode(true,true) + function direct.set_properties_mode() end +end nuts.getprop=function(n,k) local p=propertydata[n] if p then @@ -8283,7 +8286,8 @@ constructors.namemode="fullpath" constructors.version=1.01 constructors.cache=containers.define("fonts","constructors",constructors.version,false) constructors.privateoffset=fonts.privateoffsets.textbase or 0xF0000 -constructors.cacheintex=true +constructors.cacheintex=true +constructors.addtounicode=true local designsizes=allocate() constructors.designsizes=designsizes local loadedfonts=allocate() @@ -8543,6 +8547,7 @@ function constructors.scale(tfmdata,specification) targetparameters.textsize=textsize targetparameters.forcedsize=forcedsize targetparameters.extrafactor=extrafactor + local addtounicode=constructors.addtounicode local tounicode=fonts.mappings.tounicode local unknowncode=tounicode(0xFFFD) local defaultwidth=resources.defaultwidth or 0 @@ -8796,11 +8801,17 @@ function constructors.scale(tfmdata,specification) end end local isunicode=description.unicode - if isunicode then - chr.unicode=isunicode - chr.tounicode=tounicode(isunicode) + if addtounicode then + if isunicode then + chr.unicode=isunicode + chr.tounicode=tounicode(isunicode) + else + chr.tounicode=unknowncode + end else - chr.tounicode=unknowncode + if isunicode then + chr.unicode=isunicode + end end if hasquality then local ve=character.expansion_factor -- cgit v1.2.3