diff options
54 files changed, 1398 insertions, 442 deletions
diff --git a/context/data/scite/lexers/data/scite-context-data-context.lua b/context/data/scite/lexers/data/scite-context-data-context.lua index edb3087f3..6645c9f27 100644 --- a/context/data/scite/lexers/data/scite-context-data-context.lua +++ b/context/data/scite/lexers/data/scite-context-data-context.lua @@ -1,4 +1,4 @@ return { - ["constants"]={ "zerocount", "minusone", "minustwo", "plusone", "plustwo", "plusthree", "plusfour", "plusfive", "plussix", "plusseven", "pluseight", "plusnine", "plusten", "plussixteen", "plushundred", "plusthousand", "plustenthousand", "plustwentythousand", "medcard", "maxcard", "zeropoint", "onepoint", "onebasepoint", "maxdimen", "scaledpoint", "thousandpoint", "points", "zeroskip", "pluscxxvii", "pluscxxviii", "pluscclv", "pluscclvi", "endoflinetoken", "outputnewlinechar", "emptytoks", "empty", "undefined", "voidbox", "emptybox", "emptyvbox", "emptyhbox", "bigskipamount", "medskipamount", "smallskipamount", "fmtname", "fmtversion", "texengine", "texenginename", "texengineversion", "luatexengine", "pdftexengine", "xetexengine", "unknownengine", "etexversion", "pdftexversion", "xetexversion", "xetexrevision", "activecatcode", "bgroup", "egroup", "endline", "attributeunsetvalue", "uprotationangle", "rightrotatioangle", "downrotatioangle", "leftrotatioangle", "startmode", "stopmode", "startnotmode", "stopnotmode", "doifmode", "doifmodeelse", "doifnotmode", "startenvironment", "stopenvironment", "environment", "startcomponent", "stopcomponent", "component", "startproduct", "stopproduct", "product", "startproject", "stopproject", "project", "starttext", "stoptext", "startmodule", "stopmodule", "usemodule" }, - ["helpers"]={ "startsetups", "stopsetups", "startxmlsetups", "stopxmlsetups", "starttexdefinition", "stoptexdefinition", "starttexcode", "stoptexcode", "newcount", "newdimen", "newskip", "newmuskip", "newbox", "newtoks", "newread", "newwrite", "newmarks", "newinsert", "newattribute", "newif", "newlanguage", "newfamily", "newfam", "newhelp", "htdp", "unvoidbox", "scratchcounter", "globalscratchcounter", "scratchdimen", "globalscratchdimen", "scratchskip", "globalscratchskip", "scratchmuskip", "globalscratchmuskip", "scratchtoks", "globalscratchtoks", "scratchbox", "globalscratchbox", "scratchwidth", "scratchheight", "scratchdepth", "scratchcounterone", "scratchcountertwo", "scratchcounterthree", "scratchdimenone", "scratchdimentwo", "scratchdimenthree", "scratchskipone", "scratchskiptwo", "scratchskipthree", "scratchmuskipone", "scratchmuskiptwo", "scratchmuskipthree", "scratchtoksone", "scratchtokstwo", "scratchtoksthree", "scratchboxone", "scratchboxtwo", "scratchboxthree", "doif", "doifnot", "doifelse", "doifinset", "doifnotinset", "doifinsetelse", "doifnextcharelse", "doifnextoptionalelse", "doifnextparenthesiselse", "doiffastoptionalcheckelse", "doifundefinedelse", "doifdefinedelse", "doifundefined", "doifdefined", "doifelsevalue", "doifvalue", "doifnotvalue", "doifnothing", "doifsomething", "doifelsenothing", "doifsomethingelse", "doifvaluenothing", "doifvaluesomething", "doifelsevaluenothing", "doifdimensionelse", "doifnumberelse", "doifcommonelse", "doifcommon", "doifnotcommon", "doifinstring", "doifnotinstring", "doifinstringelse", "tracingall", "tracingnone", "loggingall", "appendtoks", "prependtoks", "appendtotoks", "prependtotoks", "to", "endgraf", "empty", "null", "space", "obeyspaces", "obeylines", "normalspace", "executeifdefined", "singleexpandafter", "doubleexpandafter", "tripleexpandafter", "dontleavehmode", "wait", "writestatus", "define", "redefine", "setmeasure", "setemeasure", "setgmeasure", "setxmeasure", "definemeasure", "measure", "getvalue", "setvalue", "setevalue", "setgvalue", "setxvalue", "letvalue", "letgvalue", "resetvalue", "undefinevalue", "ignorevalue", "setuvalue", "setuevalue", "setugvalue", "setuxvalue", "globallet", "glet", "getparameters", "geteparameters", "getgparameters", "getxparameters", "forgetparameters", "processcommalist", "processcommacommand", "quitcommalist", "quitprevcommalist", "processaction", "processallactions", "processfirstactioninset", "processallactionsinset", "unexpanded", "expanded", "startexpanded", "stopexpanded", "protected", "protect", "unprotect", "firstofoneargument", "firstoftwoarguments", "secondoftwoarguments", "firstofthreearguments", "secondofthreearguments", "thirdofthreearguments", "firstoffourarguments", "secondoffourarguments", "thirdoffourarguments", "fourthoffourarguments", "firstoffivearguments", "secondoffivearguments", "thirdoffivearguments", "fourthoffivearguments", "fifthoffivearguments", "firstofsixarguments", "secondofsixarguments", "thirdofsixarguments", "fourthofsixarguments", "fifthofsixarguments", "sixthofsixarguments", "gobbleoneargument", "gobbletwoarguments", "gobblethreearguments", "gobblefourarguments", "gobblefivearguments", "gobblesixarguments", "gobblesevenarguments", "gobbleeightarguments", "gobbleninearguments", "gobbletenarguments", "gobbleoneoptional", "gobbletwooptionals", "gobblethreeoptionals", "gobblefouroptionals", "gobblefiveoptionals", "dorecurse", "doloop", "exitloop", "dostepwiserecurse", "recurselevel", "recursedepth", "newconstant", "setnewconstant", "newconditional", "settrue", "setfalse", "dosingleempty", "dodoubleempty", "dotripleempty", "doquadrupleempty", "doquintupleempty", "dosixtupleempty", "doseventupleempty", "dosinglegroupempty", "dodoublegroupempty", "dotriplegroupempty", "doquadruplegroupempty", "doquintuplegroupempty", "nopdfcompression", "maximumpdfcompression", "normalpdfcompression", "modulonumber", "dividenumber", "getfirstcharacter", "doiffirstcharelse", "startnointerference", "stopnointerference" }, + ["constants"]={ "zerocount", "minusone", "minustwo", "plusone", "plustwo", "plusthree", "plusfour", "plusfive", "plussix", "plusseven", "pluseight", "plusnine", "plusten", "plussixteen", "plushundred", "plusthousand", "plustenthousand", "plustwentythousand", "medcard", "maxcard", "zeropoint", "onepoint", "onebasepoint", "maxdimen", "scaledpoint", "thousandpoint", "points", "zeroskip", "pluscxxvii", "pluscxxviii", "pluscclv", "pluscclvi", "endoflinetoken", "outputnewlinechar", "emptytoks", "empty", "undefined", "voidbox", "emptybox", "emptyvbox", "emptyhbox", "bigskipamount", "medskipamount", "smallskipamount", "fmtname", "fmtversion", "texengine", "texenginename", "texengineversion", "luatexengine", "pdftexengine", "xetexengine", "unknownengine", "etexversion", "pdftexversion", "xetexversion", "xetexrevision", "activecatcode", "bgroup", "egroup", "endline", "attributeunsetvalue", "uprotationangle", "rightrotatioangle", "downrotatioangle", "leftrotatioangle", "startmode", "stopmode", "startnotmode", "stopnotmode", "doifmode", "doifmodeelse", "doifnotmode", "startenvironment", "stopenvironment", "environment", "startcomponent", "stopcomponent", "component", "startproduct", "stopproduct", "product", "startproject", "stopproject", "project", "starttext", "stoptext", "startdocument", "stopdocument", "documentvariable", "startmodule", "stopmodule", "usemodule" }, + ["helpers"]={ "startsetups", "stopsetups", "startxmlsetups", "stopxmlsetups", "starttexdefinition", "stoptexdefinition", "starttexcode", "stoptexcode", "newcount", "newdimen", "newskip", "newmuskip", "newbox", "newtoks", "newread", "newwrite", "newmarks", "newinsert", "newattribute", "newif", "newlanguage", "newfamily", "newfam", "newhelp", "htdp", "unvoidbox", "scratchcounter", "globalscratchcounter", "scratchdimen", "globalscratchdimen", "scratchskip", "globalscratchskip", "scratchmuskip", "globalscratchmuskip", "scratchtoks", "globalscratchtoks", "scratchbox", "globalscratchbox", "scratchwidth", "scratchheight", "scratchdepth", "scratchcounterone", "scratchcountertwo", "scratchcounterthree", "scratchdimenone", "scratchdimentwo", "scratchdimenthree", "scratchskipone", "scratchskiptwo", "scratchskipthree", "scratchmuskipone", "scratchmuskiptwo", "scratchmuskipthree", "scratchtoksone", "scratchtokstwo", "scratchtoksthree", "scratchboxone", "scratchboxtwo", "scratchboxthree", "doif", "doifnot", "doifelse", "doifinset", "doifnotinset", "doifinsetelse", "doifnextcharelse", "doifnextoptionalelse", "doifnextparenthesiselse", "doiffastoptionalcheckelse", "doifundefinedelse", "doifdefinedelse", "doifundefined", "doifdefined", "doifelsevalue", "doifvalue", "doifnotvalue", "doifnothing", "doifsomething", "doifelsenothing", "doifsomethingelse", "doifvaluenothing", "doifvaluesomething", "doifelsevaluenothing", "doifdimensionelse", "doifnumberelse", "doifcommonelse", "doifcommon", "doifnotcommon", "doifinstring", "doifnotinstring", "doifinstringelse", "doifassignmentelse", "tracingall", "tracingnone", "loggingall", "appendtoks", "prependtoks", "appendtotoks", "prependtotoks", "to", "endgraf", "empty", "null", "space", "obeyspaces", "obeylines", "normalspace", "executeifdefined", "singleexpandafter", "doubleexpandafter", "tripleexpandafter", "dontleavehmode", "wait", "writestatus", "define", "redefine", "setmeasure", "setemeasure", "setgmeasure", "setxmeasure", "definemeasure", "measure", "getvalue", "setvalue", "setevalue", "setgvalue", "setxvalue", "letvalue", "letgvalue", "resetvalue", "undefinevalue", "ignorevalue", "setuvalue", "setuevalue", "setugvalue", "setuxvalue", "globallet", "glet", "getparameters", "geteparameters", "getgparameters", "getxparameters", "forgetparameters", "processcommalist", "processcommacommand", "quitcommalist", "quitprevcommalist", "processaction", "processallactions", "processfirstactioninset", "processallactionsinset", "unexpanded", "expanded", "startexpanded", "stopexpanded", "protected", "protect", "unprotect", "firstofoneargument", "firstoftwoarguments", "secondoftwoarguments", "firstofthreearguments", "secondofthreearguments", "thirdofthreearguments", "firstoffourarguments", "secondoffourarguments", "thirdoffourarguments", "fourthoffourarguments", "firstoffivearguments", "secondoffivearguments", "thirdoffivearguments", "fourthoffivearguments", "fifthoffivearguments", "firstofsixarguments", "secondofsixarguments", "thirdofsixarguments", "fourthofsixarguments", "fifthofsixarguments", "sixthofsixarguments", "gobbleoneargument", "gobbletwoarguments", "gobblethreearguments", "gobblefourarguments", "gobblefivearguments", "gobblesixarguments", "gobblesevenarguments", "gobbleeightarguments", "gobbleninearguments", "gobbletenarguments", "gobbleoneoptional", "gobbletwooptionals", "gobblethreeoptionals", "gobblefouroptionals", "gobblefiveoptionals", "dorecurse", "doloop", "exitloop", "dostepwiserecurse", "recurselevel", "recursedepth", "newconstant", "setnewconstant", "newconditional", "settrue", "setfalse", "dosingleempty", "dodoubleempty", "dotripleempty", "doquadrupleempty", "doquintupleempty", "dosixtupleempty", "doseventupleempty", "dosinglegroupempty", "dodoublegroupempty", "dotriplegroupempty", "doquadruplegroupempty", "doquintuplegroupempty", "nopdfcompression", "maximumpdfcompression", "normalpdfcompression", "modulonumber", "dividenumber", "getfirstcharacter", "doiffirstcharelse", "startnointerference", "stopnointerference", "strut", "setstrut", "strutbox", "strutht", "strutdp", "strutwd" }, }
\ No newline at end of file diff --git a/context/data/scite/lexers/scite-context-lexer-lua.lua b/context/data/scite/lexers/scite-context-lexer-lua.lua index e10f49ff3..f03dbb665 100644 --- a/context/data/scite/lexers/scite-context-lexer-lua.lua +++ b/context/data/scite/lexers/scite-context-lexer-lua.lua @@ -42,6 +42,7 @@ local constants = { local csnames = { -- todo: option "context", "metafun", + "metapost", } local level = nil @@ -99,6 +100,9 @@ local rest = token("default", any) local shortcomment = token("comment", dashes * lexer.nonnewline^0) local longcomment = token("comment", dashes * longcomment) +-- fails on very long string with \ at end of lines (needs embedded lexer) +-- and also on newline before " but it makes no sense to waste tiem on it + local shortstring = token("quote", dquote) * token("string", (escaped + (1-dquote))^0) * token("quote", dquote) diff --git a/context/data/scite/scite-context-data-context.properties b/context/data/scite/scite-context-data-context.properties index 4d352d708..6da0086f5 100644 --- a/context/data/scite/scite-context-data-context.properties +++ b/context/data/scite/scite-context-data-context.properties @@ -17,33 +17,35 @@ doifundefinedelse doifdefinedelse doifundefined doifdefined doifelsevalue \ doifvalue doifnotvalue doifnothing doifsomething doifelsenothing \ doifsomethingelse doifvaluenothing doifvaluesomething doifelsevaluenothing doifdimensionelse \ doifnumberelse doifcommonelse doifcommon doifnotcommon doifinstring \ -doifnotinstring doifinstringelse tracingall tracingnone loggingall \ -appendtoks prependtoks appendtotoks prependtotoks endgraf \ -empty null space obeyspaces obeylines \ -normalspace executeifdefined singleexpandafter doubleexpandafter tripleexpandafter \ -dontleavehmode wait writestatus define redefine \ -setmeasure setemeasure setgmeasure setxmeasure definemeasure \ -measure getvalue setvalue setevalue setgvalue \ -setxvalue letvalue letgvalue resetvalue undefinevalue \ -ignorevalue setuvalue setuevalue setugvalue setuxvalue \ -globallet glet getparameters geteparameters getgparameters \ -getxparameters forgetparameters processcommalist processcommacommand quitcommalist \ -quitprevcommalist processaction processallactions processfirstactioninset processallactionsinset \ -unexpanded expanded startexpanded stopexpanded protected \ -protect unprotect firstofoneargument firstoftwoarguments secondoftwoarguments \ -firstofthreearguments secondofthreearguments thirdofthreearguments firstoffourarguments secondoffourarguments \ -thirdoffourarguments fourthoffourarguments firstoffivearguments secondoffivearguments thirdoffivearguments \ -fourthoffivearguments fifthoffivearguments firstofsixarguments secondofsixarguments thirdofsixarguments \ -fourthofsixarguments fifthofsixarguments sixthofsixarguments gobbleoneargument gobbletwoarguments \ -gobblethreearguments gobblefourarguments gobblefivearguments gobblesixarguments gobblesevenarguments \ -gobbleeightarguments gobbleninearguments gobbletenarguments gobbleoneoptional gobbletwooptionals \ -gobblethreeoptionals gobblefouroptionals gobblefiveoptionals dorecurse doloop \ -exitloop dostepwiserecurse recurselevel recursedepth newconstant \ -setnewconstant newconditional settrue setfalse dosingleempty \ -dodoubleempty dotripleempty doquadrupleempty doquintupleempty dosixtupleempty \ -doseventupleempty dosinglegroupempty dodoublegroupempty dotriplegroupempty doquadruplegroupempty \ -doquintuplegroupempty nopdfcompression maximumpdfcompression normalpdfcompression modulonumber \ -dividenumber getfirstcharacter doiffirstcharelse +doifnotinstring doifinstringelse doifassignmentelse tracingall tracingnone \ +loggingall appendtoks prependtoks appendtotoks prependtotoks \ +to endgraf empty null space \ +obeyspaces obeylines normalspace executeifdefined singleexpandafter \ +doubleexpandafter tripleexpandafter dontleavehmode wait writestatus \ +define redefine setmeasure setemeasure setgmeasure \ +setxmeasure definemeasure measure getvalue setvalue \ +setevalue setgvalue setxvalue letvalue letgvalue \ +resetvalue undefinevalue ignorevalue setuvalue setuevalue \ +setugvalue setuxvalue globallet glet getparameters \ +geteparameters getgparameters getxparameters forgetparameters processcommalist \ +processcommacommand quitcommalist quitprevcommalist processaction processallactions \ +processfirstactioninset processallactionsinset unexpanded expanded startexpanded \ +stopexpanded protected protect unprotect firstofoneargument \ +firstoftwoarguments secondoftwoarguments firstofthreearguments secondofthreearguments thirdofthreearguments \ +firstoffourarguments secondoffourarguments thirdoffourarguments fourthoffourarguments firstoffivearguments \ +secondoffivearguments thirdoffivearguments fourthoffivearguments fifthoffivearguments firstofsixarguments \ +secondofsixarguments thirdofsixarguments fourthofsixarguments fifthofsixarguments sixthofsixarguments \ +gobbleoneargument gobbletwoarguments gobblethreearguments gobblefourarguments gobblefivearguments \ +gobblesixarguments gobblesevenarguments gobbleeightarguments gobbleninearguments gobbletenarguments \ +gobbleoneoptional gobbletwooptionals gobblethreeoptionals gobblefouroptionals gobblefiveoptionals \ +dorecurse doloop exitloop dostepwiserecurse recurselevel \ +recursedepth newconstant setnewconstant newconditional settrue \ +setfalse dosingleempty dodoubleempty dotripleempty doquadrupleempty \ +doquintupleempty dosixtupleempty doseventupleempty dosinglegroupempty dodoublegroupempty \ +dotriplegroupempty doquadruplegroupempty doquintuplegroupempty nopdfcompression maximumpdfcompression \ +normalpdfcompression modulonumber dividenumber getfirstcharacter doiffirstcharelse \ +startnointerference stopnointerference strut setstrut strutbox \ +strutht strutdp strutwd keywordclass.context.constants=\ zerocount minusone minustwo plusone \ @@ -63,5 +65,6 @@ downrotatioangle leftrotatioangle startmode stopmode startnotmode \ stopnotmode doifmode doifmodeelse doifnotmode startenvironment \ stopenvironment environment startcomponent stopcomponent component \ startproduct stopproduct product startproject stopproject \ -project starttext stoptext +project starttext stoptext startdocument stopdocument \ +documentvariable startmodule stopmodule usemodule diff --git a/context/data/scite/scite-context-data-metapost.properties b/context/data/scite/scite-context-data-metapost.properties index 9cfcb5eca..16dafbb3a 100644 --- a/context/data/scite/scite-context-data-metapost.properties +++ b/context/data/scite/scite-context-data-metapost.properties @@ -71,5 +71,5 @@ display openwindow numspecial totalweight autorounding \ fillin proofing tracingpens xoffset chardx \ granularity smoothing turningcheck yoffset chardy \ hppp tracingedges vppp extra_beginfig extra_endfig \ -mpxbreak +mpxbreak endinput diff --git a/metapost/context/base/metafun.mpiv b/metapost/context/base/metafun.mpiv index 58e871075..80cfcd423 100644 --- a/metapost/context/base/metafun.mpiv +++ b/metapost/context/base/metafun.mpiv @@ -25,7 +25,7 @@ input mp-txts.mp ; input mp-butt.mp ; input mp-shap.mp ; % mp-char.mp ; % there no need to always load this -input mp-step.mp ; % there no need to always load this (todo) +% mp-step.mp ; % there no need to always load this input mp-grph.mp ; input mp-figs.mp ; input mp-mlib.mpiv ; diff --git a/metapost/context/base/mp-tool.mp b/metapost/context/base/mp-tool.mp index 35eca4727..1a758a963 100644 --- a/metapost/context/base/mp-tool.mp +++ b/metapost/context/base/mp-tool.mp @@ -2119,19 +2119,28 @@ enddef ; % handy -vardef bbwidth (expr p) = - (if known p : - if path p or picture p : - xpart (lrcorner p - llcorner p) - else : 0 fi else : 0 - fi ) -enddef ; - -vardef bbheight (expr p) = - (if known p : if path p or picture p : - ypart (urcorner p - lrcorner p) - else : 0 fi else : 0 - fi) +vardef bbwidth (expr p) = % vardef width_of primary p = + if known p : + if path p or picture p : + xpart (lrcorner p - llcorner p) + else : + 0 + fi + else : + 0 + fi +enddef ; + +vardef bbheight (expr p) = % vardef heigth_of primary p = + if known p : + if path p or picture p : + ypart (urcorner p - lrcorner p) + else : + 0 + fi + else : + 0 + fi enddef ; color nocolor ; numeric noline ; % both unknown signals diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua index a3fbc7ff6..4604b9bde 100644 --- a/scripts/context/lua/mtxrun.lua +++ b/scripts/context/lua/mtxrun.lua @@ -4235,13 +4235,13 @@ end -- table namespace ? -local function f_empty() return "" end -- t,k -local function f_self(t,k) t[k] = k return k end -local function f_ignore() end -- t,k,v +local function f_empty () return "" end -- t,k +local function f_self (t,k) t[k] = k return k end +local function f_ignore() end -- t,k,v -local t_empty = { __index = empty } -local t_self = { __index = self } -local t_ignore = { __newindex = ignore } +local t_empty = { __index = f_empty } +local t_self = { __index = f_self } +local t_ignore = { __newindex = f_ignore } function table.setmetatableindex(t,f) local m = getmetatable(t) diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua index a3fbc7ff6..4604b9bde 100644 --- a/scripts/context/stubs/mswin/mtxrun.lua +++ b/scripts/context/stubs/mswin/mtxrun.lua @@ -4235,13 +4235,13 @@ end -- table namespace ? -local function f_empty() return "" end -- t,k -local function f_self(t,k) t[k] = k return k end -local function f_ignore() end -- t,k,v +local function f_empty () return "" end -- t,k +local function f_self (t,k) t[k] = k return k end +local function f_ignore() end -- t,k,v -local t_empty = { __index = empty } -local t_self = { __index = self } -local t_ignore = { __newindex = ignore } +local t_empty = { __index = f_empty } +local t_self = { __index = f_self } +local t_ignore = { __newindex = f_ignore } function table.setmetatableindex(t,f) local m = getmetatable(t) diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun index a3fbc7ff6..4604b9bde 100755 --- a/scripts/context/stubs/unix/mtxrun +++ b/scripts/context/stubs/unix/mtxrun @@ -4235,13 +4235,13 @@ end -- table namespace ? -local function f_empty() return "" end -- t,k -local function f_self(t,k) t[k] = k return k end -local function f_ignore() end -- t,k,v +local function f_empty () return "" end -- t,k +local function f_self (t,k) t[k] = k return k end +local function f_ignore() end -- t,k,v -local t_empty = { __index = empty } -local t_self = { __index = self } -local t_ignore = { __newindex = ignore } +local t_empty = { __index = f_empty } +local t_self = { __index = f_self } +local t_ignore = { __newindex = f_ignore } function table.setmetatableindex(t,f) local m = getmetatable(t) diff --git a/tex/context/base/anch-pgr.mkiv b/tex/context/base/anch-pgr.mkiv index af99602c7..19cc43e0e 100644 --- a/tex/context/base/anch-pgr.mkiv +++ b/tex/context/base/anch-pgr.mkiv @@ -65,7 +65,8 @@ \appendtoks \presetpositionanchors \to \beforeeverypage \appendtoks \presetpositionanchors \to \aftereverypage -% todo: change with each page size change +% todo: change with each page size change .. can be made more efficient +% as some values are the same \def\registerpageposition#1% this one is flushed first ! {\ifpositioning\ifcase\realpageno\or diff --git a/tex/context/base/anch-pos.lua b/tex/context/base/anch-pos.lua index f94ed2e9a..dcecf3c79 100644 --- a/tex/context/base/anch-pos.lua +++ b/tex/context/base/anch-pos.lua @@ -14,14 +14,17 @@ more efficient.</p> -- to be considered: store as numbers instead of string -- maybe replace texsp by our own converter (stay at the lua end) +-- eventually mp will have large numbers so we can use sp there too local tostring = tostring local concat, format, gmatch = table.concat, string.format, string.gmatch local lpegmatch = lpeg.match local allocate, mark = utilities.storage.allocate, utilities.storage.mark -local texsp = tex.sp +local texsp, texcount = tex.sp, tex.count ----- texsp = string.todimen -- because we cache this is much faster but no rounding +local pts = number.pts + local collected = allocate() local tobesaved = allocate() @@ -32,24 +35,43 @@ local jobpositions = { job.positions = jobpositions -_ptbs_, _pcol_ = tobesaved, collected -- global - -local dx, dy, nx, ny = "0pt", "0pt", 0, 0 +_plib_ = jobpositions local function initializer() tobesaved = jobpositions.tobesaved collected = jobpositions.collected - _ptbs_ = tobesaved -- global - _pcol_ = collected -- global - -- local p = collected["page:0"] -- page:1 - -- if p then - -- dx, nx = p[2] or "0pt", 0 - -- dy, ny = p[3] or "0pt", 0 - -- end end job.register('job.positions.collected', tobesaved, initializer) +function jobpositions.setraw(name,val) + tobesaved[name] = val +end + +function jobpositions.setdim(name,wd,ht,dp,plus) -- will be used when we move to sp allover + if plus then + tobesaved[name] = { texcount.realpageno, pdf.h, pdf.v, wd, ht, dp, plus } + elseif w then + tobesaved[name] = { texcount.realpageno, pdf.h, pdf.v, wd, ht, dp } + else + tobesaved[name] = { texcount.realpageno, pdf.h, pdf.v } + end +end + +function jobpositions.setall(name,p,x,y,wd,ht,dp,plus) -- will be used when we move to sp allover + if plus then + tobesaved[name] = { p, x, y, wd, ht, dp, plus } + elseif w then + tobesaved[name] = { p, x, y, wd, ht, dp } + else + tobesaved[name] = { p, x, y } + end +end + +-- _praw_ = jobpositions.setraw +-- _pdim_ = jobpositions.setdim +-- _pall_ = jobpositions.setall + function jobpositions.copy(target,source) collected[target] = collected[source] or tobesaved[source] end @@ -58,10 +80,14 @@ function jobpositions.replace(name,...) collected[name] = {...} end +function jobpositions.v(id,default) + return collected[id] or tobesaved[id] or default +end + function jobpositions.page(id) local jpi = collected[id] or tobesaved[id] if jpi then - return texsp(jpi[1]) + return jpi[1] else return 0 end @@ -70,7 +96,7 @@ end function jobpositions.x(id) local jpi = collected[id] or tobesaved[id] if jpi then - return texsp(jpi[2]) - nx + return jpi[2] else return 0 end @@ -78,44 +104,28 @@ end function jobpositions.y(id) local jpi = collected[id] or tobesaved[id] - if jpi then - return texsp(jpi[3]) - ny - else - return 0 - end + return jpi and jpi[3] or 0 end function jobpositions.width(id) local jpi = collected[id] or tobesaved[id] - if jpi then - return texsp(jpi[4]) - else - return 0 - end + return jpi and jpi[4] or 0 end function jobpositions.height(id) local jpi = collected[id] or tobesaved[id] - if jpi then - return texsp(jpi[5]) - else - return 0 - end + return jpi and jpi[5] or 0 end function jobpositions.depth(id) local jpi = collected[id] or tobesaved[id] - if jpi then - return texsp(jpi[6]) - else - return 0 - end + return jpi and jpi[6] or 0 end function jobpositions.xy(id) local jpi = collected[id] or tobesaved[id] if jpi then - return texsp(jpi[2]) - nx, texsp(jpi[3]) - ny + return jpi[2], jpi[3] else return 0, 0 end @@ -124,7 +134,7 @@ end function jobpositions.lowerleft(id) local jpi = collected[id] or tobesaved[id] if jpi then - return texsp(jpi[2]) - nx, texsp(jpi[3]) - texsp(jpi[6]) - ny + return jpi[2], jpi[3] - jpi[6] else return 0, 0 end @@ -133,7 +143,7 @@ end function jobpositions.lowerright(id) local jpi = collected[id] or tobesaved[id] if jpi then - return texsp(jpi[2]) + texsp(jpi[4]) - nx, texsp(jpi[3]) - texsp(jpi[6]) - ny + return jpi[2] + jpi[4], jpi[3] - jpi[6] else return 0, 0 end @@ -142,7 +152,7 @@ end function jobpositions.upperright(id) local jpi = collected[id] or tobesaved[id] if jpi then - return texsp(jpi[2]) + texsp(jpi[4]) - nx, texsp(jpi[3]) + texsp(jpi[5]) - ny + return jpi[2] + jpi[4], jpi[3] + jpi[5] else return 0, 0 end @@ -151,7 +161,7 @@ end function jobpositions.upperleft(id) local jpi = collected[id] or tobesaved[id] if jpi then - return texsp(jpi[2]) - nx, texsp(jpi[3]) + texsp(jpi[5]) - ny + return jpi[2], jpi[3] + jpi[5] else return 0, 0 end @@ -160,7 +170,7 @@ end function jobpositions.position(id) local jpi = collected[id] or tobesaved[id] if jpi then - return texsp(jpi[1]), texsp(jpi[2]), texsp(jpi[3]), texsp(jpi[4]), texsp(jpi[5]), texsp(jpi[6]) + return jpi[1], jpi[2], jpi[3], jpi[4], jpi[5], jpi[6] else return 0, 0, 0, 0, 0, 0 end @@ -176,11 +186,11 @@ function jobpositions.extra(id,n,default) -- assume numbers split = lpegmatch(splitter,jpi[7]) jpi[0] = split end - return texsp(split[n]) or default + return texsp(split[n]) or default -- watch the texsp here end end -local function overlapping(one,two,overlappingmargin) +local function overlapping(one,two,overlappingmargin) -- hm, strings so this is wrong .. texsp one = collected[one] or tobesaved[one] two = collected[two] or tobesaved[two] if one and two and one[1] == two[1] then @@ -252,50 +262,37 @@ end function commands.MPx(id) local jpi = collected[id] or tobesaved[id] local x = jpi and jpi[2] - if x then - if nx == 0 then - context(x) - else - context('\\the\\dimexpr%s-%s\\relax',x,dx) - end - else - context('0pt') - end + context(x and pts(x) or '0pt') end function commands.MPy(id) local jpi = collected[id] or tobesaved[id] local y = jpi and jpi[3] - if y then - if ny == 0 then - context(y) - else - context('\\the\\dimexpr%s-%s\\relax',y,dy) - end - else - context('0pt') - end + context(y and pts(y) or '0pt') end function commands.MPw(id) local jpi = collected[id] or tobesaved[id] - context(jpi and jpi[4] or '0pt') + local w = jpi and jpi[4] + context(w and pts(w) or '0pt') end function commands.MPh(id) local jpi = collected[id] or tobesaved[id] - context(jpi and jpi[5] or '0pt') + local h = jpi and jpi[5] + context(h and pts(h) or '0pt') end function commands.MPd(id) local jpi = collected[id] or tobesaved[id] - context(jpi and jpi[6] or '0pt') + local d = jpi and jpi[6] + context(d and pts(d) or '0pt') end function commands.MPxy(id) local jpi = collected[id] or tobesaved[id] if jpi then - context('(%s-%s,%s-%s)',jpi[2],dx,jpi[3],dy) + context('(%s,%s)',pts(jpi[2]),pts(jpi[3])) else context('(0,0)') end @@ -304,7 +301,7 @@ end function commands.MPll(id) local jpi = collected[id] or tobesaved[id] if jpi then - context('(%s-%s,%s-%s-%s)',jpi[2],dx,jpi[3],jpi[6],dy) + context('(%s,%s)',pts(jpi[2]),pts(jpi[3]-jpi[6])) else context('(0,0)') end @@ -313,7 +310,7 @@ end function commands.MPlr(id) local jpi = collected[id] or tobesaved[id] if jpi then - context('(%s+%s-%s,%s-%s-%s)',jpi[2],jpi[4],dx,jpi[3],jpi[6],dy) + context('(%s,%s)',pts(jpi[2]+jpi[4]),pts(jpi[3]-jpi[6])) else context('(0,0)') end @@ -322,7 +319,7 @@ end function commands.MPur(id) local jpi = collected[id] or tobesaved[id] if jpi then - context('(%s+%s-%s,%s+%s-%s)',jpi[2],jpi[4],dx,jpi[3],jpi[5],dy) + context('(%s,%s)',pts(jpi[2]+jpi[4]),pts(jpi[3]+jpi[5])) else context('(0,0)') end @@ -331,7 +328,7 @@ end function commands.MPul(id) local jpi = collected[id] or tobesaved[id] if jpi then - context('(%s-%s,%s+%s-%s)',jpi[2],dx,jpi[3],jpi[5],dy) + context('(%s,%s)',pts(jpi[2]),pts(jpi[3]+jpi[5])) else context('(0,0)') end diff --git a/tex/context/base/anch-pos.mkiv b/tex/context/base/anch-pos.mkiv index 2893e5e2c..45585cf03 100644 --- a/tex/context/base/anch-pos.mkiv +++ b/tex/context/base/anch-pos.mkiv @@ -106,31 +106,41 @@ %D method is implemented in a special driver. If needed, the %D driver can fall back on the following macros. -\def\dolazysaveposition #1#2#3#4{\normalexpanded{\ctxlatelua{_ptbs_['#1']={#2,"#3","#4"}}}} -\def\dolazysavepositionwhd #1#2#3#4#5#6#7{\normalexpanded{\ctxlatelua{_ptbs_['#1']={#2,"#3","#4","#5","#6","#7"}}}} -\def\dolazysavepositionplus#1#2#3#4#5#6#7#8{\normalexpanded{\ctxlatelua{_ptbs_['#1']={#2,"#3","#4","#5","#6","#7","#8"}}}} -\def\dosaveposition #1#2#3#4{\normalexpanded{\ctxlua {_ptbs_['#1']={#2,"#3","#4"}}}} -\def\dosavepositionwhd #1#2#3#4#5#6#7{\normalexpanded{\ctxlua {_ptbs_['#1']={#2,"#3","#4","#5","#6","#7"}}}} -\def\dosavepositionplus #1#2#3#4#5#6#7#8{\normalexpanded{\ctxlua {_ptbs_['#1']={#2,"#3","#4","#5","#6","#7","#8"}}}} - -\def\lastsavedpositionx {\the\dimexpr\pdflastxpos\scaledpoint\relax} -\def\lastsavedpositiony {\the\dimexpr\pdflastypos\scaledpoint\relax} -\let\savecurrentposition\pdfsavepos - -\def\dosetposition#1% will become commands.setposition - {\savecurrentposition - \normalexpanded{\ctxlatelua{_ptbs_['#1']={% - \noexpand\realfolio,"\noexpand\lastsavedpositionx","\noexpand\lastsavedpositiony"}}}} - -\def\dosetpositionwhd#1#2#3#4% - {\savecurrentposition - \normalexpanded{\ctxlatelua{_ptbs_['#1']={% - \noexpand\realfolio,"\noexpand\lastsavedpositionx","\noexpand\lastsavedpositiony","#2","#3","#4"}}}} - -\def\dosetpositionplus#1#2#3#4#5% - {\savecurrentposition - \normalexpanded{\ctxlatelua{_ptbs_['#1']={% - \noexpand\realfolio,"\noexpand\lastsavedpositionx","\noexpand\lastsavedpositiony","#2","#3","#4","#5"}}}} +% \def\dolazysaveposition #1#2#3#4{\normalexpanded{\ctxlatelua{_ptbs_['#1']={#2,"#3","#4"}}}} +% \def\dolazysavepositionwhd #1#2#3#4#5#6#7{\normalexpanded{\ctxlatelua{_ptbs_['#1']={#2,"#3","#4","#5","#6","#7"}}}} +% \def\dolazysavepositionplus#1#2#3#4#5#6#7#8{\normalexpanded{\ctxlatelua{_ptbs_['#1']={#2,"#3","#4","#5","#6","#7","#8"}}}} +% \def\dosaveposition #1#2#3#4{\normalexpanded{\ctxlua {_ptbs_['#1']={#2,"#3","#4"}}}} +% \def\dosavepositionwhd #1#2#3#4#5#6#7{\normalexpanded{\ctxlua {_ptbs_['#1']={#2,"#3","#4","#5","#6","#7"}}}} +% \def\dosavepositionplus #1#2#3#4#5#6#7#8{\normalexpanded{\ctxlua {_ptbs_['#1']={#2,"#3","#4","#5","#6","#7","#8"}}}} +% +% \def\lastsavedpositionx {\the\dimexpr\pdflastxpos\scaledpoint\relax} +% \def\lastsavedpositiony {\the\dimexpr\pdflastypos\scaledpoint\relax} +% \let\savecurrentposition\pdfsavepos +% +% \def\dosetposition#1% will become commands.setposition +% {\savecurrentposition +% \normalexpanded{\ctxlatelua{_ptbs_['#1']={% +% \noexpand\realfolio,"\noexpand\lastsavedpositionx","\noexpand\lastsavedpositiony"}}}} +% +% \def\dosetpositionwhd#1#2#3#4% +% {\savecurrentposition +% \normalexpanded{\ctxlatelua{_ptbs_['#1']={% +% \noexpand\realfolio,"\noexpand\lastsavedpositionx","\noexpand\lastsavedpositiony","#2","#3","#4"}}}} +% +% \def\dosetpositionplus#1#2#3#4#5% +% {\savecurrentposition +% \normalexpanded{\ctxlatelua{_ptbs_['#1']={% +% \noexpand\realfolio,"\noexpand\lastsavedpositionx","\noexpand\lastsavedpositiony","#2","#3","#4","#5"}}}} + +\def\dosaveposition #1#2#3#4{\normalexpanded{\ctxlua {_plib_.setall("#1",#2,#3,#4)}}} +\def\dosavepositionwhd #1#2#3#4#5#6#7{\normalexpanded{\ctxlua {_plib_.setall("#1",#2,#3,#4,#5,#6,#7)}}} +\def\dosavepositionplus#1#2#3#4#5#6#7#8{\normalexpanded{\ctxlua {_plib_.setall("#1",#2,#3,#4,#5,#6,#7,"#8")}}} + +\def\dosetposition #1{\normalexpanded{\ctxlatelua{_plib_.setdim("#1")}}} +\def\dosetpositionwhd #1#2#3#4{\normalexpanded{\ctxlatelua{_plib_.setdim("#1","#2","#3","#4")}}} +\def\dosetpositionplus #1#2#3#4#5{\normalexpanded{\ctxlatelua{_plib_.setdim("#1","#2","#3","#4","#5")}}} + +% % % \let\dosetpositionpapersize\gobbletwoarguments @@ -155,11 +165,6 @@ \def\replacepospxywhd#1#2#3#4#5#6#7{\ctxcommand{replacepospxywhd('#1',\number#2,"\the\dimexpr#3\relax","\the\dimexpr#4\relax","\the\dimexpr#5\relax","\the\dimexpr#6\relax","\the\dimexpr#7\relax")}} -%D For postprocessing purposes, we save the number of -%D positions. - -\newcount\currentpositions % current number of positions - %D The next switch can be used to communicate a special %D situation. Positioning and associated actions can be %D executed any time. However, in for instance backgrounds @@ -241,8 +246,7 @@ {\ifpositioning \else \global\positioningtrue \dosetpositionpapersize\printpaperwidth\printpaperheight - \fi - \global\advance\currentpositions\plusone} + \fi} \def\setpositiononly#1% {\iftrialtypesetting diff --git a/tex/context/base/back-exp.lua b/tex/context/base/back-exp.lua index 11ed26366..1f5aefb86 100644 --- a/tex/context/base/back-exp.lua +++ b/tex/context/base/back-exp.lua @@ -309,6 +309,7 @@ local styletemplate = [[ font-style : %s ; font-variant : %s ; font-weight : %s ; + font-family : %s ; color : %s ; }]] @@ -349,7 +350,11 @@ local function allusedstyles(xmlfile) local s = xml.css.fontspecification(data.style) local c = xml.css.colorspecification(data.color) result[#result+1] = format(styletemplate,element,detail, - s.style or "inherit",s.variant or "inherit",s.weight or "inherit",c or "inherit") + s.style or "inherit", + s.variant or "inherit", + s.weight or "inherit", + s.family or "inherit", + c or "inherit") end end return concat(result,"\n\n") diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii index 92b424e29..49df33cd1 100644 --- a/tex/context/base/cont-new.mkii +++ b/tex/context/base/cont-new.mkii @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2011.10.08 11:42} +\newcontextversion{2011.10.12 10:14} %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/cont-new.mkiv b/tex/context/base/cont-new.mkiv index 30e4d1da5..bf51178c4 100644 --- a/tex/context/base/cont-new.mkiv +++ b/tex/context/base/cont-new.mkiv @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2011.10.08 11:42} +\newcontextversion{2011.10.12 10:14} %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/context-version.pdf b/tex/context/base/context-version.pdf Binary files differindex be97edf8e..291952221 100644 --- a/tex/context/base/context-version.pdf +++ b/tex/context/base/context-version.pdf diff --git a/tex/context/base/context-version.png b/tex/context/base/context-version.png Binary files differindex f004e888a..3359f9548 100644 --- a/tex/context/base/context-version.png +++ b/tex/context/base/context-version.png diff --git a/tex/context/base/context.mkii b/tex/context/base/context.mkii index b1a490767..4636d7a4e 100644 --- a/tex/context/base/context.mkii +++ b/tex/context/base/context.mkii @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2011.10.08 11:42} +\edef\contextversion{2011.10.12 10:14} %D For those who want to use this: diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index 6bfecdbc8..509e457b0 100644 --- a/tex/context/base/context.mkiv +++ b/tex/context/base/context.mkiv @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2011.10.08 11:42} +\edef\contextversion{2011.10.12 10:14} %D For those who want to use this: @@ -321,6 +321,7 @@ \loadmarkfile{typo-cln} \loadmarkfile{typo-spa} \loadmarkfile{typo-krn} +\loadmkvifile{typo-itc} \loadmarkfile{typo-dir} \loadmarkfile{typo-brk} \loadmarkfile{typo-cap} diff --git a/tex/context/base/core-uti.lua b/tex/context/base/core-uti.lua index ca699d297..dc341334f 100644 --- a/tex/context/base/core-uti.lua +++ b/tex/context/base/core-uti.lua @@ -34,7 +34,7 @@ local report_jobcontrol = logs.reporter("jobcontrol") job = job or { } local job = job -job.version = 1.15 +job.version = 1.16 -- some day we will implement loading of other jobs and then we need -- job.jobs diff --git a/tex/context/base/file-job.mkvi b/tex/context/base/file-job.mkvi index 3270d9511..6f26d26d7 100644 --- a/tex/context/base/file-job.mkvi +++ b/tex/context/base/file-job.mkvi @@ -235,4 +235,26 @@ \def\stopenvironmentindeed {\signalendofinput\v!project} +%D Relatively new (might move as it depends on setups): + +\unexpanded\def\startdocument % todo: dostarttagged\t!document + {\dosingleargument\start_document} + +\unexpanded\def\start_document[#settings]% + {\setvariables[document][#settings]% + \starttext + \documentvariable\c!before} + +\unexpanded\def\stopdocument % todo: dostoptagged\t!document + {\documentvariable\c!after + \stoptext} + +\def\documentvariable#1% + {\getvariable{document}{#1}} + +\setvariables + [document] + [\c!before=\directsetup{document:start}, + \c!after=\directsetup{document:stop}] + \protect \endinput diff --git a/tex/context/base/file-mod.lua b/tex/context/base/file-mod.lua index 4d1c9aadf..2dce38bad 100644 --- a/tex/context/base/file-mod.lua +++ b/tex/context/base/file-mod.lua @@ -20,7 +20,7 @@ at the <l n='tex'/> side.</p> local format, concat, tonumber = string.format, table.concat, tonumber -local trace_modules = false trackers.register("modules.loading", function(v) trace_modules = v end) +local trace_modules = false trackers.register("modules.loading", function(v) trace_modules = v end) local report_modules = logs.reporter("resolvers","modules") diff --git a/tex/context/base/font-con.lua b/tex/context/base/font-con.lua index 18123ed1e..5352977ee 100644 --- a/tex/context/base/font-con.lua +++ b/tex/context/base/font-con.lua @@ -26,30 +26,30 @@ local report_defining = logs.reporter("fonts","defining") <p>Here we only implement a few helper functions.</p> --ldx]]-- -local fonts = fonts -local constructors = { } -fonts.constructors = constructors -local handlers = { } -fonts.handlers = handlers +local fonts = fonts +local constructors = { } +fonts.constructors = constructors +local handlers = { } +fonts.handlers = handlers -local specifiers = fonts.specifiers -local contextsetups = specifiers.contextsetups -local contextnumbers = specifiers.contextnumbers +local specifiers = fonts.specifiers +local contextsetups = specifiers.contextsetups +local contextnumbers = specifiers.contextnumbers -local allocate = utilities.storage.allocate -local setmetatableindex = table.setmetatableindex +local allocate = utilities.storage.allocate +local setmetatableindex = table.setmetatableindex -- will be directives -constructors.dontembed = allocate() -constructors.mathactions = { } -constructors.autocleanup = true -constructors.namemode = "fullpath" -- will be a function +constructors.dontembed = allocate() +constructors.mathactions = { } +constructors.autocleanup = true +constructors.namemode = "fullpath" -- will be a function -constructors.version = 1.01 -constructors.cache = containers.define("fonts", "constructors", constructors.version, false) +constructors.version = 1.01 +constructors.cache = containers.define("fonts", "constructors", constructors.version, false) -constructors.privateoffset = 0xF0000 -- 0x10FFFF +constructors.privateoffset = 0xF0000 -- 0x10FFFF -- This might become an interface; @@ -406,6 +406,26 @@ function constructors.scale(tfmdata,specification) target.mathparameters = nil -- nop end -- + local italickey = "italic" + if hasmath then + if properties.no_mathitalics then + italickey = "italic_correction" -- context specific trickery + if trace_defining then + report_defining("math italics disabled for: name '%s', fullname: '%s', filename: '%s'", + name or "noname",fullname or "nofullname",filename or "nofilename") + end + end + autoitalic = false -- new + else + if properties.no_textitalics then + italickey = "italic_correction" -- context specific trickery + if trace_defining then + report_defining("text italics disabled for: name '%s', fullname: '%s', filename: '%s'", + name or "noname",fullname or "nofullname",filename or "nofilename") + end + end + end + -- local sharedkerns = { } -- for unicode, character in next, characters do @@ -501,16 +521,16 @@ function constructors.scale(tfmdata,specification) chr.right_protruding = protrusionfactor*width*vr end end - -- todo: hasitalic + -- if autoitalic then local vi = description.italic or (description.boundingbox[3] - description.width + autoitalic) if vi and vi ~= 0 then - chr.italic = vi*hdelta + chr[italickey] = vi*hdelta end elseif hasitalic then local vi = description.italic or character.italic -- why character if vi and vi ~= 0 then - chr.italic = vi*hdelta + chr[italickey] = vi*hdelta end end -- to be tested @@ -1128,7 +1148,7 @@ function constructors.collectprocessors(what,tfmdata,features,trace,report) end end end - else + elseif trace then report("no feature processors for mode %s for font %s", mode or 'unknown', tfmdata.properties.fullname or 'unknown') end diff --git a/tex/context/base/font-ctx.lua b/tex/context/base/font-ctx.lua index 7b5b5fd10..9a92cadec 100644 --- a/tex/context/base/font-ctx.lua +++ b/tex/context/base/font-ctx.lua @@ -108,10 +108,11 @@ setmetatableindex(fontdata, function(t,k) return nulldata end) local chardata = allocate() -- chardata local parameters = allocate() -local csnames = allocate() -- namedata local quaddata = allocate() local markdata = allocate() -local xheightdata = allocate() -- xheightdata +local xheightdata = allocate() +local csnames = allocate() -- namedata +local italicsdata = allocate() hashes.characters = chardata hashes.parameters = parameters @@ -119,6 +120,7 @@ hashes.quads = quaddata hashes.marks = markdata hashes.xheights = xheightdata hashes.csnames = csnames +hashes.italics = italicsdata setmetatableindex(chardata, function(t,k) local characters = fontdata[k].characters @@ -153,6 +155,18 @@ setmetatableindex(xheightdata, function(t,k) return quad end) +setmetatableindex(italicsdata, function(t,k) + local properties = fontdata[k].properties + local italics = properties and properties.italic_correction + if italics then + italics = chardata[k] + else + italics = false + end + t[k] = italics + return italics +end) + -- this cannot be a feature initializer as there is no auto namespace -- so we never enter the loop then; we can store the defaults in the tma -- file (features.gpos.mkmk = 1 etc) diff --git a/tex/context/base/font-ext.lua b/tex/context/base/font-ext.lua index 598cfb2cb..a76d73ad9 100644 --- a/tex/context/base/font-ext.lua +++ b/tex/context/base/font-ext.lua @@ -529,6 +529,28 @@ registerafmfeature { } } +local function initializenotextitalics(tfmdata,value) + tfmdata.properties.no_textitalics = value +end + +registerotffeature { + name = "notextitalics", + description = "don't pass text italic correction to tex", + initializers = { + base = initializenotextitalics, + node = initializenotextitalics, + } +} + +registerafmfeature { + name = "notextitalics", + description = "don't pass text italic correction to tex", + initializers = { + base = initializenotextitalics, + node = initializenotextitalics, + } +} + -- slanting local function initializeslant(tfmdata,value) diff --git a/tex/context/base/font-otn.lua b/tex/context/base/font-otn.lua index 914a7dee9..beb3ae740 100644 --- a/tex/context/base/font-otn.lua +++ b/tex/context/base/font-otn.lua @@ -445,7 +445,7 @@ local function alternative_glyph(start,alternatives,kind,chainname,chainlookupna return choice, value end -local function multiple_glyphs(start,multiple) +local function multiple_glyphs(start,multiple) -- marks ? local nofmultiples = #multiple if nofmultiples > 0 then start.char = multiple[1] @@ -957,7 +957,7 @@ single lookup case. The efficiency of the replacements can be improved by deleti as less as needed but that would also make the code even more messy.</p> --ldx]]-- -local function delete_till_stop(start,stop,ignoremarks) +local function delete_till_stop(start,stop,ignoremarks) -- keeps start local n = 1 if start == stop then -- done @@ -986,10 +986,6 @@ match.</p> function chainprocs.gsub_single(start,stop,kind,chainname,currentcontext,lookuphash,currentlookup,chainlookupname,chainindex) -- todo: marks ? ---~ if not chainindex then ---~ delete_till_stop(start,stop) -- ,currentlookup.flags[1] ---~ stop = start ---~ end local current = start local subtables = currentlookup.subtables if #subtables > 1 then @@ -1035,7 +1031,7 @@ the match.</p> --ldx]]-- function chainprocs.gsub_multiple(start,stop,kind,chainname,currentcontext,lookuphash,currentlookup,chainlookupname) - delete_till_stop(start,stop) -- we can assume that marks are to be deleted + delete_till_stop(start,stop) -- we could pass ignoremarks as #3 .. local startchar = start.char local subtables = currentlookup.subtables local lookupname = subtables[1] @@ -1565,37 +1561,41 @@ local function show_skip(kind,chainname,char,ck,class) end local function normal_handle_contextchain(start,kind,chainname,contexts,sequence,lookuphash) - -- local rule, lookuptype, sequence, f, l, lookups = ck[1], ck[2] ,ck[3], ck[4], ck[5], ck[6] - local flags, done = sequence.flags, false - local skipmark, skipligature, skipbase = flags[1], flags[2], flags[3] - local someskip = skipmark or skipligature or skipbase -- could be stored in flags for a fast test (hm, flags could be false !) - local markclass = sequence.markclass -- todo, first we need a proper test - local skipped = false + -- local rule, lookuptype, sequence, f, l, lookups = ck[1], ck[2] ,ck[3], ck[4], ck[5], ck[6] + local flags = sequence.flags + local done = false + local skipmark = flags[1] + local skipligature = flags[2] + local skipbase = flags[3] + local someskip = skipmark or skipligature or skipbase -- could be stored in flags for a fast test (hm, flags could be false !) + local markclass = sequence.markclass -- todo, first we need a proper test + local skipped = false for k=1,#contexts do - local match, current, last = true, start, start - local ck = contexts[k] - local seq = ck[3] - local s = #seq + local match = true + local current = start + local last = start + local ck = contexts[k] + local seq = ck[3] + local s = #seq -- f..l = mid string if s == 1 then -- never happens match = current.id == glyph_code and current.subtype<256 and current.font == currentfont and seq[1][current.char] else - -- todo: better space check (maybe check for glue) + -- maybe we need a better space check (maybe check for glue or category or combination) + -- we cannot optimize for n=2 because there can be disc nodes local f, l = ck[4], ck[5] -- current match - if f == 1 and f == l then + if f == 1 and f == l then -- current only -- already a hit - match = true - else + -- match = true + else -- before/current/after | before/current | current/after -- no need to test first hit (to be optimized) - local n = f + 1 - last = last.next - -- we cannot optimize for n=2 because there can be disc nodes - -- if not someskip and n == l then - -- -- n=2 and no skips then faster loop - -- match = last and last.id == glyph_code and last.subtype<256 and last.font == currentfont and seq[n][last.char] - -- else + if f == l then -- new, else last out of sync (f is > 1) + -- match = true + else + local n = f + 1 + last = last.next while n <= l do if last then local id = last.id @@ -1617,24 +1617,29 @@ local function normal_handle_contextchain(start,kind,chainname,contexts,sequence end n = n + 1 else - match = false break + match = false + break end else - match = false break + match = false + break end else - match = false break + match = false + break end - elseif id == disc_code then -- what to do with kerns? + elseif id == disc_code then last = last.next else - match = false break + match = false + break end else - match = false break + match = false + break end end - -- end + end end -- before if match and f > 1 then @@ -1658,26 +1663,31 @@ local function normal_handle_contextchain(start,kind,chainname,contexts,sequence elseif seq[n][char] then n = n -1 else - match = false break + match = false + break end else - match = false break + match = false + break end else - match = false break + match = false + break end elseif id == disc_code then -- skip 'm elseif seq[n][32] then n = n -1 else - match = false break + match = false + break end prev = prev.prev elseif seq[n][32] then -- somehat special, as zapfino can have many preceding spaces n = n -1 else - match = false break + match = false + break end end elseif f == 2 then @@ -1685,7 +1695,8 @@ local function normal_handle_contextchain(start,kind,chainname,contexts,sequence else for n=f-1,1 do if not seq[n][32] then - match = false break + match = false + break end end end @@ -1713,26 +1724,31 @@ local function normal_handle_contextchain(start,kind,chainname,contexts,sequence elseif seq[n][char] then n = n + 1 else - match = false break + match = false + break end else - match = false break + match = false + break end else - match = false break + match = false + break end elseif id == disc_code then -- skip 'm elseif seq[n][32] then -- brrr n = n + 1 else - match = false break + match = false + break end current = current.next elseif seq[n][32] then n = n + 1 else - match = false break + match = false + break end end elseif s-l == 1 then @@ -1740,7 +1756,8 @@ local function normal_handle_contextchain(start,kind,chainname,contexts,sequence else for n=l+1,s do if not seq[n][32] then - match = false break + match = false + break end end end diff --git a/tex/context/base/lpdf-ano.lua b/tex/context/base/lpdf-ano.lua index fe48613a9..0769296c8 100644 --- a/tex/context/base/lpdf-ano.lua +++ b/tex/context/base/lpdf-ano.lua @@ -429,8 +429,11 @@ function specials.page(var,actions) if type(p) == "function" then -- double p = p() else - p = tonumber(references.realpageofpage(tonumber(o))) + p = references.realpageofpage(tonumber(p)) end + -- if p then + -- var.r = p + -- end end return link(nil,nil,nil,p or var.operation,actions) end @@ -454,9 +457,15 @@ function specials.userpage(var,actions) else local p = var.r if not p then -- todo: call special from reference code - p = tonumber(references.realpageofpage(var.operation)) + p = var.operation + if p then -- no function and special check here. only numbers + p = references.realpageofpage(tonumber(p)) + end + -- if p then + -- var.r = p + -- end end - return link(nil,nil,nil,p,actions) + return link(nil,nil,nil,p or var.operation,actions) end end diff --git a/tex/context/base/lxml-css.lua b/tex/context/base/lxml-css.lua index e88c3a4a1..cf946daf7 100644 --- a/tex/context/base/lxml-css.lua +++ b/tex/context/base/lxml-css.lua @@ -94,11 +94,24 @@ css.padding = padding -- context("%ssp",padding(str,pixel,hsize,exheight,emwidth)) -- end -local pattern = Cf( Ct("") * Cg( - Cc("style") * (C("italic") + C("oblique")) - + Cc("variant") * C("smallcaps") - + Cc("weight") * C("bold") - + P(1) +local pattern = Cf( Ct("") * ( + Cg( + Cc("style") * ( + C("italic") + + C("oblique") + + C("slanted") / "oblique" + ) + + Cc("variant") * ( + (C("smallcaps") + C("caps")) / "small-caps" + ) + + Cc("weight") * + C("bold") + + Cc("family") * ( + (C("mono") + C("type")) / "monospace" -- just ignore the "space(d)" + + (C("sansserif") + C("sans")) / "sans-serif" -- match before serif + + C("serif") + ) + ) + P(1) )^0 , rawset) function css.fontspecification(str) diff --git a/tex/context/base/lxml-tex.lua b/tex/context/base/lxml-tex.lua index 0dd85a808..e77736b43 100644 --- a/tex/context/base/lxml-tex.lua +++ b/tex/context/base/lxml-tex.lua @@ -966,14 +966,20 @@ end local function command(collected,cmd,otherwise) local n = collected and #collected if n and n > 0 then - for c=1,n do + local wildcard = find(cmd,"%*") + for c=1,n do -- maybe optimize for n=1 local e = collected[c] local ix = e.ix + local name = e.name if not ix then - lxml.addindex(e.name,false,true) + lxml.addindex(name,false,true) ix = e.ix end - contextsprint(ctxcatcodes,"\\xmlw{",cmd,"}{",e.name,"::",ix,"}") + if wildcard then + contextsprint(ctxcatcodes,"\\xmlw{",(gsub(cmd,"%*",e.tg)),"}{",name,"::",ix,"}") + else + contextsprint(ctxcatcodes,"\\xmlw{",cmd,"}{",name,"::",ix,"}") + end end elseif otherwise then contextsprint(ctxcatcodes,"\\xmlw{",otherwise,"}{#1}") diff --git a/tex/context/base/m-flow.lua b/tex/context/base/m-flow.lua index 9efa7a121..62d31c197 100644 --- a/tex/context/base/m-flow.lua +++ b/tex/context/base/m-flow.lua @@ -30,19 +30,19 @@ local defaults = { dot = "", }, shape = { -- FLOS - rulethickness = 65435, + rulethickness = 65436, default = "", framecolor = "green", backgroundcolor = "yellow", }, focus = { -- FLOF - rulethickness = 65435, + rulethickness = 65436, framecolor = "red", backgroundcolor = "yellow", }, line = { -- FLOL - rulethickness = 65435, - radius = 65435, + rulethickness = 65436, + radius = 65436, color = "blue", corner = "", dash = "", @@ -102,17 +102,6 @@ table.setmetatableindex(validshapes,function(t,k) return v end) -local replacements = { - ["0"] = "a", ["1"] = "b", ["2"] = "c", ["3"] = "d", ["4"] = "e", - ["5"] = "f", ["6"] = "g", ["7"] = "h", ["8"] = "i", ["9"] = "j", -} - -local function cleanname(str) - str = gsub(str,"[0-9]",replacements) - str = gsub(str,"[^a-zA-Z]","_") - return str -end - local charts = { } local data, hash, temp, last_x, last_y, name @@ -373,17 +362,20 @@ local function process_cells(chart,xoffset,yoffset) local shapedata = validshapes[shape] context("flow_begin_sub_chart ;") if shapedata.kind == "line" then - context("flow_shape_line_color := \\MPcolor{%s} ;", settings.line.color) - context("flow_shape_fill_color := \\MPcolor{%s} ;", settings.line.color) - context("flow_shape_line_width := %s ; ", points(settings.line.rulethickness)) + local linesettings = settings.line + context("flow_shape_line_color := \\MPcolor{%s} ;", linesettings.color) + context("flow_shape_fill_color := \\MPcolor{%s} ;", linesettings.backgroundcolor) + context("flow_shape_line_width := %s ; ", points(linesettingsrulethickness)) elseif hasfocus then -- doifcommonelse{FLOWcell,FLOWfocus}@@FLOWfocus - context("flow_shape_line_color := \\MPcolor{%s} ;", settings.focus.framecolor) - context("flow_shape_fill_color := \\MPcolor{%s} ;", settings.focus.backgroundcolor) - context("flow_shape_line_width := %s ; ", points(settings.focus.rulethickness)) + local focussettings = settings.focus + context("flow_shape_line_color := \\MPcolor{%s} ;", focussettings.framecolor) + context("flow_shape_fill_color := \\MPcolor{%s} ;", focussettings.backgroundcolor) + context("flow_shape_line_width := %s ; ", points(focussettings.rulethickness)) else - context("flow_shape_line_color := \\MPcolor{%s} ;", settings.shape.framecolor) - context("flow_shape_fill_color := \\MPcolor{%s} ;", settings.shape.backgroundcolor) - context("flow_shape_line_width := %s ; " , points(settings.shape.rulethickness)) + local shapesettings = settings.shape + context("flow_shape_line_color := \\MPcolor{%s} ;", shapesettings.framecolor) + context("flow_shape_fill_color := \\MPcolor{%s} ;", shapesettings.backgroundcolor) + context("flow_shape_line_width := %s ; " , points(shapesettings.rulethickness)) end context("bodyfontsize := 10pt ;") -- todo context("flow_peepshape := false ;") -- todo @@ -416,18 +408,19 @@ local function process_connections(chart,xoffset,yoffset) local otherx, othery, location = othercell.x, othercell.y, connection.location if otherx > 0 and othery > 0 and cellx > 0 and celly > 0 and connection.location then -- move to setter - local what_cell, where_cell, what_other, where_other = match(location,"([%+%-pm]-)([lrtb])([%+%-pm]-)([lrtb])") + local what_cell, where_cell, what_other, where_other = match(location,"([%+%-pm]-)([lrtb]),?([%+%-pm]-)([lrtb])") local what_cell = what [what_cell] or 0 local what_other = what [what_other] or 0 local where_cell = where[where_cell] or "left" local where_other = where[where_other] or "right" - context("flow_smooth := %s ;", settings.line.corner == variables.round and "true" or "false") - context("flow_dashline := %s ;", settings.line.dash == variables.yes and "true" or "false") - context("flow_arrowtip := %s ;", settings.line.arrow == variables.yes and "true" or "false") - context("flow_touchshape := %s ;", settings.line.offset == variables.none and "true" or "false") + local linesettings = settings.line + context("flow_smooth := %s ;", linesettings.corner == variables.round and "true" or "false") + context("flow_dashline := %s ;", linesettings.dash == variables.yes and "true" or "false") + context("flow_arrowtip := %s ;", linesettings.arrow == variables.yes and "true" or "false") + context("flow_touchshape := %s ;", linesettings.offset == variables.none and "true" or "false") context("flow_dsp_x := %s ; flow_dsp_y := %s ;",connection.dx or 0, connection.dy or 0) - context("flow_connection_line_color := green ;",chart.settings.line.color) - context("flow_connection_line_width := 2pt ;",points(chart.settings.line.rulethickness)) + context("flow_connection_line_color := \\MPcolor{%s} ;",linesettings.color) + context("flow_connection_line_width := 2pt ;",points(linesettings.rulethickness)) context("flow_connect_%s_%s(%s,%s,%s) (%s,%s,%s) ;",where_cell,where_other,cellx,celly,what_cell,otherx,othery,what_other) context("flow_dsp_x := 0 ; flow_dsp_y := 0 ;") end @@ -544,10 +537,10 @@ local function makechart(chart) local gridwidth = shapewidth + 2*settings.chart.dx local shapeheight = settings.chart.height local gridheight = shapeheight + 2*settings.chart.dy - context("flow_grid_width := %s ;", points(gridwidth)) - context("flow_grid_height := %s ;", points(gridheight)) - context("flow_shape_width := %s ;", points(shapewidth)) - context("flow_shape_height := %s ;", points(shapeheight)) + context("flow_grid_width := %s ;", points(gridwidth)) + context("flow_grid_height := %s ;", points(gridheight)) + context("flow_shape_width := %s ;", points(shapewidth)) + context("flow_shape_height := %s ;", points(shapeheight)) -- local radius = settings.line.radius local rulethickness = settings.line.rulethickness @@ -562,10 +555,10 @@ local function makechart(chart) radius = dy end end - context("flow_connection_line_width := %s ;", points(rulethickness)) + context("flow_connection_line_width := %s ;", points(rulethickness)) context("flow_connection_smooth_size := %s ;", points(radius)) - context("flow_connection_arrow_size := %s ;", points(radius)) - context("flow_connection_dash_size := %s ;", points(radius)) + context("flow_connection_arrow_size := %s ;", points(radius)) + context("flow_connection_dash_size := %s ;", points(radius)) -- local offset = settings.chart.offset -- todo: pass string if offset == variables.none or offset == variables.overlay or offset == "" then diff --git a/tex/context/base/m-flow.mkvi b/tex/context/base/m-flow.mkvi index c0c08059b..425d7e490 100644 --- a/tex/context/base/m-flow.mkvi +++ b/tex/context/base/m-flow.mkvi @@ -28,18 +28,6 @@ \unprotect -\ifdefined \installsimplecommandhandler \else - - \unexpanded\def\installsimplecommandhandler#1#2#3% no define - {\installparameterhandler {#1}{#2}% - \installparameterhashhandler{#1}{#2}% - \installparametersethandler {#1}{#2}% - \installrootparameterhandler{#1}{#2}% - \installsetuphandler {#1}{#2}% - \installattributehandler {#1}{#2}} - -\fi - % todo: figure out a nice way to define the lot: share current and % support current as name (nb: we need to set parent then) @@ -175,6 +163,7 @@ line = { rulethickness = \number\dimexpr\FLOWlineparameter\c!rulethickness, radius = \number\dimexpr\FLOWlineparameter\c!radius, + color = "\FLOWlineparameter\c!color", corner = "\FLOWlineparameter\c!corner", dash = "\FLOWlineparameter\c!dash", arrow = "\FLOWlineparameter\c!arrow", @@ -221,6 +210,7 @@ line = { rulethickness = \number\dimexpr\FLOWlineparameter\c!rulethickness, radius = \number\dimexpr\FLOWlineparameter\c!radius, + color = "\FLOWlineparameter\c!color", corner = "\FLOWlineparameter\c!corner", dash = "\FLOWlineparameter\c!dash", arrow = "\FLOWlineparameter\c!arrow", diff --git a/tex/context/base/meta-pdh.mkiv b/tex/context/base/meta-pdh.mkiv index 677b40aec..30402c6ea 100644 --- a/tex/context/base/meta-pdh.mkiv +++ b/tex/context/base/meta-pdh.mkiv @@ -652,16 +652,6 @@ %D \setMPlayer [test] [somepos-2] {Whatever we need there!} %D \stoptyping -% \defineMPspecial{50} % x y width height label -% {\dosavepositionwhd -% {\gMPs5}% -% {0}% -% {\the\dimexpr-\MPllx\onebasepoint+\gMPs1\onebasepoint\relax} -% {\the\dimexpr\gMPs2\onebasepoint-\scratchdimen+\MPury\onebasepoint\relax}% scratchdimen ? -% {\the\dimexpr\gMPs3\onebasepoint\relax}% -% {\the\dimexpr\gMPs4\onebasepoint\relax}% -% {0pt}} - \startMPinitializations mp_shade_version := 2 ; \stopMPinitializations diff --git a/tex/context/base/mlib-pps.lua b/tex/context/base/mlib-pps.lua index ca3bbaa75..85352d8fc 100644 --- a/tex/context/base/mlib-pps.lua +++ b/tex/context/base/mlib-pps.lua @@ -468,7 +468,7 @@ local do_begin_fig = "; beginfig(1) ; " local do_end_fig = "; endfig ;" local do_safeguard = ";" -function metapost.texttextsdata() +function metapost.textextsdata() local t, nt, n = { }, 0, 0 for n, box in next, textexts do if box then @@ -573,7 +573,7 @@ function metapost.graphic_extra_pass(askedfig) metapost.process(current_format, { wrappit and do_begin_fig or "", no_trial_run, - concat(metapost.texttextsdata()," ;\n"), + concat(metapost.textextsdata()," ;\n"), current_initializations, do_safeguard, current_graphic, @@ -753,7 +753,7 @@ local function tx_analyze(object,prescript) -- todo: hash content and reuse them s = format("\\colored[c=%f,m=%f,y=%f,k=%f]%s",c[1],c[2],c[3],c[4],s) end end - context.MPLIBsettext(tx_number,s) + context.MPLIBsettext(tx_number,s) -- combine colored in here, saves call metapost.multipass = true end end diff --git a/tex/context/base/mult-aux.mkiv b/tex/context/base/mult-aux.mkiv index e19db2481..ea4337809 100644 --- a/tex/context/base/mult-aux.mkiv +++ b/tex/context/base/mult-aux.mkiv @@ -274,6 +274,15 @@ \installswitchsetuphandler {#1}{#2}% \installattributehandler {#1}{#2}} +\unexpanded\def\installsimplecommandhandler#1#2#3% no define (experiment) + {\installparameterhandler {#1}{#2}% + \installparameterhashhandler{#1}{#2}% + \installparametersethandler {#1}{#2}% + \installrootparameterhandler{#1}{#2}% + \installsetuphandler {#1}{#2}% + \installattributehandler {#1}{#2}} + + \unexpanded\def\installnamespace#1% {\setvalue{????#1}{@@@@#1}} diff --git a/tex/context/base/mult-low.lua b/tex/context/base/mult-low.lua index d76010e07..3b581061e 100644 --- a/tex/context/base/mult-low.lua +++ b/tex/context/base/mult-low.lua @@ -46,7 +46,7 @@ return { "startcomponent", "stopcomponent", "component", "startproduct", "stopproduct", "product", "startproject", "stopproject", "project", - "starttext", "stoptext", + "starttext", "stoptext", "startdocument", "stopdocument", "documentvariable", "startmodule", "stopmodule", "usemodule", }, ["helpers"] = { @@ -61,6 +61,7 @@ return { -- "htdp", "unvoidbox", + "vfilll", -- "scratchcounter", "globalscratchcounter", "scratchdimen", "globalscratchdimen", @@ -88,6 +89,7 @@ return { "doifdimensionelse", "doifnumberelse", "doifcommonelse", "doifcommon", "doifnotcommon", "doifinstring", "doifnotinstring", "doifinstringelse", + "doifassignmentelse", -- "tracingall", "tracingnone", "loggingall", -- @@ -141,5 +143,6 @@ return { -- "startnointerference", "stopnointerference", -- + "strut", "setstrut", "strutbox", "strutht", "strutdp", "strutwd", } } diff --git a/tex/context/base/node-aux.lua b/tex/context/base/node-aux.lua index df62dda27..fc5b8ff9c 100644 --- a/tex/context/base/node-aux.lua +++ b/tex/context/base/node-aux.lua @@ -6,6 +6,8 @@ if not modules then modules = { } end modules ['node-aux'] = { license = "see context related readme files" } +-- todo: n1 .. n2 : __concat metatable + local type, tostring = type, tostring local nodes, node = nodes, node diff --git a/tex/context/base/node-tra.lua b/tex/context/base/node-tra.lua index 5012095b3..3b5b1d018 100644 --- a/tex/context/base/node-tra.lua +++ b/tex/context/base/node-tra.lua @@ -643,15 +643,32 @@ local bpfactor = number.dimenfactors.bp local stripper = lpeg.patterns.stripzeros local points = function(n) - return lpegmatch(stripper,format("%.5fpt",n*ptfactor)) + if not n or n == 0 then + return "0pt" + else + return lpegmatch(stripper,format("%.5fpt",n*ptfactor)) + end end local basepoints = function(n) - return lpegmatch(stripper,format("%.5fbp",n*bpfactor)) + if not n or n == 0 then + return "0bp" + else + return lpegmatch(stripper,format("%.5fbp",n*bpfactor)) + end +end + +local pts = function(n) + if not n or n == 0 then + return "0pt" + else + return format("%.5fpt",n*ptfactor) + end end number.points = points number.basepoints = basepoints +number.pts = pts --~ function nodes.thespec(s) --~ local stretch_order = s.stretch_order diff --git a/tex/context/base/page-txt.mkiv b/tex/context/base/page-txt.mkiv index 012f1acf0..57f391f7c 100644 --- a/tex/context/base/page-txt.mkiv +++ b/tex/context/base/page-txt.mkiv @@ -446,6 +446,8 @@ \calculatehsizes \swapmargins \vskip\dimexpr\headerheight+\headerdistance+\layoutparameter\c!textdistance\relax + \dontleavehmode + % \dosetanchor{text}% failed experiment \hbox to \makeupwidth {\bgroup \swapmargins diff --git a/tex/context/base/s-fnt-21.mkiv b/tex/context/base/s-fnt-21.mkiv index 3e1bf0ad3..a48854679 100644 --- a/tex/context/base/s-fnt-21.mkiv +++ b/tex/context/base/s-fnt-21.mkiv @@ -1,4 +1,4 @@ -D \module +%D \module %D [ file=s-fnt-20, %D version=2009.01.10, %D title=\CONTEXT\ Style File, diff --git a/tex/context/base/s-fnt-26.mkiv b/tex/context/base/s-fnt-26.mkiv index b8da09533..904091f06 100644 --- a/tex/context/base/s-fnt-26.mkiv +++ b/tex/context/base/s-fnt-26.mkiv @@ -71,4 +71,12 @@ \def\showgoodiesfeaturesets #1{\ctxlua{document.show_goodies_featuresets ("#1")}} \def\showgoodiescolorschemes#1{\ctxlua{document.show_goodies_colorschemes("#1")}} -\endinput +\continueifinputfile{s-fnt-26.mkiv} + +\starttext + + \showgoodiesstylistics {husayni} + \showgoodiesfeaturesets {husayni} + \showgoodiescolorschemes{husayni} + +\stoptext diff --git a/tex/context/base/s-fnt-35.mkiv b/tex/context/base/s-fnt-35.mkiv new file mode 100644 index 000000000..157d3062c --- /dev/null +++ b/tex/context/base/s-fnt-35.mkiv @@ -0,0 +1,341 @@ +%D \module +%D [ file=s-fnt-35, +%D version=2011.10.10, +%D title=\CONTEXT\ Style File, +%D subtitle=Feature List, +%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. + +% we already have a way to show character tables + +\startluacode + +-- the table will move to a font-* file + +moduledata.fonts = moduledata.fonts or { } + +local digits = { + dflt = { + dflt = "1234567890 1/2", + }, +} + +local punctuation = { + dflt = { + dflt = ". , : ; ? !", + }, +} + +local symbols = { + dflt = { + dflt = "@ # $ % & * () [] {} <> + - = / |", + }, +} + +local uppercase = { + latn = { + dflt = "ABCDEFGHIJKLMNOPQRSTUVWXYZ", + }, + grek = { + dftl = "ΑΒΓΔΕΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ", + }, + cyrl= { + dflt = "АБВГДЕЖЗИІЙКЛМНОПРСТУФХЦЧШЩЪЫЬѢЭЮЯѲ" + }, +} + +local lowercase = { + latn = { + dftl = "abcdefghijklmnopqrstuvwxyz", + }, + grek = { + dftl = "αβγδεηθικλμνξοπρστυφχψω", + }, + cyrl= { + dflt = "абвгдежзиійклмнопрстуфхцчшщъыьѣэюяѳ" + }, +} + +local samples = { + digits = digits, + punctuation = punctuation, + symbols = symbols, + uppercase = uppercase, + lowercase = lowercase, +} + +fonts.tracers.samples = samples + +table.setmetatableindex(uppercase, function(t,k) return rawget(t,"latn") end) +table.setmetatableindex(lowercase, function(t,k) return rawget(t,"latn") end) +table.setmetatableindex(digits, function(t,k) return rawget(t,"dflt") end) +table.setmetatableindex(symbols, function(t,k) return rawget(t,"dflt") end) +table.setmetatableindex(punctuation, function(t,k) return rawget(t,"dflt") end) + +table.setmetatableindex(uppercase.latn, function(t,k) return rawget(t,"dflt") end) +table.setmetatableindex(uppercase.grek, function(t,k) return rawget(t,"dflt") end) +table.setmetatableindex(uppercase.cyrl, function(t,k) return rawget(t,"dflt") end) + +table.setmetatableindex(lowercase.latn, function(t,k) return rawget(t,"dflt") end) +table.setmetatableindex(lowercase.grek, function(t,k) return rawget(t,"dflt") end) +table.setmetatableindex(lowercase.cyrl, function(t,k) return rawget(t,"dflt") end) + +table.setmetatableindex(digits.dflt, function(t,k) return rawget(t,"dflt") end) +table.setmetatableindex(symbols.dflt, function(t,k) return rawget(t,"dflt") end) +table.setmetatableindex(punctuation.dflt, function(t,k) return rawget(t,"dflt") end) + +fonts.constructors.keys = { + properties = { + encodingbytes = "number", + embedding = "number", + cidinfo = "table", + format = "string", + fontname = "string", + fullname = "string", + filename = "filename", + psname = "string", + name = "string", + virtualized = "boolean", + italic_correction = "boolean", + auto_italic_correction = "boolean", + no_stackmath = "boolean", + noglyphnames = "boolean", + mode = "string", + has_math = "boolean", + no_math_italics = "boolean", + no_text_italics = "boolean", + finalized = "boolean", + }, + parameters = { + mathsize = "scaledpoints", + scriptpercentage = "float", + scriptscriptpercentage = "float", + units = "cardinal", + designsize = "basepoints", + expansion = "table", + protrusion = "table", + expand_factor = "float", + slant_factor = "float", + factor = "float", + hfactor = "float", + vfactor = "float", + size = "scaledpoints", + units = "scaledpoints", + scaledpoints = "scaledpoints", + slant = "float", + space = "scaledpoints", + space_stretch = "scaledpoints", + space_shrink = "scaledpoints", + x_height = "scaledpoints", + quad = "scaledpoints", + extra_space = "scaledpoints", + ascender = "scaledpoints", + descender = "scaledpoints", + }, +} + +-- parameters.expansion = { +-- stretch = tfmdata.stretch or 0, +-- shrink = tfmdata.shrink or 0, +-- step = tfmdata.step or 0, +-- auto = tfmdata.auto_expand or false, +-- } +-- parameters.protrusion = { +-- auto = auto_protrude +-- } + +local function showtable(t,keys) + if t then + context.starttabulate { "|Tl|Tl|" } + for k, v in table.sortedhash(keys) do + context.NC() + context(k) + context.NC() + local tk = t[k] + if not tk then + context("<unset>") + elseif v == "filename" then + context(file.basename(tk)) + elseif v == "boolean" then + context(tostring(tk or false)) + elseif v == "scaledpoints" or v == "basepoints" then + context(number.points(tk)) + elseif v == "table" then + -- todo + context("<table>") + else + context(tostring(tk)) + end + context.NC() + context.NR() + end + context.stoptabulate() + end +end + +function moduledata.fonts.show_properties() + local tfmdata = fonts.hashes.identifiers[font.current()] + showtable(tfmdata.properties,fonts.constructors.keys.properties) +end + +function moduledata.fonts.show_parameters() + local tfmdata = fonts.hashes.identifiers[font.current()] + showtable(tfmdata.parameters,fonts.constructors.keys.parameters) +end + +function moduledata.fonts.show_positional_features() + local tfmdata = fonts.hashes.identifiers[font.current()] + local resources = tfmdata.resources + if resources then + local features = resources.features + if features then + local gpos = features.gpos + if gpos and next(gpos) then + context.starttabulate { "|Tl|Tl|Tlp|" } + for feature, scripts in table.sortedpairs(gpos) do + for script, languages in table.sortedpairs(scripts) do + context.NC() + context(feature) + context.NC() + context(script) + context.NC() + context(table.concat(table.sortedkeys(languages)," ")) + context.NC() + context.NR() + end + end + context.stoptabulate() + else + context("no entries") + context.par() + end + end + end +end + +local dynamics = true + +function moduledata.fonts.show_substitution_features() + local tfmdata = fonts.hashes.identifiers[font.current()] + local resources = tfmdata.resources + if resources then + local features = resources.features + if features then + local gsub = features.gsub + if gsub then + local makes_sense = { } + for feature, scripts in table.sortedpairs(gsub) do + for script, languages in table.sortedpairs(scripts) do + for language in table.sortedpairs(languages) do + local tag = string.format("dummy-%s-%s-%s",feature,script,language) + local fnt = string.format("file:%s*%s",file.basename(tfmdata.properties.filename),tag) + context.definefontfeature ( + { tag }, + { + mode = "node", + script = script, + language = language, + [feature] = "yes" + } + ) + if not dynamics then + context.definefont( { fnt }, { fnt } ) + end + makes_sense[#makes_sense+1] = { + feature = feature, + tag = tag, + script = script, + language = language, + fontname = fnt, + } + end + end + end + if #makes_sense > 0 then + context.starttabulate { "|Tl|Tl|Tl|p|" } + for i=1,#makes_sense do + local data = makes_sense[i] + local script = data.script + local language = data.language + context.NC() + context(data.feature) + context.NC() + context(script) + context.NC() + context(language) + context.NC() + if not dynamics then + context.startfont { data.fontname } + else + context.addff(data.tag) + end + context.verbatim(samples.lowercase [script][language]) context.par() + context.verbatim(samples.uppercase [script][language]) context.par() + context.verbatim(samples.digits [script][language]) context.par() + context.verbatim(samples.punctuation[script][language]) + context.verbatim(samples.symbols [script][language]) + if not dynamics then + context.stopfont() + end + context.NC() + context.NR() + end + context.stoptabulate() + else + context("no entries") + context.par() + end + end + end + end +end + +function moduledata.fonts.show_a_lot(title) + + if title == "" then title = false end + + if title then + context.starttitle { title = title } + end + + context.startsubject { title = "Properties" } + moduledata.fonts.show_properties() + context.stopsubject() + + context.startsubject { title = "Parameters" } + moduledata.fonts.show_parameters() + context.stopsubject() + + context.startsubject { title = "Positional features" } + moduledata.fonts.show_positional_features() + context.stopsubject() + + context.startsubject { title = "Substitution features" } + moduledata.fonts.show_substitution_features() + context.stopsubject() + + if title then + context.stoptitle() + end + +end + +\stopluacode + +% todo: make a mtxrun --script --font <name> option + +\continueifinputfile{s-fnt-35.mkiv} + +\usemodule[art-01] + +\setupbodyfont + [cambria] + +\starttext + \ctxlua{moduledata.fonts.show_a_lot("Cambria")} +\stoptext diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf Binary files differindex ad5015f08..533df1129 100644 --- a/tex/context/base/status-files.pdf +++ b/tex/context/base/status-files.pdf diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf Binary files differindex 6ecca0352..3ce4e99c2 100644 --- a/tex/context/base/status-lua.pdf +++ b/tex/context/base/status-lua.pdf diff --git a/tex/context/base/strc-lst.mkiv b/tex/context/base/strc-lst.mkiv index ec09b3b2d..d24a8b2f5 100644 --- a/tex/context/base/strc-lst.mkiv +++ b/tex/context/base/strc-lst.mkiv @@ -390,7 +390,6 @@ \dostructurelistinject[#1][\c!type=userdata][#2]% \fi}} - \def\dowritetolist[#1][#2]#3#4% we can overload location {\doif{\namedlistparameter{#1}\c!state}\v!start {\ifsecondargument diff --git a/tex/context/base/strc-ref.lua b/tex/context/base/strc-ref.lua index da0549bb9..f83301b4e 100644 --- a/tex/context/base/strc-ref.lua +++ b/tex/context/base/strc-ref.lua @@ -1770,7 +1770,7 @@ end local plist, nofrealpages -local function realpageofpage(p) +local function realpageofpage(p) -- the last one counts ! if not plist then local pages = structures.pages.collected nofrealpages = #pages diff --git a/tex/context/base/syst-aux.mkiv b/tex/context/base/syst-aux.mkiv index 3ef9acaaa..f73f4436c 100644 --- a/tex/context/base/syst-aux.mkiv +++ b/tex/context/base/syst-aux.mkiv @@ -3240,6 +3240,8 @@ \egroup +\unexpanded\def\texdefinition#1{\csname\ifcsname#1\endcsname#1\else donothing\fi\endcsname} + % This is a first variant, more might be added: \def\starttexcode{\unprotect} diff --git a/tex/context/base/task-ini.lua b/tex/context/base/task-ini.lua index c3122aee0..b044e8c6a 100644 --- a/tex/context/base/task-ini.lua +++ b/tex/context/base/task-ini.lua @@ -41,6 +41,7 @@ appendaction("processors", "fonts", "nodes.handlers.stripping") appendaction("processors", "lists", "typesetters.spacings.handler") -- disabled appendaction("processors", "lists", "typesetters.kerns.handler") -- disabled appendaction("processors", "lists", "typesetters.digits.handler") -- disabled (after otf handling) +appendaction("processors", "lists", "typesetters.italics.handler") -- disabled (after otf/kern handling) appendaction("shipouts", "normalizers", "nodes.handlers.cleanuppage") -- disabled appendaction("shipouts", "normalizers", "typesetters.alignments.handler") @@ -99,6 +100,7 @@ disableaction("processors", "typesetters.directions.handler") disableaction("processors", "languages.words.check") disableaction("processors", "typesetters.spacings.handler") disableaction("processors", "typesetters.kerns.handler") +disableaction("processors", "typesetters.italics.handler") disableaction("processors", "nodes.handlers.stripping") disableaction("shipouts", "typesetters.alignments.handler") diff --git a/tex/context/base/typo-cln.lua b/tex/context/base/typo-cln.lua index a8542c1a1..e36575bce 100644 --- a/tex/context/base/typo-cln.lua +++ b/tex/context/base/typo-cln.lua @@ -1,6 +1,6 @@ -if not modules then modules = { } end modules ['typo-cap'] = { +if not modules then modules = { } end modules ['typo-cln'] = { version = 1.001, - comment = "companion to typo-cap.mkiv", + comment = "companion to typo-cln.mkiv", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright = "PRAGMA ADE / ConTeXt Development Team", license = "see context related readme files" @@ -15,8 +15,8 @@ local utfbyte = utf.byte local trace_cleaners = false trackers.register("typesetters.cleaners", function(v) trace_cleaners = v end) local trace_autocase = false trackers.register("typesetters.cleaners.autocase",function(v) trace_autocase = v end) -local report_cleaners = logs.reporters("nodes","cleaners") -local report_autocase = logs.reporters("nodes","autocase") +local report_cleaners = logs.reporter("nodes","cleaners") +local report_autocase = logs.reporter("nodes","autocase") typesetters.cleaners = typesetters.cleaners or { } local cleaners = typesetters.cleaners diff --git a/tex/context/base/typo-itc.lua b/tex/context/base/typo-itc.lua new file mode 100644 index 000000000..9cf4de8cd --- /dev/null +++ b/tex/context/base/typo-itc.lua @@ -0,0 +1,214 @@ +if not modules then modules = { } end modules ['typo-itc'] = { + version = 1.001, + comment = "companion to typo-itc.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +local utfchar = utf.char + +local trace_italics = false trackers.register("typesetters.italics", function(v) trace_italics = v end) + +local report_italics = logs.reporter("nodes","italics") + +typesetters.italics = typesetters.italics or { } +local italics = typesetters.italics + +local nodecodes = nodes.nodecodes +local glyph_code = nodecodes.glyph +local kern_code = nodecodes.kern +local glue_code = nodecodes.glue + +local tasks = nodes.tasks + +local insert_node_after = node.insert_after +local delete_node = nodes.delete +local has_attribute = node.has_attribute + +local texattribute = tex.attribute +local a_italics = attributes.private("italics") +local unsetvalue = attributes.unsetvalue + +----- new_correction = nodes.pool.fontkern +----- new_correction = nodes.pool.fontkern +local new_correction = nodes.pool.glue + +local points = number.points + +local fonthashes = fonts.hashes +local fontdata = fonthashes.identifiers +local chardata = fonthashes.characters +local italicsdata = fonthashes.italics + +local forcedvariant = false + +function typesetters.italics.forcevariant(variant) + forcedvariant = variant +end + +-- we could delay the calculations in the font scaler to here: +-- +-- local description = descdata[char] +-- local vi = description.italic or (description.boundingbox[3] - description.width + properties[font].auto_italic_correction) +-- if vi and vi ~= 0 then +-- italic = vi*parameters[font].hfactor +-- end +-- +-- this saves us quite entries in the characters table + +local function process(namespace,attribute,head) + local done = false + local italic = 0 + local lastfont = nil + local lastattr = nil + local previous = nil + local prevchar = nil + local current = head + local inserted = nil + while current do + local id = current.id + if id == glyph_code then + local font = current.font + local char = current.char + local data = italicsdata[font] + if font ~= lastfont then + if italic ~= 0 then + if data then + if trace_italics then + report_italics("ignoring %s between italic %s and italic %s",points(italic),utfchar(prevchar),utfchar(char)) + end + else + if trace_italics then + report_italics("inserting %s between italic %s and regular %s",points(italic),utfchar(prevchar),utfchar(char)) + end + insert_node_after(head,previous,new_correction(italic),new_correction(italic)) + done = true + end + elseif inserted and data then + if trace_italics then + report_italics("deleting last correction before %s",utfchar(char)) + end + delete_node(head,inserted) + end + end + if data then + local attr = forcedvariant or has_attribute(current,attribute) + if attr and attr > 0 then + local cd = data[char] + italic = cd.italic or cd.italic_correction + if not italic then + italic = 0 + elseif italic ~= 0 then + lastfont = font + lastattr = attr + previous = current + prevchar = char + end + else + italic = 0 + end + else + italic = 0 + end + inserted = nil + elseif id == kern_code then + inserted = nil + italic = 0 + elseif id == glue_code then + if italic ~= 0 then + if trace_italics then + report_italics("inserting %s between italic %s and glue",points(italic),utfchar(prevchar)) + end + inserted = new_correction(italic) + insert_node_after(head,previous,inserted) + italic = 0 + done = true + end + elseif italic ~= 0 then + if trace_italics then + report_italics("inserting %s between italic %s and whatever",points(italic),utfchar(prevchar)) + end + inserted = nil + insert_node_after(head,previous,new_correction(italic),new_correction(italic)) + italic = 0 + done = true + end + current = current.next + end + if italic ~= 0 and lastattr > 1 then -- more control is needed here + if trace_italics then + report_italics("inserting %s between italic %s and end of list",points(italic),utfchar(prevchar)) + end + insert_node_after(head,previous,new_correction(italic),new_correction(italic)) + done = true + end + return head, done +end + +local enable + +enable = function() + tasks.enableaction("processors","typesetters.italics.handler") + if trace_italics then + report_italics("enabling italics") + end + enable = false +end + +function italics.set(n) + if enable then + enable() + end + texattribute[a_italics] = n +end + +function italics.reset() + texattribute[a_italics] = unsetvalue +end + +italics.handler = nodes.installattributehandler { + name = "italics", + namespace = italics, + processor = process, +} + +local variables = interfaces.variables +local settings_to_hash = utilities.parsers.settings_to_hash + +function commands.setupitaliccorrection(option) -- no grouping ! + if enable then + enable() + end + local options = settings_to_hash(option) + local variant = unsetvalue + if options[variables.text] then + variant = 1 + elseif options[variables.always] then + variant = 2 + end + if options[variables.global] then + forcevariant = variant + texattribute[a_italics] = unsetvalue + else + forcevariant = false + texattribute[a_italics] = variant + end + if trace_italics then + report_italics("force: %s, variant: %s",tostring(forcevariant),tostring(variant ~= unsetvalue and variant)) + end +end + +-- for manuals: + +local stack = { } + +function commands.pushitaliccorrection() + table.insert(stack,{forcevariant, texattribute[a_italics] }) +end + +function commands.popitaliccorrection() + local top = table.remove(stack) + forcevariant = top[1] + texattribute[a_italics] = top[2] +end diff --git a/tex/context/base/typo-itc.mkvi b/tex/context/base/typo-itc.mkvi new file mode 100644 index 000000000..471b905b4 --- /dev/null +++ b/tex/context/base/typo-itc.mkvi @@ -0,0 +1,62 @@ +%D \module +%D [ file=typo-itc, +%D version=2011.10.08, +%D title=\CONTEXT\ Typesetting Macros, +%D subtitle=Italic Correction, +%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. + +\writestatus{loading}{ConTeXt Typesetting Macros / Italics Corrections} + +\unprotect + +%D The brave might try: +%D +%D \starttyping +%D \definefontfeature[default][default][itlc=yes,notextitalics=yes] +%D \setupitaliccorrection[global,always] +%D \stoptyping + +\registerctxluafile{typo-itc}{1.001} + +\definesystemattribute[italics][public] + +% \let\/=/ +% \let\emphasiscorrection\donothing + +\ifdefined \normalitaliccorrection \else + \let\normalitaliccorrection\italiccorrection +\fi + +\unexpanded\def\italiccorrection + {\ifnum\attribute\italicsattribute<\plusone\normalitaliccorrection\fi} + +\let\/\italicscorrection + +% 1 = end of word +% 2 = end of word and end of a list + +\unexpanded\def\setitaliccorrection[#code]% rather low level (might go away) + {\ctxlua{typesetters.italics.set(\number#code)}} + +\unexpanded\def\resetitaliccorrection% rather low level (might go away) + {\ctxlua{typesetters.italics.reset()}} + +% global : no attributes, just always (faster and less memory) +% text : only text +% always : text and boxes +% none : - + +\unexpanded\def\setupitaliccorrection[#settings]% + {\ctxcommand{setupitaliccorrection("#settings")}} + +\appendtoks + \attribute\italicsattribute\attributeunsetvalue +\to \everymathematics + +\protect \endinput diff --git a/tex/context/base/typo-mar.lua b/tex/context/base/typo-mar.lua index 8b25d95f9..431523154 100644 --- a/tex/context/base/typo-mar.lua +++ b/tex/context/base/typo-mar.lua @@ -13,6 +13,66 @@ if not modules then modules = { } end modules ['typo-mar'] = { -- using margin data then as also vertical spacing kicks in -- * floating margin data, with close-to-call anchoring +-- -- experiment (does not work, too much interference) +-- +-- local pdfprint = pdf.print +-- local format = string.format +-- +-- anchors = anchors or { } +-- +-- local whatever = { } +-- local factor = (7200/7227)/65536 +-- +-- function anchors.set(tag) +-- whatever[tag] = { pdf.h, pdf.v } +-- end +-- +-- function anchors.reset(tag) +-- whatever[tag] = nil +-- end +-- +-- function anchors.startmove(tag,how) +-- local w = whatever[tag] +-- if not w then +-- -- error +-- elseif how == "horizontal" or how == "h" then +-- pdfprint("page",format(" q 1 0 0 1 %s 0 cm ", (w[1] - pdf.h) * factor)) +-- elseif how == "vertical" or how == "v" then +-- pdfprint("page",format(" q 1 0 0 1 0 %s cm ", (w[2] - pdf.v) * factor)) +-- else +-- pdfprint("page",format(" q 1 0 0 1 %s %s cm ", (w[1] - pdf.h) * factor, (w[2] - pdf.v) * factor)) +-- end +-- end +-- +-- function anchors.stopmove(tag) +-- local w = whatever[tag] +-- if not w then +-- -- error +-- else +-- pdfprint("page"," Q ") +-- end +-- end +-- +-- local latelua = nodes.pool.latelua +-- +-- function anchors.node_set(tag) +-- return latelua(format("anchors.set(%q)",tag)) +-- end +-- +-- function anchors.node_reset(tag) +-- return latelua(format("anchors.reset(%q)",tag)) +-- end +-- +-- function anchors.node_start_move(tag,how) +-- return latelua(format("anchors.startmove(%q,%q)",tag,how)) +-- end +-- +-- function anchors.node_stop_move(tag) +-- return latelua(format("anchors.stopmove(%q)",tag)) +-- end + +-- so far + local format = string.format local insert, remove = table.insert, table.remove local setmetatable, next = setmetatable, next @@ -84,6 +144,7 @@ local nodepool = nodes.pool local new_kern = nodepool.kern local new_stretch = nodepool.stretch local new_usernumber = nodepool.usernumber +local new_latelua = nodepool.latelua local texcount = tex.count local texdimen = tex.dimen @@ -150,14 +211,25 @@ local defaults = { local enablelocal, enableglobal -- forward reference (delayed initialization) +-- local function showstore(store,banner) +-- if #store == 0 then +-- report_margindata("%s: nothing stored",banner) +-- else +-- for i=1,#store do +-- local si =store[i] +-- report_margindata("%s: stored at %s: %s => %s",banner,i,si.name or "no name",nodes.toutf(si.box.list)) +-- end +-- end +-- end + local function showstore(store,banner) - if #store == 0 then - report_margindata("%s: nothing stored",banner) - else - for i=1,#store do + if next(store) then + for i, si in table.sortedpairs(store) do local si =store[i] report_margindata("%s: stored at %s: %s => %s",banner,i,si.name or "no name",nodes.toutf(si.box.list)) end + else + report_margindata("%s: nothing stored",banner) end end @@ -195,11 +267,21 @@ function margins.save(t) showstore(store,"before ") end if name and name ~= "" then - for i=#store,1,-1 do - local si = store[i] - if si.name == name then - local s = remove(store,i) - free_node_list(s.box) + if inlinestore then -- todo: inline store has to be done differently (not sparse) + local t = table.sortedkeys(store) for j=#t,1,-1 do local i = t[i] + local si = store[i] + if si.name == name then + local s = remove(store,i) + free_node_list(s.box) + end + end + else + for i=#store,1,-1 do + local si = store[i] + if si.name == name then + local s = remove(store,i) + free_node_list(s.box) + end end end if trace_marginstack then @@ -253,7 +335,7 @@ end -- When the prototype inner/outer code that was part of this proved to be -- okay it was moved elsewhere. -local status, nofstatus = { }, 0 +local status, nofstatus, anchors = { }, 0, 0 local function realign(current,candidate) local location = candidate.location @@ -285,6 +367,7 @@ local function realign(current,candidate) if leftpage then leftdistance, rightdistance = rightdistance, leftdistance end + if location == v_left then delta = hoffset + width + leftdistance + leftdelta elseif location == v_right then @@ -302,15 +385,31 @@ local function realign(current,candidate) delta = -hoffset - hsize - rightdistance + rightdelta end end + -- we assume that list is a hbox, otherwise we had to take the whole current -- in order to get it right + current.width = 0 ---~ delta = delta + hsize - current.list = hpack_nodes(link_nodes(new_kern(-delta),current.list,new_kern(delta))) - current.width = 0 - if trace_margindata then - report_margindata("realigned: %s, location: %s, margin: %s",candidate.n,location,margin) + + if candidate.inline then -- this mess is needed for alignments (combinations) + anchors = anchors + 1 + local anchor = new_latelua(format("_plib_.setraw('_md_:%s',pdf.h)",anchors)) + local blob_x = job.positions.v("_md_:"..anchors) or 0 + local text_x = job.positions.x("text:"..tex.count.realpageno) or 0 + local move_x = text_x - blob_x + delta = delta - move_x + current.list = hpack_nodes(link_nodes(anchor,new_kern(-delta),current.list,new_kern(delta))) + if trace_margindata then + report_margindata("realigned: %s, location: %s, margin: %s, move: %s",candidate.n,location,margin,number.points(move_x)) + end + else + current.list = hpack_nodes(link_nodes(new_kern(-delta),current.list,new_kern(delta))) + if trace_margindata then + report_margindata("realigned: %s, location: %s, margin: %s",candidate.n,location,margin) + end end + + current.width = 0 end local function realigned(current,a) @@ -468,7 +567,7 @@ local function flushed(scope,parent) -- current is hlist local location = locations[l] local store = displaystore[category][location][scope] while true do - local candidate = remove(store,1) + local candidate = remove(store,1) -- brr, local stores are sparse if candidate then -- no vpack, as we want to realign head = inject(parent,head,candidate) -- maybe return applied offset done = true @@ -534,11 +633,15 @@ function margins.localhandler(head,group) end end -function margins.globalhandler(head,group) +function margins.globalhandler(head,group) -- check group --~ print(group) - if conditionals.inhibitmargindata then + if conditionals.inhibitmargindata or nofstored == 0 then return head, false - elseif nofstored > 0 and group == "hmode_par" then + elseif group == "hmode_par" then + return handler("global",head,group) + elseif group == "vmode_par" then -- experiment (for alignments) + return handler("global",head,group) + elseif group == "box" then -- experiment (for alignments) return handler("global",head,group) else return head, false @@ -583,6 +686,9 @@ function margins.finalhandler(head) end end +-- Somehow the vbox builder (in combinations) gets pretty confused and decides to +-- go horizontal. So this needs more testing. + prependaction("finalizers", "lists", "typesetters.margins.localhandler") prependaction("vboxbuilders", "normalizers", "typesetters.margins.localhandler") prependaction("mvlbuilders", "normalizers", "typesetters.margins.globalhandler") @@ -595,7 +701,7 @@ disableaction("shipouts", "typesetters.margins.finalhandler") enablelocal = function() enableaction("finalizers", "typesetters.margins.localhandler") - enableaction("vboxbuilders", "typesetters.margins.localhandler") + -- enableaction("vboxbuilders", "typesetters.margins.localhandler") enableaction("shipouts", "typesetters.margins.finalhandler") enablelocal = nil end diff --git a/tex/context/base/typo-mar.mkiv b/tex/context/base/typo-mar.mkiv index 269ab83a1..99ed1ac0d 100644 --- a/tex/context/base/typo-mar.mkiv +++ b/tex/context/base/typo-mar.mkiv @@ -136,27 +136,41 @@ \newconditional\inhibitmargindata % This one is used at the Lua end! \newtoks \everymargindatacontent % Later on we will set this one. -\unexpanded\def\margindata[#name]% - {\setfalse\inhibitmargindata % flushing afterwards - \begingroup - %\settrue\inhibitmargindata % no flushing in here - \def\currentmargindata{#name}% - \let\currentmarginframed\currentmargindata - \dodoubleempty\domargindata} - \appendtoks \settrue\inhibitmargindata \to \everyforgetall -% option test -> ruled - \appendtoks \forgetall \tf \deactivatecolor \to \everymargindatacontent -\unexpanded\def\domargindata[#dataparameters][#textparameters]#content% +% trialtypesetting: no need for margin stuff while trialing as +% is has no dimensions + +\unexpanded\def\margindata + {\iftrialtypesetting + \expandafter\nomargindata + \else + \expandafter\domargindata + \fi} + +\def\nomargindata[#name]% + {\dodoubleempty\donomargindata} + +\def\domargindata[#name]% + {\setfalse\inhibitmargindata % flushing afterwards + \begingroup + %\settrue\inhibitmargindata % no flushing in here + \def\currentmargindata{#name}% + \let\currentmarginframed\currentmargindata + \dodoubleempty\dodomargindata} + +\unexpanded\def\donomargindata[#dataparameters][#textparameters]#content% + {} + +\unexpanded\def\dodomargindata[#dataparameters][#textparameters]#content% {\iffirstargument \setupcurrentmargindata[#dataparameters]% \fi @@ -192,22 +206,25 @@ \let\currentmarginfirstheight\empty \else \dosetraggedcommand{\margindataparameter\c!align}% - \setbox\nextbox\hbox \bgroup\vtop \bgroup % hbox is needed - \the\everymargindatacontent - \dosetmargindataattributes\c!style\c!color - \hsize\currentmargindatawidth - \raggedcommand - \ifx\currentmargindatastrut\empty \else - \dosetupstrut[\currentmargindatastrut]% - \fi - \begstrut\margindataparameter\c!command{#content}\endstrut - \egroup \egroup + % hbox is always needed + \vtop \bgroup + \the\everymargindatacontent + \dosetmargindataattributes\c!style\c!color + \hsize\currentmargindatawidth + \raggedcommand + \ifx\currentmargindatastrut\empty \else + \dosetupstrut[\currentmargindatastrut]% + \fi + \begstrut\margindataparameter\c!command{#content}\endstrut + \egroup + \egroup \edef\currentmarginfirstheight{true}% \fi \fi \dostoptagged \fi \ifdone + \initializenextposition % we use positions at the lua end \ctxlua{typesetters.margins.save{ \c!location = "\margindataparameter\c!location", \c!method = "\margindataparameter\c!method", @@ -229,7 +246,7 @@ \c!align = "\margindataparameter\c!align", \c!line = "\margindataparameter\c!line", \c!stack = "\margindataparameter\c!stack", - \c!number = \number\nextbox + \c!number = \number\nextbox, }}% \else \ctxlua{typesetters.margins.save{ @@ -345,4 +362,19 @@ \let\setupinmargin\setupmargindata % only partial (no framed) +% begin of experimental code (will move) +% +% \dosetanchor{x}test \dostarthanchoring{x}\llap{crap}\dostophanchoring{x}test test test +% test \dostarthanchoring{text}\llap{crap}\dostophanchoring{text}test test test + +% \def\dosetanchor #1{\dontleavehmode\latelua{anchors.set("#1")}} +% \def\doresetanchor #1{\dontleavehmode\latelua{anchors.reset("#1")}} +% \def\doresetanchornow #1{\directlua{anchors.reset("#1")}} +% \def\dostartanchoring #1{\dontleavehmode\latelua{anchors.startmove("#1")}} +% \def\dostopanchoring #1{\dontleavehmode\latelua{anchors.stopmove("#1")}} +% \def\dostarthanchoring#1{\dontleavehmode\latelua{anchors.startmove("#1","h")}} +% \def\dostartvanchoring#1{\dontleavehmode\latelua{anchors.startmove("#1","v")}} +% \let\dostophanchoring \dostopanchoring +% \let\dostopvanchoring \dostopanchoring + \protect \endinput diff --git a/tex/context/base/util-sto.lua b/tex/context/base/util-sto.lua index 4c0052f0e..052e472cf 100644 --- a/tex/context/base/util-sto.lua +++ b/tex/context/base/util-sto.lua @@ -98,13 +98,13 @@ end -- table namespace ? -local function f_empty() return "" end -- t,k -local function f_self(t,k) t[k] = k return k end -local function f_ignore() end -- t,k,v +local function f_empty () return "" end -- t,k +local function f_self (t,k) t[k] = k return k end +local function f_ignore() end -- t,k,v -local t_empty = { __index = empty } -local t_self = { __index = self } -local t_ignore = { __newindex = ignore } +local t_empty = { __index = f_empty } +local t_self = { __index = f_self } +local t_ignore = { __newindex = f_ignore } function table.setmetatableindex(t,f) local m = getmetatable(t) diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 7156e0a00..7d2846b28 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 : luatex-fonts-merged.lua -- parent file : luatex-fonts.lua --- merge date : 10/08/11 11:42:24 +-- merge date : 10/12/11 10:14:56 do -- begin closure to overcome local limits and interference @@ -3184,30 +3184,30 @@ local report_defining = logs.reporter("fonts","defining") <p>Here we only implement a few helper functions.</p> --ldx]]-- -local fonts = fonts -local constructors = { } -fonts.constructors = constructors -local handlers = { } -fonts.handlers = handlers +local fonts = fonts +local constructors = { } +fonts.constructors = constructors +local handlers = { } +fonts.handlers = handlers -local specifiers = fonts.specifiers -local contextsetups = specifiers.contextsetups -local contextnumbers = specifiers.contextnumbers +local specifiers = fonts.specifiers +local contextsetups = specifiers.contextsetups +local contextnumbers = specifiers.contextnumbers -local allocate = utilities.storage.allocate -local setmetatableindex = table.setmetatableindex +local allocate = utilities.storage.allocate +local setmetatableindex = table.setmetatableindex -- will be directives -constructors.dontembed = allocate() -constructors.mathactions = { } -constructors.autocleanup = true -constructors.namemode = "fullpath" -- will be a function +constructors.dontembed = allocate() +constructors.mathactions = { } +constructors.autocleanup = true +constructors.namemode = "fullpath" -- will be a function -constructors.version = 1.01 -constructors.cache = containers.define("fonts", "constructors", constructors.version, false) +constructors.version = 1.01 +constructors.cache = containers.define("fonts", "constructors", constructors.version, false) -constructors.privateoffset = 0xF0000 -- 0x10FFFF +constructors.privateoffset = 0xF0000 -- 0x10FFFF -- This might become an interface; @@ -3564,6 +3564,26 @@ function constructors.scale(tfmdata,specification) target.mathparameters = nil -- nop end -- + local italickey = "italic" + if hasmath then + if properties.no_mathitalics then + italickey = "italic_correction" -- context specific trickery + if trace_defining then + report_defining("math italics disabled for: name '%s', fullname: '%s', filename: '%s'", + name or "noname",fullname or "nofullname",filename or "nofilename") + end + end + autoitalic = false -- new + else + if properties.no_textitalics then + italickey = "italic_correction" -- context specific trickery + if trace_defining then + report_defining("text italics disabled for: name '%s', fullname: '%s', filename: '%s'", + name or "noname",fullname or "nofullname",filename or "nofilename") + end + end + end + -- local sharedkerns = { } -- for unicode, character in next, characters do @@ -3659,16 +3679,16 @@ function constructors.scale(tfmdata,specification) chr.right_protruding = protrusionfactor*width*vr end end - -- todo: hasitalic + -- if autoitalic then local vi = description.italic or (description.boundingbox[3] - description.width + autoitalic) if vi and vi ~= 0 then - chr.italic = vi*hdelta + chr[italickey] = vi*hdelta end elseif hasitalic then local vi = description.italic or character.italic -- why character if vi and vi ~= 0 then - chr.italic = vi*hdelta + chr[italickey] = vi*hdelta end end -- to be tested @@ -4286,7 +4306,7 @@ function constructors.collectprocessors(what,tfmdata,features,trace,report) end end end - else + elseif trace then report("no feature processors for mode %s for font %s", mode or 'unknown', tfmdata.properties.fullname or 'unknown') end @@ -8640,7 +8660,7 @@ local function alternative_glyph(start,alternatives,kind,chainname,chainlookupna return choice, value end -local function multiple_glyphs(start,multiple) +local function multiple_glyphs(start,multiple) -- marks ? local nofmultiples = #multiple if nofmultiples > 0 then start.char = multiple[1] @@ -9152,7 +9172,7 @@ single lookup case. The efficiency of the replacements can be improved by deleti as less as needed but that would also make the code even more messy.</p> --ldx]]-- -local function delete_till_stop(start,stop,ignoremarks) +local function delete_till_stop(start,stop,ignoremarks) -- keeps start local n = 1 if start == stop then -- done @@ -9181,10 +9201,6 @@ match.</p> function chainprocs.gsub_single(start,stop,kind,chainname,currentcontext,lookuphash,currentlookup,chainlookupname,chainindex) -- todo: marks ? ---~ if not chainindex then ---~ delete_till_stop(start,stop) -- ,currentlookup.flags[1] ---~ stop = start ---~ end local current = start local subtables = currentlookup.subtables if #subtables > 1 then @@ -9230,7 +9246,7 @@ the match.</p> --ldx]]-- function chainprocs.gsub_multiple(start,stop,kind,chainname,currentcontext,lookuphash,currentlookup,chainlookupname) - delete_till_stop(start,stop) -- we can assume that marks are to be deleted + delete_till_stop(start,stop) -- we could pass ignoremarks as #3 .. local startchar = start.char local subtables = currentlookup.subtables local lookupname = subtables[1] @@ -9760,37 +9776,41 @@ local function show_skip(kind,chainname,char,ck,class) end local function normal_handle_contextchain(start,kind,chainname,contexts,sequence,lookuphash) - -- local rule, lookuptype, sequence, f, l, lookups = ck[1], ck[2] ,ck[3], ck[4], ck[5], ck[6] - local flags, done = sequence.flags, false - local skipmark, skipligature, skipbase = flags[1], flags[2], flags[3] - local someskip = skipmark or skipligature or skipbase -- could be stored in flags for a fast test (hm, flags could be false !) - local markclass = sequence.markclass -- todo, first we need a proper test - local skipped = false + -- local rule, lookuptype, sequence, f, l, lookups = ck[1], ck[2] ,ck[3], ck[4], ck[5], ck[6] + local flags = sequence.flags + local done = false + local skipmark = flags[1] + local skipligature = flags[2] + local skipbase = flags[3] + local someskip = skipmark or skipligature or skipbase -- could be stored in flags for a fast test (hm, flags could be false !) + local markclass = sequence.markclass -- todo, first we need a proper test + local skipped = false for k=1,#contexts do - local match, current, last = true, start, start - local ck = contexts[k] - local seq = ck[3] - local s = #seq + local match = true + local current = start + local last = start + local ck = contexts[k] + local seq = ck[3] + local s = #seq -- f..l = mid string if s == 1 then -- never happens match = current.id == glyph_code and current.subtype<256 and current.font == currentfont and seq[1][current.char] else - -- todo: better space check (maybe check for glue) + -- maybe we need a better space check (maybe check for glue or category or combination) + -- we cannot optimize for n=2 because there can be disc nodes local f, l = ck[4], ck[5] -- current match - if f == 1 and f == l then + if f == 1 and f == l then -- current only -- already a hit - match = true - else + -- match = true + else -- before/current/after | before/current | current/after -- no need to test first hit (to be optimized) - local n = f + 1 - last = last.next - -- we cannot optimize for n=2 because there can be disc nodes - -- if not someskip and n == l then - -- -- n=2 and no skips then faster loop - -- match = last and last.id == glyph_code and last.subtype<256 and last.font == currentfont and seq[n][last.char] - -- else + if f == l then -- new, else last out of sync (f is > 1) + -- match = true + else + local n = f + 1 + last = last.next while n <= l do if last then local id = last.id @@ -9812,24 +9832,29 @@ local function normal_handle_contextchain(start,kind,chainname,contexts,sequence end n = n + 1 else - match = false break + match = false + break end else - match = false break + match = false + break end else - match = false break + match = false + break end - elseif id == disc_code then -- what to do with kerns? + elseif id == disc_code then last = last.next else - match = false break + match = false + break end else - match = false break + match = false + break end end - -- end + end end -- before if match and f > 1 then @@ -9853,26 +9878,31 @@ local function normal_handle_contextchain(start,kind,chainname,contexts,sequence elseif seq[n][char] then n = n -1 else - match = false break + match = false + break end else - match = false break + match = false + break end else - match = false break + match = false + break end elseif id == disc_code then -- skip 'm elseif seq[n][32] then n = n -1 else - match = false break + match = false + break end prev = prev.prev elseif seq[n][32] then -- somehat special, as zapfino can have many preceding spaces n = n -1 else - match = false break + match = false + break end end elseif f == 2 then @@ -9880,7 +9910,8 @@ local function normal_handle_contextchain(start,kind,chainname,contexts,sequence else for n=f-1,1 do if not seq[n][32] then - match = false break + match = false + break end end end @@ -9908,26 +9939,31 @@ local function normal_handle_contextchain(start,kind,chainname,contexts,sequence elseif seq[n][char] then n = n + 1 else - match = false break + match = false + break end else - match = false break + match = false + break end else - match = false break + match = false + break end elseif id == disc_code then -- skip 'm elseif seq[n][32] then -- brrr n = n + 1 else - match = false break + match = false + break end current = current.next elseif seq[n][32] then n = n + 1 else - match = false break + match = false + break end end elseif s-l == 1 then @@ -9935,7 +9971,8 @@ local function normal_handle_contextchain(start,kind,chainname,contexts,sequence else for n=l+1,s do if not seq[n][32] then - match = false break + match = false + break end end end |