diff options
135 files changed, 5287 insertions, 2689 deletions
diff --git a/context/data/scite/context/lexers/data/scite-context-data-context.lua b/context/data/scite/context/lexers/data/scite-context-data-context.lua index ed8bb2174..dd8a9d273 100644 --- a/context/data/scite/context/lexers/data/scite-context-data-context.lua +++ b/context/data/scite/context/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", "plusfifty", "plushundred", "plusonehundred", "plustwohundred", "plusfivehundred", "plusthousand", "plustenthousand", "plustwentythousand", "medcard", "maxcard", "maxcardminusone", "zeropoint", "onepoint", "halfapoint", "onebasepoint", "maxcount", "maxdimen", "scaledpoint", "thousandpoint", "points", "halfpoint", "zeroskip", "zeromuskip", "onemuskip", "pluscxxvii", "pluscxxviii", "pluscclv", "pluscclvi", "normalpagebox", "endoflinetoken", "outputnewlinechar", "emptytoks", "empty", "undefined", "voidbox", "emptybox", "emptyvbox", "emptyhbox", "bigskipamount", "medskipamount", "smallskipamount", "fmtname", "fmtversion", "texengine", "texenginename", "texengineversion", "texenginefunctionality", "luatexengine", "pdftexengine", "xetexengine", "unknownengine", "activecatcode", "bgroup", "egroup", "endline", "conditionaltrue", "conditionalfalse", "attributeunsetvalue", "uprotationangle", "rightrotationangle", "downrotationangle", "leftrotationangle", "inicatcodes", "ctxcatcodes", "texcatcodes", "notcatcodes", "txtcatcodes", "vrbcatcodes", "prtcatcodes", "nilcatcodes", "luacatcodes", "tpacatcodes", "tpbcatcodes", "xmlcatcodes", "ctdcatcodes", "escapecatcode", "begingroupcatcode", "endgroupcatcode", "mathshiftcatcode", "alignmentcatcode", "endoflinecatcode", "parametercatcode", "superscriptcatcode", "subscriptcatcode", "ignorecatcode", "spacecatcode", "lettercatcode", "othercatcode", "activecatcode", "commentcatcode", "invalidcatcode", "tabasciicode", "newlineasciicode", "formfeedasciicode", "endoflineasciicode", "endoffileasciicode", "spaceasciicode", "hashasciicode", "dollarasciicode", "commentasciicode", "ampersandasciicode", "colonasciicode", "backslashasciicode", "circumflexasciicode", "underscoreasciicode", "leftbraceasciicode", "barasciicode", "rightbraceasciicode", "tildeasciicode", "delasciicode", "leftparentasciicode", "rightparentasciicode", "lessthanasciicode", "morethanasciicode", "doublecommentsignal", "atsignasciicode", "exclamationmarkasciicode", "questionmarkasciicode", "doublequoteasciicode", "singlequoteasciicode", "forwardslashasciicode", "primeasciicode", "hyphenasciicode", "activemathcharcode", "activetabtoken", "activeformfeedtoken", "activeendoflinetoken", "batchmodecode", "nonstopmodecode", "scrollmodecode", "errorstopmodecode", "bottomlevelgroupcode", "simplegroupcode", "hboxgroupcode", "adjustedhboxgroupcode", "vboxgroupcode", "vtopgroupcode", "aligngroupcode", "noaligngroupcode", "outputgroupcode", "mathgroupcode", "discretionarygroupcode", "insertgroupcode", "vcentergroupcode", "mathchoicegroupcode", "semisimplegroupcode", "mathshiftgroupcode", "mathleftgroupcode", "vadjustgroupcode", "charnodecode", "hlistnodecode", "vlistnodecode", "rulenodecode", "insertnodecode", "marknodecode", "adjustnodecode", "ligaturenodecode", "discretionarynodecode", "whatsitnodecode", "mathnodecode", "gluenodecode", "kernnodecode", "penaltynodecode", "unsetnodecode", "mathsnodecode", "charifcode", "catifcode", "numifcode", "dimifcode", "oddifcode", "vmodeifcode", "hmodeifcode", "mmodeifcode", "innerifcode", "voidifcode", "hboxifcode", "vboxifcode", "xifcode", "eofifcode", "trueifcode", "falseifcode", "caseifcode", "definedifcode", "csnameifcode", "fontcharifcode", "fontslantperpoint", "fontinterwordspace", "fontinterwordstretch", "fontinterwordshrink", "fontexheight", "fontemwidth", "fontextraspace", "slantperpoint", "mathexheight", "mathemwidth", "interwordspace", "interwordstretch", "interwordshrink", "exheight", "emwidth", "extraspace", "mathsupdisplay", "mathsupnormal", "mathsupcramped", "mathsubnormal", "mathsubcombined", "mathaxisheight", "muquad", "startmode", "stopmode", "startnotmode", "stopnotmode", "startmodeset", "stopmodeset", "doifmode", "doifelsemode", "doifmodeelse", "doifnotmode", "startmodeset", "stopmodeset", "startallmodes", "stopallmodes", "startnotallmodes", "stopnotallmodes", "doifallmodes", "doifelseallmodes", "doifallmodeselse", "doifnotallmodes", "startenvironment", "stopenvironment", "environment", "startcomponent", "stopcomponent", "component", "startproduct", "stopproduct", "product", "startproject", "stopproject", "project", "starttext", "stoptext", "startnotext", "stopnotext", "startdocument", "stopdocument", "documentvariable", "unexpandeddocumentvariable", "setupdocument", "presetdocument", "doifelsedocumentvariable", "doifdocumentvariableelse", "doifdocumentvariable", "doifnotdocumentvariable", "startmodule", "stopmodule", "usemodule", "usetexmodule", "useluamodule", "setupmodule", "currentmoduleparameter", "moduleparameter", "everystarttext", "everystoptext", "startTEXpage", "stopTEXpage", "enablemode", "disablemode", "preventmode", "definemode", "globalenablemode", "globaldisablemode", "globalpreventmode", "pushmode", "popmode", "typescriptone", "typescripttwo", "typescriptthree", "mathsizesuffix", "mathordcode", "mathopcode", "mathbincode", "mathrelcode", "mathopencode", "mathclosecode", "mathpunctcode", "mathalphacode", "mathinnercode", "mathnothingcode", "mathlimopcode", "mathnolopcode", "mathboxcode", "mathchoicecode", "mathaccentcode", "mathradicalcode", "constantnumber", "constantnumberargument", "constantdimen", "constantdimenargument", "constantemptyargument", "continueifinputfile", "luastringsep", "!!bs", "!!es", "lefttorightmark", "righttoleftmark", "lrm", "rlm", "bidilre", "bidirle", "bidipop", "bidilro", "bidirlo", "breakablethinspace", "nobreakspace", "nonbreakablespace", "narrownobreakspace", "zerowidthnobreakspace", "ideographicspace", "ideographichalffillspace", "twoperemspace", "threeperemspace", "fourperemspace", "fiveperemspace", "sixperemspace", "figurespace", "punctuationspace", "hairspace", "enquad", "emquad", "zerowidthspace", "zerowidthnonjoiner", "zerowidthjoiner", "zwnj", "zwj", "optionalspace", "asciispacechar", "softhyphen", "Ux", "eUx", "Umathaccents", "parfillleftskip", "parfillrightskip" }, - ["helpers"]={ "startsetups", "stopsetups", "startxmlsetups", "stopxmlsetups", "startluasetups", "stopluasetups", "starttexsetups", "stoptexsetups", "startrawsetups", "stoprawsetups", "startlocalsetups", "stoplocalsetups", "starttexdefinition", "stoptexdefinition", "starttexcode", "stoptexcode", "startcontextcode", "stopcontextcode", "startcontextdefinitioncode", "stopcontextdefinitioncode", "texdefinition", "doifelsesetups", "doifsetupselse", "doifsetups", "doifnotsetups", "setup", "setups", "texsetup", "xmlsetup", "luasetup", "directsetup", "fastsetup", "copysetups", "resetsetups", "doifelsecommandhandler", "doifcommandhandlerelse", "doifnotcommandhandler", "doifcommandhandler", "newmode", "setmode", "resetmode", "newsystemmode", "setsystemmode", "resetsystemmode", "pushsystemmode", "popsystemmode", "booleanmodevalue", "newcount", "newdimen", "newskip", "newmuskip", "newbox", "newtoks", "newread", "newwrite", "newmarks", "newinsert", "newattribute", "newif", "newlanguage", "newfamily", "newfam", "newhelp", "then", "begcsname", "autorule", "strippedcsname", "checkedstrippedcsname", "firstargumentfalse", "firstargumenttrue", "secondargumentfalse", "secondargumenttrue", "thirdargumentfalse", "thirdargumenttrue", "fourthargumentfalse", "fourthargumenttrue", "fifthargumentfalse", "fifthargumenttrue", "sixthargumentfalse", "sixthargumenttrue", "seventhargumentfalse", "seventhargumenttrue", "vkern", "hkern", "doglobal", "dodoglobal", "redoglobal", "resetglobal", "donothing", "dontcomplain", "forgetall", "donetrue", "donefalse", "foundtrue", "foundfalse", "inlineordisplaymath", "indisplaymath", "forcedisplaymath", "startforceddisplaymath", "stopforceddisplaymath", "startpickupmath", "stoppickupmath", "reqno", "mathortext", "htdp", "unvoidbox", "hfilll", "vfilll", "mathbox", "mathlimop", "mathnolop", "mathnothing", "mathalpha", "currentcatcodetable", "defaultcatcodetable", "catcodetablename", "newcatcodetable", "startcatcodetable", "stopcatcodetable", "startextendcatcodetable", "stopextendcatcodetable", "pushcatcodetable", "popcatcodetable", "restorecatcodes", "setcatcodetable", "letcatcodecommand", "defcatcodecommand", "uedcatcodecommand", "hglue", "vglue", "hfillneg", "vfillneg", "hfilllneg", "vfilllneg", "ruledhss", "ruledhfil", "ruledhfill", "ruledhfilll", "ruledhfilneg", "ruledhfillneg", "normalhfillneg", "normalhfilllneg", "ruledvss", "ruledvfil", "ruledvfill", "ruledvfilll", "ruledvfilneg", "ruledvfillneg", "normalvfillneg", "normalvfilllneg", "ruledhbox", "ruledvbox", "ruledvtop", "ruledvcenter", "ruledmbox", "ruledhpack", "ruledvpack", "ruledtpack", "ruledhskip", "ruledvskip", "ruledkern", "ruledmskip", "ruledmkern", "ruledhglue", "ruledvglue", "normalhglue", "normalvglue", "ruledpenalty", "filledhboxb", "filledhboxr", "filledhboxg", "filledhboxc", "filledhboxm", "filledhboxy", "filledhboxk", "scratchcounter", "globalscratchcounter", "privatescratchcounter", "scratchdimen", "globalscratchdimen", "privatescratchdimen", "scratchskip", "globalscratchskip", "privatescratchskip", "scratchmuskip", "globalscratchmuskip", "privatescratchmuskip", "scratchtoks", "globalscratchtoks", "privatescratchtoks", "scratchbox", "globalscratchbox", "privatescratchbox", "groupedcommand", "groupedcommandcs", "triggergroupedcommand", "triggergroupedcommandcs", "simplegroupedcommand", "pickupgroupedcommand", "normalbaselineskip", "normallineskip", "normallineskiplimit", "availablehsize", "localhsize", "setlocalhsize", "distributedhsize", "hsizefraction", "next", "nexttoken", "nextbox", "dowithnextbox", "dowithnextboxcs", "dowithnextboxcontent", "dowithnextboxcontentcs", "flushnextbox", "boxisempty", "scratchwidth", "scratchheight", "scratchdepth", "scratchoffset", "scratchdistance", "scratchhsize", "scratchvsize", "scratchxoffset", "scratchyoffset", "scratchhoffset", "scratchvoffset", "scratchxposition", "scratchyposition", "scratchtopoffset", "scratchbottomoffset", "scratchleftoffset", "scratchrightoffset", "scratchcounterone", "scratchcountertwo", "scratchcounterthree", "scratchcounterfour", "scratchcounterfive", "scratchcountersix", "scratchdimenone", "scratchdimentwo", "scratchdimenthree", "scratchdimenfour", "scratchdimenfive", "scratchdimensix", "scratchskipone", "scratchskiptwo", "scratchskipthree", "scratchskipfour", "scratchskipfive", "scratchskipsix", "scratchmuskipone", "scratchmuskiptwo", "scratchmuskipthree", "scratchmuskipfour", "scratchmuskipfive", "scratchmuskipsix", "scratchtoksone", "scratchtokstwo", "scratchtoksthree", "scratchtoksfour", "scratchtoksfive", "scratchtokssix", "scratchboxone", "scratchboxtwo", "scratchboxthree", "scratchboxfour", "scratchboxfive", "scratchboxsix", "scratchnx", "scratchny", "scratchmx", "scratchmy", "scratchunicode", "scratchmin", "scratchmax", "scratchleftskip", "scratchrightskip", "scratchtopskip", "scratchbottomskip", "doif", "doifnot", "doifelse", "firstinset", "doifinset", "doifnotinset", "doifelseinset", "doifinsetelse", "doifelsenextchar", "doifnextcharelse", "doifelsenextoptional", "doifnextoptionalelse", "doifelsenextoptionalcs", "doifnextoptionalcselse", "doifelsefastoptionalcheck", "doiffastoptionalcheckelse", "doifelsefastoptionalcheckcs", "doiffastoptionalcheckcselse", "doifelsenextbgroup", "doifnextbgroupelse", "doifelsenextbgroupcs", "doifnextbgroupcselse", "doifelsenextparenthesis", "doifnextparenthesiselse", "doifelseundefined", "doifundefinedelse", "doifelsedefined", "doifdefinedelse", "doifundefined", "doifdefined", "doifelsevalue", "doifvalue", "doifnotvalue", "doifnothing", "doifsomething", "doifelsenothing", "doifnothingelse", "doifelsesomething", "doifsomethingelse", "doifvaluenothing", "doifvaluesomething", "doifelsevaluenothing", "doifvaluenothingelse", "doifelsedimension", "doifdimensionelse", "doifelsenumber", "doifnumberelse", "doifnumber", "doifnotnumber", "doifelsecommon", "doifcommonelse", "doifcommon", "doifnotcommon", "doifinstring", "doifnotinstring", "doifelseinstring", "doifinstringelse", "doifelseassignment", "doifassignmentelse", "docheckassignment", "doifelseassignmentcs", "doifassignmentelsecs", "doiftext", "doifelsetext", "doiftextelse", "doifnottext", "tracingall", "tracingnone", "loggingall", "removetoks", "appendtoks", "prependtoks", "appendtotoks", "prependtotoks", "to", "endgraf", "endpar", "everyendpar", "reseteverypar", "finishpar", "empty", "null", "space", "quad", "enspace", "emspace", "charspace", "nbsp", "crlf", "obeyspaces", "obeylines", "obeyedspace", "obeyedline", "obeyedtab", "obeyedpage", "normalspace", "executeifdefined", "singleexpandafter", "doubleexpandafter", "tripleexpandafter", "dontleavehmode", "removelastspace", "removeunwantedspaces", "keepunwantedspaces", "removepunctuation", "ignoreparskip", "forcestrutdepth", "wait", "writestatus", "define", "defineexpandable", "redefine", "setmeasure", "setemeasure", "setgmeasure", "setxmeasure", "definemeasure", "freezemeasure", "measure", "measured", "installcorenamespace", "getvalue", "getuvalue", "setvalue", "setevalue", "setgvalue", "setxvalue", "letvalue", "letgvalue", "resetvalue", "undefinevalue", "ignorevalue", "setuvalue", "setuevalue", "setugvalue", "setuxvalue", "globallet", "glet", "udef", "ugdef", "uedef", "uxdef", "checked", "unique", "getparameters", "geteparameters", "getgparameters", "getxparameters", "forgetparameters", "copyparameters", "getdummyparameters", "dummyparameter", "directdummyparameter", "setdummyparameter", "letdummyparameter", "setexpandeddummyparameter", "usedummystyleandcolor", "usedummystyleparameter", "usedummycolorparameter", "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", "firstofoneunexpanded", "firstoftwounexpanded", "secondoftwounexpanded", "firstofthreeunexpanded", "secondofthreeunexpanded", "thirdofthreeunexpanded", "gobbleoneargument", "gobbletwoarguments", "gobblethreearguments", "gobblefourarguments", "gobblefivearguments", "gobblesixarguments", "gobblesevenarguments", "gobbleeightarguments", "gobbleninearguments", "gobbletenarguments", "gobbleoneoptional", "gobbletwooptionals", "gobblethreeoptionals", "gobblefouroptionals", "gobblefiveoptionals", "dorecurse", "doloop", "exitloop", "dostepwiserecurse", "recurselevel", "recursedepth", "dofastloopcs", "fastloopindex", "fastloopfinal", "dowith", "newconstant", "setnewconstant", "setconstant", "setconstantvalue", "newconditional", "settrue", "setfalse", "settruevalue", "setfalsevalue", "newmacro", "setnewmacro", "newfraction", "newsignal", "dosingleempty", "dodoubleempty", "dotripleempty", "doquadrupleempty", "doquintupleempty", "dosixtupleempty", "doseventupleempty", "dosingleargument", "dodoubleargument", "dotripleargument", "doquadrupleargument", "doquintupleargument", "dosixtupleargument", "doseventupleargument", "dosinglegroupempty", "dodoublegroupempty", "dotriplegroupempty", "doquadruplegroupempty", "doquintuplegroupempty", "permitspacesbetweengroups", "dontpermitspacesbetweengroups", "nopdfcompression", "maximumpdfcompression", "normalpdfcompression", "modulonumber", "dividenumber", "getfirstcharacter", "doifelsefirstchar", "doiffirstcharelse", "startnointerference", "stopnointerference", "twodigits", "threedigits", "leftorright", "offinterlineskip", "oninterlineskip", "nointerlineskip", "strut", "halfstrut", "quarterstrut", "depthstrut", "halflinestrut", "noheightstrut", "setstrut", "strutbox", "strutht", "strutdp", "strutwd", "struthtdp", "strutgap", "begstrut", "endstrut", "lineheight", "leftboundary", "rightboundary", "signalcharacter", "ordordspacing", "ordopspacing", "ordbinspacing", "ordrelspacing", "ordopenspacing", "ordclosespacing", "ordpunctspacing", "ordinnerspacing", "opordspacing", "opopspacing", "opbinspacing", "oprelspacing", "opopenspacing", "opclosespacing", "oppunctspacing", "opinnerspacing", "binordspacing", "binopspacing", "binbinspacing", "binrelspacing", "binopenspacing", "binclosespacing", "binpunctspacing", "bininnerspacing", "relordspacing", "relopspacing", "relbinspacing", "relrelspacing", "relopenspacing", "relclosespacing", "relpunctspacing", "relinnerspacing", "openordspacing", "openopspacing", "openbinspacing", "openrelspacing", "openopenspacing", "openclosespacing", "openpunctspacing", "openinnerspacing", "closeordspacing", "closeopspacing", "closebinspacing", "closerelspacing", "closeopenspacing", "closeclosespacing", "closepunctspacing", "closeinnerspacing", "punctordspacing", "punctopspacing", "punctbinspacing", "punctrelspacing", "punctopenspacing", "punctclosespacing", "punctpunctspacing", "punctinnerspacing", "innerordspacing", "inneropspacing", "innerbinspacing", "innerrelspacing", "inneropenspacing", "innerclosespacing", "innerpunctspacing", "innerinnerspacing", "normalreqno", "startimath", "stopimath", "normalstartimath", "normalstopimath", "startdmath", "stopdmath", "normalstartdmath", "normalstopdmath", "normalsuperscript", "normalsubscript", "normalnosuperscript", "normalnosubscript", "superscript", "subscript", "nosuperscript", "nosubscript", "uncramped", "cramped", "triggermathstyle", "mathstylefont", "mathsmallstylefont", "mathstyleface", "mathsmallstyleface", "mathstylecommand", "mathpalette", "mathstylehbox", "mathstylevbox", "mathstylevcenter", "mathstylevcenteredhbox", "mathstylevcenteredvbox", "mathtext", "setmathsmalltextbox", "setmathtextbox", "pushmathstyle", "popmathstyle", "triggerdisplaystyle", "triggertextstyle", "triggerscriptstyle", "triggerscriptscriptstyle", "triggeruncrampedstyle", "triggercrampedstyle", "triggersmallstyle", "triggeruncrampedsmallstyle", "triggercrampedsmallstyle", "triggerbigstyle", "triggeruncrampedbigstyle", "triggercrampedbigstyle", "luaexpr", "expelsedoif", "expdoif", "expdoifnot", "expdoifelsecommon", "expdoifcommonelse", "expdoifelseinset", "expdoifinsetelse", "ctxdirectlua", "ctxlatelua", "ctxsprint", "ctxwrite", "ctxcommand", "ctxdirectcommand", "ctxlatecommand", "ctxreport", "ctxlua", "luacode", "lateluacode", "directluacode", "registerctxluafile", "ctxloadluafile", "luaversion", "luamajorversion", "luaminorversion", "ctxluacode", "luaconditional", "luaexpanded", "startluaparameterset", "stopluaparameterset", "luaparameterset", "definenamedlua", "obeylualines", "obeyluatokens", "startluacode", "stopluacode", "startlua", "stoplua", "startctxfunction", "stopctxfunction", "ctxfunction", "startctxfunctiondefinition", "stopctxfunctiondefinition", "installctxfunction", "installprotectedctxfunction", "installprotectedctxscanner", "installctxscanner", "resetctxscanner", "cldprocessfile", "cldloadfile", "cldloadviafile", "cldcontext", "cldcommand", "carryoverpar", "lastlinewidth", "assumelongusagecs", "Umathbotaccent", "righttolefthbox", "lefttorighthbox", "righttoleftvbox", "lefttorightvbox", "righttoleftvtop", "lefttorightvtop", "rtlhbox", "ltrhbox", "rtlvbox", "ltrvbox", "rtlvtop", "ltrvtop", "autodirhbox", "autodirvbox", "autodirvtop", "leftorrighthbox", "leftorrightvbox", "leftorrightvtop", "lefttoright", "righttoleft", "checkedlefttoright", "checkedrighttoleft", "synchronizelayoutdirection", "synchronizedisplaydirection", "synchronizeinlinedirection", "dirlre", "dirrle", "dirlro", "dirrlo", "lesshyphens", "morehyphens", "nohyphens", "dohyphens", "Ucheckedstartdisplaymath", "Ucheckedstopdisplaymath", "break", "nobreak", "allowbreak", "goodbreak", "nospace", "nospacing", "dospacing", "naturalhbox", "naturalvbox", "naturalvtop", "naturalhpack", "naturalvpack", "frule", "compoundhyphenpenalty", "start", "stop" }, + ["helpers"]={ "startsetups", "stopsetups", "startxmlsetups", "stopxmlsetups", "startluasetups", "stopluasetups", "starttexsetups", "stoptexsetups", "startrawsetups", "stoprawsetups", "startlocalsetups", "stoplocalsetups", "starttexdefinition", "stoptexdefinition", "starttexcode", "stoptexcode", "startcontextcode", "stopcontextcode", "startcontextdefinitioncode", "stopcontextdefinitioncode", "texdefinition", "doifelsesetups", "doifsetupselse", "doifsetups", "doifnotsetups", "setup", "setups", "texsetup", "xmlsetup", "luasetup", "directsetup", "fastsetup", "copysetups", "resetsetups", "doifelsecommandhandler", "doifcommandhandlerelse", "doifnotcommandhandler", "doifcommandhandler", "newmode", "setmode", "resetmode", "newsystemmode", "setsystemmode", "resetsystemmode", "pushsystemmode", "popsystemmode", "globalsetmode", "globalresetmode", "globalsetsystemmode", "globalresetsystemmode", "booleanmodevalue", "newcount", "newdimen", "newskip", "newmuskip", "newbox", "newtoks", "newread", "newwrite", "newmarks", "newinsert", "newattribute", "newif", "newlanguage", "newfamily", "newfam", "newhelp", "then", "begcsname", "autorule", "strippedcsname", "checkedstrippedcsname", "firstargumentfalse", "firstargumenttrue", "secondargumentfalse", "secondargumenttrue", "thirdargumentfalse", "thirdargumenttrue", "fourthargumentfalse", "fourthargumenttrue", "fifthargumentfalse", "fifthargumenttrue", "sixthargumentfalse", "sixthargumenttrue", "seventhargumentfalse", "seventhargumenttrue", "vkern", "hkern", "doglobal", "dodoglobal", "redoglobal", "resetglobal", "donothing", "dontcomplain", "forgetall", "donetrue", "donefalse", "foundtrue", "foundfalse", "inlineordisplaymath", "indisplaymath", "forcedisplaymath", "startforceddisplaymath", "stopforceddisplaymath", "startpickupmath", "stoppickupmath", "reqno", "mathortext", "htdp", "unvoidbox", "hfilll", "vfilll", "mathbox", "mathlimop", "mathnolop", "mathnothing", "mathalpha", "currentcatcodetable", "defaultcatcodetable", "catcodetablename", "newcatcodetable", "startcatcodetable", "stopcatcodetable", "startextendcatcodetable", "stopextendcatcodetable", "pushcatcodetable", "popcatcodetable", "restorecatcodes", "setcatcodetable", "letcatcodecommand", "defcatcodecommand", "uedcatcodecommand", "hglue", "vglue", "hfillneg", "vfillneg", "hfilllneg", "vfilllneg", "ruledhss", "ruledhfil", "ruledhfill", "ruledhfilll", "ruledhfilneg", "ruledhfillneg", "normalhfillneg", "normalhfilllneg", "ruledvss", "ruledvfil", "ruledvfill", "ruledvfilll", "ruledvfilneg", "ruledvfillneg", "normalvfillneg", "normalvfilllneg", "ruledhbox", "ruledvbox", "ruledvtop", "ruledvcenter", "ruledmbox", "ruledhpack", "ruledvpack", "ruledtpack", "ruledhskip", "ruledvskip", "ruledkern", "ruledmskip", "ruledmkern", "ruledhglue", "ruledvglue", "normalhglue", "normalvglue", "ruledpenalty", "filledhboxb", "filledhboxr", "filledhboxg", "filledhboxc", "filledhboxm", "filledhboxy", "filledhboxk", "scratchcounter", "globalscratchcounter", "privatescratchcounter", "scratchdimen", "globalscratchdimen", "privatescratchdimen", "scratchskip", "globalscratchskip", "privatescratchskip", "scratchmuskip", "globalscratchmuskip", "privatescratchmuskip", "scratchtoks", "globalscratchtoks", "privatescratchtoks", "scratchbox", "globalscratchbox", "privatescratchbox", "groupedcommand", "groupedcommandcs", "triggergroupedcommand", "triggergroupedcommandcs", "simplegroupedcommand", "pickupgroupedcommand", "normalbaselineskip", "normallineskip", "normallineskiplimit", "availablehsize", "localhsize", "setlocalhsize", "distributedhsize", "hsizefraction", "next", "nexttoken", "nextbox", "dowithnextbox", "dowithnextboxcs", "dowithnextboxcontent", "dowithnextboxcontentcs", "flushnextbox", "boxisempty", "scratchwidth", "scratchheight", "scratchdepth", "scratchoffset", "scratchdistance", "scratchhsize", "scratchvsize", "scratchxoffset", "scratchyoffset", "scratchhoffset", "scratchvoffset", "scratchxposition", "scratchyposition", "scratchtopoffset", "scratchbottomoffset", "scratchleftoffset", "scratchrightoffset", "scratchcounterone", "scratchcountertwo", "scratchcounterthree", "scratchcounterfour", "scratchcounterfive", "scratchcountersix", "scratchdimenone", "scratchdimentwo", "scratchdimenthree", "scratchdimenfour", "scratchdimenfive", "scratchdimensix", "scratchskipone", "scratchskiptwo", "scratchskipthree", "scratchskipfour", "scratchskipfive", "scratchskipsix", "scratchmuskipone", "scratchmuskiptwo", "scratchmuskipthree", "scratchmuskipfour", "scratchmuskipfive", "scratchmuskipsix", "scratchtoksone", "scratchtokstwo", "scratchtoksthree", "scratchtoksfour", "scratchtoksfive", "scratchtokssix", "scratchboxone", "scratchboxtwo", "scratchboxthree", "scratchboxfour", "scratchboxfive", "scratchboxsix", "scratchnx", "scratchny", "scratchmx", "scratchmy", "scratchunicode", "scratchmin", "scratchmax", "scratchleftskip", "scratchrightskip", "scratchtopskip", "scratchbottomskip", "doif", "doifnot", "doifelse", "firstinset", "doifinset", "doifnotinset", "doifelseinset", "doifinsetelse", "doifelsenextchar", "doifnextcharelse", "doifelsenextoptional", "doifnextoptionalelse", "doifelsenextoptionalcs", "doifnextoptionalcselse", "doifelsefastoptionalcheck", "doiffastoptionalcheckelse", "doifelsefastoptionalcheckcs", "doiffastoptionalcheckcselse", "doifelsenextbgroup", "doifnextbgroupelse", "doifelsenextbgroupcs", "doifnextbgroupcselse", "doifelsenextparenthesis", "doifnextparenthesiselse", "doifelseundefined", "doifundefinedelse", "doifelsedefined", "doifdefinedelse", "doifundefined", "doifdefined", "doifelsevalue", "doifvalue", "doifnotvalue", "doifnothing", "doifsomething", "doifelsenothing", "doifnothingelse", "doifelsesomething", "doifsomethingelse", "doifvaluenothing", "doifvaluesomething", "doifelsevaluenothing", "doifvaluenothingelse", "doifelsedimension", "doifdimensionelse", "doifelsenumber", "doifnumberelse", "doifnumber", "doifnotnumber", "doifelsecommon", "doifcommonelse", "doifcommon", "doifnotcommon", "doifinstring", "doifnotinstring", "doifelseinstring", "doifinstringelse", "doifelseassignment", "doifassignmentelse", "docheckassignment", "doifelseassignmentcs", "doifassignmentelsecs", "doiftext", "doifelsetext", "doiftextelse", "doifnottext", "tracingall", "tracingnone", "loggingall", "removetoks", "appendtoks", "prependtoks", "appendtotoks", "prependtotoks", "to", "endgraf", "endpar", "everyendpar", "reseteverypar", "finishpar", "empty", "null", "space", "quad", "enspace", "emspace", "charspace", "nbsp", "crlf", "obeyspaces", "obeylines", "obeyedspace", "obeyedline", "obeyedtab", "obeyedpage", "normalspace", "executeifdefined", "singleexpandafter", "doubleexpandafter", "tripleexpandafter", "dontleavehmode", "removelastspace", "removeunwantedspaces", "keepunwantedspaces", "removepunctuation", "ignoreparskip", "forcestrutdepth", "wait", "writestatus", "define", "defineexpandable", "redefine", "setmeasure", "setemeasure", "setgmeasure", "setxmeasure", "definemeasure", "freezemeasure", "measure", "measured", "installcorenamespace", "getvalue", "getuvalue", "setvalue", "setevalue", "setgvalue", "setxvalue", "letvalue", "letgvalue", "resetvalue", "undefinevalue", "ignorevalue", "setuvalue", "setuevalue", "setugvalue", "setuxvalue", "globallet", "glet", "udef", "ugdef", "uedef", "uxdef", "checked", "unique", "getparameters", "geteparameters", "getgparameters", "getxparameters", "forgetparameters", "copyparameters", "getdummyparameters", "dummyparameter", "directdummyparameter", "setdummyparameter", "letdummyparameter", "setexpandeddummyparameter", "usedummystyleandcolor", "usedummystyleparameter", "usedummycolorparameter", "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", "firstofoneunexpanded", "firstoftwounexpanded", "secondoftwounexpanded", "firstofthreeunexpanded", "secondofthreeunexpanded", "thirdofthreeunexpanded", "gobbleoneargument", "gobbletwoarguments", "gobblethreearguments", "gobblefourarguments", "gobblefivearguments", "gobblesixarguments", "gobblesevenarguments", "gobbleeightarguments", "gobbleninearguments", "gobbletenarguments", "gobbleoneoptional", "gobbletwooptionals", "gobblethreeoptionals", "gobblefouroptionals", "gobblefiveoptionals", "dorecurse", "doloop", "exitloop", "dostepwiserecurse", "recurselevel", "recursedepth", "dofastloopcs", "fastloopindex", "fastloopfinal", "dowith", "newconstant", "setnewconstant", "setconstant", "setconstantvalue", "newconditional", "settrue", "setfalse", "settruevalue", "setfalsevalue", "newmacro", "setnewmacro", "newfraction", "newsignal", "dosingleempty", "dodoubleempty", "dotripleempty", "doquadrupleempty", "doquintupleempty", "dosixtupleempty", "doseventupleempty", "dosingleargument", "dodoubleargument", "dotripleargument", "doquadrupleargument", "doquintupleargument", "dosixtupleargument", "doseventupleargument", "dosinglegroupempty", "dodoublegroupempty", "dotriplegroupempty", "doquadruplegroupempty", "doquintuplegroupempty", "permitspacesbetweengroups", "dontpermitspacesbetweengroups", "nopdfcompression", "maximumpdfcompression", "normalpdfcompression", "modulonumber", "dividenumber", "getfirstcharacter", "doifelsefirstchar", "doiffirstcharelse", "startnointerference", "stopnointerference", "twodigits", "threedigits", "leftorright", "offinterlineskip", "oninterlineskip", "nointerlineskip", "strut", "halfstrut", "quarterstrut", "depthstrut", "halflinestrut", "noheightstrut", "setstrut", "strutbox", "strutht", "strutdp", "strutwd", "struthtdp", "strutgap", "begstrut", "endstrut", "lineheight", "leftboundary", "rightboundary", "signalcharacter", "ordordspacing", "ordopspacing", "ordbinspacing", "ordrelspacing", "ordopenspacing", "ordclosespacing", "ordpunctspacing", "ordinnerspacing", "opordspacing", "opopspacing", "opbinspacing", "oprelspacing", "opopenspacing", "opclosespacing", "oppunctspacing", "opinnerspacing", "binordspacing", "binopspacing", "binbinspacing", "binrelspacing", "binopenspacing", "binclosespacing", "binpunctspacing", "bininnerspacing", "relordspacing", "relopspacing", "relbinspacing", "relrelspacing", "relopenspacing", "relclosespacing", "relpunctspacing", "relinnerspacing", "openordspacing", "openopspacing", "openbinspacing", "openrelspacing", "openopenspacing", "openclosespacing", "openpunctspacing", "openinnerspacing", "closeordspacing", "closeopspacing", "closebinspacing", "closerelspacing", "closeopenspacing", "closeclosespacing", "closepunctspacing", "closeinnerspacing", "punctordspacing", "punctopspacing", "punctbinspacing", "punctrelspacing", "punctopenspacing", "punctclosespacing", "punctpunctspacing", "punctinnerspacing", "innerordspacing", "inneropspacing", "innerbinspacing", "innerrelspacing", "inneropenspacing", "innerclosespacing", "innerpunctspacing", "innerinnerspacing", "normalreqno", "startimath", "stopimath", "normalstartimath", "normalstopimath", "startdmath", "stopdmath", "normalstartdmath", "normalstopdmath", "normalsuperscript", "normalsubscript", "normalnosuperscript", "normalnosubscript", "superscript", "subscript", "nosuperscript", "nosubscript", "uncramped", "cramped", "triggermathstyle", "mathstylefont", "mathsmallstylefont", "mathstyleface", "mathsmallstyleface", "mathstylecommand", "mathpalette", "mathstylehbox", "mathstylevbox", "mathstylevcenter", "mathstylevcenteredhbox", "mathstylevcenteredvbox", "mathtext", "setmathsmalltextbox", "setmathtextbox", "pushmathstyle", "popmathstyle", "triggerdisplaystyle", "triggertextstyle", "triggerscriptstyle", "triggerscriptscriptstyle", "triggeruncrampedstyle", "triggercrampedstyle", "triggersmallstyle", "triggeruncrampedsmallstyle", "triggercrampedsmallstyle", "triggerbigstyle", "triggeruncrampedbigstyle", "triggercrampedbigstyle", "luaexpr", "expelsedoif", "expdoif", "expdoifnot", "expdoifelsecommon", "expdoifcommonelse", "expdoifelseinset", "expdoifinsetelse", "ctxdirectlua", "ctxlatelua", "ctxsprint", "ctxwrite", "ctxcommand", "ctxdirectcommand", "ctxlatecommand", "ctxreport", "ctxlua", "luacode", "lateluacode", "directluacode", "registerctxluafile", "ctxloadluafile", "luaversion", "luamajorversion", "luaminorversion", "ctxluacode", "luaconditional", "luaexpanded", "startluaparameterset", "stopluaparameterset", "luaparameterset", "definenamedlua", "obeylualines", "obeyluatokens", "startluacode", "stopluacode", "startlua", "stoplua", "startctxfunction", "stopctxfunction", "ctxfunction", "startctxfunctiondefinition", "stopctxfunctiondefinition", "installctxfunction", "installprotectedctxfunction", "installprotectedctxscanner", "installctxscanner", "resetctxscanner", "cldprocessfile", "cldloadfile", "cldloadviafile", "cldcontext", "cldcommand", "carryoverpar", "lastlinewidth", "assumelongusagecs", "Umathbotaccent", "righttolefthbox", "lefttorighthbox", "righttoleftvbox", "lefttorightvbox", "righttoleftvtop", "lefttorightvtop", "rtlhbox", "ltrhbox", "rtlvbox", "ltrvbox", "rtlvtop", "ltrvtop", "autodirhbox", "autodirvbox", "autodirvtop", "leftorrighthbox", "leftorrightvbox", "leftorrightvtop", "lefttoright", "righttoleft", "checkedlefttoright", "checkedrighttoleft", "synchronizelayoutdirection", "synchronizedisplaydirection", "synchronizeinlinedirection", "dirlre", "dirrle", "dirlro", "dirrlo", "lesshyphens", "morehyphens", "nohyphens", "dohyphens", "Ucheckedstartdisplaymath", "Ucheckedstopdisplaymath", "break", "nobreak", "allowbreak", "goodbreak", "nospace", "nospacing", "dospacing", "naturalhbox", "naturalvbox", "naturalvtop", "naturalhpack", "naturalvpack", "frule", "compoundhyphenpenalty", "start", "stop" }, }
\ No newline at end of file diff --git a/context/data/scite/context/scite-context-data-context.properties b/context/data/scite/context/scite-context-data-context.properties index 2e5c84735..2d1364530 100644 --- a/context/data/scite/context/scite-context-data-context.properties +++ b/context/data/scite/context/scite-context-data-context.properties @@ -82,155 +82,155 @@ doifnotsetups setup setups texsetup xmlsetup \ luasetup directsetup fastsetup copysetups resetsetups \ doifelsecommandhandler doifcommandhandlerelse doifnotcommandhandler doifcommandhandler newmode \ setmode resetmode newsystemmode setsystemmode resetsystemmode \ -pushsystemmode popsystemmode booleanmodevalue newcount newdimen \ -newskip newmuskip newbox newtoks newread \ -newwrite newmarks newinsert newattribute newif \ -newlanguage newfamily newfam newhelp then \ -begcsname autorule strippedcsname checkedstrippedcsname firstargumentfalse \ -firstargumenttrue secondargumentfalse secondargumenttrue thirdargumentfalse thirdargumenttrue \ -fourthargumentfalse fourthargumenttrue fifthargumentfalse fifthargumenttrue sixthargumentfalse \ -sixthargumenttrue seventhargumentfalse seventhargumenttrue vkern hkern \ -doglobal dodoglobal redoglobal resetglobal donothing \ -dontcomplain forgetall donetrue donefalse foundtrue \ -foundfalse inlineordisplaymath indisplaymath forcedisplaymath startforceddisplaymath \ -stopforceddisplaymath startpickupmath stoppickupmath reqno mathortext \ -htdp unvoidbox hfilll vfilll mathbox \ -mathlimop mathnolop mathnothing mathalpha currentcatcodetable \ -defaultcatcodetable catcodetablename newcatcodetable startcatcodetable stopcatcodetable \ -startextendcatcodetable stopextendcatcodetable pushcatcodetable popcatcodetable restorecatcodes \ -setcatcodetable letcatcodecommand defcatcodecommand uedcatcodecommand hglue \ -vglue hfillneg vfillneg hfilllneg vfilllneg \ -ruledhss ruledhfil ruledhfill ruledhfilll ruledhfilneg \ -ruledhfillneg normalhfillneg normalhfilllneg ruledvss ruledvfil \ -ruledvfill ruledvfilll ruledvfilneg ruledvfillneg normalvfillneg \ -normalvfilllneg ruledhbox ruledvbox ruledvtop ruledvcenter \ -ruledmbox ruledhpack ruledvpack ruledtpack ruledhskip \ -ruledvskip ruledkern ruledmskip ruledmkern ruledhglue \ -ruledvglue normalhglue normalvglue ruledpenalty filledhboxb \ -filledhboxr filledhboxg filledhboxc filledhboxm filledhboxy \ -filledhboxk scratchcounter globalscratchcounter privatescratchcounter scratchdimen \ -globalscratchdimen privatescratchdimen scratchskip globalscratchskip privatescratchskip \ -scratchmuskip globalscratchmuskip privatescratchmuskip scratchtoks globalscratchtoks \ -privatescratchtoks scratchbox globalscratchbox privatescratchbox groupedcommand \ -groupedcommandcs triggergroupedcommand triggergroupedcommandcs simplegroupedcommand pickupgroupedcommand \ -normalbaselineskip normallineskip normallineskiplimit availablehsize localhsize \ -setlocalhsize distributedhsize hsizefraction next nexttoken \ -nextbox dowithnextbox dowithnextboxcs dowithnextboxcontent dowithnextboxcontentcs \ -flushnextbox boxisempty scratchwidth scratchheight scratchdepth \ -scratchoffset scratchdistance scratchhsize scratchvsize scratchxoffset \ -scratchyoffset scratchhoffset scratchvoffset scratchxposition scratchyposition \ -scratchtopoffset scratchbottomoffset scratchleftoffset scratchrightoffset scratchcounterone \ -scratchcountertwo scratchcounterthree scratchcounterfour scratchcounterfive scratchcountersix \ -scratchdimenone scratchdimentwo scratchdimenthree scratchdimenfour scratchdimenfive \ -scratchdimensix scratchskipone scratchskiptwo scratchskipthree scratchskipfour \ -scratchskipfive scratchskipsix scratchmuskipone scratchmuskiptwo scratchmuskipthree \ -scratchmuskipfour scratchmuskipfive scratchmuskipsix scratchtoksone scratchtokstwo \ -scratchtoksthree scratchtoksfour scratchtoksfive scratchtokssix scratchboxone \ -scratchboxtwo scratchboxthree scratchboxfour scratchboxfive scratchboxsix \ -scratchnx scratchny scratchmx scratchmy scratchunicode \ -scratchmin scratchmax scratchleftskip scratchrightskip scratchtopskip \ -scratchbottomskip doif doifnot doifelse firstinset \ -doifinset doifnotinset doifelseinset doifinsetelse doifelsenextchar \ -doifnextcharelse doifelsenextoptional doifnextoptionalelse doifelsenextoptionalcs doifnextoptionalcselse \ -doifelsefastoptionalcheck doiffastoptionalcheckelse doifelsefastoptionalcheckcs doiffastoptionalcheckcselse doifelsenextbgroup \ -doifnextbgroupelse doifelsenextbgroupcs doifnextbgroupcselse doifelsenextparenthesis doifnextparenthesiselse \ -doifelseundefined doifundefinedelse doifelsedefined doifdefinedelse doifundefined \ -doifdefined doifelsevalue doifvalue doifnotvalue doifnothing \ -doifsomething doifelsenothing doifnothingelse doifelsesomething doifsomethingelse \ -doifvaluenothing doifvaluesomething doifelsevaluenothing doifvaluenothingelse doifelsedimension \ -doifdimensionelse doifelsenumber doifnumberelse doifnumber doifnotnumber \ -doifelsecommon doifcommonelse doifcommon doifnotcommon doifinstring \ -doifnotinstring doifelseinstring doifinstringelse doifelseassignment doifassignmentelse \ -docheckassignment doifelseassignmentcs doifassignmentelsecs doiftext doifelsetext \ -doiftextelse doifnottext tracingall tracingnone loggingall \ -removetoks appendtoks prependtoks appendtotoks prependtotoks \ -to endgraf endpar everyendpar reseteverypar \ -finishpar empty null space quad \ -enspace emspace charspace nbsp crlf \ -obeyspaces obeylines obeyedspace obeyedline obeyedtab \ -obeyedpage normalspace executeifdefined singleexpandafter doubleexpandafter \ -tripleexpandafter dontleavehmode removelastspace removeunwantedspaces keepunwantedspaces \ -removepunctuation ignoreparskip forcestrutdepth wait writestatus \ -define defineexpandable redefine setmeasure setemeasure \ -setgmeasure setxmeasure definemeasure freezemeasure measure \ -measured installcorenamespace getvalue getuvalue setvalue \ -setevalue setgvalue setxvalue letvalue letgvalue \ -resetvalue undefinevalue ignorevalue setuvalue setuevalue \ -setugvalue setuxvalue globallet glet udef \ -ugdef uedef uxdef checked unique \ -getparameters geteparameters getgparameters getxparameters forgetparameters \ -copyparameters getdummyparameters dummyparameter directdummyparameter setdummyparameter \ -letdummyparameter setexpandeddummyparameter usedummystyleandcolor usedummystyleparameter usedummycolorparameter \ -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 firstofoneunexpanded firstoftwounexpanded secondoftwounexpanded firstofthreeunexpanded \ -secondofthreeunexpanded thirdofthreeunexpanded gobbleoneargument gobbletwoarguments gobblethreearguments \ -gobblefourarguments gobblefivearguments gobblesixarguments gobblesevenarguments gobbleeightarguments \ -gobbleninearguments gobbletenarguments gobbleoneoptional gobbletwooptionals gobblethreeoptionals \ -gobblefouroptionals gobblefiveoptionals dorecurse doloop exitloop \ -dostepwiserecurse recurselevel recursedepth dofastloopcs fastloopindex \ -fastloopfinal dowith newconstant setnewconstant setconstant \ -setconstantvalue newconditional settrue setfalse settruevalue \ -setfalsevalue newmacro setnewmacro newfraction newsignal \ -dosingleempty dodoubleempty dotripleempty doquadrupleempty doquintupleempty \ -dosixtupleempty doseventupleempty dosingleargument dodoubleargument dotripleargument \ -doquadrupleargument doquintupleargument dosixtupleargument doseventupleargument dosinglegroupempty \ -dodoublegroupempty dotriplegroupempty doquadruplegroupempty doquintuplegroupempty permitspacesbetweengroups \ -dontpermitspacesbetweengroups nopdfcompression maximumpdfcompression normalpdfcompression modulonumber \ -dividenumber getfirstcharacter doifelsefirstchar doiffirstcharelse startnointerference \ -stopnointerference twodigits threedigits leftorright offinterlineskip \ -oninterlineskip nointerlineskip strut halfstrut quarterstrut \ -depthstrut halflinestrut noheightstrut setstrut strutbox \ -strutht strutdp strutwd struthtdp strutgap \ -begstrut endstrut lineheight leftboundary rightboundary \ -signalcharacter ordordspacing ordopspacing ordbinspacing ordrelspacing \ -ordopenspacing ordclosespacing ordpunctspacing ordinnerspacing opordspacing \ -opopspacing opbinspacing oprelspacing opopenspacing opclosespacing \ -oppunctspacing opinnerspacing binordspacing binopspacing binbinspacing \ -binrelspacing binopenspacing binclosespacing binpunctspacing bininnerspacing \ -relordspacing relopspacing relbinspacing relrelspacing relopenspacing \ -relclosespacing relpunctspacing relinnerspacing openordspacing openopspacing \ -openbinspacing openrelspacing openopenspacing openclosespacing openpunctspacing \ -openinnerspacing closeordspacing closeopspacing closebinspacing closerelspacing \ -closeopenspacing closeclosespacing closepunctspacing closeinnerspacing punctordspacing \ -punctopspacing punctbinspacing punctrelspacing punctopenspacing punctclosespacing \ -punctpunctspacing punctinnerspacing innerordspacing inneropspacing innerbinspacing \ -innerrelspacing inneropenspacing innerclosespacing innerpunctspacing innerinnerspacing \ -normalreqno startimath stopimath normalstartimath normalstopimath \ -startdmath stopdmath normalstartdmath normalstopdmath normalsuperscript \ -normalsubscript normalnosuperscript normalnosubscript superscript subscript \ -nosuperscript nosubscript uncramped cramped triggermathstyle \ -mathstylefont mathsmallstylefont mathstyleface mathsmallstyleface mathstylecommand \ -mathpalette mathstylehbox mathstylevbox mathstylevcenter mathstylevcenteredhbox \ -mathstylevcenteredvbox mathtext setmathsmalltextbox setmathtextbox pushmathstyle \ -popmathstyle triggerdisplaystyle triggertextstyle triggerscriptstyle triggerscriptscriptstyle \ -triggeruncrampedstyle triggercrampedstyle triggersmallstyle triggeruncrampedsmallstyle triggercrampedsmallstyle \ -triggerbigstyle triggeruncrampedbigstyle triggercrampedbigstyle luaexpr expelsedoif \ -expdoif expdoifnot expdoifelsecommon expdoifcommonelse expdoifelseinset \ -expdoifinsetelse ctxdirectlua ctxlatelua ctxsprint ctxwrite \ -ctxcommand ctxdirectcommand ctxlatecommand ctxreport ctxlua \ -luacode lateluacode directluacode registerctxluafile ctxloadluafile \ -luaversion luamajorversion luaminorversion ctxluacode luaconditional \ -luaexpanded startluaparameterset stopluaparameterset luaparameterset definenamedlua \ -obeylualines obeyluatokens startluacode stopluacode startlua \ -stoplua startctxfunction stopctxfunction ctxfunction startctxfunctiondefinition \ -stopctxfunctiondefinition installctxfunction installprotectedctxfunction installprotectedctxscanner installctxscanner \ -resetctxscanner cldprocessfile cldloadfile cldloadviafile cldcontext \ -cldcommand carryoverpar lastlinewidth assumelongusagecs Umathbotaccent \ -righttolefthbox lefttorighthbox righttoleftvbox lefttorightvbox righttoleftvtop \ -lefttorightvtop rtlhbox ltrhbox rtlvbox ltrvbox \ -rtlvtop ltrvtop autodirhbox autodirvbox autodirvtop \ -leftorrighthbox leftorrightvbox leftorrightvtop lefttoright righttoleft \ -checkedlefttoright checkedrighttoleft synchronizelayoutdirection synchronizedisplaydirection synchronizeinlinedirection \ -dirlre dirrle dirlro dirrlo lesshyphens \ -morehyphens nohyphens dohyphens Ucheckedstartdisplaymath Ucheckedstopdisplaymath \ -break nobreak allowbreak goodbreak nospace \ -nospacing dospacing naturalhbox naturalvbox naturalvtop \ -naturalhpack naturalvpack frule compoundhyphenpenalty start \ -stop +pushsystemmode popsystemmode globalsetmode globalresetmode globalsetsystemmode \ +globalresetsystemmode booleanmodevalue newcount newdimen newskip \ +newmuskip newbox newtoks newread newwrite \ +newmarks newinsert newattribute newif newlanguage \ +newfamily newfam newhelp then begcsname \ +autorule strippedcsname checkedstrippedcsname firstargumentfalse firstargumenttrue \ +secondargumentfalse secondargumenttrue thirdargumentfalse thirdargumenttrue fourthargumentfalse \ +fourthargumenttrue fifthargumentfalse fifthargumenttrue sixthargumentfalse sixthargumenttrue \ +seventhargumentfalse seventhargumenttrue vkern hkern doglobal \ +dodoglobal redoglobal resetglobal donothing dontcomplain \ +forgetall donetrue donefalse foundtrue foundfalse \ +inlineordisplaymath indisplaymath forcedisplaymath startforceddisplaymath stopforceddisplaymath \ +startpickupmath stoppickupmath reqno mathortext htdp \ +unvoidbox hfilll vfilll mathbox mathlimop \ +mathnolop mathnothing mathalpha currentcatcodetable defaultcatcodetable \ +catcodetablename newcatcodetable startcatcodetable stopcatcodetable startextendcatcodetable \ +stopextendcatcodetable pushcatcodetable popcatcodetable restorecatcodes setcatcodetable \ +letcatcodecommand defcatcodecommand uedcatcodecommand hglue vglue \ +hfillneg vfillneg hfilllneg vfilllneg ruledhss \ +ruledhfil ruledhfill ruledhfilll ruledhfilneg ruledhfillneg \ +normalhfillneg normalhfilllneg ruledvss ruledvfil ruledvfill \ +ruledvfilll ruledvfilneg ruledvfillneg normalvfillneg normalvfilllneg \ +ruledhbox ruledvbox ruledvtop ruledvcenter ruledmbox \ +ruledhpack ruledvpack ruledtpack ruledhskip ruledvskip \ +ruledkern ruledmskip ruledmkern ruledhglue ruledvglue \ +normalhglue normalvglue ruledpenalty filledhboxb filledhboxr \ +filledhboxg filledhboxc filledhboxm filledhboxy filledhboxk \ +scratchcounter globalscratchcounter privatescratchcounter scratchdimen globalscratchdimen \ +privatescratchdimen scratchskip globalscratchskip privatescratchskip scratchmuskip \ +globalscratchmuskip privatescratchmuskip scratchtoks globalscratchtoks privatescratchtoks \ +scratchbox globalscratchbox privatescratchbox groupedcommand groupedcommandcs \ +triggergroupedcommand triggergroupedcommandcs simplegroupedcommand pickupgroupedcommand normalbaselineskip \ +normallineskip normallineskiplimit availablehsize localhsize setlocalhsize \ +distributedhsize hsizefraction next nexttoken nextbox \ +dowithnextbox dowithnextboxcs dowithnextboxcontent dowithnextboxcontentcs flushnextbox \ +boxisempty scratchwidth scratchheight scratchdepth scratchoffset \ +scratchdistance scratchhsize scratchvsize scratchxoffset scratchyoffset \ +scratchhoffset scratchvoffset scratchxposition scratchyposition scratchtopoffset \ +scratchbottomoffset scratchleftoffset scratchrightoffset scratchcounterone scratchcountertwo \ +scratchcounterthree scratchcounterfour scratchcounterfive scratchcountersix scratchdimenone \ +scratchdimentwo scratchdimenthree scratchdimenfour scratchdimenfive scratchdimensix \ +scratchskipone scratchskiptwo scratchskipthree scratchskipfour scratchskipfive \ +scratchskipsix scratchmuskipone scratchmuskiptwo scratchmuskipthree scratchmuskipfour \ +scratchmuskipfive scratchmuskipsix scratchtoksone scratchtokstwo scratchtoksthree \ +scratchtoksfour scratchtoksfive scratchtokssix scratchboxone scratchboxtwo \ +scratchboxthree scratchboxfour scratchboxfive scratchboxsix scratchnx \ +scratchny scratchmx scratchmy scratchunicode scratchmin \ +scratchmax scratchleftskip scratchrightskip scratchtopskip scratchbottomskip \ +doif doifnot doifelse firstinset doifinset \ +doifnotinset doifelseinset doifinsetelse doifelsenextchar doifnextcharelse \ +doifelsenextoptional doifnextoptionalelse doifelsenextoptionalcs doifnextoptionalcselse doifelsefastoptionalcheck \ +doiffastoptionalcheckelse doifelsefastoptionalcheckcs doiffastoptionalcheckcselse doifelsenextbgroup doifnextbgroupelse \ +doifelsenextbgroupcs doifnextbgroupcselse doifelsenextparenthesis doifnextparenthesiselse doifelseundefined \ +doifundefinedelse doifelsedefined doifdefinedelse doifundefined doifdefined \ +doifelsevalue doifvalue doifnotvalue doifnothing doifsomething \ +doifelsenothing doifnothingelse doifelsesomething doifsomethingelse doifvaluenothing \ +doifvaluesomething doifelsevaluenothing doifvaluenothingelse doifelsedimension doifdimensionelse \ +doifelsenumber doifnumberelse doifnumber doifnotnumber doifelsecommon \ +doifcommonelse doifcommon doifnotcommon doifinstring doifnotinstring \ +doifelseinstring doifinstringelse doifelseassignment doifassignmentelse docheckassignment \ +doifelseassignmentcs doifassignmentelsecs doiftext doifelsetext doiftextelse \ +doifnottext tracingall tracingnone loggingall removetoks \ +appendtoks prependtoks appendtotoks prependtotoks to \ +endgraf endpar everyendpar reseteverypar finishpar \ +empty null space quad enspace \ +emspace charspace nbsp crlf obeyspaces \ +obeylines obeyedspace obeyedline obeyedtab obeyedpage \ +normalspace executeifdefined singleexpandafter doubleexpandafter tripleexpandafter \ +dontleavehmode removelastspace removeunwantedspaces keepunwantedspaces removepunctuation \ +ignoreparskip forcestrutdepth wait writestatus define \ +defineexpandable redefine setmeasure setemeasure setgmeasure \ +setxmeasure definemeasure freezemeasure measure measured \ +installcorenamespace getvalue getuvalue setvalue setevalue \ +setgvalue setxvalue letvalue letgvalue resetvalue \ +undefinevalue ignorevalue setuvalue setuevalue setugvalue \ +setuxvalue globallet glet udef ugdef \ +uedef uxdef checked unique getparameters \ +geteparameters getgparameters getxparameters forgetparameters copyparameters \ +getdummyparameters dummyparameter directdummyparameter setdummyparameter letdummyparameter \ +setexpandeddummyparameter usedummystyleandcolor usedummystyleparameter usedummycolorparameter 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 \ +firstofoneunexpanded firstoftwounexpanded secondoftwounexpanded firstofthreeunexpanded secondofthreeunexpanded \ +thirdofthreeunexpanded gobbleoneargument gobbletwoarguments gobblethreearguments gobblefourarguments \ +gobblefivearguments gobblesixarguments gobblesevenarguments gobbleeightarguments gobbleninearguments \ +gobbletenarguments gobbleoneoptional gobbletwooptionals gobblethreeoptionals gobblefouroptionals \ +gobblefiveoptionals dorecurse doloop exitloop dostepwiserecurse \ +recurselevel recursedepth dofastloopcs fastloopindex fastloopfinal \ +dowith newconstant setnewconstant setconstant setconstantvalue \ +newconditional settrue setfalse settruevalue setfalsevalue \ +newmacro setnewmacro newfraction newsignal dosingleempty \ +dodoubleempty dotripleempty doquadrupleempty doquintupleempty dosixtupleempty \ +doseventupleempty dosingleargument dodoubleargument dotripleargument doquadrupleargument \ +doquintupleargument dosixtupleargument doseventupleargument dosinglegroupempty dodoublegroupempty \ +dotriplegroupempty doquadruplegroupempty doquintuplegroupempty permitspacesbetweengroups dontpermitspacesbetweengroups \ +nopdfcompression maximumpdfcompression normalpdfcompression modulonumber dividenumber \ +getfirstcharacter doifelsefirstchar doiffirstcharelse startnointerference stopnointerference \ +twodigits threedigits leftorright offinterlineskip oninterlineskip \ +nointerlineskip strut halfstrut quarterstrut depthstrut \ +halflinestrut noheightstrut setstrut strutbox strutht \ +strutdp strutwd struthtdp strutgap begstrut \ +endstrut lineheight leftboundary rightboundary signalcharacter \ +ordordspacing ordopspacing ordbinspacing ordrelspacing ordopenspacing \ +ordclosespacing ordpunctspacing ordinnerspacing opordspacing opopspacing \ +opbinspacing oprelspacing opopenspacing opclosespacing oppunctspacing \ +opinnerspacing binordspacing binopspacing binbinspacing binrelspacing \ +binopenspacing binclosespacing binpunctspacing bininnerspacing relordspacing \ +relopspacing relbinspacing relrelspacing relopenspacing relclosespacing \ +relpunctspacing relinnerspacing openordspacing openopspacing openbinspacing \ +openrelspacing openopenspacing openclosespacing openpunctspacing openinnerspacing \ +closeordspacing closeopspacing closebinspacing closerelspacing closeopenspacing \ +closeclosespacing closepunctspacing closeinnerspacing punctordspacing punctopspacing \ +punctbinspacing punctrelspacing punctopenspacing punctclosespacing punctpunctspacing \ +punctinnerspacing innerordspacing inneropspacing innerbinspacing innerrelspacing \ +inneropenspacing innerclosespacing innerpunctspacing innerinnerspacing normalreqno \ +startimath stopimath normalstartimath normalstopimath startdmath \ +stopdmath normalstartdmath normalstopdmath normalsuperscript normalsubscript \ +normalnosuperscript normalnosubscript superscript subscript nosuperscript \ +nosubscript uncramped cramped triggermathstyle mathstylefont \ +mathsmallstylefont mathstyleface mathsmallstyleface mathstylecommand mathpalette \ +mathstylehbox mathstylevbox mathstylevcenter mathstylevcenteredhbox mathstylevcenteredvbox \ +mathtext setmathsmalltextbox setmathtextbox pushmathstyle popmathstyle \ +triggerdisplaystyle triggertextstyle triggerscriptstyle triggerscriptscriptstyle triggeruncrampedstyle \ +triggercrampedstyle triggersmallstyle triggeruncrampedsmallstyle triggercrampedsmallstyle triggerbigstyle \ +triggeruncrampedbigstyle triggercrampedbigstyle luaexpr expelsedoif expdoif \ +expdoifnot expdoifelsecommon expdoifcommonelse expdoifelseinset expdoifinsetelse \ +ctxdirectlua ctxlatelua ctxsprint ctxwrite ctxcommand \ +ctxdirectcommand ctxlatecommand ctxreport ctxlua luacode \ +lateluacode directluacode registerctxluafile ctxloadluafile luaversion \ +luamajorversion luaminorversion ctxluacode luaconditional luaexpanded \ +startluaparameterset stopluaparameterset luaparameterset definenamedlua obeylualines \ +obeyluatokens startluacode stopluacode startlua stoplua \ +startctxfunction stopctxfunction ctxfunction startctxfunctiondefinition stopctxfunctiondefinition \ +installctxfunction installprotectedctxfunction installprotectedctxscanner installctxscanner resetctxscanner \ +cldprocessfile cldloadfile cldloadviafile cldcontext cldcommand \ +carryoverpar lastlinewidth assumelongusagecs Umathbotaccent righttolefthbox \ +lefttorighthbox righttoleftvbox lefttorightvbox righttoleftvtop lefttorightvtop \ +rtlhbox ltrhbox rtlvbox ltrvbox rtlvtop \ +ltrvtop autodirhbox autodirvbox autodirvtop leftorrighthbox \ +leftorrightvbox leftorrightvtop lefttoright righttoleft checkedlefttoright \ +checkedrighttoleft synchronizelayoutdirection synchronizedisplaydirection synchronizeinlinedirection dirlre \ +dirrle dirlro dirrlo lesshyphens morehyphens \ +nohyphens dohyphens Ucheckedstartdisplaymath Ucheckedstopdisplaymath break \ +nobreak allowbreak goodbreak nospace nospacing \ +dospacing naturalhbox naturalvbox naturalvtop naturalhpack \ +naturalvpack frule compoundhyphenpenalty start stop diff --git a/context/data/textadept/context/data/scite-context-data-context.lua b/context/data/textadept/context/data/scite-context-data-context.lua index ed8bb2174..dd8a9d273 100644 --- a/context/data/textadept/context/data/scite-context-data-context.lua +++ b/context/data/textadept/context/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", "plusfifty", "plushundred", "plusonehundred", "plustwohundred", "plusfivehundred", "plusthousand", "plustenthousand", "plustwentythousand", "medcard", "maxcard", "maxcardminusone", "zeropoint", "onepoint", "halfapoint", "onebasepoint", "maxcount", "maxdimen", "scaledpoint", "thousandpoint", "points", "halfpoint", "zeroskip", "zeromuskip", "onemuskip", "pluscxxvii", "pluscxxviii", "pluscclv", "pluscclvi", "normalpagebox", "endoflinetoken", "outputnewlinechar", "emptytoks", "empty", "undefined", "voidbox", "emptybox", "emptyvbox", "emptyhbox", "bigskipamount", "medskipamount", "smallskipamount", "fmtname", "fmtversion", "texengine", "texenginename", "texengineversion", "texenginefunctionality", "luatexengine", "pdftexengine", "xetexengine", "unknownengine", "activecatcode", "bgroup", "egroup", "endline", "conditionaltrue", "conditionalfalse", "attributeunsetvalue", "uprotationangle", "rightrotationangle", "downrotationangle", "leftrotationangle", "inicatcodes", "ctxcatcodes", "texcatcodes", "notcatcodes", "txtcatcodes", "vrbcatcodes", "prtcatcodes", "nilcatcodes", "luacatcodes", "tpacatcodes", "tpbcatcodes", "xmlcatcodes", "ctdcatcodes", "escapecatcode", "begingroupcatcode", "endgroupcatcode", "mathshiftcatcode", "alignmentcatcode", "endoflinecatcode", "parametercatcode", "superscriptcatcode", "subscriptcatcode", "ignorecatcode", "spacecatcode", "lettercatcode", "othercatcode", "activecatcode", "commentcatcode", "invalidcatcode", "tabasciicode", "newlineasciicode", "formfeedasciicode", "endoflineasciicode", "endoffileasciicode", "spaceasciicode", "hashasciicode", "dollarasciicode", "commentasciicode", "ampersandasciicode", "colonasciicode", "backslashasciicode", "circumflexasciicode", "underscoreasciicode", "leftbraceasciicode", "barasciicode", "rightbraceasciicode", "tildeasciicode", "delasciicode", "leftparentasciicode", "rightparentasciicode", "lessthanasciicode", "morethanasciicode", "doublecommentsignal", "atsignasciicode", "exclamationmarkasciicode", "questionmarkasciicode", "doublequoteasciicode", "singlequoteasciicode", "forwardslashasciicode", "primeasciicode", "hyphenasciicode", "activemathcharcode", "activetabtoken", "activeformfeedtoken", "activeendoflinetoken", "batchmodecode", "nonstopmodecode", "scrollmodecode", "errorstopmodecode", "bottomlevelgroupcode", "simplegroupcode", "hboxgroupcode", "adjustedhboxgroupcode", "vboxgroupcode", "vtopgroupcode", "aligngroupcode", "noaligngroupcode", "outputgroupcode", "mathgroupcode", "discretionarygroupcode", "insertgroupcode", "vcentergroupcode", "mathchoicegroupcode", "semisimplegroupcode", "mathshiftgroupcode", "mathleftgroupcode", "vadjustgroupcode", "charnodecode", "hlistnodecode", "vlistnodecode", "rulenodecode", "insertnodecode", "marknodecode", "adjustnodecode", "ligaturenodecode", "discretionarynodecode", "whatsitnodecode", "mathnodecode", "gluenodecode", "kernnodecode", "penaltynodecode", "unsetnodecode", "mathsnodecode", "charifcode", "catifcode", "numifcode", "dimifcode", "oddifcode", "vmodeifcode", "hmodeifcode", "mmodeifcode", "innerifcode", "voidifcode", "hboxifcode", "vboxifcode", "xifcode", "eofifcode", "trueifcode", "falseifcode", "caseifcode", "definedifcode", "csnameifcode", "fontcharifcode", "fontslantperpoint", "fontinterwordspace", "fontinterwordstretch", "fontinterwordshrink", "fontexheight", "fontemwidth", "fontextraspace", "slantperpoint", "mathexheight", "mathemwidth", "interwordspace", "interwordstretch", "interwordshrink", "exheight", "emwidth", "extraspace", "mathsupdisplay", "mathsupnormal", "mathsupcramped", "mathsubnormal", "mathsubcombined", "mathaxisheight", "muquad", "startmode", "stopmode", "startnotmode", "stopnotmode", "startmodeset", "stopmodeset", "doifmode", "doifelsemode", "doifmodeelse", "doifnotmode", "startmodeset", "stopmodeset", "startallmodes", "stopallmodes", "startnotallmodes", "stopnotallmodes", "doifallmodes", "doifelseallmodes", "doifallmodeselse", "doifnotallmodes", "startenvironment", "stopenvironment", "environment", "startcomponent", "stopcomponent", "component", "startproduct", "stopproduct", "product", "startproject", "stopproject", "project", "starttext", "stoptext", "startnotext", "stopnotext", "startdocument", "stopdocument", "documentvariable", "unexpandeddocumentvariable", "setupdocument", "presetdocument", "doifelsedocumentvariable", "doifdocumentvariableelse", "doifdocumentvariable", "doifnotdocumentvariable", "startmodule", "stopmodule", "usemodule", "usetexmodule", "useluamodule", "setupmodule", "currentmoduleparameter", "moduleparameter", "everystarttext", "everystoptext", "startTEXpage", "stopTEXpage", "enablemode", "disablemode", "preventmode", "definemode", "globalenablemode", "globaldisablemode", "globalpreventmode", "pushmode", "popmode", "typescriptone", "typescripttwo", "typescriptthree", "mathsizesuffix", "mathordcode", "mathopcode", "mathbincode", "mathrelcode", "mathopencode", "mathclosecode", "mathpunctcode", "mathalphacode", "mathinnercode", "mathnothingcode", "mathlimopcode", "mathnolopcode", "mathboxcode", "mathchoicecode", "mathaccentcode", "mathradicalcode", "constantnumber", "constantnumberargument", "constantdimen", "constantdimenargument", "constantemptyargument", "continueifinputfile", "luastringsep", "!!bs", "!!es", "lefttorightmark", "righttoleftmark", "lrm", "rlm", "bidilre", "bidirle", "bidipop", "bidilro", "bidirlo", "breakablethinspace", "nobreakspace", "nonbreakablespace", "narrownobreakspace", "zerowidthnobreakspace", "ideographicspace", "ideographichalffillspace", "twoperemspace", "threeperemspace", "fourperemspace", "fiveperemspace", "sixperemspace", "figurespace", "punctuationspace", "hairspace", "enquad", "emquad", "zerowidthspace", "zerowidthnonjoiner", "zerowidthjoiner", "zwnj", "zwj", "optionalspace", "asciispacechar", "softhyphen", "Ux", "eUx", "Umathaccents", "parfillleftskip", "parfillrightskip" }, - ["helpers"]={ "startsetups", "stopsetups", "startxmlsetups", "stopxmlsetups", "startluasetups", "stopluasetups", "starttexsetups", "stoptexsetups", "startrawsetups", "stoprawsetups", "startlocalsetups", "stoplocalsetups", "starttexdefinition", "stoptexdefinition", "starttexcode", "stoptexcode", "startcontextcode", "stopcontextcode", "startcontextdefinitioncode", "stopcontextdefinitioncode", "texdefinition", "doifelsesetups", "doifsetupselse", "doifsetups", "doifnotsetups", "setup", "setups", "texsetup", "xmlsetup", "luasetup", "directsetup", "fastsetup", "copysetups", "resetsetups", "doifelsecommandhandler", "doifcommandhandlerelse", "doifnotcommandhandler", "doifcommandhandler", "newmode", "setmode", "resetmode", "newsystemmode", "setsystemmode", "resetsystemmode", "pushsystemmode", "popsystemmode", "booleanmodevalue", "newcount", "newdimen", "newskip", "newmuskip", "newbox", "newtoks", "newread", "newwrite", "newmarks", "newinsert", "newattribute", "newif", "newlanguage", "newfamily", "newfam", "newhelp", "then", "begcsname", "autorule", "strippedcsname", "checkedstrippedcsname", "firstargumentfalse", "firstargumenttrue", "secondargumentfalse", "secondargumenttrue", "thirdargumentfalse", "thirdargumenttrue", "fourthargumentfalse", "fourthargumenttrue", "fifthargumentfalse", "fifthargumenttrue", "sixthargumentfalse", "sixthargumenttrue", "seventhargumentfalse", "seventhargumenttrue", "vkern", "hkern", "doglobal", "dodoglobal", "redoglobal", "resetglobal", "donothing", "dontcomplain", "forgetall", "donetrue", "donefalse", "foundtrue", "foundfalse", "inlineordisplaymath", "indisplaymath", "forcedisplaymath", "startforceddisplaymath", "stopforceddisplaymath", "startpickupmath", "stoppickupmath", "reqno", "mathortext", "htdp", "unvoidbox", "hfilll", "vfilll", "mathbox", "mathlimop", "mathnolop", "mathnothing", "mathalpha", "currentcatcodetable", "defaultcatcodetable", "catcodetablename", "newcatcodetable", "startcatcodetable", "stopcatcodetable", "startextendcatcodetable", "stopextendcatcodetable", "pushcatcodetable", "popcatcodetable", "restorecatcodes", "setcatcodetable", "letcatcodecommand", "defcatcodecommand", "uedcatcodecommand", "hglue", "vglue", "hfillneg", "vfillneg", "hfilllneg", "vfilllneg", "ruledhss", "ruledhfil", "ruledhfill", "ruledhfilll", "ruledhfilneg", "ruledhfillneg", "normalhfillneg", "normalhfilllneg", "ruledvss", "ruledvfil", "ruledvfill", "ruledvfilll", "ruledvfilneg", "ruledvfillneg", "normalvfillneg", "normalvfilllneg", "ruledhbox", "ruledvbox", "ruledvtop", "ruledvcenter", "ruledmbox", "ruledhpack", "ruledvpack", "ruledtpack", "ruledhskip", "ruledvskip", "ruledkern", "ruledmskip", "ruledmkern", "ruledhglue", "ruledvglue", "normalhglue", "normalvglue", "ruledpenalty", "filledhboxb", "filledhboxr", "filledhboxg", "filledhboxc", "filledhboxm", "filledhboxy", "filledhboxk", "scratchcounter", "globalscratchcounter", "privatescratchcounter", "scratchdimen", "globalscratchdimen", "privatescratchdimen", "scratchskip", "globalscratchskip", "privatescratchskip", "scratchmuskip", "globalscratchmuskip", "privatescratchmuskip", "scratchtoks", "globalscratchtoks", "privatescratchtoks", "scratchbox", "globalscratchbox", "privatescratchbox", "groupedcommand", "groupedcommandcs", "triggergroupedcommand", "triggergroupedcommandcs", "simplegroupedcommand", "pickupgroupedcommand", "normalbaselineskip", "normallineskip", "normallineskiplimit", "availablehsize", "localhsize", "setlocalhsize", "distributedhsize", "hsizefraction", "next", "nexttoken", "nextbox", "dowithnextbox", "dowithnextboxcs", "dowithnextboxcontent", "dowithnextboxcontentcs", "flushnextbox", "boxisempty", "scratchwidth", "scratchheight", "scratchdepth", "scratchoffset", "scratchdistance", "scratchhsize", "scratchvsize", "scratchxoffset", "scratchyoffset", "scratchhoffset", "scratchvoffset", "scratchxposition", "scratchyposition", "scratchtopoffset", "scratchbottomoffset", "scratchleftoffset", "scratchrightoffset", "scratchcounterone", "scratchcountertwo", "scratchcounterthree", "scratchcounterfour", "scratchcounterfive", "scratchcountersix", "scratchdimenone", "scratchdimentwo", "scratchdimenthree", "scratchdimenfour", "scratchdimenfive", "scratchdimensix", "scratchskipone", "scratchskiptwo", "scratchskipthree", "scratchskipfour", "scratchskipfive", "scratchskipsix", "scratchmuskipone", "scratchmuskiptwo", "scratchmuskipthree", "scratchmuskipfour", "scratchmuskipfive", "scratchmuskipsix", "scratchtoksone", "scratchtokstwo", "scratchtoksthree", "scratchtoksfour", "scratchtoksfive", "scratchtokssix", "scratchboxone", "scratchboxtwo", "scratchboxthree", "scratchboxfour", "scratchboxfive", "scratchboxsix", "scratchnx", "scratchny", "scratchmx", "scratchmy", "scratchunicode", "scratchmin", "scratchmax", "scratchleftskip", "scratchrightskip", "scratchtopskip", "scratchbottomskip", "doif", "doifnot", "doifelse", "firstinset", "doifinset", "doifnotinset", "doifelseinset", "doifinsetelse", "doifelsenextchar", "doifnextcharelse", "doifelsenextoptional", "doifnextoptionalelse", "doifelsenextoptionalcs", "doifnextoptionalcselse", "doifelsefastoptionalcheck", "doiffastoptionalcheckelse", "doifelsefastoptionalcheckcs", "doiffastoptionalcheckcselse", "doifelsenextbgroup", "doifnextbgroupelse", "doifelsenextbgroupcs", "doifnextbgroupcselse", "doifelsenextparenthesis", "doifnextparenthesiselse", "doifelseundefined", "doifundefinedelse", "doifelsedefined", "doifdefinedelse", "doifundefined", "doifdefined", "doifelsevalue", "doifvalue", "doifnotvalue", "doifnothing", "doifsomething", "doifelsenothing", "doifnothingelse", "doifelsesomething", "doifsomethingelse", "doifvaluenothing", "doifvaluesomething", "doifelsevaluenothing", "doifvaluenothingelse", "doifelsedimension", "doifdimensionelse", "doifelsenumber", "doifnumberelse", "doifnumber", "doifnotnumber", "doifelsecommon", "doifcommonelse", "doifcommon", "doifnotcommon", "doifinstring", "doifnotinstring", "doifelseinstring", "doifinstringelse", "doifelseassignment", "doifassignmentelse", "docheckassignment", "doifelseassignmentcs", "doifassignmentelsecs", "doiftext", "doifelsetext", "doiftextelse", "doifnottext", "tracingall", "tracingnone", "loggingall", "removetoks", "appendtoks", "prependtoks", "appendtotoks", "prependtotoks", "to", "endgraf", "endpar", "everyendpar", "reseteverypar", "finishpar", "empty", "null", "space", "quad", "enspace", "emspace", "charspace", "nbsp", "crlf", "obeyspaces", "obeylines", "obeyedspace", "obeyedline", "obeyedtab", "obeyedpage", "normalspace", "executeifdefined", "singleexpandafter", "doubleexpandafter", "tripleexpandafter", "dontleavehmode", "removelastspace", "removeunwantedspaces", "keepunwantedspaces", "removepunctuation", "ignoreparskip", "forcestrutdepth", "wait", "writestatus", "define", "defineexpandable", "redefine", "setmeasure", "setemeasure", "setgmeasure", "setxmeasure", "definemeasure", "freezemeasure", "measure", "measured", "installcorenamespace", "getvalue", "getuvalue", "setvalue", "setevalue", "setgvalue", "setxvalue", "letvalue", "letgvalue", "resetvalue", "undefinevalue", "ignorevalue", "setuvalue", "setuevalue", "setugvalue", "setuxvalue", "globallet", "glet", "udef", "ugdef", "uedef", "uxdef", "checked", "unique", "getparameters", "geteparameters", "getgparameters", "getxparameters", "forgetparameters", "copyparameters", "getdummyparameters", "dummyparameter", "directdummyparameter", "setdummyparameter", "letdummyparameter", "setexpandeddummyparameter", "usedummystyleandcolor", "usedummystyleparameter", "usedummycolorparameter", "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", "firstofoneunexpanded", "firstoftwounexpanded", "secondoftwounexpanded", "firstofthreeunexpanded", "secondofthreeunexpanded", "thirdofthreeunexpanded", "gobbleoneargument", "gobbletwoarguments", "gobblethreearguments", "gobblefourarguments", "gobblefivearguments", "gobblesixarguments", "gobblesevenarguments", "gobbleeightarguments", "gobbleninearguments", "gobbletenarguments", "gobbleoneoptional", "gobbletwooptionals", "gobblethreeoptionals", "gobblefouroptionals", "gobblefiveoptionals", "dorecurse", "doloop", "exitloop", "dostepwiserecurse", "recurselevel", "recursedepth", "dofastloopcs", "fastloopindex", "fastloopfinal", "dowith", "newconstant", "setnewconstant", "setconstant", "setconstantvalue", "newconditional", "settrue", "setfalse", "settruevalue", "setfalsevalue", "newmacro", "setnewmacro", "newfraction", "newsignal", "dosingleempty", "dodoubleempty", "dotripleempty", "doquadrupleempty", "doquintupleempty", "dosixtupleempty", "doseventupleempty", "dosingleargument", "dodoubleargument", "dotripleargument", "doquadrupleargument", "doquintupleargument", "dosixtupleargument", "doseventupleargument", "dosinglegroupempty", "dodoublegroupempty", "dotriplegroupempty", "doquadruplegroupempty", "doquintuplegroupempty", "permitspacesbetweengroups", "dontpermitspacesbetweengroups", "nopdfcompression", "maximumpdfcompression", "normalpdfcompression", "modulonumber", "dividenumber", "getfirstcharacter", "doifelsefirstchar", "doiffirstcharelse", "startnointerference", "stopnointerference", "twodigits", "threedigits", "leftorright", "offinterlineskip", "oninterlineskip", "nointerlineskip", "strut", "halfstrut", "quarterstrut", "depthstrut", "halflinestrut", "noheightstrut", "setstrut", "strutbox", "strutht", "strutdp", "strutwd", "struthtdp", "strutgap", "begstrut", "endstrut", "lineheight", "leftboundary", "rightboundary", "signalcharacter", "ordordspacing", "ordopspacing", "ordbinspacing", "ordrelspacing", "ordopenspacing", "ordclosespacing", "ordpunctspacing", "ordinnerspacing", "opordspacing", "opopspacing", "opbinspacing", "oprelspacing", "opopenspacing", "opclosespacing", "oppunctspacing", "opinnerspacing", "binordspacing", "binopspacing", "binbinspacing", "binrelspacing", "binopenspacing", "binclosespacing", "binpunctspacing", "bininnerspacing", "relordspacing", "relopspacing", "relbinspacing", "relrelspacing", "relopenspacing", "relclosespacing", "relpunctspacing", "relinnerspacing", "openordspacing", "openopspacing", "openbinspacing", "openrelspacing", "openopenspacing", "openclosespacing", "openpunctspacing", "openinnerspacing", "closeordspacing", "closeopspacing", "closebinspacing", "closerelspacing", "closeopenspacing", "closeclosespacing", "closepunctspacing", "closeinnerspacing", "punctordspacing", "punctopspacing", "punctbinspacing", "punctrelspacing", "punctopenspacing", "punctclosespacing", "punctpunctspacing", "punctinnerspacing", "innerordspacing", "inneropspacing", "innerbinspacing", "innerrelspacing", "inneropenspacing", "innerclosespacing", "innerpunctspacing", "innerinnerspacing", "normalreqno", "startimath", "stopimath", "normalstartimath", "normalstopimath", "startdmath", "stopdmath", "normalstartdmath", "normalstopdmath", "normalsuperscript", "normalsubscript", "normalnosuperscript", "normalnosubscript", "superscript", "subscript", "nosuperscript", "nosubscript", "uncramped", "cramped", "triggermathstyle", "mathstylefont", "mathsmallstylefont", "mathstyleface", "mathsmallstyleface", "mathstylecommand", "mathpalette", "mathstylehbox", "mathstylevbox", "mathstylevcenter", "mathstylevcenteredhbox", "mathstylevcenteredvbox", "mathtext", "setmathsmalltextbox", "setmathtextbox", "pushmathstyle", "popmathstyle", "triggerdisplaystyle", "triggertextstyle", "triggerscriptstyle", "triggerscriptscriptstyle", "triggeruncrampedstyle", "triggercrampedstyle", "triggersmallstyle", "triggeruncrampedsmallstyle", "triggercrampedsmallstyle", "triggerbigstyle", "triggeruncrampedbigstyle", "triggercrampedbigstyle", "luaexpr", "expelsedoif", "expdoif", "expdoifnot", "expdoifelsecommon", "expdoifcommonelse", "expdoifelseinset", "expdoifinsetelse", "ctxdirectlua", "ctxlatelua", "ctxsprint", "ctxwrite", "ctxcommand", "ctxdirectcommand", "ctxlatecommand", "ctxreport", "ctxlua", "luacode", "lateluacode", "directluacode", "registerctxluafile", "ctxloadluafile", "luaversion", "luamajorversion", "luaminorversion", "ctxluacode", "luaconditional", "luaexpanded", "startluaparameterset", "stopluaparameterset", "luaparameterset", "definenamedlua", "obeylualines", "obeyluatokens", "startluacode", "stopluacode", "startlua", "stoplua", "startctxfunction", "stopctxfunction", "ctxfunction", "startctxfunctiondefinition", "stopctxfunctiondefinition", "installctxfunction", "installprotectedctxfunction", "installprotectedctxscanner", "installctxscanner", "resetctxscanner", "cldprocessfile", "cldloadfile", "cldloadviafile", "cldcontext", "cldcommand", "carryoverpar", "lastlinewidth", "assumelongusagecs", "Umathbotaccent", "righttolefthbox", "lefttorighthbox", "righttoleftvbox", "lefttorightvbox", "righttoleftvtop", "lefttorightvtop", "rtlhbox", "ltrhbox", "rtlvbox", "ltrvbox", "rtlvtop", "ltrvtop", "autodirhbox", "autodirvbox", "autodirvtop", "leftorrighthbox", "leftorrightvbox", "leftorrightvtop", "lefttoright", "righttoleft", "checkedlefttoright", "checkedrighttoleft", "synchronizelayoutdirection", "synchronizedisplaydirection", "synchronizeinlinedirection", "dirlre", "dirrle", "dirlro", "dirrlo", "lesshyphens", "morehyphens", "nohyphens", "dohyphens", "Ucheckedstartdisplaymath", "Ucheckedstopdisplaymath", "break", "nobreak", "allowbreak", "goodbreak", "nospace", "nospacing", "dospacing", "naturalhbox", "naturalvbox", "naturalvtop", "naturalhpack", "naturalvpack", "frule", "compoundhyphenpenalty", "start", "stop" }, + ["helpers"]={ "startsetups", "stopsetups", "startxmlsetups", "stopxmlsetups", "startluasetups", "stopluasetups", "starttexsetups", "stoptexsetups", "startrawsetups", "stoprawsetups", "startlocalsetups", "stoplocalsetups", "starttexdefinition", "stoptexdefinition", "starttexcode", "stoptexcode", "startcontextcode", "stopcontextcode", "startcontextdefinitioncode", "stopcontextdefinitioncode", "texdefinition", "doifelsesetups", "doifsetupselse", "doifsetups", "doifnotsetups", "setup", "setups", "texsetup", "xmlsetup", "luasetup", "directsetup", "fastsetup", "copysetups", "resetsetups", "doifelsecommandhandler", "doifcommandhandlerelse", "doifnotcommandhandler", "doifcommandhandler", "newmode", "setmode", "resetmode", "newsystemmode", "setsystemmode", "resetsystemmode", "pushsystemmode", "popsystemmode", "globalsetmode", "globalresetmode", "globalsetsystemmode", "globalresetsystemmode", "booleanmodevalue", "newcount", "newdimen", "newskip", "newmuskip", "newbox", "newtoks", "newread", "newwrite", "newmarks", "newinsert", "newattribute", "newif", "newlanguage", "newfamily", "newfam", "newhelp", "then", "begcsname", "autorule", "strippedcsname", "checkedstrippedcsname", "firstargumentfalse", "firstargumenttrue", "secondargumentfalse", "secondargumenttrue", "thirdargumentfalse", "thirdargumenttrue", "fourthargumentfalse", "fourthargumenttrue", "fifthargumentfalse", "fifthargumenttrue", "sixthargumentfalse", "sixthargumenttrue", "seventhargumentfalse", "seventhargumenttrue", "vkern", "hkern", "doglobal", "dodoglobal", "redoglobal", "resetglobal", "donothing", "dontcomplain", "forgetall", "donetrue", "donefalse", "foundtrue", "foundfalse", "inlineordisplaymath", "indisplaymath", "forcedisplaymath", "startforceddisplaymath", "stopforceddisplaymath", "startpickupmath", "stoppickupmath", "reqno", "mathortext", "htdp", "unvoidbox", "hfilll", "vfilll", "mathbox", "mathlimop", "mathnolop", "mathnothing", "mathalpha", "currentcatcodetable", "defaultcatcodetable", "catcodetablename", "newcatcodetable", "startcatcodetable", "stopcatcodetable", "startextendcatcodetable", "stopextendcatcodetable", "pushcatcodetable", "popcatcodetable", "restorecatcodes", "setcatcodetable", "letcatcodecommand", "defcatcodecommand", "uedcatcodecommand", "hglue", "vglue", "hfillneg", "vfillneg", "hfilllneg", "vfilllneg", "ruledhss", "ruledhfil", "ruledhfill", "ruledhfilll", "ruledhfilneg", "ruledhfillneg", "normalhfillneg", "normalhfilllneg", "ruledvss", "ruledvfil", "ruledvfill", "ruledvfilll", "ruledvfilneg", "ruledvfillneg", "normalvfillneg", "normalvfilllneg", "ruledhbox", "ruledvbox", "ruledvtop", "ruledvcenter", "ruledmbox", "ruledhpack", "ruledvpack", "ruledtpack", "ruledhskip", "ruledvskip", "ruledkern", "ruledmskip", "ruledmkern", "ruledhglue", "ruledvglue", "normalhglue", "normalvglue", "ruledpenalty", "filledhboxb", "filledhboxr", "filledhboxg", "filledhboxc", "filledhboxm", "filledhboxy", "filledhboxk", "scratchcounter", "globalscratchcounter", "privatescratchcounter", "scratchdimen", "globalscratchdimen", "privatescratchdimen", "scratchskip", "globalscratchskip", "privatescratchskip", "scratchmuskip", "globalscratchmuskip", "privatescratchmuskip", "scratchtoks", "globalscratchtoks", "privatescratchtoks", "scratchbox", "globalscratchbox", "privatescratchbox", "groupedcommand", "groupedcommandcs", "triggergroupedcommand", "triggergroupedcommandcs", "simplegroupedcommand", "pickupgroupedcommand", "normalbaselineskip", "normallineskip", "normallineskiplimit", "availablehsize", "localhsize", "setlocalhsize", "distributedhsize", "hsizefraction", "next", "nexttoken", "nextbox", "dowithnextbox", "dowithnextboxcs", "dowithnextboxcontent", "dowithnextboxcontentcs", "flushnextbox", "boxisempty", "scratchwidth", "scratchheight", "scratchdepth", "scratchoffset", "scratchdistance", "scratchhsize", "scratchvsize", "scratchxoffset", "scratchyoffset", "scratchhoffset", "scratchvoffset", "scratchxposition", "scratchyposition", "scratchtopoffset", "scratchbottomoffset", "scratchleftoffset", "scratchrightoffset", "scratchcounterone", "scratchcountertwo", "scratchcounterthree", "scratchcounterfour", "scratchcounterfive", "scratchcountersix", "scratchdimenone", "scratchdimentwo", "scratchdimenthree", "scratchdimenfour", "scratchdimenfive", "scratchdimensix", "scratchskipone", "scratchskiptwo", "scratchskipthree", "scratchskipfour", "scratchskipfive", "scratchskipsix", "scratchmuskipone", "scratchmuskiptwo", "scratchmuskipthree", "scratchmuskipfour", "scratchmuskipfive", "scratchmuskipsix", "scratchtoksone", "scratchtokstwo", "scratchtoksthree", "scratchtoksfour", "scratchtoksfive", "scratchtokssix", "scratchboxone", "scratchboxtwo", "scratchboxthree", "scratchboxfour", "scratchboxfive", "scratchboxsix", "scratchnx", "scratchny", "scratchmx", "scratchmy", "scratchunicode", "scratchmin", "scratchmax", "scratchleftskip", "scratchrightskip", "scratchtopskip", "scratchbottomskip", "doif", "doifnot", "doifelse", "firstinset", "doifinset", "doifnotinset", "doifelseinset", "doifinsetelse", "doifelsenextchar", "doifnextcharelse", "doifelsenextoptional", "doifnextoptionalelse", "doifelsenextoptionalcs", "doifnextoptionalcselse", "doifelsefastoptionalcheck", "doiffastoptionalcheckelse", "doifelsefastoptionalcheckcs", "doiffastoptionalcheckcselse", "doifelsenextbgroup", "doifnextbgroupelse", "doifelsenextbgroupcs", "doifnextbgroupcselse", "doifelsenextparenthesis", "doifnextparenthesiselse", "doifelseundefined", "doifundefinedelse", "doifelsedefined", "doifdefinedelse", "doifundefined", "doifdefined", "doifelsevalue", "doifvalue", "doifnotvalue", "doifnothing", "doifsomething", "doifelsenothing", "doifnothingelse", "doifelsesomething", "doifsomethingelse", "doifvaluenothing", "doifvaluesomething", "doifelsevaluenothing", "doifvaluenothingelse", "doifelsedimension", "doifdimensionelse", "doifelsenumber", "doifnumberelse", "doifnumber", "doifnotnumber", "doifelsecommon", "doifcommonelse", "doifcommon", "doifnotcommon", "doifinstring", "doifnotinstring", "doifelseinstring", "doifinstringelse", "doifelseassignment", "doifassignmentelse", "docheckassignment", "doifelseassignmentcs", "doifassignmentelsecs", "doiftext", "doifelsetext", "doiftextelse", "doifnottext", "tracingall", "tracingnone", "loggingall", "removetoks", "appendtoks", "prependtoks", "appendtotoks", "prependtotoks", "to", "endgraf", "endpar", "everyendpar", "reseteverypar", "finishpar", "empty", "null", "space", "quad", "enspace", "emspace", "charspace", "nbsp", "crlf", "obeyspaces", "obeylines", "obeyedspace", "obeyedline", "obeyedtab", "obeyedpage", "normalspace", "executeifdefined", "singleexpandafter", "doubleexpandafter", "tripleexpandafter", "dontleavehmode", "removelastspace", "removeunwantedspaces", "keepunwantedspaces", "removepunctuation", "ignoreparskip", "forcestrutdepth", "wait", "writestatus", "define", "defineexpandable", "redefine", "setmeasure", "setemeasure", "setgmeasure", "setxmeasure", "definemeasure", "freezemeasure", "measure", "measured", "installcorenamespace", "getvalue", "getuvalue", "setvalue", "setevalue", "setgvalue", "setxvalue", "letvalue", "letgvalue", "resetvalue", "undefinevalue", "ignorevalue", "setuvalue", "setuevalue", "setugvalue", "setuxvalue", "globallet", "glet", "udef", "ugdef", "uedef", "uxdef", "checked", "unique", "getparameters", "geteparameters", "getgparameters", "getxparameters", "forgetparameters", "copyparameters", "getdummyparameters", "dummyparameter", "directdummyparameter", "setdummyparameter", "letdummyparameter", "setexpandeddummyparameter", "usedummystyleandcolor", "usedummystyleparameter", "usedummycolorparameter", "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", "firstofoneunexpanded", "firstoftwounexpanded", "secondoftwounexpanded", "firstofthreeunexpanded", "secondofthreeunexpanded", "thirdofthreeunexpanded", "gobbleoneargument", "gobbletwoarguments", "gobblethreearguments", "gobblefourarguments", "gobblefivearguments", "gobblesixarguments", "gobblesevenarguments", "gobbleeightarguments", "gobbleninearguments", "gobbletenarguments", "gobbleoneoptional", "gobbletwooptionals", "gobblethreeoptionals", "gobblefouroptionals", "gobblefiveoptionals", "dorecurse", "doloop", "exitloop", "dostepwiserecurse", "recurselevel", "recursedepth", "dofastloopcs", "fastloopindex", "fastloopfinal", "dowith", "newconstant", "setnewconstant", "setconstant", "setconstantvalue", "newconditional", "settrue", "setfalse", "settruevalue", "setfalsevalue", "newmacro", "setnewmacro", "newfraction", "newsignal", "dosingleempty", "dodoubleempty", "dotripleempty", "doquadrupleempty", "doquintupleempty", "dosixtupleempty", "doseventupleempty", "dosingleargument", "dodoubleargument", "dotripleargument", "doquadrupleargument", "doquintupleargument", "dosixtupleargument", "doseventupleargument", "dosinglegroupempty", "dodoublegroupempty", "dotriplegroupempty", "doquadruplegroupempty", "doquintuplegroupempty", "permitspacesbetweengroups", "dontpermitspacesbetweengroups", "nopdfcompression", "maximumpdfcompression", "normalpdfcompression", "modulonumber", "dividenumber", "getfirstcharacter", "doifelsefirstchar", "doiffirstcharelse", "startnointerference", "stopnointerference", "twodigits", "threedigits", "leftorright", "offinterlineskip", "oninterlineskip", "nointerlineskip", "strut", "halfstrut", "quarterstrut", "depthstrut", "halflinestrut", "noheightstrut", "setstrut", "strutbox", "strutht", "strutdp", "strutwd", "struthtdp", "strutgap", "begstrut", "endstrut", "lineheight", "leftboundary", "rightboundary", "signalcharacter", "ordordspacing", "ordopspacing", "ordbinspacing", "ordrelspacing", "ordopenspacing", "ordclosespacing", "ordpunctspacing", "ordinnerspacing", "opordspacing", "opopspacing", "opbinspacing", "oprelspacing", "opopenspacing", "opclosespacing", "oppunctspacing", "opinnerspacing", "binordspacing", "binopspacing", "binbinspacing", "binrelspacing", "binopenspacing", "binclosespacing", "binpunctspacing", "bininnerspacing", "relordspacing", "relopspacing", "relbinspacing", "relrelspacing", "relopenspacing", "relclosespacing", "relpunctspacing", "relinnerspacing", "openordspacing", "openopspacing", "openbinspacing", "openrelspacing", "openopenspacing", "openclosespacing", "openpunctspacing", "openinnerspacing", "closeordspacing", "closeopspacing", "closebinspacing", "closerelspacing", "closeopenspacing", "closeclosespacing", "closepunctspacing", "closeinnerspacing", "punctordspacing", "punctopspacing", "punctbinspacing", "punctrelspacing", "punctopenspacing", "punctclosespacing", "punctpunctspacing", "punctinnerspacing", "innerordspacing", "inneropspacing", "innerbinspacing", "innerrelspacing", "inneropenspacing", "innerclosespacing", "innerpunctspacing", "innerinnerspacing", "normalreqno", "startimath", "stopimath", "normalstartimath", "normalstopimath", "startdmath", "stopdmath", "normalstartdmath", "normalstopdmath", "normalsuperscript", "normalsubscript", "normalnosuperscript", "normalnosubscript", "superscript", "subscript", "nosuperscript", "nosubscript", "uncramped", "cramped", "triggermathstyle", "mathstylefont", "mathsmallstylefont", "mathstyleface", "mathsmallstyleface", "mathstylecommand", "mathpalette", "mathstylehbox", "mathstylevbox", "mathstylevcenter", "mathstylevcenteredhbox", "mathstylevcenteredvbox", "mathtext", "setmathsmalltextbox", "setmathtextbox", "pushmathstyle", "popmathstyle", "triggerdisplaystyle", "triggertextstyle", "triggerscriptstyle", "triggerscriptscriptstyle", "triggeruncrampedstyle", "triggercrampedstyle", "triggersmallstyle", "triggeruncrampedsmallstyle", "triggercrampedsmallstyle", "triggerbigstyle", "triggeruncrampedbigstyle", "triggercrampedbigstyle", "luaexpr", "expelsedoif", "expdoif", "expdoifnot", "expdoifelsecommon", "expdoifcommonelse", "expdoifelseinset", "expdoifinsetelse", "ctxdirectlua", "ctxlatelua", "ctxsprint", "ctxwrite", "ctxcommand", "ctxdirectcommand", "ctxlatecommand", "ctxreport", "ctxlua", "luacode", "lateluacode", "directluacode", "registerctxluafile", "ctxloadluafile", "luaversion", "luamajorversion", "luaminorversion", "ctxluacode", "luaconditional", "luaexpanded", "startluaparameterset", "stopluaparameterset", "luaparameterset", "definenamedlua", "obeylualines", "obeyluatokens", "startluacode", "stopluacode", "startlua", "stoplua", "startctxfunction", "stopctxfunction", "ctxfunction", "startctxfunctiondefinition", "stopctxfunctiondefinition", "installctxfunction", "installprotectedctxfunction", "installprotectedctxscanner", "installctxscanner", "resetctxscanner", "cldprocessfile", "cldloadfile", "cldloadviafile", "cldcontext", "cldcommand", "carryoverpar", "lastlinewidth", "assumelongusagecs", "Umathbotaccent", "righttolefthbox", "lefttorighthbox", "righttoleftvbox", "lefttorightvbox", "righttoleftvtop", "lefttorightvtop", "rtlhbox", "ltrhbox", "rtlvbox", "ltrvbox", "rtlvtop", "ltrvtop", "autodirhbox", "autodirvbox", "autodirvtop", "leftorrighthbox", "leftorrightvbox", "leftorrightvtop", "lefttoright", "righttoleft", "checkedlefttoright", "checkedrighttoleft", "synchronizelayoutdirection", "synchronizedisplaydirection", "synchronizeinlinedirection", "dirlre", "dirrle", "dirlro", "dirrlo", "lesshyphens", "morehyphens", "nohyphens", "dohyphens", "Ucheckedstartdisplaymath", "Ucheckedstopdisplaymath", "break", "nobreak", "allowbreak", "goodbreak", "nospace", "nospacing", "dospacing", "naturalhbox", "naturalvbox", "naturalvtop", "naturalhpack", "naturalvpack", "frule", "compoundhyphenpenalty", "start", "stop" }, }
\ No newline at end of file diff --git a/doc/context/documents/general/manuals/luatex.pdf b/doc/context/documents/general/manuals/luatex.pdf Binary files differindex 19c1aa51e..7db3dc14c 100644 --- a/doc/context/documents/general/manuals/luatex.pdf +++ b/doc/context/documents/general/manuals/luatex.pdf diff --git a/doc/context/documents/general/qrcs/setup-cs.pdf b/doc/context/documents/general/qrcs/setup-cs.pdf Binary files differindex c7d6a120e..44f0b4b60 100644 --- a/doc/context/documents/general/qrcs/setup-cs.pdf +++ b/doc/context/documents/general/qrcs/setup-cs.pdf diff --git a/doc/context/documents/general/qrcs/setup-de.pdf b/doc/context/documents/general/qrcs/setup-de.pdf Binary files differindex ad88a3407..fe38d07ce 100644 --- a/doc/context/documents/general/qrcs/setup-de.pdf +++ b/doc/context/documents/general/qrcs/setup-de.pdf diff --git a/doc/context/documents/general/qrcs/setup-en.pdf b/doc/context/documents/general/qrcs/setup-en.pdf Binary files differindex 5af37d839..94584fd03 100644 --- a/doc/context/documents/general/qrcs/setup-en.pdf +++ b/doc/context/documents/general/qrcs/setup-en.pdf diff --git a/doc/context/documents/general/qrcs/setup-fr.pdf b/doc/context/documents/general/qrcs/setup-fr.pdf Binary files differindex 051c9b57b..ee3773be3 100644 --- a/doc/context/documents/general/qrcs/setup-fr.pdf +++ b/doc/context/documents/general/qrcs/setup-fr.pdf diff --git a/doc/context/documents/general/qrcs/setup-it.pdf b/doc/context/documents/general/qrcs/setup-it.pdf Binary files differindex d00631ee3..e80e4d143 100644 --- a/doc/context/documents/general/qrcs/setup-it.pdf +++ b/doc/context/documents/general/qrcs/setup-it.pdf diff --git a/doc/context/documents/general/qrcs/setup-mapping-cs.pdf b/doc/context/documents/general/qrcs/setup-mapping-cs.pdf Binary files differindex fcea50fe8..5e5e8bb7a 100644 --- a/doc/context/documents/general/qrcs/setup-mapping-cs.pdf +++ b/doc/context/documents/general/qrcs/setup-mapping-cs.pdf diff --git a/doc/context/documents/general/qrcs/setup-mapping-de.pdf b/doc/context/documents/general/qrcs/setup-mapping-de.pdf Binary files differindex 523676873..0a8068bba 100644 --- a/doc/context/documents/general/qrcs/setup-mapping-de.pdf +++ b/doc/context/documents/general/qrcs/setup-mapping-de.pdf diff --git a/doc/context/documents/general/qrcs/setup-mapping-en.pdf b/doc/context/documents/general/qrcs/setup-mapping-en.pdf Binary files differindex 478f26510..2918fcbac 100644 --- a/doc/context/documents/general/qrcs/setup-mapping-en.pdf +++ b/doc/context/documents/general/qrcs/setup-mapping-en.pdf diff --git a/doc/context/documents/general/qrcs/setup-mapping-fr.pdf b/doc/context/documents/general/qrcs/setup-mapping-fr.pdf Binary files differindex 1deb0f13a..975855bf1 100644 --- a/doc/context/documents/general/qrcs/setup-mapping-fr.pdf +++ b/doc/context/documents/general/qrcs/setup-mapping-fr.pdf diff --git a/doc/context/documents/general/qrcs/setup-mapping-it.pdf b/doc/context/documents/general/qrcs/setup-mapping-it.pdf Binary files differindex 481c3dcaa..6ff109c19 100644 --- a/doc/context/documents/general/qrcs/setup-mapping-it.pdf +++ b/doc/context/documents/general/qrcs/setup-mapping-it.pdf diff --git a/doc/context/documents/general/qrcs/setup-mapping-nl.pdf b/doc/context/documents/general/qrcs/setup-mapping-nl.pdf Binary files differindex 4fddb97c8..846cd2d98 100644 --- a/doc/context/documents/general/qrcs/setup-mapping-nl.pdf +++ b/doc/context/documents/general/qrcs/setup-mapping-nl.pdf diff --git a/doc/context/documents/general/qrcs/setup-mapping-ro.pdf b/doc/context/documents/general/qrcs/setup-mapping-ro.pdf Binary files differindex b1febc0aa..1e4ebd1cc 100644 --- a/doc/context/documents/general/qrcs/setup-mapping-ro.pdf +++ b/doc/context/documents/general/qrcs/setup-mapping-ro.pdf diff --git a/doc/context/documents/general/qrcs/setup-nl.pdf b/doc/context/documents/general/qrcs/setup-nl.pdf Binary files differindex 7eb50d16e..28f1452e6 100644 --- a/doc/context/documents/general/qrcs/setup-nl.pdf +++ b/doc/context/documents/general/qrcs/setup-nl.pdf diff --git a/doc/context/documents/general/qrcs/setup-ro.pdf b/doc/context/documents/general/qrcs/setup-ro.pdf Binary files differindex e85c12bfe..2faa3e708 100644 --- a/doc/context/documents/general/qrcs/setup-ro.pdf +++ b/doc/context/documents/general/qrcs/setup-ro.pdf diff --git a/doc/context/scripts/mkiv/context.html b/doc/context/scripts/mkiv/context.html index b8837c525..2c64bf8df 100644 --- a/doc/context/scripts/mkiv/context.html +++ b/doc/context/scripts/mkiv/context.html @@ -104,6 +104,7 @@ <tr><th>--timing</th><td></td><td>generate timing and statistics overview</td></tr> <tr><th>--keeptuc</th><td></td><td>keep previous tuc files (jobname-tuc-[run].tmp)</td></tr> <tr><th>--keeplog</th><td></td><td>keep previous log files (jobname-log-[run].tmp)</td></tr> + <tr><th>--lmtx</th><td></td><td>force lmtx mode (when available)</td></tr> <tr><th/><td/><td/></tr> <tr><th>--extra=name</th><td></td><td>process extra (mtx-context-... in distribution)</td></tr> <tr><th>--extras</th><td></td><td>show extras</td></tr> diff --git a/doc/context/scripts/mkiv/context.man b/doc/context/scripts/mkiv/context.man index fc92dd7aa..de457caa9 100644 --- a/doc/context/scripts/mkiv/context.man +++ b/doc/context/scripts/mkiv/context.man @@ -168,6 +168,9 @@ keep previous tuc files (jobname-tuc-[run].tmp) .B --keeplog keep previous log files (jobname-log-[run].tmp) .TP +.B --lmtx +force lmtx mode (when available) +.TP .B --extra=name process extra (mtx-context-... in distribution) .TP diff --git a/doc/context/scripts/mkiv/context.xml b/doc/context/scripts/mkiv/context.xml index c4d634443..8c21eaa8c 100644 --- a/doc/context/scripts/mkiv/context.xml +++ b/doc/context/scripts/mkiv/context.xml @@ -190,6 +190,9 @@ <flag name="keeplog"> <short>keep previous log files (jobname-log-[run].tmp)</short> </flag> + <flag name="lmtx"> + <short>force lmtx mode (when available)</short> + </flag> </subcategory> <subcategory> <flag name="extra=name"> diff --git a/doc/context/scripts/mkiv/mtx-context.html b/doc/context/scripts/mkiv/mtx-context.html index b8837c525..2c64bf8df 100644 --- a/doc/context/scripts/mkiv/mtx-context.html +++ b/doc/context/scripts/mkiv/mtx-context.html @@ -104,6 +104,7 @@ <tr><th>--timing</th><td></td><td>generate timing and statistics overview</td></tr> <tr><th>--keeptuc</th><td></td><td>keep previous tuc files (jobname-tuc-[run].tmp)</td></tr> <tr><th>--keeplog</th><td></td><td>keep previous log files (jobname-log-[run].tmp)</td></tr> + <tr><th>--lmtx</th><td></td><td>force lmtx mode (when available)</td></tr> <tr><th/><td/><td/></tr> <tr><th>--extra=name</th><td></td><td>process extra (mtx-context-... in distribution)</td></tr> <tr><th>--extras</th><td></td><td>show extras</td></tr> diff --git a/doc/context/scripts/mkiv/mtx-context.man b/doc/context/scripts/mkiv/mtx-context.man index fc92dd7aa..de457caa9 100644 --- a/doc/context/scripts/mkiv/mtx-context.man +++ b/doc/context/scripts/mkiv/mtx-context.man @@ -168,6 +168,9 @@ keep previous tuc files (jobname-tuc-[run].tmp) .B --keeplog keep previous log files (jobname-log-[run].tmp) .TP +.B --lmtx +force lmtx mode (when available) +.TP .B --extra=name process extra (mtx-context-... in distribution) .TP diff --git a/doc/context/scripts/mkiv/mtx-context.xml b/doc/context/scripts/mkiv/mtx-context.xml index c4d634443..8c21eaa8c 100644 --- a/doc/context/scripts/mkiv/mtx-context.xml +++ b/doc/context/scripts/mkiv/mtx-context.xml @@ -190,6 +190,9 @@ <flag name="keeplog"> <short>keep previous log files (jobname-log-[run].tmp)</short> </flag> + <flag name="lmtx"> + <short>force lmtx mode (when available)</short> + </flag> </subcategory> <subcategory> <flag name="extra=name"> diff --git a/doc/context/scripts/mkiv/mtx-evohome.html b/doc/context/scripts/mkiv/mtx-evohome.html index dc21f7721..c8ec42b95 100644 --- a/doc/context/scripts/mkiv/mtx-evohome.html +++ b/doc/context/scripts/mkiv/mtx-evohome.html @@ -40,6 +40,7 @@ <tr><th style="width: 10em">flag</th><th style="width: 8em">value</th><th>description</th></tr> <tr><th/><td/><td/></tr> <tr><th>--collect</th><td></td><td>collect data from device</td></tr> + <tr><th>--update</th><td></td><td>update data from device</td></tr> <tr><th>--presets</th><td></td><td>file with authenciation data</td></tr> <tr><th>--auto</th><td></td><td>fetch temperature data every hour</td></tr> <tr><th>--port</th><td></td><td>server port when running the service, default: 8068</td></tr> diff --git a/doc/context/scripts/mkiv/mtx-evohome.man b/doc/context/scripts/mkiv/mtx-evohome.man index 3c20161dc..2bc272eda 100644 --- a/doc/context/scripts/mkiv/mtx-evohome.man +++ b/doc/context/scripts/mkiv/mtx-evohome.man @@ -14,6 +14,9 @@ .B --collect collect data from device .TP +.B --update +update data from device +.TP .B --presets file with authenciation data .TP diff --git a/doc/context/scripts/mkiv/mtx-evohome.xml b/doc/context/scripts/mkiv/mtx-evohome.xml index 7224d4183..abdb9fb99 100644 --- a/doc/context/scripts/mkiv/mtx-evohome.xml +++ b/doc/context/scripts/mkiv/mtx-evohome.xml @@ -9,6 +9,7 @@ <category name="basic"> <subcategory> <flag name="collect"><short>collect data from device</short></flag> + <flag name="update"><short>update data from device</short></flag> <flag name="presets"><short>file with authenciation data</short></flag> <flag name="auto"><short>fetch temperature data every hour</short></flag> <flag name="port"><short>server port when running the service, default: 8068</short></flag> diff --git a/metapost/context/base/mpiv/mp-luas.mpiv b/metapost/context/base/mpiv/mp-luas.mpiv index 293ebadaf..e5cfe0371 100644 --- a/metapost/context/base/mpiv/mp-luas.mpiv +++ b/metapost/context/base/mpiv/mp-luas.mpiv @@ -225,8 +225,23 @@ vardef texstr(expr name) = lua.mp.texstr(name) enddef ; % endfor cycle ; % \stopMPcode -def inpath suffix p = - = 1 step 1 until lua.mp.mf_path_length(str p) +% def inpath suffix p = +% = 1 step 1 until lua.mp.mf_path_length(str p) +% enddef ; + +% def inpath suffix p = +% % = 1 step 1 until lua.mp.mf_path_length(str p) +% = 1 step 1 until (begingroup save n ; n := lua.mp.mf_path_length(str p) ; if n = 0 : 1 else : n fi endgroup) +% enddef ; + +def inpath suffix p = % permits p[0] + = 1 step 1 until + begingroup + save mfun_inpath_r,mfun_inpath_n ; path mfun_inpath_r ; + mfun_inpath_r = p ; + mfun_inpath_n := lua.mp.mf_path_length(str mfun_inpath_r) ; + if mfun_inpath_n = 0 : 1 else : mfun_inpath_n fi + endgroup enddef ; vardef pointof primary i = lua.mp.mf_path_point(i) enddef ; diff --git a/metapost/context/base/mpiv/mp-mlib.mpiv b/metapost/context/base/mpiv/mp-mlib.mpiv index b7fc60b21..eb7b13834 100644 --- a/metapost/context/base/mpiv/mp-mlib.mpiv +++ b/metapost/context/base/mpiv/mp-mlib.mpiv @@ -605,7 +605,7 @@ enddef; vardef thelabel@#(expr p,z) = if numeric p : - thelabel@#(decimal p) + thelabel@#(decimal p,z) elseif string p : thelabel@#(rawtextext("\definedfont[" & defaultfont & "]" & p) scaled defaultscale,z) else : @@ -1771,8 +1771,8 @@ enddef ; vardef strfmt(expr f, x) = "\MPgraphformat{" & escaped_format(f) & "}{" & mfun_tagged_string(x) & "}" enddef ; vardef varfmt(expr f, x) = "\MPformatted{" & escaped_format(f) & "}{" & mfun_tagged_string(x) & "}" enddef ; -vardef format (expr f, x) = textext(strfmt(f, x)) enddef ; -vardef formatted(expr f, x) = textext(varfmt(f, x)) enddef ; +vardef format@# (expr f, x) = textext@#(strfmt(f, x)) enddef ; +vardef formatted@#(expr f, x) = textext@#(varfmt(f, x)) enddef ; % could be this (something to discuss with alan as it involves graph): % diff --git a/scripts/context/lua/mtx-context.lua b/scripts/context/lua/mtx-context.lua index 4244dfc83..1f3ce8301 100644 --- a/scripts/context/lua/mtx-context.lua +++ b/scripts/context/lua/mtx-context.lua @@ -665,11 +665,11 @@ function scripts.context.run(ctxdata,filename) -- side effects (so no bug reports please) .. we provide --sandbox that -- does similar things but tries to ensure that context works as expected - local a_safer = getargument("safer") - - if a_safer then - report("warning: using the luatex safer options, processing is not guaranteed") - end + -- local a_safer = getargument("safer") + -- + -- if a_safer then + -- report("warning: using the luatex safer options, processing is not guaranteed") + -- end -- a_batchmode = (a_batchmode and "batchmode") or (a_nonstopmode and "nonstopmode") or (a_scrollmode and "scrollmode") or nil @@ -810,7 +810,7 @@ function scripts.context.run(ctxdata,filename) ["interaction"] = a_batchmode, -- ["synctex"] = false, -- context has its own way ["no-parse-first-line"] = true, -- obsolete - ["safer"] = a_safer, -- better use --sandbox + -- ["safer"] = a_safer, -- better use --sandbox -- ["no-mktex"] = true, -- ["file-line-error-style"] = true, ["fmt"] = formatfile, diff --git a/scripts/context/lua/mtx-context.xml b/scripts/context/lua/mtx-context.xml index c4d634443..8c21eaa8c 100644 --- a/scripts/context/lua/mtx-context.xml +++ b/scripts/context/lua/mtx-context.xml @@ -190,6 +190,9 @@ <flag name="keeplog"> <short>keep previous log files (jobname-log-[run].tmp)</short> </flag> + <flag name="lmtx"> + <short>force lmtx mode (when available)</short> + </flag> </subcategory> <subcategory> <flag name="extra=name"> diff --git a/scripts/context/lua/mtx-evohome.lua b/scripts/context/lua/mtx-evohome.lua index 7fd8612ec..83f87abdf 100644 --- a/scripts/context/lua/mtx-evohome.lua +++ b/scripts/context/lua/mtx-evohome.lua @@ -24,6 +24,7 @@ local helpinfo = [[ <category name="basic"> <subcategory> <flag name="collect"><short>collect data from device</short></flag> + <flag name="update"><short>update data from device</short></flag> <flag name="presets"><short>file with authenciation data</short></flag> <flag name="auto"><short>fetch temperature data every hour</short></flag> <flag name="port"><short>server port when running the service, default: 8068</short></flag> diff --git a/scripts/context/lua/mtx-update.lua b/scripts/context/lua/mtx-update.lua index 6663be7a2..d9deb1b36 100644 --- a/scripts/context/lua/mtx-update.lua +++ b/scripts/context/lua/mtx-update.lua @@ -220,6 +220,8 @@ update.platforms = { -- ["solaris-sparc"] = "solaris-sparc", ["solaris"] = "solaris-sparc", + -- + ["unknown"] = "unknown", } local windowsplatform = { diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua index c45ed26ca..560e247fe 100644 --- a/scripts/context/lua/mtxrun.lua +++ b/scripts/context/lua/mtxrun.lua @@ -444,7 +444,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-sandbox"] = package.loaded["l-sandbox"] or true --- original size: 9678, stripped down to: 6688 +-- original size: 9747, stripped down to: 6739 if not modules then modules={} end modules ['l-sandbox']={ version=1.001, @@ -610,6 +610,9 @@ function blockrequire(name,lib) end function sandbox.enable() if not sandboxed then + debug={ + traceback=debug.traceback, + } for i=1,#initializers do initializers[i].action() end @@ -2015,7 +2018,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-table"] = package.loaded["l-table"] or true --- original size: 40802, stripped down to: 24000 +-- original size: 40960, stripped down to: 24090 if not modules then modules={} end modules ['l-table']={ version=1.001, @@ -2029,7 +2032,6 @@ local table,string=table,string local concat,sort,insert,remove=table.concat,table.sort,table.insert,table.remove local format,lower,dump=string.format,string.lower,string.dump local getmetatable,setmetatable=getmetatable,setmetatable -local getinfo=debug.getinfo local lpegmatch,patterns=lpeg.match,lpeg.patterns local floor=math.floor local stripper=patterns.stripper @@ -2591,20 +2593,23 @@ local function do_serialize(root,name,depth,level,indexed) end elseif tv=="function" then if functions then - local f=getinfo(v).what=="C" and dump(dummy) or dump(v) - if tk=="number" then - if hexify then - handle(format("%s [0x%X]=load(%q),",depth,k,f)) + local getinfo=debug and debug.getinfo + if getinfo then + local f=getinfo(v).what=="C" and dump(dummy) or dump(v) + if tk=="number" then + if hexify then + handle(format("%s [0x%X]=load(%q),",depth,k,f)) + else + handle(format("%s [%s]=load(%q),",depth,k,f)) + end + elseif tk=="boolean" then + handle(format("%s [%s]=load(%q),",depth,k and "true" or "false",f)) + elseif tk~="string" then + elseif noquotes and not reserved[k] and lpegmatch(propername,k) then + handle(format("%s %s=load(%q),",depth,k,f)) else - handle(format("%s [%s]=load(%q),",depth,k,f)) + handle(format("%s [%q]=load(%q),",depth,k,f)) end - elseif tk=="boolean" then - handle(format("%s [%s]=load(%q),",depth,k and "true" or "false",f)) - elseif tk~="string" then - elseif noquotes and not reserved[k] and lpegmatch(propername,k) then - handle(format("%s %s=load(%q),",depth,k,f)) - else - handle(format("%s [%q]=load(%q),",depth,k,f)) end end else @@ -3461,7 +3466,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-number"] = package.loaded["l-number"] or true --- original size: 5713, stripped down to: 2304 +-- original size: 5720, stripped down to: 2392 if not modules then modules={} end modules ['l-number']={ version=1.001, @@ -3485,11 +3490,14 @@ if bit32 then "0","0","0","0","0","0","0","0", "0","0","0","0","0","0","0","0", } - function number.tobitstring(b,m) - local n=32 - for i=0,31 do + function number.tobitstring(b,m,w) + if not w then + w=32 + end + local n=w + for i=0,w-1 do local v=bextract(b,i) - local k=32-i + local k=w-i if v==1 then n=k t[k]="1" @@ -3497,12 +3505,14 @@ if bit32 then t[k]="0" end end - if m then + if w then + return concat(t,"",1,w) + elseif m then m=33-m*8 if m<1 then m=1 end - return concat(t,"",m) + return concat(t,"",1,m) elseif n<8 then return concat(t) elseif n<16 then @@ -6264,7 +6274,7 @@ do -- create closure to overcome 200 locals limit package.loaded["util-str"] = package.loaded["util-str"] or true --- original size: 43376, stripped down to: 23750 +-- original size: 43481, stripped down to: 23845 if not modules then modules={} end modules ['util-str']={ version=1.001, @@ -7134,6 +7144,10 @@ function strings.newcollector() end end end +local f_16_16=formatters["%0.5N"] +function number.to16dot16(n) + return f_16_16(n/65536.0) +end end -- of closure @@ -7768,7 +7782,7 @@ do -- create closure to overcome 200 locals limit package.loaded["util-fil"] = package.loaded["util-fil"] or true --- original size: 9034, stripped down to: 6958 +-- original size: 8607, stripped down to: 6990 if not modules then modules={} end modules ['util-fil']={ version=1.001, @@ -7777,6 +7791,7 @@ if not modules then modules={} end modules ['util-fil']={ copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files" } +local tonumber=tonumber local byte=string.byte local char=string.char utilities=utilities or {} @@ -7935,17 +7950,17 @@ end function files.readfixed2(f) local a,b=byte(f:read(2),1,2) if a>=0x80 then - return (a-0x100)+b/0x100 + tonumber((a-0x100).."."..b) else - return (a )+b/0x100 + tonumber((a ).."."..b) end end function files.readfixed4(f) local a,b,c,d=byte(f:read(4),1,4) if a>=0x80 then - return (0x100*a+b-0x10000)+(0x100*c+d)/0x10000 + tonumber((0x100*a+b-0x10000).."."..(0x100*c+d)) else - return (0x100*a+b )+(0x100*c+d)/0x10000 + tonumber((0x100*a+b ).."."..(0x100*c+d)) end end if bit32 then @@ -8067,7 +8082,7 @@ do -- create closure to overcome 200 locals limit package.loaded["util-sac"] = package.loaded["util-sac"] or true --- original size: 11000, stripped down to: 8650 +-- original size: 11065, stripped down to: 8695 if not modules then modules={} end modules ['util-sac']={ version=1.001, @@ -8077,16 +8092,20 @@ if not modules then modules={} end modules ['util-sac']={ license="see context related readme files" } local byte,sub=string.byte,string.sub -local extract=bit32 and bit32.extract +local tonumber=tonumber utilities=utilities or {} local streams={} utilities.streams=streams function streams.open(filename,zerobased) - local f=io.loaddata(filename) - return { f,1,#f,zerobased or false } + local f=filename and io.loaddata(filename) + if f then + return { f,1,#f,zerobased or false } + end end function streams.openstring(f,zerobased) - return { f,1,#f,zerobased or false } + if f then + return { f,1,#f,zerobased or false } + end end function streams.close() end @@ -8272,29 +8291,29 @@ function streams.readinteger4le(f) return 0x1000000*a+0x10000*b+0x100*c+d end end -function streams.readfixed4(f) +function streams.readfixed2(f) local i=f[2] - local j=i+3 + local j=i+1 f[2]=j+1 - local a,b,c,d=byte(f[1],i,j) + local a,b=byte(f[1],i,j) if a>=0x80 then - return (0x100*a+b-0x10000)+(0x100*c+d)/0x10000 + tonumber((a-0x100).."."..b) else - return (0x100*a+b )+(0x100*c+d)/0x10000 + tonumber((a ).."."..b) end end -function streams.readfixed2(f) +function streams.readfixed4(f) local i=f[2] - local j=i+1 + local j=i+3 f[2]=j+1 - local a,b=byte(f[1],i,j) + local a,b,c,d=byte(f[1],i,j) if a>=0x80 then - return (a-0x100)+b/0x100 + tonumber((0x100*a+b-0x10000).."."..(0x100*c+d)) else - return (a )+b/0x100 + tonumber((0x100*a+b ).."."..(0x100*c+d)) end end -if extract then +if bit32 then local extract=bit32.extract local band=bit32.band function streams.read2dot14(f) @@ -13875,7 +13894,7 @@ do -- create closure to overcome 200 locals limit package.loaded["util-deb"] = package.loaded["util-deb"] or true --- original size: 9387, stripped down to: 6861 +-- original size: 9956, stripped down to: 7311 if not modules then modules={} end modules ['util-deb']={ version=1.001, @@ -13884,8 +13903,6 @@ if not modules then modules={} end modules ['util-deb']={ copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files" } -local debug=require "debug" -local getinfo,sethook=debug.getinfo,debug.sethook local type,next,tostring,tonumber=type,next,tostring,tonumber local format,find,sub,gsub=string.format,string.find,string.sub,string.gsub local insert,remove,sort=table.insert,table.remove,table.sort @@ -14090,6 +14107,28 @@ function debugger.showstats(printer,threshold) printer(format("calls : %i",calls)) printer(format("overhead : %f",seconds(overhead/1000))) end +local getinfo=nil +local sethook=nil +local function getdebug() + if sethook and getinfo then + return + end + if not debug then + local okay + okay,debug=pcall(require,"debug") + end + if type(debug)~="table" then + return + end + getinfo=debug.getinfo + sethook=debug.sethook + if type(getinfo)~="function" then + getinfo=nil + end + if type(sethook)~="function" then + sethook=nil + end +end function debugger.savestats(filename,threshold) local f=io.open(filename,'w') if f then @@ -14098,7 +14137,8 @@ function debugger.savestats(filename,threshold) end end function debugger.enable() - if nesting==0 then + getdebug() + if sethook and getinfo and nesting==0 then running=true if initialize then initialize() @@ -14119,23 +14159,26 @@ function debugger.disable() if nesting>0 then nesting=nesting-1 end - if nesting==0 then + if sethook and getinfo and nesting==0 then sethook() end end local function showtraceback(rep) - local level=2 - local reporter=rep or report - while true do - local info=getinfo(level,"Sl") - if not info then - break - elseif info.what=="C" then - reporter("%2i : %s",level-1,"C function") - else - reporter("%2i : %s : %s",level-1,info.short_src,info.currentline) + getdebug() + if getinfo then + local level=2 + local reporter=rep or report + while true do + local info=getinfo(level,"Sl") + if not info then + break + elseif info.what=="C" then + reporter("%2i : %s",level-1,"C function") + else + reporter("%2i : %s : %s",level-1,info.short_src,info.currentline) + end + level=level+1 end - level=level+1 end end debugger.showtraceback=showtraceback @@ -24666,8 +24709,8 @@ end -- of closure -- used libraries : l-lua.lua l-macro.lua l-sandbox.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-sha.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-fil.lua util-sac.lua util-sto.lua util-prs.lua util-fmt.lua util-soc-imp-reset.lua util-soc-imp-socket.lua util-soc-imp-copas.lua util-soc-imp-ltn12.lua util-soc-imp-mime.lua util-soc-imp-url.lua util-soc-imp-headers.lua util-soc-imp-tp.lua util-soc-imp-http.lua util-soc-imp-ftp.lua util-soc-imp-smtp.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-tpl.lua util-sbx.lua util-mrg.lua util-env.lua luat-env.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua util-lib.lua luat-sta.lua luat-fmt.lua -- skipped libraries : - --- original bytes : 985600 --- stripped bytes : 348489 +-- original bytes : 986146 +-- stripped bytes : 348184 -- end library merge diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua index c45ed26ca..560e247fe 100644 --- a/scripts/context/stubs/mswin/mtxrun.lua +++ b/scripts/context/stubs/mswin/mtxrun.lua @@ -444,7 +444,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-sandbox"] = package.loaded["l-sandbox"] or true --- original size: 9678, stripped down to: 6688 +-- original size: 9747, stripped down to: 6739 if not modules then modules={} end modules ['l-sandbox']={ version=1.001, @@ -610,6 +610,9 @@ function blockrequire(name,lib) end function sandbox.enable() if not sandboxed then + debug={ + traceback=debug.traceback, + } for i=1,#initializers do initializers[i].action() end @@ -2015,7 +2018,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-table"] = package.loaded["l-table"] or true --- original size: 40802, stripped down to: 24000 +-- original size: 40960, stripped down to: 24090 if not modules then modules={} end modules ['l-table']={ version=1.001, @@ -2029,7 +2032,6 @@ local table,string=table,string local concat,sort,insert,remove=table.concat,table.sort,table.insert,table.remove local format,lower,dump=string.format,string.lower,string.dump local getmetatable,setmetatable=getmetatable,setmetatable -local getinfo=debug.getinfo local lpegmatch,patterns=lpeg.match,lpeg.patterns local floor=math.floor local stripper=patterns.stripper @@ -2591,20 +2593,23 @@ local function do_serialize(root,name,depth,level,indexed) end elseif tv=="function" then if functions then - local f=getinfo(v).what=="C" and dump(dummy) or dump(v) - if tk=="number" then - if hexify then - handle(format("%s [0x%X]=load(%q),",depth,k,f)) + local getinfo=debug and debug.getinfo + if getinfo then + local f=getinfo(v).what=="C" and dump(dummy) or dump(v) + if tk=="number" then + if hexify then + handle(format("%s [0x%X]=load(%q),",depth,k,f)) + else + handle(format("%s [%s]=load(%q),",depth,k,f)) + end + elseif tk=="boolean" then + handle(format("%s [%s]=load(%q),",depth,k and "true" or "false",f)) + elseif tk~="string" then + elseif noquotes and not reserved[k] and lpegmatch(propername,k) then + handle(format("%s %s=load(%q),",depth,k,f)) else - handle(format("%s [%s]=load(%q),",depth,k,f)) + handle(format("%s [%q]=load(%q),",depth,k,f)) end - elseif tk=="boolean" then - handle(format("%s [%s]=load(%q),",depth,k and "true" or "false",f)) - elseif tk~="string" then - elseif noquotes and not reserved[k] and lpegmatch(propername,k) then - handle(format("%s %s=load(%q),",depth,k,f)) - else - handle(format("%s [%q]=load(%q),",depth,k,f)) end end else @@ -3461,7 +3466,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-number"] = package.loaded["l-number"] or true --- original size: 5713, stripped down to: 2304 +-- original size: 5720, stripped down to: 2392 if not modules then modules={} end modules ['l-number']={ version=1.001, @@ -3485,11 +3490,14 @@ if bit32 then "0","0","0","0","0","0","0","0", "0","0","0","0","0","0","0","0", } - function number.tobitstring(b,m) - local n=32 - for i=0,31 do + function number.tobitstring(b,m,w) + if not w then + w=32 + end + local n=w + for i=0,w-1 do local v=bextract(b,i) - local k=32-i + local k=w-i if v==1 then n=k t[k]="1" @@ -3497,12 +3505,14 @@ if bit32 then t[k]="0" end end - if m then + if w then + return concat(t,"",1,w) + elseif m then m=33-m*8 if m<1 then m=1 end - return concat(t,"",m) + return concat(t,"",1,m) elseif n<8 then return concat(t) elseif n<16 then @@ -6264,7 +6274,7 @@ do -- create closure to overcome 200 locals limit package.loaded["util-str"] = package.loaded["util-str"] or true --- original size: 43376, stripped down to: 23750 +-- original size: 43481, stripped down to: 23845 if not modules then modules={} end modules ['util-str']={ version=1.001, @@ -7134,6 +7144,10 @@ function strings.newcollector() end end end +local f_16_16=formatters["%0.5N"] +function number.to16dot16(n) + return f_16_16(n/65536.0) +end end -- of closure @@ -7768,7 +7782,7 @@ do -- create closure to overcome 200 locals limit package.loaded["util-fil"] = package.loaded["util-fil"] or true --- original size: 9034, stripped down to: 6958 +-- original size: 8607, stripped down to: 6990 if not modules then modules={} end modules ['util-fil']={ version=1.001, @@ -7777,6 +7791,7 @@ if not modules then modules={} end modules ['util-fil']={ copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files" } +local tonumber=tonumber local byte=string.byte local char=string.char utilities=utilities or {} @@ -7935,17 +7950,17 @@ end function files.readfixed2(f) local a,b=byte(f:read(2),1,2) if a>=0x80 then - return (a-0x100)+b/0x100 + tonumber((a-0x100).."."..b) else - return (a )+b/0x100 + tonumber((a ).."."..b) end end function files.readfixed4(f) local a,b,c,d=byte(f:read(4),1,4) if a>=0x80 then - return (0x100*a+b-0x10000)+(0x100*c+d)/0x10000 + tonumber((0x100*a+b-0x10000).."."..(0x100*c+d)) else - return (0x100*a+b )+(0x100*c+d)/0x10000 + tonumber((0x100*a+b ).."."..(0x100*c+d)) end end if bit32 then @@ -8067,7 +8082,7 @@ do -- create closure to overcome 200 locals limit package.loaded["util-sac"] = package.loaded["util-sac"] or true --- original size: 11000, stripped down to: 8650 +-- original size: 11065, stripped down to: 8695 if not modules then modules={} end modules ['util-sac']={ version=1.001, @@ -8077,16 +8092,20 @@ if not modules then modules={} end modules ['util-sac']={ license="see context related readme files" } local byte,sub=string.byte,string.sub -local extract=bit32 and bit32.extract +local tonumber=tonumber utilities=utilities or {} local streams={} utilities.streams=streams function streams.open(filename,zerobased) - local f=io.loaddata(filename) - return { f,1,#f,zerobased or false } + local f=filename and io.loaddata(filename) + if f then + return { f,1,#f,zerobased or false } + end end function streams.openstring(f,zerobased) - return { f,1,#f,zerobased or false } + if f then + return { f,1,#f,zerobased or false } + end end function streams.close() end @@ -8272,29 +8291,29 @@ function streams.readinteger4le(f) return 0x1000000*a+0x10000*b+0x100*c+d end end -function streams.readfixed4(f) +function streams.readfixed2(f) local i=f[2] - local j=i+3 + local j=i+1 f[2]=j+1 - local a,b,c,d=byte(f[1],i,j) + local a,b=byte(f[1],i,j) if a>=0x80 then - return (0x100*a+b-0x10000)+(0x100*c+d)/0x10000 + tonumber((a-0x100).."."..b) else - return (0x100*a+b )+(0x100*c+d)/0x10000 + tonumber((a ).."."..b) end end -function streams.readfixed2(f) +function streams.readfixed4(f) local i=f[2] - local j=i+1 + local j=i+3 f[2]=j+1 - local a,b=byte(f[1],i,j) + local a,b,c,d=byte(f[1],i,j) if a>=0x80 then - return (a-0x100)+b/0x100 + tonumber((0x100*a+b-0x10000).."."..(0x100*c+d)) else - return (a )+b/0x100 + tonumber((0x100*a+b ).."."..(0x100*c+d)) end end -if extract then +if bit32 then local extract=bit32.extract local band=bit32.band function streams.read2dot14(f) @@ -13875,7 +13894,7 @@ do -- create closure to overcome 200 locals limit package.loaded["util-deb"] = package.loaded["util-deb"] or true --- original size: 9387, stripped down to: 6861 +-- original size: 9956, stripped down to: 7311 if not modules then modules={} end modules ['util-deb']={ version=1.001, @@ -13884,8 +13903,6 @@ if not modules then modules={} end modules ['util-deb']={ copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files" } -local debug=require "debug" -local getinfo,sethook=debug.getinfo,debug.sethook local type,next,tostring,tonumber=type,next,tostring,tonumber local format,find,sub,gsub=string.format,string.find,string.sub,string.gsub local insert,remove,sort=table.insert,table.remove,table.sort @@ -14090,6 +14107,28 @@ function debugger.showstats(printer,threshold) printer(format("calls : %i",calls)) printer(format("overhead : %f",seconds(overhead/1000))) end +local getinfo=nil +local sethook=nil +local function getdebug() + if sethook and getinfo then + return + end + if not debug then + local okay + okay,debug=pcall(require,"debug") + end + if type(debug)~="table" then + return + end + getinfo=debug.getinfo + sethook=debug.sethook + if type(getinfo)~="function" then + getinfo=nil + end + if type(sethook)~="function" then + sethook=nil + end +end function debugger.savestats(filename,threshold) local f=io.open(filename,'w') if f then @@ -14098,7 +14137,8 @@ function debugger.savestats(filename,threshold) end end function debugger.enable() - if nesting==0 then + getdebug() + if sethook and getinfo and nesting==0 then running=true if initialize then initialize() @@ -14119,23 +14159,26 @@ function debugger.disable() if nesting>0 then nesting=nesting-1 end - if nesting==0 then + if sethook and getinfo and nesting==0 then sethook() end end local function showtraceback(rep) - local level=2 - local reporter=rep or report - while true do - local info=getinfo(level,"Sl") - if not info then - break - elseif info.what=="C" then - reporter("%2i : %s",level-1,"C function") - else - reporter("%2i : %s : %s",level-1,info.short_src,info.currentline) + getdebug() + if getinfo then + local level=2 + local reporter=rep or report + while true do + local info=getinfo(level,"Sl") + if not info then + break + elseif info.what=="C" then + reporter("%2i : %s",level-1,"C function") + else + reporter("%2i : %s : %s",level-1,info.short_src,info.currentline) + end + level=level+1 end - level=level+1 end end debugger.showtraceback=showtraceback @@ -24666,8 +24709,8 @@ end -- of closure -- used libraries : l-lua.lua l-macro.lua l-sandbox.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-sha.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-fil.lua util-sac.lua util-sto.lua util-prs.lua util-fmt.lua util-soc-imp-reset.lua util-soc-imp-socket.lua util-soc-imp-copas.lua util-soc-imp-ltn12.lua util-soc-imp-mime.lua util-soc-imp-url.lua util-soc-imp-headers.lua util-soc-imp-tp.lua util-soc-imp-http.lua util-soc-imp-ftp.lua util-soc-imp-smtp.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-tpl.lua util-sbx.lua util-mrg.lua util-env.lua luat-env.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua util-lib.lua luat-sta.lua luat-fmt.lua -- skipped libraries : - --- original bytes : 985600 --- stripped bytes : 348489 +-- original bytes : 986146 +-- stripped bytes : 348184 -- end library merge diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun index c45ed26ca..560e247fe 100644 --- a/scripts/context/stubs/unix/mtxrun +++ b/scripts/context/stubs/unix/mtxrun @@ -444,7 +444,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-sandbox"] = package.loaded["l-sandbox"] or true --- original size: 9678, stripped down to: 6688 +-- original size: 9747, stripped down to: 6739 if not modules then modules={} end modules ['l-sandbox']={ version=1.001, @@ -610,6 +610,9 @@ function blockrequire(name,lib) end function sandbox.enable() if not sandboxed then + debug={ + traceback=debug.traceback, + } for i=1,#initializers do initializers[i].action() end @@ -2015,7 +2018,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-table"] = package.loaded["l-table"] or true --- original size: 40802, stripped down to: 24000 +-- original size: 40960, stripped down to: 24090 if not modules then modules={} end modules ['l-table']={ version=1.001, @@ -2029,7 +2032,6 @@ local table,string=table,string local concat,sort,insert,remove=table.concat,table.sort,table.insert,table.remove local format,lower,dump=string.format,string.lower,string.dump local getmetatable,setmetatable=getmetatable,setmetatable -local getinfo=debug.getinfo local lpegmatch,patterns=lpeg.match,lpeg.patterns local floor=math.floor local stripper=patterns.stripper @@ -2591,20 +2593,23 @@ local function do_serialize(root,name,depth,level,indexed) end elseif tv=="function" then if functions then - local f=getinfo(v).what=="C" and dump(dummy) or dump(v) - if tk=="number" then - if hexify then - handle(format("%s [0x%X]=load(%q),",depth,k,f)) + local getinfo=debug and debug.getinfo + if getinfo then + local f=getinfo(v).what=="C" and dump(dummy) or dump(v) + if tk=="number" then + if hexify then + handle(format("%s [0x%X]=load(%q),",depth,k,f)) + else + handle(format("%s [%s]=load(%q),",depth,k,f)) + end + elseif tk=="boolean" then + handle(format("%s [%s]=load(%q),",depth,k and "true" or "false",f)) + elseif tk~="string" then + elseif noquotes and not reserved[k] and lpegmatch(propername,k) then + handle(format("%s %s=load(%q),",depth,k,f)) else - handle(format("%s [%s]=load(%q),",depth,k,f)) + handle(format("%s [%q]=load(%q),",depth,k,f)) end - elseif tk=="boolean" then - handle(format("%s [%s]=load(%q),",depth,k and "true" or "false",f)) - elseif tk~="string" then - elseif noquotes and not reserved[k] and lpegmatch(propername,k) then - handle(format("%s %s=load(%q),",depth,k,f)) - else - handle(format("%s [%q]=load(%q),",depth,k,f)) end end else @@ -3461,7 +3466,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-number"] = package.loaded["l-number"] or true --- original size: 5713, stripped down to: 2304 +-- original size: 5720, stripped down to: 2392 if not modules then modules={} end modules ['l-number']={ version=1.001, @@ -3485,11 +3490,14 @@ if bit32 then "0","0","0","0","0","0","0","0", "0","0","0","0","0","0","0","0", } - function number.tobitstring(b,m) - local n=32 - for i=0,31 do + function number.tobitstring(b,m,w) + if not w then + w=32 + end + local n=w + for i=0,w-1 do local v=bextract(b,i) - local k=32-i + local k=w-i if v==1 then n=k t[k]="1" @@ -3497,12 +3505,14 @@ if bit32 then t[k]="0" end end - if m then + if w then + return concat(t,"",1,w) + elseif m then m=33-m*8 if m<1 then m=1 end - return concat(t,"",m) + return concat(t,"",1,m) elseif n<8 then return concat(t) elseif n<16 then @@ -6264,7 +6274,7 @@ do -- create closure to overcome 200 locals limit package.loaded["util-str"] = package.loaded["util-str"] or true --- original size: 43376, stripped down to: 23750 +-- original size: 43481, stripped down to: 23845 if not modules then modules={} end modules ['util-str']={ version=1.001, @@ -7134,6 +7144,10 @@ function strings.newcollector() end end end +local f_16_16=formatters["%0.5N"] +function number.to16dot16(n) + return f_16_16(n/65536.0) +end end -- of closure @@ -7768,7 +7782,7 @@ do -- create closure to overcome 200 locals limit package.loaded["util-fil"] = package.loaded["util-fil"] or true --- original size: 9034, stripped down to: 6958 +-- original size: 8607, stripped down to: 6990 if not modules then modules={} end modules ['util-fil']={ version=1.001, @@ -7777,6 +7791,7 @@ if not modules then modules={} end modules ['util-fil']={ copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files" } +local tonumber=tonumber local byte=string.byte local char=string.char utilities=utilities or {} @@ -7935,17 +7950,17 @@ end function files.readfixed2(f) local a,b=byte(f:read(2),1,2) if a>=0x80 then - return (a-0x100)+b/0x100 + tonumber((a-0x100).."."..b) else - return (a )+b/0x100 + tonumber((a ).."."..b) end end function files.readfixed4(f) local a,b,c,d=byte(f:read(4),1,4) if a>=0x80 then - return (0x100*a+b-0x10000)+(0x100*c+d)/0x10000 + tonumber((0x100*a+b-0x10000).."."..(0x100*c+d)) else - return (0x100*a+b )+(0x100*c+d)/0x10000 + tonumber((0x100*a+b ).."."..(0x100*c+d)) end end if bit32 then @@ -8067,7 +8082,7 @@ do -- create closure to overcome 200 locals limit package.loaded["util-sac"] = package.loaded["util-sac"] or true --- original size: 11000, stripped down to: 8650 +-- original size: 11065, stripped down to: 8695 if not modules then modules={} end modules ['util-sac']={ version=1.001, @@ -8077,16 +8092,20 @@ if not modules then modules={} end modules ['util-sac']={ license="see context related readme files" } local byte,sub=string.byte,string.sub -local extract=bit32 and bit32.extract +local tonumber=tonumber utilities=utilities or {} local streams={} utilities.streams=streams function streams.open(filename,zerobased) - local f=io.loaddata(filename) - return { f,1,#f,zerobased or false } + local f=filename and io.loaddata(filename) + if f then + return { f,1,#f,zerobased or false } + end end function streams.openstring(f,zerobased) - return { f,1,#f,zerobased or false } + if f then + return { f,1,#f,zerobased or false } + end end function streams.close() end @@ -8272,29 +8291,29 @@ function streams.readinteger4le(f) return 0x1000000*a+0x10000*b+0x100*c+d end end -function streams.readfixed4(f) +function streams.readfixed2(f) local i=f[2] - local j=i+3 + local j=i+1 f[2]=j+1 - local a,b,c,d=byte(f[1],i,j) + local a,b=byte(f[1],i,j) if a>=0x80 then - return (0x100*a+b-0x10000)+(0x100*c+d)/0x10000 + tonumber((a-0x100).."."..b) else - return (0x100*a+b )+(0x100*c+d)/0x10000 + tonumber((a ).."."..b) end end -function streams.readfixed2(f) +function streams.readfixed4(f) local i=f[2] - local j=i+1 + local j=i+3 f[2]=j+1 - local a,b=byte(f[1],i,j) + local a,b,c,d=byte(f[1],i,j) if a>=0x80 then - return (a-0x100)+b/0x100 + tonumber((0x100*a+b-0x10000).."."..(0x100*c+d)) else - return (a )+b/0x100 + tonumber((0x100*a+b ).."."..(0x100*c+d)) end end -if extract then +if bit32 then local extract=bit32.extract local band=bit32.band function streams.read2dot14(f) @@ -13875,7 +13894,7 @@ do -- create closure to overcome 200 locals limit package.loaded["util-deb"] = package.loaded["util-deb"] or true --- original size: 9387, stripped down to: 6861 +-- original size: 9956, stripped down to: 7311 if not modules then modules={} end modules ['util-deb']={ version=1.001, @@ -13884,8 +13903,6 @@ if not modules then modules={} end modules ['util-deb']={ copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files" } -local debug=require "debug" -local getinfo,sethook=debug.getinfo,debug.sethook local type,next,tostring,tonumber=type,next,tostring,tonumber local format,find,sub,gsub=string.format,string.find,string.sub,string.gsub local insert,remove,sort=table.insert,table.remove,table.sort @@ -14090,6 +14107,28 @@ function debugger.showstats(printer,threshold) printer(format("calls : %i",calls)) printer(format("overhead : %f",seconds(overhead/1000))) end +local getinfo=nil +local sethook=nil +local function getdebug() + if sethook and getinfo then + return + end + if not debug then + local okay + okay,debug=pcall(require,"debug") + end + if type(debug)~="table" then + return + end + getinfo=debug.getinfo + sethook=debug.sethook + if type(getinfo)~="function" then + getinfo=nil + end + if type(sethook)~="function" then + sethook=nil + end +end function debugger.savestats(filename,threshold) local f=io.open(filename,'w') if f then @@ -14098,7 +14137,8 @@ function debugger.savestats(filename,threshold) end end function debugger.enable() - if nesting==0 then + getdebug() + if sethook and getinfo and nesting==0 then running=true if initialize then initialize() @@ -14119,23 +14159,26 @@ function debugger.disable() if nesting>0 then nesting=nesting-1 end - if nesting==0 then + if sethook and getinfo and nesting==0 then sethook() end end local function showtraceback(rep) - local level=2 - local reporter=rep or report - while true do - local info=getinfo(level,"Sl") - if not info then - break - elseif info.what=="C" then - reporter("%2i : %s",level-1,"C function") - else - reporter("%2i : %s : %s",level-1,info.short_src,info.currentline) + getdebug() + if getinfo then + local level=2 + local reporter=rep or report + while true do + local info=getinfo(level,"Sl") + if not info then + break + elseif info.what=="C" then + reporter("%2i : %s",level-1,"C function") + else + reporter("%2i : %s : %s",level-1,info.short_src,info.currentline) + end + level=level+1 end - level=level+1 end end debugger.showtraceback=showtraceback @@ -24666,8 +24709,8 @@ end -- of closure -- used libraries : l-lua.lua l-macro.lua l-sandbox.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-sha.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-fil.lua util-sac.lua util-sto.lua util-prs.lua util-fmt.lua util-soc-imp-reset.lua util-soc-imp-socket.lua util-soc-imp-copas.lua util-soc-imp-ltn12.lua util-soc-imp-mime.lua util-soc-imp-url.lua util-soc-imp-headers.lua util-soc-imp-tp.lua util-soc-imp-http.lua util-soc-imp-ftp.lua util-soc-imp-smtp.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-tpl.lua util-sbx.lua util-mrg.lua util-env.lua luat-env.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua util-lib.lua luat-sta.lua luat-fmt.lua -- skipped libraries : - --- original bytes : 985600 --- stripped bytes : 348489 +-- original bytes : 986146 +-- stripped bytes : 348184 -- end library merge diff --git a/scripts/context/stubs/win64/mtxrun.lua b/scripts/context/stubs/win64/mtxrun.lua index c45ed26ca..560e247fe 100644 --- a/scripts/context/stubs/win64/mtxrun.lua +++ b/scripts/context/stubs/win64/mtxrun.lua @@ -444,7 +444,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-sandbox"] = package.loaded["l-sandbox"] or true --- original size: 9678, stripped down to: 6688 +-- original size: 9747, stripped down to: 6739 if not modules then modules={} end modules ['l-sandbox']={ version=1.001, @@ -610,6 +610,9 @@ function blockrequire(name,lib) end function sandbox.enable() if not sandboxed then + debug={ + traceback=debug.traceback, + } for i=1,#initializers do initializers[i].action() end @@ -2015,7 +2018,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-table"] = package.loaded["l-table"] or true --- original size: 40802, stripped down to: 24000 +-- original size: 40960, stripped down to: 24090 if not modules then modules={} end modules ['l-table']={ version=1.001, @@ -2029,7 +2032,6 @@ local table,string=table,string local concat,sort,insert,remove=table.concat,table.sort,table.insert,table.remove local format,lower,dump=string.format,string.lower,string.dump local getmetatable,setmetatable=getmetatable,setmetatable -local getinfo=debug.getinfo local lpegmatch,patterns=lpeg.match,lpeg.patterns local floor=math.floor local stripper=patterns.stripper @@ -2591,20 +2593,23 @@ local function do_serialize(root,name,depth,level,indexed) end elseif tv=="function" then if functions then - local f=getinfo(v).what=="C" and dump(dummy) or dump(v) - if tk=="number" then - if hexify then - handle(format("%s [0x%X]=load(%q),",depth,k,f)) + local getinfo=debug and debug.getinfo + if getinfo then + local f=getinfo(v).what=="C" and dump(dummy) or dump(v) + if tk=="number" then + if hexify then + handle(format("%s [0x%X]=load(%q),",depth,k,f)) + else + handle(format("%s [%s]=load(%q),",depth,k,f)) + end + elseif tk=="boolean" then + handle(format("%s [%s]=load(%q),",depth,k and "true" or "false",f)) + elseif tk~="string" then + elseif noquotes and not reserved[k] and lpegmatch(propername,k) then + handle(format("%s %s=load(%q),",depth,k,f)) else - handle(format("%s [%s]=load(%q),",depth,k,f)) + handle(format("%s [%q]=load(%q),",depth,k,f)) end - elseif tk=="boolean" then - handle(format("%s [%s]=load(%q),",depth,k and "true" or "false",f)) - elseif tk~="string" then - elseif noquotes and not reserved[k] and lpegmatch(propername,k) then - handle(format("%s %s=load(%q),",depth,k,f)) - else - handle(format("%s [%q]=load(%q),",depth,k,f)) end end else @@ -3461,7 +3466,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-number"] = package.loaded["l-number"] or true --- original size: 5713, stripped down to: 2304 +-- original size: 5720, stripped down to: 2392 if not modules then modules={} end modules ['l-number']={ version=1.001, @@ -3485,11 +3490,14 @@ if bit32 then "0","0","0","0","0","0","0","0", "0","0","0","0","0","0","0","0", } - function number.tobitstring(b,m) - local n=32 - for i=0,31 do + function number.tobitstring(b,m,w) + if not w then + w=32 + end + local n=w + for i=0,w-1 do local v=bextract(b,i) - local k=32-i + local k=w-i if v==1 then n=k t[k]="1" @@ -3497,12 +3505,14 @@ if bit32 then t[k]="0" end end - if m then + if w then + return concat(t,"",1,w) + elseif m then m=33-m*8 if m<1 then m=1 end - return concat(t,"",m) + return concat(t,"",1,m) elseif n<8 then return concat(t) elseif n<16 then @@ -6264,7 +6274,7 @@ do -- create closure to overcome 200 locals limit package.loaded["util-str"] = package.loaded["util-str"] or true --- original size: 43376, stripped down to: 23750 +-- original size: 43481, stripped down to: 23845 if not modules then modules={} end modules ['util-str']={ version=1.001, @@ -7134,6 +7144,10 @@ function strings.newcollector() end end end +local f_16_16=formatters["%0.5N"] +function number.to16dot16(n) + return f_16_16(n/65536.0) +end end -- of closure @@ -7768,7 +7782,7 @@ do -- create closure to overcome 200 locals limit package.loaded["util-fil"] = package.loaded["util-fil"] or true --- original size: 9034, stripped down to: 6958 +-- original size: 8607, stripped down to: 6990 if not modules then modules={} end modules ['util-fil']={ version=1.001, @@ -7777,6 +7791,7 @@ if not modules then modules={} end modules ['util-fil']={ copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files" } +local tonumber=tonumber local byte=string.byte local char=string.char utilities=utilities or {} @@ -7935,17 +7950,17 @@ end function files.readfixed2(f) local a,b=byte(f:read(2),1,2) if a>=0x80 then - return (a-0x100)+b/0x100 + tonumber((a-0x100).."."..b) else - return (a )+b/0x100 + tonumber((a ).."."..b) end end function files.readfixed4(f) local a,b,c,d=byte(f:read(4),1,4) if a>=0x80 then - return (0x100*a+b-0x10000)+(0x100*c+d)/0x10000 + tonumber((0x100*a+b-0x10000).."."..(0x100*c+d)) else - return (0x100*a+b )+(0x100*c+d)/0x10000 + tonumber((0x100*a+b ).."."..(0x100*c+d)) end end if bit32 then @@ -8067,7 +8082,7 @@ do -- create closure to overcome 200 locals limit package.loaded["util-sac"] = package.loaded["util-sac"] or true --- original size: 11000, stripped down to: 8650 +-- original size: 11065, stripped down to: 8695 if not modules then modules={} end modules ['util-sac']={ version=1.001, @@ -8077,16 +8092,20 @@ if not modules then modules={} end modules ['util-sac']={ license="see context related readme files" } local byte,sub=string.byte,string.sub -local extract=bit32 and bit32.extract +local tonumber=tonumber utilities=utilities or {} local streams={} utilities.streams=streams function streams.open(filename,zerobased) - local f=io.loaddata(filename) - return { f,1,#f,zerobased or false } + local f=filename and io.loaddata(filename) + if f then + return { f,1,#f,zerobased or false } + end end function streams.openstring(f,zerobased) - return { f,1,#f,zerobased or false } + if f then + return { f,1,#f,zerobased or false } + end end function streams.close() end @@ -8272,29 +8291,29 @@ function streams.readinteger4le(f) return 0x1000000*a+0x10000*b+0x100*c+d end end -function streams.readfixed4(f) +function streams.readfixed2(f) local i=f[2] - local j=i+3 + local j=i+1 f[2]=j+1 - local a,b,c,d=byte(f[1],i,j) + local a,b=byte(f[1],i,j) if a>=0x80 then - return (0x100*a+b-0x10000)+(0x100*c+d)/0x10000 + tonumber((a-0x100).."."..b) else - return (0x100*a+b )+(0x100*c+d)/0x10000 + tonumber((a ).."."..b) end end -function streams.readfixed2(f) +function streams.readfixed4(f) local i=f[2] - local j=i+1 + local j=i+3 f[2]=j+1 - local a,b=byte(f[1],i,j) + local a,b,c,d=byte(f[1],i,j) if a>=0x80 then - return (a-0x100)+b/0x100 + tonumber((0x100*a+b-0x10000).."."..(0x100*c+d)) else - return (a )+b/0x100 + tonumber((0x100*a+b ).."."..(0x100*c+d)) end end -if extract then +if bit32 then local extract=bit32.extract local band=bit32.band function streams.read2dot14(f) @@ -13875,7 +13894,7 @@ do -- create closure to overcome 200 locals limit package.loaded["util-deb"] = package.loaded["util-deb"] or true --- original size: 9387, stripped down to: 6861 +-- original size: 9956, stripped down to: 7311 if not modules then modules={} end modules ['util-deb']={ version=1.001, @@ -13884,8 +13903,6 @@ if not modules then modules={} end modules ['util-deb']={ copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files" } -local debug=require "debug" -local getinfo,sethook=debug.getinfo,debug.sethook local type,next,tostring,tonumber=type,next,tostring,tonumber local format,find,sub,gsub=string.format,string.find,string.sub,string.gsub local insert,remove,sort=table.insert,table.remove,table.sort @@ -14090,6 +14107,28 @@ function debugger.showstats(printer,threshold) printer(format("calls : %i",calls)) printer(format("overhead : %f",seconds(overhead/1000))) end +local getinfo=nil +local sethook=nil +local function getdebug() + if sethook and getinfo then + return + end + if not debug then + local okay + okay,debug=pcall(require,"debug") + end + if type(debug)~="table" then + return + end + getinfo=debug.getinfo + sethook=debug.sethook + if type(getinfo)~="function" then + getinfo=nil + end + if type(sethook)~="function" then + sethook=nil + end +end function debugger.savestats(filename,threshold) local f=io.open(filename,'w') if f then @@ -14098,7 +14137,8 @@ function debugger.savestats(filename,threshold) end end function debugger.enable() - if nesting==0 then + getdebug() + if sethook and getinfo and nesting==0 then running=true if initialize then initialize() @@ -14119,23 +14159,26 @@ function debugger.disable() if nesting>0 then nesting=nesting-1 end - if nesting==0 then + if sethook and getinfo and nesting==0 then sethook() end end local function showtraceback(rep) - local level=2 - local reporter=rep or report - while true do - local info=getinfo(level,"Sl") - if not info then - break - elseif info.what=="C" then - reporter("%2i : %s",level-1,"C function") - else - reporter("%2i : %s : %s",level-1,info.short_src,info.currentline) + getdebug() + if getinfo then + local level=2 + local reporter=rep or report + while true do + local info=getinfo(level,"Sl") + if not info then + break + elseif info.what=="C" then + reporter("%2i : %s",level-1,"C function") + else + reporter("%2i : %s : %s",level-1,info.short_src,info.currentline) + end + level=level+1 end - level=level+1 end end debugger.showtraceback=showtraceback @@ -24666,8 +24709,8 @@ end -- of closure -- used libraries : l-lua.lua l-macro.lua l-sandbox.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-sha.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-fil.lua util-sac.lua util-sto.lua util-prs.lua util-fmt.lua util-soc-imp-reset.lua util-soc-imp-socket.lua util-soc-imp-copas.lua util-soc-imp-ltn12.lua util-soc-imp-mime.lua util-soc-imp-url.lua util-soc-imp-headers.lua util-soc-imp-tp.lua util-soc-imp-http.lua util-soc-imp-ftp.lua util-soc-imp-smtp.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-tpl.lua util-sbx.lua util-mrg.lua util-env.lua luat-env.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua util-lib.lua luat-sta.lua luat-fmt.lua -- skipped libraries : - --- original bytes : 985600 --- stripped bytes : 348489 +-- original bytes : 986146 +-- stripped bytes : 348184 -- end library merge diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii index 3f7c0e7ef..541ed647d 100644 --- a/tex/context/base/mkii/cont-new.mkii +++ b/tex/context/base/mkii/cont-new.mkii @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2018.10.18 00:07} +\newcontextversion{2018.11.18 14:07} %D This file is loaded at runtime, thereby providing an %D excellent place for hacks, patches, extensions and new diff --git a/tex/context/base/mkii/context.mkii b/tex/context/base/mkii/context.mkii index d530cd65d..6da22d53c 100644 --- a/tex/context/base/mkii/context.mkii +++ b/tex/context/base/mkii/context.mkii @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2018.10.18 00:07} +\edef\contextversion{2018.11.18 14:07} %D For those who want to use this: diff --git a/tex/context/base/mkii/mult-nl.mkii b/tex/context/base/mkii/mult-nl.mkii index a21064a23..e0f445eb2 100644 --- a/tex/context/base/mkii/mult-nl.mkii +++ b/tex/context/base/mkii/mult-nl.mkii @@ -1241,6 +1241,7 @@ \setinterfaceconstant{textstyle}{tekstletter} \setinterfaceconstant{textwidth}{tekstbreedte} \setinterfaceconstant{threshold}{threshold} +\setinterfaceconstant{time}{tijd} \setinterfaceconstant{title}{titel} \setinterfaceconstant{titlecolor}{titelkleur} \setinterfaceconstant{titlecommand}{titelcommando} diff --git a/tex/context/base/mkiv/back-ini.lua b/tex/context/base/mkiv/back-ini.lua index 256fcf445..059e1c8a8 100644 --- a/tex/context/base/mkiv/back-ini.lua +++ b/tex/context/base/mkiv/back-ini.lua @@ -73,7 +73,8 @@ function backends.install(what) end backends.current = what for category, default in next, defaults do - local target, plugin = backends[category], backend[category] + local target = backends[category] + local plugin = backend [category] setmetatableindex(plugin, default) setmetatableindex(target, plugin) end diff --git a/tex/context/base/mkiv/back-ini.mkiv b/tex/context/base/mkiv/back-ini.mkiv index e810ecde5..c7a62f078 100644 --- a/tex/context/base/mkiv/back-ini.mkiv +++ b/tex/context/base/mkiv/back-ini.mkiv @@ -17,6 +17,7 @@ \writestatus{loading}{ConTeXt Backend Macros / Initialization} \registerctxluafile{back-ini}{} +\registerctxluafile{back-res}{} %D We currently have a curious mix between tex and lua backend %D handling but eventually most will move to lua. @@ -113,6 +114,12 @@ \clf_setrealspaces{\backendparameter\c!space}% \to \everysetupbackend +\appendtoks + \ifdefined\clf_resetmapfile + \clf_resetmapfile + \fi +\to \everysetupbackend + %D For older styles: \let\setupoutput\gobbleoneoptional diff --git a/tex/context/base/mkiv/back-pdf.lua b/tex/context/base/mkiv/back-pdf.lua index f45783e51..27e9cb69c 100644 --- a/tex/context/base/mkiv/back-pdf.lua +++ b/tex/context/base/mkiv/back-pdf.lua @@ -18,7 +18,6 @@ local context = context local scanners = tokens.scanners local scannumber = scanners.number local scankeyword = scanners.keyword -local scandimen = scanners.dimen local scancount = scanners.count local scanstring = scanners.string @@ -38,14 +37,14 @@ end backends.install("pdf") -local f_matrix = string.formatters["%F %F %F %F"] -- 0.8 is default - -scanners.pdfrotation = function() -- a - -- todo: check for 1 and 0 and flush sparse - local a = scannumber() - local s, c = sind(a), cosd(a) - context(f_matrix(c,s,-s,c)) -end +-- local f_matrix = string.formatters["%F %F %F %F"] -- 0.8 is default +-- +-- scanners.pdfrotation = function() -- a +-- -- todo: check for 1 and 0 and flush sparse +-- local a = scannumber() +-- local s, c = sind(a), cosd(a) +-- context(f_matrix(c,s,-s,c)) +-- end -- experimental code (somewhat weird here) .. todo: nodeinjections .. this will only work -- out well if we also calculate the accumulated cm and wrap inclusions / annotations in @@ -53,14 +52,29 @@ end -- -- we could also do the save restore wrapping here + colorhack -local pdfsave = nodes.pool.pdfsave -local pdfrestore = nodes.pool.pdfrestore -local pdfsetmatrix = nodes.pool.pdfsetmatrix +local nodepool = nodes.pool +local pdfsave = nodepool.pdfsave +local pdfrestore = nodepool.pdfrestore +local pdfsetmatrix = nodepool.pdfsetmatrix local stack = { } local restore = true -- false -scanners.pdfstartrotation = function() +local function pdfstopsomething() + local top = remove(stack) + if top == false then + -- not wrapped + elseif top == true then + context(pdfrestore()) + elseif top then + context(pdfsetmatrix(unpack(top))) -- not really needed anymore + context(pdfrestore()) + else + -- nesting error + end +end + +local function pdfstartrotation() local a = scannumber() if a == 0 then insert(stack,false) @@ -72,7 +86,10 @@ scanners.pdfstartrotation = function() end end -scanners.pdfstartscaling = function() -- at the tex end we use sx and sy instead of rx and ry +implement { name = "pdfstartrotation", actions = pdfstartrotation } +implement { name = "pdfstoprotation", actions = pdfstopsomething } + +local function pdfstartscaling() -- at the tex end we use sx and sy instead of rx and ry local rx, ry = 1, 1 while true do if scankeyword("rx") then @@ -107,7 +124,10 @@ scanners.pdfstartscaling = function() -- at the tex end we use sx and sy instead end end -scanners.pdfstartmatrix = function() -- rx sx sy ry -- tx, ty +implement { name = "pdfstartscaling", actions = pdfstartscaling } +implement { name = "pdfstopscaling", actions = pdfstopsomething } + +local function pdfstartmatrix() -- rx sx sy ry -- tx, ty local rx, sx, sy, ry = 1, 0, 0, 1 while true do if scankeyword("rx") then rx = scannumber() @@ -125,46 +145,32 @@ scanners.pdfstartmatrix = function() -- rx sx sy ry -- tx, ty end end -local function pdfstopsomething() - local top = remove(stack) - if top == false then - -- not wrapped - elseif top == true then - context(pdfrestore()) - elseif top then - context(pdfsetmatrix(unpack(top))) -- not really needed anymore - context(pdfrestore()) - else - -- nesting error - end -end +implement { name = "pdfstartmatrix", actions = pdfstartmatrix } +implement { name = "pdfstopmatrix", actions = pdfstopsomething } -scanners.pdfstoprotation = pdfstopsomething -scanners.pdfstopscaling = pdfstopsomething -scanners.pdfstopmatrix = pdfstopsomething - -scanners.pdfstartmirroring = function() +local function pdfstartmirroring() context(pdfsetmatrix(-1,0,0,1)) end +implement { name = "pdfstartmirroring", actions = pdfstartmirroring } +implement { name = "pdfstopmirroring", actions = pdfstopsomething } + if environment.arguments.nocompression then lpdf.setcompression(0,0,true) end -scanners.pdfstopmirroring = scanners.pdfstartmirroring - --- todo, change the above to implement too -- +-- todo: implement { name = "setmapfile", arguments = "string", - actions = pdf.mapfile + actions = lpdf.setmapfile } implement { name = "setmapline", arguments = "string", - actions = pdf.mapline + actions = lpdf.setmapline } implement { @@ -173,135 +179,3 @@ implement { actions = lpdf.setcompression, } -local report = logs.reporter("backend","pdftex primitives") -local trace = false - -scanners.pdfannot = function() - if scankeyword("reserveobjectnum") then - report("\\pdfannot reserveobjectnum is not (yet) supported") - -- if trace then - -- report() - -- report("\\pdfannot: reserved number (not supported yet)") - -- report() - -- end - else - local width = false - local height = false - local depth = false - local data = false - local object = false - local attr = false - -- - if scankeyword("useobjnum") then - object = scancount() - report("\\pdfannot useobjectnum is not (yet) supported") - end - while true do - if scankeyword("width") then - width = scandimen() - elseif scankeyword("height") then - height = scandimen() - elseif scankeyword("depth") then - depth = scandimen() - else - break - end - end - if scankeyword("attr") then - attr = scanstring() - end - data = scanstring() - -- - -- less strict variant: - -- - -- while true do - -- if scankeyword("width") then - -- width = scandimen() - -- elseif scankeyword("height") then - -- height = scandimen() - -- elseif scankeyword("depth") then - -- depth = scandimen() - -- elseif scankeyword("useobjnum") then - -- object = scancount() - -- elseif scankeyword("attr") then - -- attr = scanstring() - -- else - -- data = scanstring() - -- break - -- end - -- end - -- - -- if trace then - -- report() - -- report("\\pdfannot:") - -- report() - -- report(" object: %s",object or "<unset> (not supported yet)") - -- report(" width : %p",width or "<unset>") - -- report(" height: %p",height or "<unset>") - -- report(" depth : %p",depth or "<unset>") - -- report(" attr : %s",attr or "<unset>") - -- report(" data : %s",data or "<unset>") - -- report() - -- end - context(backends.nodeinjections.annotation(width or 0,height or 0,depth or 0,data or "")) - end -end - -scanners.pdfdest = function() - local name = false - local zoom = false - local view = false - local width = false - local height = false - local depth = false - if scankeyword("num") then - report("\\pdfdest num is not (yet) supported") - elseif scankeyword("name") then - name = scanstring() - end - if scankeyword("xyz") then - view = "xyz" - if scankeyword("zoom") then - report("\\pdfdest zoom is ignored") - zoom = scancount() -- will be divided by 1000 in the backend - end - elseif scankeyword("fitbh") then - view = "fitbh" - elseif scankeyword("fitbv") then - view = "fitbv" - elseif scankeyword("fitb") then - view = "fitb" - elseif scankeyword("fith") then - view = "fith" - elseif scankeyword("fitv") then - view = "fitv" - elseif scankeyword("fitr") then - view = "fitr" - while true do - if scankeyword("width") then - width = scandimen() - elseif scankeyword("height") then - height = scandimen() - elseif scankeyword("depth") then - depth = scandimen() - else - break - end - end - elseif scankeyword("fit") then - view = "fit" - end - -- if trace then - -- report() - -- report("\\pdfdest:") - -- report() - -- report(" name : %s",name or "<unset>") - -- report(" view : %s",view or "<unset>") - -- report(" zoom : %s",zoom or "<unset> (not supported)") - -- report(" width : %p",width or "<unset>") - -- report(" height: %p",height or "<unset>") - -- report(" depth : %p",depth or "<unset>") - -- report() - -- end - context(backends.nodeinjections.destination(width or 0,height or 0,depth or 0,{ name or "" },view or "fit")) -end diff --git a/tex/context/base/mkiv/back-pdf.mkiv b/tex/context/base/mkiv/back-pdf.mkiv index 799df2538..c3cb7657f 100644 --- a/tex/context/base/mkiv/back-pdf.mkiv +++ b/tex/context/base/mkiv/back-pdf.mkiv @@ -32,15 +32,17 @@ \registerctxluafile{lpdf-swf}{} % this will become a module \registerctxluafile{lpdf-tag}{} \registerctxluafile{lpdf-fmt}{} +\registerctxluafile{lpdf-pde}{} +\registerctxluafile{lpdf-img}{optimize} +\registerctxluafile{lpdf-epa}{} -\ifnum\texenginefunctionality<6802 - \registerctxluafile{lpdf-epd}{} -\else - \registerctxluafile{lpdf-pde}{} - \registerctxluafile{lpdf-img}{optimize} -\fi +\doifelsefileexists {lpdf-emb.lua} { + \registerctxluafile{lpdf-emb}{optimize} +} { + % nothing +} -\registerctxluafile{lpdf-epa}{} +\registerctxluafile{back-pdp}{} \ifnum\texenginefunctionality>6856 \registerctxluafile{lpdf-fnt}{} @@ -65,6 +67,26 @@ %D \type {\pdfextension} and \type {\pdffeedback} primitives but it will probably %D have bad side effects. +%D For the moment we put these here as they are pdf related but they might move to +%D a better place. We overload the primitives with our own but use a bit of indirection +%D for the purpose of tracing. + +\unexpanded\def\saveboxresource {\clf_saveboxresource} +\unexpanded\def\lastsavedboxresourceindex {\numexpr\clf_lastsavedboxresourceindex\relax} +\unexpanded\def\useboxresource {\clf_useboxresource} + +\unexpanded\def\saveimageresource {\clf_saveimageresource} +\unexpanded\def\lastsavedimageresourceindex{\numexpr\clf_lastsavedimageresourceindex\relax} +\unexpanded\def\lastsavedimageresourcepages{\numexpr\clf_lastsavedimageresourcepages\relax} +\unexpanded\def\useimageresource {\clf_useimageresource} + +\unexpanded\def\savepos {\clf_savepos} + \def\lastxpos {\clf_lastxpos} + \def\lastypos {\clf_lastypos} + +\unexpanded\def\pdfextension {\clf_pdfextension} + \def\pdffeedback {\clf_pdffeedback} + %D These are no-ops and don't even intercept what comes next. Maybe some day %D I'll write a parser that maps onto \CONTEXT. @@ -120,11 +142,11 @@ %D We don't support these directives, at least not this way. If they are needed %D by third party modules we can provide some interface. -% \pdfcreationdate +%pdfcreationdate \let\pdfdecimaldigits \relax \newcount\pdfdecimaldigits \let\pdfdestmargin \relax \newdimen\pdfdestmargin -% \pdffontname -% \pdffontobjnum +% pdffontname +% pdffontobjnum \let\pdffontsize \relax \newcount\pdffontsize \let\pdfgamma \relax \newcount\pdfgamma \let\pdfgentounicode \relax \newcount\pdfgentounicode @@ -139,21 +161,21 @@ \let\pdfinclusioncopyfonts \relax \newcount\pdfinclusioncopyfonts \let\pdfinclusionerrorlevel \relax \newcount\pdfinclusionerrorlevel \let\pdfinfoomitdate \relax \newcount\pdfinfoomitdate -% \pdflastannot -% \pdflastlink +% pdflastannot +% pdflastlink \let\pdflinkmargin \relax \newdimen\pdflinkmargin \let\pdfmajorversion \relax \newcount\pdfmajorversion \let\pdfminorversion \relax \newcount\pdfminorversion \let\pdfpagebox \relax \newcount\pdfpagebox -% \pdfpageref +% pdfpageref \let\pdfpkfixeddpi \relax \newcount\pdfpkfixeddpi \let\pdfpkmode \relax \newtoks \pdfpkmode \let\pdfpkresolution \relax \newcount\pdfpkresolution -% \pdfretval +% pdfretval \let\pdfsuppressoptionalinfo \relax \newcount\pdfsuppressoptionalinfo \let\pdfsuppressptexinfo \relax \newcount\pdfsuppressptexinfo -% \pdftexrevision -% \pdftexversion +% pdftexrevision +% pdftexversion \let\pdfthreadmargin \relax \newdimen\pdfthreadmargin \let\pdftrailerid \relax \newtoks \pdftrailerid \let\pdfuniqueresname \relax \newcount\pdfuniqueresname @@ -163,27 +185,33 @@ %D These are still accepted but are normally not needed. +\let\pdfxform \saveboxresource +\let\pdfximage \saveimageresource + \let\pdflastxform \lastsavedboxresourceindex \let\pdflastximage \lastsavedimageresourceindex -\let\pdflastximagepages \lastsavedimageresourcepages -\let\pdflastxpos \lastxpos -\let\pdflastypos \lastypos + \let\pdfrefxform \useboxresource \let\pdfrefximage \useimageresource + +\let\pdflastximagepages \lastsavedimageresourcepages + \let\pdfsavepos \savepos -\let\pdfxform \saveboxresource -\let\pdfximage \saveimageresource +\let\pdflastxpos \lastxpos +\let\pdflastypos \lastypos %D For the moment we keep these as they are but they will become \LUA\ calls %D eventually, after which we will nil the three \type {\pdf} interface primitives. -\normalprotected\def\pdfliteral {\pdfextension literal } -\normalprotected\def\pdfobj {\pdfextension obj } - \def\pdflastobj {\numexpr\pdffeedback lastobj\relax} +\normalprotected\def\pdfliteral {\clf_pdfliteral}% + +\normalprotected\def\pdfobj {\clf_pdfobj}% +\normalprotected\def\pdflastobj {\numexpr\clf_pdflastobj\relax}% + \normalprotected\def\pdfrefobj {\pdfextension refobj } -\normalprotected\def\pdfrestore {\pdfextension restore\relax} -\normalprotected\def\pdfsave {\pdfextension save\relax} -\normalprotected\def\pdfsetmatrix{\pdfextension setmatrix } +\normalprotected\def\pdfrestore {\clf_restore} +\normalprotected\def\pdfsave {\clf_save} +\normalprotected\def\pdfsetmatrix{\clf_setmatrix} %D This one can be consulted by users although the suffix is also a system mode. diff --git a/tex/context/base/mkiv/back-pdp.lua b/tex/context/base/mkiv/back-pdp.lua new file mode 100644 index 000000000..69f497b3f --- /dev/null +++ b/tex/context/base/mkiv/back-pdp.lua @@ -0,0 +1,453 @@ +if not modules then modules = { } end modules ['back-pdp'] = { + version = 1.001, + comment = "companion to lpdf-ini.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +-- This is temporary ... awaiting a better test .. basically we can +-- always use this: pdf primitives. + +local context = context + +local lpdfreserveobject = lpdf.reserveobject +local lpdfcompresslevel = lpdf.compresslevel +local lpdfgethpos = lpdf.gethpos +local lpdfgetvpos = lpdf.getvpos +local lpdfobj = lpdf.obj +local lpdfpagereference = lpdf.pagereference +local lpdfxformname = lpdf.xformname + +local scanword = tokens.scanners.word +local scankeyword = tokens.scanners.keyword +local scanstring = tokens.scanners.string +local scaninteger = tokens.scanners.integer +local scandimension = tokens.scanners.dimension + +local trace = false trackers.register("commands", function(v) trace = v end) +local report = logs.reporter("command") + +local nodepool = nodes.pool +local newsavepos = nodepool.savepos +local newliteral = nodepool.pdfliteral +local newsave = nodepool.pdfsave +local newrestore = nodepool.pdfrestore +local newsetmatrix = nodepool.pdfsetmatrix + +local implement = interfaces.implement +local constants = interfaces.constants +local variables = interfaces.variables + +-- helper + +local function scanwhd() + local width, height, depth + while true do + if scankeyword("width") then + width = scandimension() + elseif scankeyword("height") then + height = scandimension() + elseif scankeyword("depth") then + depth = scandimension() + else + break + end + end + if width or height or depth then + return width or 0, height or 0, depth or 0 + else + -- we inherit + end +end + +-- positions + +local function savepos() + context(newsavepos()) +end + +local function lastxpos() + context(lpdfgethpos()) +end + +local function lastypos() + context(lpdfgetvpos()) +end + +implement { name = "savepos", actions = savepos } +implement { name = "lastxpos", actions = lastxpos } +implement { name = "lastypos", actions = lastypos } + +-- literals + +local function pdfliteral() + context(newliteral(scanword() or "origin",scanstring())) +end + +implement { name = "pdfliteral", actions = pdfliteral } + +-- box resources + +local boxresources = tex.boxresources +local savebox = boxresources.save +local usebox = boxresources.use + +local lastindex = 0 + +local function saveboxresource() + local immediate = true + local kind = scankeyword("type") and scaninteger() or 0 + local attributes = scankeyword("attr") and scanstring() or nil + local resources = scankeyword("resources") and scanstring() or nil + local margin = scankeyword("margin") and scandimension() or 0 -- register + local boxnumber = scaninteger() + -- + lastindex = savebox(boxnumber,attributes,resources,immediate,kind,margin) + if trace then + report("\\saveboxresource: index %i",lastindex) + end +end + +local function lastsavedboxresourceindex() + if trace then + report("\\lastsaveboxresource: index %i",lastindex) + end + context("%i",lastindex) +end + +local function useboxresource() + local width, height, depth = scanwhd() + local index = scaninteger() + local node = usebox(index,width,height,depth) + if trace then + report("\\useboxresource: index %i",index) + end + context(node) +end + +implement { name = "saveboxresource", actions = saveboxresource } +implement { name = "lastsavedboxresourceindex", actions = lastsavedboxresourceindex } +implement { name = "useboxresource", actions = useboxresource } + +-- image resources (messy: will move) + +local newrule = nodes.pool.rule +local image_rule_code = nodes.rulecodes.image + +local imageresources = { } +local lastindex = 0 +local lastpages = 1 + +local function saveimageresource() + local width, height, depth = scanwhd() + local page = 1 + local immediate = true + local margin = 0 -- or dimension + local attributes = scankeyword("attr") and scanstring() or nil + if scankeyword("named") then + scanstring() -- ignored + elseif scankeyword("page") then + page = scaninteger() + end + local userpassword = scankeyword("userpassword") and scanstring() or nil + local ownerpassword = scankeyword("ownerpassword") and scanstring() or nil + local visiblefilename = scankeyword("visiblefilename") and scanstring() or nil + local colorspace = scankeyword("colorspace") and scaninteger() or nil + local pagebox = scanword() or nil + local filename = scanstring() +-- pcall + context.getfiguredimensions( { filename }, { + [constants.userpassword] = userpassword, + [constants.ownerpassword] = ownerpassword, + [constants.page] = page or 1, + [constants.size] = pagebox, + }) + context.relax() + lastindex = lastindex + 1 + lastpages = 1 + imageresources[lastindex] = { + filename = filename, + page = page or 1, + size = pagebox, + width = width, + height = height, + depth = depth, + attr = attributes, + -- margin = margin, + } +end + +local function lastsavedimageresourceindex() + context("%i",lastindex or 0) +end + +local function lastsavedimageresourcepages() + context("%i",lastpages or 0) -- todo +end + +local function useimageresource() + local width, height, depth = scanwhd() + if scankeyword("keepopen") then + -- ignored + end + local index = scaninteger() + local l = imageresources[index] + if l then + if not (width or height or depth) then + width = l.width + height = l.height + depth = l.depth + end +-- pcall + context.externalfigure( { l.filename }, { + [constants.userpassword] = l.userpassword, + [constants.ownerpassword] = l.ownerpassword, + [constants.width] = width and (width .. "sp") or nil, + [constants.height] = height and (height .. "sp") or nil, + [constants.page] = l.page or 1, + [constants.size] = pagebox, + }) + context.relax() + else + print("no image resource",index) + end +end + +implement { name = "saveimageresource", actions = saveimageresource } +implement { name = "lastsavedimageresourceindex", actions = lastsavedimageresourceindex } +implement { name = "lastsavedimageresourcepages", actions = lastsavedimageresourcepages } +implement { name = "useimageresource", actions = useimageresource } + +-- objects + +local lastobjnum = 0 + +local function pdfobj() + if scankeyword("reserveobjnum") then + lastobjnum = lpdfreserveobject() + if trace then + report("\\pdfobj reserveobjnum: object %i",lastobjnum) + end + else + local immediate = true + local objnum = scankeyword("useobjnum") and scaninteger() or lpdfreserveobject() + local uncompress = scankeyword("uncompressed") or lpdfcompresslevel() == 0 + local streamobject = scankeyword("stream") and true or false + local attributes = scankeyword("attr") and scanstring() + local fileobject = scankeyword("file") + local content = scanstring() + local object = { + immediate = immediate, + attr = attributes, + objnum = objnum, + type = streamobject and "stream" or nil, + compresslevel = uncompress and 0 or nil, + } + if fileobject then + object.filename = content + else + object.string = content + end + lpdfobj(object) + lastobjnum = objnum + if trace then + report("\\pdfobj: object %i",lastobjnum) + end + end +end + +local function pdflastobj() + context("%i",lastobjnum) + if trace then + report("\\lastobj: object %i",lastobjnum) + end +end + +local function pdfrefobj() + local objnum = scaninteger() + if trace then + report("\\refobj: object %i (todo)",objnum) + end +end + +implement { name = "pdfobj", actions = pdfobj } +implement { name = "pdflastobj", actions = pdflastobj } +implement { name = "pdfrefobj", actions = pdfrefobj } + +-- annotations + +local lastobjnum = 0 + +local function pdfannot() + if scankeyword("reserveobjnum") then + lastobjnum = lpdfreserveobject() + if trace then + report("\\pdfannot reserveobjnum: object %i",lastobjnum) + end + else + local width = false + local height = false + local depth = false + local data = false + local object = false + local attr = false + -- + if scankeyword("useobjnum") then + object = scancount() + report("\\pdfannot useobjectnum is not (yet) supported") + end + local width, height, depth = scanwhd() + if scankeyword("attr") then + attr = scanstring() + end + data = scanstring() + context(backends.nodeinjections.annotation(width or 0,height or 0,depth or 0,data or "")) + end +end + +implement { name = "pdfannot", actions = pdfannot } + +local function pdfdest() + local name = false + local zoom = false + local view = false + local width = false + local height = false + local depth = false + if scankeyword("num") then + report("\\pdfdest num is not (yet) supported") + elseif scankeyword("name") then + name = scanstring() + end + if scankeyword("xyz") then + view = "xyz" + if scankeyword("zoom") then + report("\\pdfdest zoom is ignored") + zoom = scancount() -- will be divided by 1000 in the backend + end + elseif scankeyword("fitbh") then + view = "fitbh" + elseif scankeyword("fitbv") then + view = "fitbv" + elseif scankeyword("fitb") then + view = "fitb" + elseif scankeyword("fith") then + view = "fith" + elseif scankeyword("fitv") then + view = "fitv" + elseif scankeyword("fitr") then + view = "fitr" + width, height, depth = scanwhd() + elseif scankeyword("fit") then + view = "fit" + end + context(backends.nodeinjections.destination(width or 0,height or 0,depth or 0,{ name or "" },view or "fit")) +end + +implement { name = "pdfdest", actions = pdfdest } + +-- management + + +local function pdfsave() + context(newsave()) +end + +local function pdfrestore() + context(newrestore()) +end + +local function pdfsetmatrix() + context(newsetmatrix(scanstring())) +end + + +-- extras + +local function pdfpageref() + context(lpdfpagereference()) +end + +local function pdfxformname() + context(lpdfxformname()) +end + +-- extensions: literal dest annot save restore setmatrix obj refobj colorstack +-- startlink endlink startthread endthread thread outline glyphtounicode fontattr +-- mapfile mapline includechars catalog info names trailer + +local extensions = { + literal = pdfliteral, + obj = pdfobj, + refobj = pdfrefobj, + dest = pdfdest, + annot = pdfannot, + save = pdfsave, + restore = pdfrestore, + setmatrix = pdfsetmatrix, +} + +local function pdfextension() + local w = scanword() + if w then + local e = extensions[w] + if e then + e() + else + report("\\pdfextension: unknown %a",w) + end + end +end + +implement { name = "pdfextension", actions = pdfextension } + +-- feedbacks: colorstackinit creationdate fontname fontobjnum fontsize lastannot +-- lastlink lastobj pageref retval revision version xformname + +local feedbacks = { + lastobj = pdflastobj, + pageref = pdfpageref, + xformname = pdfxformname, +} + +local function pdffeedback() + local w = scanword() + if w then + local f = feedbacks[w] + if f then + f() + else + report("\\pdffeedback: unknown %a",w) + end + end +end + +implement { name = "pdffeedback", actions = pdffeedback } + +-- variables: (integers:) compresslevel decimaldigits gamma gentounicode +-- ignoreunknownimages imageaddfilename imageapplygamma imagegamma imagehicolor +-- imageresolution inclusioncopyfonts inclusionerrorlevel majorversion minorversion +-- objcompresslevel omitcharset omitcidset pagebox pkfixeddpi pkresolution +-- recompress suppressoptionalinfo uniqueresname (dimensions:) destmargin horigin +-- linkmargin threadmargin vorigin xformmargin (tokenlists:) pageattr pageresources +-- pagesattr pkmode trailerid xformattr xformresources + +-- local variables = { +-- } +-- +-- local function pdfvariable() +-- local w = scanword() +-- if w then +-- local f = variables[w] +-- if f then +-- f() +-- else +-- print("invalid variable",w) +-- end +-- else +-- print("missing variable") +-- end +-- end + +--------- { name = "pdfvariable", actions = pdfvariable } diff --git a/tex/context/base/mkiv/back-res.lua b/tex/context/base/mkiv/back-res.lua new file mode 100644 index 000000000..be92c74a6 --- /dev/null +++ b/tex/context/base/mkiv/back-res.lua @@ -0,0 +1,44 @@ +if not modules then modules = { } end modules ['back-res'] = { + version = 1.001, + comment = "companion to lpdf-ini.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +-- A box resource has an index. This happens to be an object number +-- due to the pdf backend but in fact it's an abstraction. This is why +-- we have explicit fetchers. The internal number (as in \Fm123) is yet +-- another number. + +local tex_saveboxresource = tex.saveboxresource +local tex_useboxresource = tex.useboxresource +local tex_getboxresourcebox = tex.getboxresourcebox +local tex_getboxresourcedimensions = tex.getboxresourcedimensions + +updaters.register("backend.update",function() + tex_saveboxresource = tex.saveboxresource + tex_useboxresource = tex.useboxresource + tex_getboxresourcebox = tex.getboxresourcebox + tex_getboxresourcedimensions = tex.getboxresourcedimensions +end) + +tex.boxresources = { + save = function(...) return tex_saveboxresource(...) end, + use = function(...) return tex_useboxresource(...) end, + getbox = function(...) return tex_getboxresourcebox(...) end, + getdimensions = function(...) return tex_getboxresourcedimensions(...) end, +} + +-- local tex_saveimageresource = tex.saveimageresource +-- local tex_useimageresource = tex.useimageresource +-- +-- updaters.register("backend.update",function() +-- tex_saveimageresource = tex.saveimageresource +-- tex_useimageresource = tex.useimageresource +-- end) +-- +-- tex.imageresources = { +-- save = function(...) return tex_saveimageresource(...) end, +-- use = function(...) return tex_useimageresource(...) end, +-- } diff --git a/tex/context/base/mkiv/cldf-bas.lua b/tex/context/base/mkiv/cldf-bas.lua index 27bb4f343..de436e445 100644 --- a/tex/context/base/mkiv/cldf-bas.lua +++ b/tex/context/base/mkiv/cldf-bas.lua @@ -49,6 +49,11 @@ local texsetcount = tex.setcount -- a set of basic fast ones +function context.setfontid(n) + -- isn't there a setter? + context("\\setfontid%i\\relax",n) +end + function context.char(k) -- used as escape too, so don't change to utf if type(k) == "table" then local n = #k diff --git a/tex/context/base/mkiv/cont-log.mkiv b/tex/context/base/mkiv/cont-log.mkiv index 8b4660f3a..87cbf9dc6 100644 --- a/tex/context/base/mkiv/cont-log.mkiv +++ b/tex/context/base/mkiv/cont-log.mkiv @@ -133,7 +133,7 @@ \let\logofont\nullfont -\loadmapfile[original-base.map] % stil needed? not if we assume afm +% \loadmapfile[original-base.map] % stil needed? not if we assume afm \unexpanded\def\setMFPfont% more sensitive for low level changes {\font\logofont=logo% @@ -317,6 +317,8 @@ \unexpanded\def\MPIV{MpIV} \unexpanded\def\MPVI{MpVI} +\unexpanded\def\LMTX{lmtx} + \appendtoks \def\ConTeXt {ConTeXt}% \def\MetaPost {MetaPost}% diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index 02b2e4f41..f9bf51f32 100644 --- a/tex/context/base/mkiv/cont-new.mkiv +++ b/tex/context/base/mkiv/cont-new.mkiv @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2018.10.18 00:07} +\newcontextversion{2018.11.18 14:07} %D This file is loaded at runtime, thereby providing an excellent place for %D hacks, patches, extensions and new features. @@ -30,7 +30,13 @@ \let\w\mathword \to \everymathematics -\let\assumelongusagecs\relax +% \let\assumelongusagecs\relax % todo: fails on legends-001.tex + +% experimental + +\ifdefined\enablelmtx\else + \let\enablelmtx\relax +\fi % done diff --git a/tex/context/base/mkiv/cont-run.lua b/tex/context/base/mkiv/cont-run.lua index 9bd252e60..6d789fe1d 100644 --- a/tex/context/base/mkiv/cont-run.lua +++ b/tex/context/base/mkiv/cont-run.lua @@ -142,6 +142,7 @@ trackers.register("sandbox.tracecalls",sandbox.logcalls) trackers.register("sandbox.tracefiles",sandbox.logfiles) local sandboxing = environment.arguments.sandbox +local debugging = environment.arguments.debug if sandboxing then @@ -170,6 +171,22 @@ if sandboxing then \let\normalprimitive\relax ]] + debug = { + traceback = traceback, + } + +elseif debugging then + + -- we keep debug + +else + + debug = { + traceback = traceback, + getinfo = getinfo, + sethook = sethook, + } + end local function processjob() @@ -180,6 +197,11 @@ local function processjob() local suffix = environment.suffix local filename = environment.filename -- hm, not inputfilename ! + if arguments.lmtx then + context.enablelmtx() + environment.lmtxmode = true + end + if arguments.nosynctex then luatex.synctex.setup { state = interfaces.variables.never, diff --git a/tex/context/base/mkiv/cont-run.mkiv b/tex/context/base/mkiv/cont-run.mkiv index f841ce530..3d6103148 100644 --- a/tex/context/base/mkiv/cont-run.mkiv +++ b/tex/context/base/mkiv/cont-run.mkiv @@ -22,6 +22,10 @@ \unprotect +\ifdefined\enablelmtx\else + \let\enablelmtx\relax +\fi + \let\synctexsetfilename \clf_synctexsetfilename \let\synctexresetfilename\clf_synctexresetfilename \let\synctexblockfilename\clf_synctexblockfilename diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv index e8a83d039..62aeae740 100644 --- a/tex/context/base/mkiv/context.mkiv +++ b/tex/context/base/mkiv/context.mkiv @@ -42,7 +42,7 @@ %D has to match \type {YYYY.MM.DD HH:MM} format. \edef\contextformat {\jobname} -\edef\contextversion{2018.10.18 00:07} +\edef\contextversion{2018.11.18 14:07} \edef\contextkind {beta} %D For those who want to use this: @@ -570,8 +570,6 @@ \loadmarkfile{back-pdf} % actually, this one should load the next three using document.arguments.backend -\doifelsefileexists{back-shp.mkiv}{\loadmarkfile{back-shp}}{} - \loadmarkfile{mlib-pdf} \loadmarkfile{mlib-pps} \loadmarkfile{meta-pdf} @@ -585,6 +583,8 @@ \loadmarkfile{cont-run} % the main runner (used in cont-yes.mkiv) +\doifelsefileexists{back-shp.mkiv}{\loadmarkfile{back-shp}}{} + \setupcurrentlanguage[\defaultlanguagetag] \prependtoks diff --git a/tex/context/base/mkiv/core-env.mkiv b/tex/context/base/mkiv/core-env.mkiv index fac34a1aa..f30f2b5bd 100644 --- a/tex/context/base/mkiv/core-env.mkiv +++ b/tex/context/base/mkiv/core-env.mkiv @@ -68,6 +68,14 @@ {\ifcsname\??mode#1\endcsname\else\syst_modes_new{#1}\fi \lastnamedcs\disabledmode} +\unexpanded\def\globalsetmode#1% + {\ifcsname\??mode#1\endcsname\else\syst_modes_new{#1}\fi + \global\lastnamedcs\enabledmode} + +\unexpanded\def\globalresetmode#1% + {\ifcsname\??mode#1\endcsname\else\syst_modes_new{#1}\fi + \global\lastnamedcs\disabledmode} + \unexpanded\def\newsystemmode#1% {\ifcsname\??mode\systemmodeprefix#1\endcsname\else\syst_modes_new{\systemmodeprefix#1}\fi} @@ -79,6 +87,14 @@ {\ifcsname\??mode\systemmodeprefix#1\endcsname\else\syst_modes_new{\systemmodeprefix#1}\fi \lastnamedcs\disabledmode} +\unexpanded\def\globalsetsystemmode#1% + {\ifcsname\??mode\systemmodeprefix#1\endcsname\else\syst_modes_new{\systemmodeprefix#1}\fi + \global\lastnamedcs\enabledmode} + +\unexpanded\def\globalresetsystemmode#1% + {\ifcsname\??mode\systemmodeprefix#1\endcsname\else\syst_modes_new{\systemmodeprefix#1}\fi + \global\lastnamedcs\disabledmode} + % \def\dosetsystemmode#1% % {\csname\??mode\systemmodeprefix#1\endcsname\enabledmode} % diff --git a/tex/context/base/mkiv/font-aux.lua b/tex/context/base/mkiv/font-aux.lua index fcbcd6d32..4ac6278cb 100644 --- a/tex/context/base/mkiv/font-aux.lua +++ b/tex/context/base/mkiv/font-aux.lua @@ -185,6 +185,7 @@ end local getters = { -- maybe better getters[format][...] kern = { ["type1"] = afm.getkern, + ["type3"] = afm.getkern, ["opentype"] = otf.getkern, }, substitution = { diff --git a/tex/context/base/mkiv/font-cff.lua b/tex/context/base/mkiv/font-cff.lua index 2c7d61521..75486624b 100644 --- a/tex/context/base/mkiv/font-cff.lua +++ b/tex/context/base/mkiv/font-cff.lua @@ -26,7 +26,7 @@ if not modules then modules = { } end modules ['font-cff'] = { -- with merging subroutines and flattening, not so much with calculations.) On -- the other hand, we can now feed back cff2 stuff. -local next, type, tonumber = next, type, tonumber +local next, type, tonumber, rawget = next, type, tonumber, rawget local byte, char, gmatch = string.byte, string.char, string.gmatch local concat, remove, unpack = table.concat, table.remove, table.unpack local floor, abs, round, ceil, min, max = math.floor, math.abs, math.round, math.ceil, math.min, math.max @@ -34,6 +34,8 @@ local P, C, R, S, C, Cs, Ct = lpeg.P, lpeg.C, lpeg.R, lpeg.S, lpeg.C, lpeg.Cs, l local lpegmatch = lpeg.match local formatters = string.formatters local bytetable = string.bytetable +local idiv = number.idiv +local rshift, band, extract = bit32.rshift, bit32.band, bit32.extract local readers = fonts.handlers.otf.readers local streamreader = readers.streamreader @@ -287,12 +289,30 @@ do result.fontbbox = { unpack(stack,1,4) } top = 0 end - -- + P("\06") / function() end -- bluevalues - -- + P("\07") / function() end -- otherblues - -- + P("\08") / function() end -- familyblues - -- + P("\09") / function() end -- familyotherblues - -- + P("\10") / function() end -- strhw - -- + P("\11") / function() end -- stdvw + + P("\06") / function() + result.bluevalues = { unpack(stack,1,top) } + top = 0 + end + + P("\07") / function() + result.otherblues = { unpack(stack,1,top) } + top = 0 + end + + P("\08") / function() + result.familyblues = { unpack(stack,1,top) } + top = 0 + end + + P("\09") / function() + result.familyotherblues = { unpack(stack,1,top) } + top = 0 + end + + P("\10") / function() + result.strhw = stack[top] + top = 0 + end + + P("\11") / function() + result.strvw = stack[top] + top = 0 + end + P("\13") / function() result.uniqueid = stack[top] top = 0 @@ -386,6 +406,26 @@ do result.strokewidth = stack[top] top = 0 end + + P("\09") / function() + result.bluescale = stack[top] + top = 0 + end + + P("\10") / function() + result.bluesnap = stack[top] + top = 0 + end + + P("\11") / function() + result.bluefuzz = stack[top] + top = 0 + end + + P("\12") / function() + result.stemsnaph = { unpack(stack,1,top) } + top = 0 + end + + P("\13") / function() + result.stemsnapv = { unpack(stack,1,top) } + top = 0 + end + P("\20") / function() result.syntheticbase = stack[top] top = 0 @@ -446,52 +486,27 @@ do -- the second variant is much faster. Not that it matters much as we don't see -- such numbers often. - local p_last = P("\x0F") / "0" + P("\x1F") / "1" + P("\x2F") / "2" + P("\x3F") / "3" - + P("\x4F") / "4" + P("\x5F") / "5" + P("\x6F") / "6" + P("\x7F") / "7" - + P("\x8F") / "8" + P("\x9F") / "9" + P("\xAF") / "" + P("\xBF") / "" - + P("\xCF") / "" + P("\xDF") / "" + P("\xEF") / "" + R("\xF0\xFF") / "" - - -- local remap = { [0] = - -- "00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "0.", "0E", "0E-", "0", "0-", "0", - -- "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "0.", "0E", "0E-", "0", "0-", "0", - -- "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "0.", "0E", "0E-", "0", "0-", "0", - -- "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "0.", "0E", "0E-", "0", "0-", "0", - -- "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "0.", "0E", "0E-", "0", "0-", "0", - -- "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "0.", "0E", "0E-", "0", "0-", "0", - -- "60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "0.", "0E", "0E-", "0", "0-", "0", - -- "70", "71", "72", "73", "74", "75", "76", "77", "78", "79", "0.", "0E", "0E-", "0", "0-", "0", - -- "80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "0.", "0E", "0E-", "0", "0-", "0", - -- "90", "91", "92", "93", "94", "95", "96", "97", "98", "99", "0.", "0E", "0E-", "0", "0-", "0", - -- ".0", ".1", ".2", ".3", ".4", ".5", ".6", ".7", ".8", ".9", "..", ".E", ".E-", ".", ".-", ".", - -- "E0", "E1", "E2", "E3", "E4", "E5", "E6", "E7", "E8", "E9", "E.", "EE", "EE-", "E", "E-", "E", - -- "E-0", "E-1", "E-2", "E-3", "E-4", "E-5", "E-6", "E-7", "E-8", "E-9", "E-.", "E-E", "E-E-", "E-", "E--", "E-", - -- "-0", "-1", "-2", "-3", "-4", "-5", "-6", "-7", "-8", "-9", "-.", "-E", "-E-", "-", "--", "-", - -- } - - -- local p_nibbles = Cs(((1-p_last)/byte/remap)^0+p_last) - - -- local p = P("\30") * p_nibbles / function(t) - -- print(tonumber(t)) - -- end - local remap = { ["\x00"] = "00", ["\x01"] = "01", ["\x02"] = "02", ["\x03"] = "03", ["\x04"] = "04", ["\x05"] = "05", ["\x06"] = "06", ["\x07"] = "07", ["\x08"] = "08", ["\x09"] = "09", ["\x0A"] = "0.", ["\x0B"] = "0E", ["\x0C"] = "0E-", ["\x0D"] = "0", ["\x0E"] = "0-", ["\x0F"] = "0", - ["\x10"] = "10", ["\x11"] = "11", ["\x12"] = "12", ["\x13"] = "13", ["\x14"] = "14", ["\x15"] = "15", ["\x16"] = "16", ["\x17"] = "17", ["\x18"] = "18", ["\x19"] = "19", ["\x1A"] = "0.", ["\x1B"] = "0E", ["\x1C"] = "0E-", ["\x1D"] = "0", ["\x1E"] = "0-", ["\x1F"] = "0", - ["\x20"] = "20", ["\x21"] = "21", ["\x22"] = "22", ["\x23"] = "23", ["\x24"] = "24", ["\x25"] = "25", ["\x26"] = "26", ["\x27"] = "27", ["\x28"] = "28", ["\x29"] = "29", ["\x2A"] = "0.", ["\x2B"] = "0E", ["\x2C"] = "0E-", ["\x2D"] = "0", ["\x2E"] = "0-", ["\x2F"] = "0", - ["\x30"] = "30", ["\x31"] = "31", ["\x32"] = "32", ["\x33"] = "33", ["\x34"] = "34", ["\x35"] = "35", ["\x36"] = "36", ["\x37"] = "37", ["\x38"] = "38", ["\x39"] = "39", ["\x3A"] = "0.", ["\x3B"] = "0E", ["\x3C"] = "0E-", ["\x3D"] = "0", ["\x3E"] = "0-", ["\x3F"] = "0", - ["\x40"] = "40", ["\x41"] = "41", ["\x42"] = "42", ["\x43"] = "43", ["\x44"] = "44", ["\x45"] = "45", ["\x46"] = "46", ["\x47"] = "47", ["\x48"] = "48", ["\x49"] = "49", ["\x4A"] = "0.", ["\x4B"] = "0E", ["\x4C"] = "0E-", ["\x4D"] = "0", ["\x4E"] = "0-", ["\x4F"] = "0", - ["\x50"] = "50", ["\x51"] = "51", ["\x52"] = "52", ["\x53"] = "53", ["\x54"] = "54", ["\x55"] = "55", ["\x56"] = "56", ["\x57"] = "57", ["\x58"] = "58", ["\x59"] = "59", ["\x5A"] = "0.", ["\x5B"] = "0E", ["\x5C"] = "0E-", ["\x5D"] = "0", ["\x5E"] = "0-", ["\x5F"] = "0", - ["\x60"] = "60", ["\x61"] = "61", ["\x62"] = "62", ["\x63"] = "63", ["\x64"] = "64", ["\x65"] = "65", ["\x66"] = "66", ["\x67"] = "67", ["\x68"] = "68", ["\x69"] = "69", ["\x6A"] = "0.", ["\x6B"] = "0E", ["\x6C"] = "0E-", ["\x6D"] = "0", ["\x6E"] = "0-", ["\x6F"] = "0", - ["\x70"] = "70", ["\x71"] = "71", ["\x72"] = "72", ["\x73"] = "73", ["\x74"] = "74", ["\x75"] = "75", ["\x76"] = "76", ["\x77"] = "77", ["\x78"] = "78", ["\x79"] = "79", ["\x7A"] = "0.", ["\x7B"] = "0E", ["\x7C"] = "0E-", ["\x7D"] = "0", ["\x7E"] = "0-", ["\x7F"] = "0", - ["\x80"] = "80", ["\x81"] = "81", ["\x82"] = "82", ["\x83"] = "83", ["\x84"] = "84", ["\x85"] = "85", ["\x86"] = "86", ["\x87"] = "87", ["\x88"] = "88", ["\x89"] = "89", ["\x8A"] = "0.", ["\x8B"] = "0E", ["\x8C"] = "0E-", ["\x8D"] = "0", ["\x8E"] = "0-", ["\x8F"] = "0", - ["\x90"] = "90", ["\x91"] = "91", ["\x92"] = "92", ["\x93"] = "93", ["\x94"] = "94", ["\x95"] = "95", ["\x96"] = "96", ["\x97"] = "97", ["\x98"] = "98", ["\x99"] = "99", ["\x9A"] = "0.", ["\x9B"] = "0E", ["\x9C"] = "0E-", ["\x9D"] = "0", ["\x9E"] = "0-", ["\x9F"] = "0", + ["\x10"] = "10", ["\x11"] = "11", ["\x12"] = "12", ["\x13"] = "13", ["\x14"] = "14", ["\x15"] = "15", ["\x16"] = "16", ["\x17"] = "17", ["\x18"] = "18", ["\x19"] = "19", ["\x1A"] = "1.", ["\x1B"] = "1E", ["\x1C"] = "1E-", ["\x1D"] = "1", ["\x1E"] = "1-", ["\x1F"] = "1", + ["\x20"] = "20", ["\x21"] = "21", ["\x22"] = "22", ["\x23"] = "23", ["\x24"] = "24", ["\x25"] = "25", ["\x26"] = "26", ["\x27"] = "27", ["\x28"] = "28", ["\x29"] = "29", ["\x2A"] = "2.", ["\x2B"] = "2E", ["\x2C"] = "2E-", ["\x2D"] = "2", ["\x2E"] = "2-", ["\x2F"] = "2", + ["\x30"] = "30", ["\x31"] = "31", ["\x32"] = "32", ["\x33"] = "33", ["\x34"] = "34", ["\x35"] = "35", ["\x36"] = "36", ["\x37"] = "37", ["\x38"] = "38", ["\x39"] = "39", ["\x3A"] = "3.", ["\x3B"] = "3E", ["\x3C"] = "3E-", ["\x3D"] = "3", ["\x3E"] = "3-", ["\x3F"] = "3", + ["\x40"] = "40", ["\x41"] = "41", ["\x42"] = "42", ["\x43"] = "43", ["\x44"] = "44", ["\x45"] = "45", ["\x46"] = "46", ["\x47"] = "47", ["\x48"] = "48", ["\x49"] = "49", ["\x4A"] = "4.", ["\x4B"] = "4E", ["\x4C"] = "4E-", ["\x4D"] = "4", ["\x4E"] = "4-", ["\x4F"] = "4", + ["\x50"] = "50", ["\x51"] = "51", ["\x52"] = "52", ["\x53"] = "53", ["\x54"] = "54", ["\x55"] = "55", ["\x56"] = "56", ["\x57"] = "57", ["\x58"] = "58", ["\x59"] = "59", ["\x5A"] = "5.", ["\x5B"] = "5E", ["\x5C"] = "5E-", ["\x5D"] = "5", ["\x5E"] = "5-", ["\x5F"] = "5", + ["\x60"] = "60", ["\x61"] = "61", ["\x62"] = "62", ["\x63"] = "63", ["\x64"] = "64", ["\x65"] = "65", ["\x66"] = "66", ["\x67"] = "67", ["\x68"] = "68", ["\x69"] = "69", ["\x6A"] = "6.", ["\x6B"] = "6E", ["\x6C"] = "6E-", ["\x6D"] = "6", ["\x6E"] = "6-", ["\x6F"] = "6", + ["\x70"] = "70", ["\x71"] = "71", ["\x72"] = "72", ["\x73"] = "73", ["\x74"] = "74", ["\x75"] = "75", ["\x76"] = "76", ["\x77"] = "77", ["\x78"] = "78", ["\x79"] = "79", ["\x7A"] = "7.", ["\x7B"] = "7E", ["\x7C"] = "7E-", ["\x7D"] = "7", ["\x7E"] = "7-", ["\x7F"] = "7", + ["\x80"] = "80", ["\x81"] = "81", ["\x82"] = "82", ["\x83"] = "83", ["\x84"] = "84", ["\x85"] = "85", ["\x86"] = "86", ["\x87"] = "87", ["\x88"] = "88", ["\x89"] = "89", ["\x8A"] = "8.", ["\x8B"] = "8E", ["\x8C"] = "8E-", ["\x8D"] = "8", ["\x8E"] = "8-", ["\x8F"] = "8", + ["\x90"] = "90", ["\x91"] = "91", ["\x92"] = "92", ["\x93"] = "93", ["\x94"] = "94", ["\x95"] = "95", ["\x96"] = "96", ["\x97"] = "97", ["\x98"] = "98", ["\x99"] = "99", ["\x9A"] = "9.", ["\x9B"] = "9E", ["\x9C"] = "9E-", ["\x9D"] = "9", ["\x9E"] = "9-", ["\x9F"] = "9", ["\xA0"] = ".0", ["\xA1"] = ".1", ["\xA2"] = ".2", ["\xA3"] = ".3", ["\xA4"] = ".4", ["\xA5"] = ".5", ["\xA6"] = ".6", ["\xA7"] = ".7", ["\xA8"] = ".8", ["\xA9"] = ".9", ["\xAA"] = "..", ["\xAB"] = ".E", ["\xAC"] = ".E-", ["\xAD"] = ".", ["\xAE"] = ".-", ["\xAF"] = ".", ["\xB0"] = "E0", ["\xB1"] = "E1", ["\xB2"] = "E2", ["\xB3"] = "E3", ["\xB4"] = "E4", ["\xB5"] = "E5", ["\xB6"] = "E6", ["\xB7"] = "E7", ["\xB8"] = "E8", ["\xB9"] = "E9", ["\xBA"] = "E.", ["\xBB"] = "EE", ["\xBC"] = "EE-", ["\xBD"] = "E", ["\xBE"] = "E-", ["\xBF"] = "E", ["\xC0"] = "E-0", ["\xC1"] = "E-1", ["\xC2"] = "E-2", ["\xC3"] = "E-3", ["\xC4"] = "E-4", ["\xC5"] = "E-5", ["\xC6"] = "E-6", ["\xC7"] = "E-7", ["\xC8"] = "E-8", ["\xC9"] = "E-9", ["\xCA"] = "E-.", ["\xCB"] = "E-E", ["\xCC"] = "E-E-", ["\xCD"] = "E-", ["\xCE"] = "E--", ["\xCF"] = "E-", ["\xD0"] = "-0", ["\xD1"] = "-1", ["\xD2"] = "-2", ["\xD3"] = "-3", ["\xD4"] = "-4", ["\xD5"] = "-5", ["\xD6"] = "-6", ["\xD7"] = "-7", ["\xD8"] = "-8", ["\xD9"] = "-9", ["\xDA"] = "-.", ["\xDB"] = "-E", ["\xDC"] = "-E-", ["\xDD"] = "-", ["\xDE"] = "--", ["\xDF"] = "-", } - local p_nibbles = P("\30") * Cs(((1-p_last)/remap)^0+p_last) / function(n) + local p_last = S("\x0F\x1F\x2F\x3F\x4F\x5F\x6F\x7F\x8F\x9F\xAF\xBF") + + R("\xF0\xFF") + + local p_nibbles = P("\30") * Cs(((1-p_last)/remap)^0 * (P(1)/remap)) / function(n) -- 0-9=digit a=. b=E c=E- d=reserved e=- f=finish top = top + 1 stack[top] = tonumber(n) or 0 @@ -1230,7 +1245,7 @@ do if trace_charstrings then showstate("stem") end - stems = stems + top/2 + stems = stems + idiv(top,2) top = 0 end @@ -1251,14 +1266,15 @@ do if trace_charstrings then showstate(operator == 19 and "hintmark" or "cntrmask") end - stems = stems + top/2 + stems = stems + idiv(top,2) top = 0 if stems == 0 then -- forget about it elseif stems <= 8 then return 1 else - return floor((stems+7)/8) + -- return floor((stems+7)/8) + return idiv(stems+7,8) end end @@ -1305,8 +1321,9 @@ do local function hsbw() if version == 1 then if trace_charstrings then - showstate("dotsection") + showstate("hsbw") end + -- lsb = stack[top-1] width = stack[top] end top = 0 @@ -1528,89 +1545,115 @@ do [037] = flex1, } - local c_endchar = char(14) + local chars = setmetatableindex(function (t,k) + local v = char(k) + t[k] = v + return v + end) - local passon do + local c_endchar = chars[14] - -- todo: round in blend - -- todo: delay this hash + -- todo: round in blend - local rshift = bit32.rshift - local band = bit32.band - local round = math.round + local encode = { } - local encode = table.setmetatableindex(function(t,i) - for i=-2048,-1130 do - t[i] = char(28,band(rshift(i,8),0xFF),band(i,0xFF)) - end - for i=-1131,-108 do - local v = 0xFB00 - i - 108 - t[i] = char(band(rshift(v,8),0xFF),band(v,0xFF)) - end - for i=-107,107 do - t[i] = char(i + 139) - end - for i=108,1131 do - local v = 0xF700 + i - 108 - t[i] = char(band(rshift(v,8),0xFF),band(v,0xFF)) - end - for i=1132,2048 do - t[i] = char(28,band(rshift(i,8),0xFF),band(i,0xFF)) + -- this eventually can become a helper + + setmetatableindex(encode,function(t,i) + for i=-2048,-1130 do + t[i] = char(28,band(rshift(i,8),0xFF),band(i,0xFF)) + end + for i=-1131,-108 do + local v = 0xFB00 - i - 108 + t[i] = char(band(rshift(v,8),0xFF),band(v,0xFF)) + end + for i=-107,107 do + t[i] = chars[i + 139] + end + for i=108,1131 do + local v = 0xF700 + i - 108 +-- t[i] = char(band(rshift(v,8),0xFF),band(v,0xFF)) + t[i] = char(extract(v,8,8),extract(v,0,8)) + end + for i=1132,2048 do + t[i] = char(28,band(rshift(i,8),0xFF),band(i,0xFF)) + end + setmetatableindex(encode,function(t,k) + -- 16.16-bit signed fixed value + local r = round(k) + local v = rawget(t,r) + if v then + return v end - return t[i] + local v1 = floor(k) + local v2 = floor((k - v1) * 0x10000) + return char(255,extract(v1,8,8),extract(v1,0,8),extract(v2,8,8),extract(v2,0,8)) end) + return t[i] + end) - local function setvsindex() - local vsindex = stack[top] - updateregions(vsindex) - top = top - 1 - end + readers.cffencoder = encode - local function blend() - -- leaves n values on stack - local n = stack[top] - top = top - 1 - if not axis then - -- fatal error - elseif n == 1 then - top = top - nofregions - local v = stack[top] + local function p_setvsindex() + local vsindex = stack[top] + updateregions(vsindex) + top = top - 1 + end + + local function p_blend() + -- leaves n values on stack + local n = stack[top] + top = top - 1 + if not axis then + -- fatal error + elseif n == 1 then + top = top - nofregions + local v = stack[top] + for r=1,nofregions do + v = v + stack[top+r] * factors[r] + end + stack[top] = round(v) + else + top = top - nofregions * n + local d = top + local k = top - n + for i=1,n do + k = k + 1 + local v = stack[k] for r=1,nofregions do - v = v + stack[top+r] * factors[r] - end - stack[top] = round(v) - else - top = top - nofregions * n - local d = top - local k = top - n - for i=1,n do - k = k + 1 - local v = stack[k] - for r=1,nofregions do - v = v + stack[d+r] * factors[r] - end - stack[k] = round(v) - d = d + nofregions + v = v + stack[d+r] * factors[r] end + stack[k] = round(v) + d = d + nofregions end end + end - passon = function(operation) - if operation == 15 then - setvsindex() - elseif operation == 16 then - blend() - else - for i=1,top do - r = r + 1 - result[r] = encode[stack[i]] - end - r = r + 1 - result[r] = char(operation) -- maybe use a hash - top = 0 - end + local function p_getstem() + local n = 0 + if top % 2 ~= 0 then + n = 1 + end + if top > n then + stems = stems + idiv(top-n,2) end + end + local function p_getmask() + local n = 0 + if top % 2 ~= 0 then + n = 1 + end + if top > n then + stems = stems + idiv(top-n,2) + end + if stems == 0 then + return 0 + elseif stems <= 8 then + return 1 + else + return idiv(stems+7,8) + end end -- end of experiment @@ -1643,6 +1686,42 @@ do local justpass = false + -- local function decode(str) + -- local a, b, c, d, e = byte(str,1,5) + -- if a == 28 then + -- if c then + -- local n = 0x100 * b + c + -- if n >= 0x8000 then + -- return n - 0x10000 + -- else + -- return n + -- end + -- end + -- elseif a < 32 then + -- return false + -- elseif a <= 246 then + -- return a - 139 + -- elseif a <= 250 then + -- if b then + -- return a*256 - 63124 + b + -- end + -- elseif a <= 254 then + -- if b then + -- return -a*256 + 64148 - b + -- end + -- else + -- if e then + -- local n = 0x100 * b + c + -- if n >= 0x8000 then + -- return n - 0x10000 + (0x100 * d + e)/0xFFFF + -- else + -- return n + (0x100 * d + e)/0xFFFF + -- end + -- end + -- end + -- return false + -- end + process = function(tab) local i = 1 local n = #tab @@ -1667,9 +1746,9 @@ do stack[top] = -t*256 + 64148 - tab[i+1] i = i + 2 else + -- a 16.16 float local n = 0x100 * tab[i+1] + tab[i+2] - if n >= 0x8000 then - -- stack[top] = n - 0xFFFF - 1 + (0x100 * tab[i+3] + tab[i+4])/0xFFFF + if n >= 0x8000 then stack[top] = n - 0x10000 + (0x100 * tab[i+3] + tab[i+4])/0xFFFF else stack[top] = n + (0x100 * tab[i+3] + tab[i+4])/0xFFFF @@ -1716,19 +1795,94 @@ do elseif t == 12 then i = i + 1 local t = tab[i] - local a = subactions[t] - if a then - a(t) + if justpass then + if t >= 34 or t <= 37 then -- flexes + for i=1,top do + r = r + 1 ; result[r] = encode[stack[i]] + end + r = r + 1 ; result[r] = chars[12] + r = r + 1 ; result[r] = chars[t] + top = 0 + else + local a = subactions[t] + if a then + a(t) + else + top = 0 + end + end else - if trace_charstrings then - showvalue("<subaction>",t) + local a = subactions[t] + if a then + a(t) + else + if trace_charstrings then + showvalue("<subaction>",t) + end + top = 0 end - top = 0 end i = i + 1 elseif justpass then - passon(t) - i = i + 1 + -- todo: local a = passactions + if t == 15 then + p_setvsindex() + i = i + 1 + elseif t == 16 then + local s = p_blend() or 0 + i = i + s + 1 + -- cff 1: (when cff2 strip them) + elseif t == 1 or t == 3 or t == 18 or operation == 23 then + p_getstem() -- at the start +if true then + if top > 0 then + for i=1,top do + r = r + 1 ; result[r] = encode[stack[i]] + end + top = 0 + end + r = r + 1 ; result[r] = chars[t] +else + top = 0 +end + i = i + 1 + -- cff 1: (when cff2 strip them) + elseif t == 19 or t == 20 then + local s = p_getmask() or 0 -- after the stems +if true then + if top > 0 then + for i=1,top do + r = r + 1 ; result[r] = encode[stack[i]] + end + top = 0 + end + r = r + 1 ; result[r] = chars[t] + for j=1,s do + i = i + 1 + r = r + 1 ; result[r] = chars[tab[i]] + end +else + i = i + s + top = 0 +end + i = i + 1 + -- cff 1: closepath + elseif t == 9 then + top = 0 + i = i + 1 + elseif t == 13 then + local s = hsbw() or 0 + i = i + s + 1 + else + if top > 0 then + for i=1,top do + r = r + 1 ; result[r] = encode[stack[i]] + end + top = 0 + end + r = r + 1 ; result[r] = chars[t] + i = i + 1 + end else local a = actions[t] if a then @@ -1788,20 +1942,32 @@ do -- end local function setbias(globals,locals) - if version == 1 then - return - false, - false - else +-- if version == 1 then -- charstring version, not cff +-- return +-- 0, +-- 0 +-- return +-- 1, +-- 1 +-- else local g, l = #globals, #locals return - ((g < 1240 and 107) or (g < 33900 and 1131) or 32768) + 1, - ((l < 1240 and 107) or (l < 33900 and 1131) or 32768) + 1 - end + ((g < 1240 and 107) or (g < 33900 and 1131) or 32768) + 1, + ((l < 1240 and 107) or (l < 33900 and 1131) or 32768) + 1 +-- end end local function processshape(tab,index) + if not tab then + glyphs[index] = { + boundingbox = { 0, 0, 0, 0 }, + width = 0, + name = charset and charset[index] or nil, + } + return + end + tab = bytetable(tab) x = 0 @@ -1817,7 +1983,6 @@ do ymin = 0 ymax = 0 checked = false - if trace_charstrings then report("glyph: %i",index) report("data : % t",tab) @@ -1937,19 +2102,20 @@ do globalbias, localbias = setbias(globals,locals) nominalwidth, defaultwidth = setwidths(dictionary.private) - startparsing(fontdata,data,streams) - - for index=1,#charstrings do - processshape(charstrings[index],index-1) - charstrings[index] = nil -- free memory (what if used more often?) + if charstrings then + startparsing(fontdata,data,streams) + for index=1,#charstrings do + processshape(charstrings[index],index-1) +-- charstrings[index] = nil -- free memory (what if used more often?) + end + stopparsing(fontdata,data) + else + report("no charstrings") end - - stopparsing(fontdata,data) - return glyphs end - parsecharstring = function(fontdata,data,dictionary,tab,glphs,index,doshapes,tversion) + parsecharstring = function(fontdata,data,dictionary,tab,glphs,index,doshapes,tversion,streams) keepcurve = doshapes version = tversion @@ -1960,6 +2126,8 @@ do vsindex = dictionary.vsindex or 0 glyphs = glphs or { } + justpass = streams == true + globalbias, localbias = setbias(globals,locals) nominalwidth, defaultwidth = setwidths(dictionary.private) @@ -2134,7 +2302,7 @@ local function readfdselect(f,fontdata,data,glyphs,doshapes,version,streams) local format = readbyte(f) if format == 1 then for i=0,nofglyphs do -- notdef included (needs checking) - local index = readbyte(i) + local index = readbyte(f) fdindex[i] = index if index > maxindex then maxindex = index @@ -2165,23 +2333,27 @@ local function readfdselect(f,fontdata,data,glyphs,doshapes,version,streams) -- hm, always if maxindex >= 0 then local cidarray = cid.fdarray - setposition(f,header.offset+cidarray) - local dictionaries = readlengths(f) - for i=1,#dictionaries do - dictionaries[i] = readstring(f,dictionaries[i]) - end - parsedictionaries(data,dictionaries) - cid.dictionaries = dictionaries - readcidprivates(f,data) - for i=1,#dictionaries do - readlocals(f,data,dictionaries[i]) - end - startparsing(fontdata,data,streams) - for i=1,#charstrings do - parsecharstring(fontdata,data,dictionaries[fdindex[i]+1],charstrings[i],glyphs,i,doshapes,version) - charstrings[i] = nil + if cidarray then + setposition(f,header.offset+cidarray) + local dictionaries = readlengths(f) + for i=1,#dictionaries do + dictionaries[i] = readstring(f,dictionaries[i]) + end + parsedictionaries(data,dictionaries) + cid.dictionaries = dictionaries + readcidprivates(f,data) + for i=1,#dictionaries do + readlocals(f,data,dictionaries[i]) + end + startparsing(fontdata,data,streams) + for i=1,#charstrings do + parsecharstring(fontdata,data,dictionaries[fdindex[i]+1],charstrings[i],glyphs,i,doshapes,version,streams) +-- charstrings[i] = nil + end + stopparsing(fontdata,data) + else + report("no cid array") end - stopparsing(fontdata,data) end end @@ -2200,7 +2372,7 @@ local function cleanup(data,dictionaries) end function readers.cff(f,fontdata,specification) - local tableoffset = gotodatatable(f,fontdata,"cff",specification.details) + local tableoffset = gotodatatable(f,fontdata,"cff",specification.details or specification.glyphs) if tableoffset then local header = readheader(f) if header.major ~= 1 then @@ -2223,14 +2395,17 @@ function readers.cff(f,fontdata,specification) -- local dic = dictionaries[1] local cid = dic.cid - fontdata.cffinfo = { - familynamename = dic.familyname, + -- + local cffinfo = { + familyname = dic.familyname, fullname = dic.fullname, boundingbox = dic.boundingbox, weight = dic.weight, italicangle = dic.italicangle, underlineposition = dic.underlineposition, underlinethickness = dic.underlinethickness, + defaultwidth = dic.defaultwidthx, + nominalwidth = dic.nominalwidthx, monospaced = dic.monospaced, } fontdata.cidinfo = cid and { @@ -2238,13 +2413,31 @@ function readers.cff(f,fontdata,specification) ordering = cid.ordering, supplement = cid.supplement, } + fontdata.cffinfo = cffinfo -- - if specification.glyphs then - local all = specification.shapes or false + local all = specification.shapes or specification.streams or false + if specification.glyphs or all then if cid and cid.fdselect then - readfdselect(f,fontdata,data,glyphs,all,"cff") + readfdselect(f,fontdata,data,glyphs,all,"cff",specification.streams) else - readnoselect(f,fontdata,data,glyphs,all,"cff") + readnoselect(f,fontdata,data,glyphs,all,"cff",specification.streams) + end + end + local private = dic.private + if private then + local data = private.data + if type(data) == "table" then + cffinfo.defaultwidth = data.defaultwidth or cffinfo.defaultwidth + cffinfo.nominalwidth = data.nominalwidth or cffinfo.nominalwidth + cffinfo.bluevalues = data.bluevalues + cffinfo.otherblues = data.otherblues + cffinfo.familyblues = data.familyblues + cffinfo.familyotherblues = data.familyotherblues + cffinfo.bluescale = data.bluescale + cffinfo.blueshift = data.blueshift + cffinfo.bluefuzz = data.bluefuzz + cffinfo.stdhw = data.stdhw + cffinfo.stdvw = data.stdvw end end cleanup(data,dictionaries) @@ -2283,7 +2476,7 @@ function readers.cff2(f,fontdata,specification) data.factors = specification.factors -- local cid = data.dictionaries[1].cid - local all = specification.shapes or false + local all = specification.shapes or specification.streams or false if cid and cid.fdselect then readfdselect(f,fontdata,data,glyphs,all,"cff2",specification.streams) else @@ -2316,7 +2509,7 @@ function readers.cffcheck(filename) dictionaries = dictionaries, strings = strings, glyphs = glyphs, - nofglyphs = 4, + nofglyphs = 0, } -- parsedictionaries(data,dictionaries,"cff") diff --git a/tex/context/base/mkiv/font-con.lua b/tex/context/base/mkiv/font-con.lua index b067c8c40..92911bd3f 100644 --- a/tex/context/base/mkiv/font-con.lua +++ b/tex/context/base/mkiv/font-con.lua @@ -592,6 +592,7 @@ function constructors.scale(tfmdata,specification) targetparameters.descender = delta * descender end -- +-- inspect(targetparameters) constructors.enhanceparameters(targetparameters) -- official copies for us, now virtual -- local protrusionfactor = (targetquad ~= 0 and 1000/targetquad) or 0 @@ -1027,24 +1028,22 @@ function constructors.finalize(tfmdata) properties.virtualized = tfmdata.type == "virtual" end -- - if not tfmdata.properties then - tfmdata.properties = { - fontname = tfmdata.fontname, - filename = tfmdata.filename, - fullname = tfmdata.fullname, - name = tfmdata.name, - psname = tfmdata.psname, - -- - encodingbytes = tfmdata.encodingbytes or 1, - embedding = tfmdata.embedding or "subset", - tounicode = tfmdata.tounicode or 1, - cidinfo = tfmdata.cidinfo or nil, - format = tfmdata.format or "type1", - direction = tfmdata.direction or 0, - writingmode = tfmdata.writingmode or "horizontal", - identity = tfmdata.identity or "horizontal", - } - end + properties.fontname = tfmdata.fontname + properties.filename = tfmdata.filename + properties.fullname = tfmdata.fullname + properties.name = tfmdata.name + properties.psname = tfmdata.psname + -- + properties.encodingbytes = tfmdata.encodingbytes or 1 + properties.embedding = tfmdata.embedding or "subset" + properties.tounicode = tfmdata.tounicode or 1 + properties.cidinfo = tfmdata.cidinfo or nil + properties.format = tfmdata.format or "type1" + properties.direction = tfmdata.direction or 0 + properties.writingmode = tfmdata.writingmode or "horizontal" + properties.identity = tfmdata.identity or "horizontal" + properties.usedbitmap = tfmdata.usedbitmap + -- if not tfmdata.resources then tfmdata.resources = { } end diff --git a/tex/context/base/mkiv/font-ctx.lua b/tex/context/base/mkiv/font-ctx.lua index 73d39d036..e6547dedd 100644 --- a/tex/context/base/mkiv/font-ctx.lua +++ b/tex/context/base/mkiv/font-ctx.lua @@ -1852,7 +1852,7 @@ function mappings.loadfile(name) if trace_mapfiles then report_mapfiles("loading map file %a",name) end - pdf.mapfile(name) + lpdf.setmapfile(name) loaded[name] = true end end @@ -1870,17 +1870,15 @@ function mappings.loadline(how,line) if trace_mapfiles then report_mapfiles("processing map line %a",line) end - pdf.mapline(how) + lpdf.setmapline(how) loaded[how] = true end end function mappings.reset() - pdf.mapfile("") + lpdf.setmapfile("") -- tricky ... backend related end -mappings.reset() -- resets the default file - implement { name = "loadmapfile", actions = mappings.loadfile, diff --git a/tex/context/base/mkiv/font-dsp.lua b/tex/context/base/mkiv/font-dsp.lua index 127afd9cb..4a0fc71bc 100644 --- a/tex/context/base/mkiv/font-dsp.lua +++ b/tex/context/base/mkiv/font-dsp.lua @@ -2297,7 +2297,7 @@ do local function loadvariations(f,fontdata,variationsoffset,lookuptypes,featurehash,featureorder) setposition(f,variationsoffset) - local version = readulong(f) + local version = readulong(f) -- two times readushort local nofrecords = readulong(f) local records = { } for i=1,nofrecords do @@ -3186,8 +3186,7 @@ end -- } -- end -- --- local majorversion = readushort(f) --- local minorversion = readushort(f) +-- local version = readulong(f) -- local nofsizetables = readulong(f) -- local sizetable = { } -- for i=1,nofsizetables do @@ -3387,11 +3386,10 @@ function readers.avar(f,fontdata,specification) return false end - local majorversion = readushort(f) -- 1 - local minorversion = readushort(f) -- 0 - local reserved = readushort(f) - local nofaxis = readushort(f) - local segments = { } + local version = readulong(f) -- 0x00010000 + local reserved = readushort(f) + local nofaxis = readushort(f) + local segments = { } for i=1,nofaxis do segments[i] = collect() end @@ -3402,7 +3400,7 @@ end function readers.fvar(f,fontdata,specification) local tableoffset = gotodatatable(f,fontdata,"fvar",true) -- specification.variable or specification.instancenames if tableoffset then - local version = readulong(f) -- 1.0 + local version = readulong(f) -- 0x00010000 local offsettoaxis = tableoffset + readushort(f) local reserved = skipshort(f) -- pair 1 @@ -3488,7 +3486,7 @@ function readers.hvar(f,fontdata,specification) return end - local version = readulong(f) -- 1.0 + local version = readulong(f) -- 0x00010000 local variationoffset = tableoffset + readulong(f) -- the store local advanceoffset = tableoffset + readulong(f) local lsboffset = tableoffset + readulong(f) @@ -3585,7 +3583,7 @@ end function readers.mvar(f,fontdata,specification) local tableoffset = gotodatatable(f,fontdata,"mvar",specification.variable) if tableoffset then - local version = readulong(f) -- 1.0 + local version = readulong(f) -- 0x00010000 local reserved = skipshort(f,1) local recordsize = readushort(f) local nofrecords = readushort(f) diff --git a/tex/context/base/mkiv/font-hsh.lua b/tex/context/base/mkiv/font-hsh.lua index 81059a5f9..8d1e85145 100644 --- a/tex/context/base/mkiv/font-hsh.lua +++ b/tex/context/base/mkiv/font-hsh.lua @@ -70,7 +70,9 @@ local nulldata = allocate { name = "nullfont", characters = { }, descriptions = { }, - properties = { }, + properties = { + designsize = 786432, + }, parameters = { -- lmromanregular @ 12pt slantperpoint = 0, spacing = { @@ -89,6 +91,7 @@ local nulldata = allocate { x_height = 338952, -- 5 quad = 786432, -- 6 extra_space = 85459, -- 7 + size = 786432, }, } diff --git a/tex/context/base/mkiv/font-imp-quality.lua b/tex/context/base/mkiv/font-imp-quality.lua index bb78d9435..c0ccfb227 100644 --- a/tex/context/base/mkiv/font-imp-quality.lua +++ b/tex/context/base/mkiv/font-imp-quality.lua @@ -325,6 +325,16 @@ local function map_opbd_onto_protrusion(tfmdata,value,opbd) else factor = tonumber(value) or 1 end + local lfactor = left * factor + local rfactor = right * factor + if trace_protrusion then + report_protrusions("left factor %0.3F, right factor %0.3F",lfactor,rfactor) + end + tfmdata.parameters.protrusion = { + factor = factor, + left = left, + right = right, + } if opbd ~= "right" then local validlookups, lookuplist = otf.collectlookups(rawdata,"lfbd",script,language) if validlookups then @@ -343,10 +353,16 @@ local function map_opbd_onto_protrusion(tfmdata,value,opbd) if v == true then -- zero else - local p = - (v[3] / 1000) * factor * left - characters[k].left_protruding = p - if trace_protrusion then - report_protrusions("lfbd -> %C -> %p",k,p) + local w = descriptions[k].width + local d = - v[1] + if w == 0 or d == 0 then + -- ignored + else + local p = lfactor * ((w+d)/d)/100 + characters[k].left_protruding = p + if trace_protrusion then + report_protrusions("lfbd -> %0.3F %C",p,k) + end end end end @@ -375,10 +391,16 @@ local function map_opbd_onto_protrusion(tfmdata,value,opbd) if v == true then -- zero else - local p = (v[1] / 1000) * factor * right -- or [3] ? - characters[k].right_protruding = p - if trace_protrusion then - report_protrusions("rtbd -> %C -> %p",k,p) + local w = descriptions[k].width + local d = - v[3] + if w == 0 or d == 0 then + -- ignored + else + local p = rfactor * ((w+d)/d)/100 + characters[k].right_protruding = p + if trace_protrusion then + report_protrusions("rtbd -> %0.3F %C",p,k) + end end end end @@ -414,6 +436,11 @@ local function initialize(tfmdata,value) end local data = characters.data local emwidth = tfmdata.parameters.quad + local lfactor = left * factor + local rfactor = right * factor + if trace_protrusion then + report_protrusions("left factor %0.3F, right factor %0.3F",lfactor,rfactor) + end tfmdata.parameters.protrusion = { factor = factor, left = left, @@ -442,10 +469,18 @@ local function initialize(tfmdata,value) end end if pl and pl ~= 0 then - chr.left_protruding = left *pl*factor + local p = pl * lfactor + chr.left_protruding = p + if trace_protrusion then + report_protrusions("left -> %0.3F %C ",p,i) + end end if pr and pr ~= 0 then - chr.right_protruding = right*pr*factor + local p = pr * rfactor + chr.right_protruding = p + if trace_protrusion then + report_protrusions("right -> %0.3F %C",p,i) + end end end elseif trace_protrusion then diff --git a/tex/context/base/mkiv/font-lib.mkvi b/tex/context/base/mkiv/font-lib.mkvi index 7f8601f4e..981db9496 100644 --- a/tex/context/base/mkiv/font-lib.mkvi +++ b/tex/context/base/mkiv/font-lib.mkvi @@ -62,6 +62,12 @@ \registerctxluafile{font-tfm}{} +\doifelsefileexists {font-tpk.lua} { + \registerctxluafile{font-tpk}{optimize} +} { + % nothing +} + % name database \registerctxluafile{font-syn}{} diff --git a/tex/context/base/mkiv/font-ocl.lua b/tex/context/base/mkiv/font-ocl.lua index f97487ecd..866d6dd36 100644 --- a/tex/context/base/mkiv/font-ocl.lua +++ b/tex/context/base/mkiv/font-ocl.lua @@ -306,17 +306,6 @@ fonts.handlers.otf.features.register { do - -- local f_setstream = formatters[ [[io.savedata("svg-glyph-%05i",%q)]] ] - -- local f_getstream = formatters[ [[svg-glyph-%05i]] ] - - -- function otfsvg.storepdfdata(pdf) - -- nofstreams = nofstreams + 1 - -- storepdfdata = function(pdf) - -- nofstreams = nofstreams + 1 - -- return f_setstream(nofstreams,pdf), f_getstream(nofstreams) - -- end - -- end - local nofstreams = 0 local f_name = formatters[ [[pdf-glyph-%05i]] ] local f_used = context and formatters[ [[original:///%s]] ] or formatters[ [[%s]] ] @@ -336,7 +325,7 @@ do done = f_used(n) hashed[pdf] = done end - return nil, done, nil + return done end else @@ -353,48 +342,16 @@ do done = f_used(n) hashed[pdf] = done end - return nil, done, nil + return done end end - -- maybe more efficient but much slower (and we hash already) - -- - -- if context then - -- - -- local storepdfdata = otf.storepdfdata - -- local initialized = false - -- - -- function otf.storepdfdata(pdf) - -- if not initialized then - -- if resolvers.setmemstream then - -- local f_setstream = formatters[ [[resolvers.setmemstream("pdf-glyph-%05i",%q,true)]] ] - -- local f_getstream = formatters[ [[memstream:///pdf-glyph-%05i]] ] - -- local f_nilstream = formatters[ [[resolvers.resetmemstream("pdf-glyph-%05i",true)]] ] - -- storepdfdata = function(pdf) - -- local done = hashed[pdf] - -- local set = nil - -- local reset = nil - -- if not done then - -- nofstreams = nofstreams + 1 - -- set = f_setstream(nofstreams,pdf) - -- done = f_getstream(nofstreams) - -- reset = f_nilstream(nofstreams) - -- hashed[pdf] = done - -- end - -- return set, done, reset - -- end - -- otf.storepdfdata = storepdfdata - -- end - -- initialized = true - -- end - -- return storepdfdata(pdf) - -- end - -- - -- end - end +-- I'll probably make a variant for context as we can do it more efficient there than in +-- generic. + local function pdftovirtual(tfmdata,pdfshapes,kind) -- kind = sbix|svg if not tfmdata or not pdfshapes or not kind then return @@ -418,6 +375,12 @@ local function pdftovirtual(tfmdata,pdfshapes,kind) -- kind = sbix|svg local actualb = { "pdf", "page", b } -- saves tables local actuale = { "pdf", "page", e } -- saves tables -- + local vfimage = lpdf and lpdf.vfimage or function(wd,ht,dp,data,name) + -- needed for generic (if used there at all) + local name = storepdfdata(data) + return { "image", { filename = name, width = wd, height = ht, depth = dp } } + end + -- for unicode, character in sortedhash(characters) do -- sort is nicer for svg local index = character.index if index then @@ -438,23 +401,20 @@ local function pdftovirtual(tfmdata,pdfshapes,kind) -- kind = sbix|svg if data then -- We can delay storage by a lua function in commands: but then we need to -- be able to provide our own mem stream name (so that we can reserve it). - local setcode, name, nilcode = storepdfdata(data) - if name then - local bt = unicode and getactualtext(unicode) - local wd = character.width or 0 - local ht = character.height or 0 - local dp = character.depth or 0 - character.commands = { - not unicode and actualb or { "pdf", "page", (getactualtext(unicode)) }, - downcommand[dp + dy * hfactor], - rightcommand[dx * hfactor], - -- setcode and { "lua", setcode } or nop, - { "image", { filename = name, width = wd, height = ht, depth = dp } }, - -- nilcode and { "lua", nilcode } or nop, - actuale, - } - character[kind] = true - end + -- Anyway, we will do this different in a future version of context. + local bt = unicode and getactualtext(unicode) + local wd = character.width or 0 + local ht = character.height or 0 + local dp = character.depth or 0 + -- The down and right will change too (we can move that elsewhere). + character.commands = { + not unicode and actualb or { "pdf", "page", (getactualtext(unicode)) }, + downcommand[dp + dy * hfactor], + rightcommand[dx * hfactor], + vfimage(wd,ht,dp,data,name), + actuale, + } + character[kind] = true end end end @@ -668,6 +628,8 @@ do end +-- This will change in a future version of context. More direct. + local function initializesbix(tfmdata,kind,value) -- hm, always value if value and otf.sbixenabled then local sbix = tfmdata.properties.sbix diff --git a/tex/context/base/mkiv/font-onr.lua b/tex/context/base/mkiv/font-onr.lua index 7c806c692..8523d8729 100644 --- a/tex/context/base/mkiv/font-onr.lua +++ b/tex/context/base/mkiv/font-onr.lua @@ -26,7 +26,7 @@ local match, lower, gsub, strip, find = string.match, string.lower, string.gsub, local char, byte, sub = string.char, string.byte, string.sub local abs = math.abs local bxor, rshift = bit32.bxor, bit32.rshift -local P, S, R, Cmt, C, Ct, Cs, Carg, Cf, Cg = lpeg.P, lpeg.S, lpeg.R, lpeg.Cmt, lpeg.C, lpeg.Ct, lpeg.Cs, lpeg.Carg, lpeg.Cf, lpeg.Cg +local P, S, R, V, Cmt, C, Ct, Cs, Carg, Cf, Cg, Cc = lpeg.P, lpeg.S, lpeg.R, lpeg.V, lpeg.Cmt, lpeg.C, lpeg.Ct, lpeg.Cs, lpeg.Carg, lpeg.Cf, lpeg.Cg, lpeg.Cc local lpegmatch, patterns = lpeg.match, lpeg.patterns local trace_indexing = false trackers.register("afm.indexing", function(v) trace_indexing = v end) @@ -83,31 +83,40 @@ do end - local charstrings = P("/CharStrings") - local subroutines = P("/Subrs") - local encoding = P("/Encoding") - local dup = P("dup") - local put = P("put") - local array = P("array") - local name = P("/") * C((R("az","AZ","09")+S("-_."))^1) - local digits = R("09")^1 - local cardinal = digits / tonumber - local spaces = P(" ")^1 - local spacing = patterns.whitespace^0 + local charstrings = P("/CharStrings") + local subroutines = P("/Subrs") + local encoding = P("/Encoding") + local dup = P("dup") + local put = P("put") + local array = P("array") + local name = P("/") * C((R("az","AZ","09")+S("-_."))^1) + local digits = R("09")^1 + local cardinal = digits / tonumber + local spaces = P(" ")^1 + local spacing = patterns.whitespace^0 local routines, vector, chars, n, m local initialize = function(str,position,size) n = 0 - m = size -- % tonumber(size) + m = size return position + 1 end local setroutine = function(str,position,index,size,filename) - local forward = position + tonumber(size) + if routines[index] then + -- we have passed the end + return false + end + local forward = position + size local stream = decrypt(sub(str,position+1,forward),4330,4) routines[index] = { byte(stream,1,#stream) } - return forward + n = n + 1 + if n >= m then + -- m should be index now but can we assume ordering? + return #str + end + return forward + 1 end local setvector = function(str,position,name,size,filename) @@ -152,7 +161,7 @@ do local p_filterroutines = -- dup <i> <n> RD or -| <n encrypted bytes> NP or | (1-subroutines)^0 * subroutines * spaces * Cmt(cardinal,initialize) - * (Cmt(cardinal * spaces * cardinal * p_rd * Carg(1), setroutine) * p_np + P(1))^1 + * (Cmt(cardinal * spaces * cardinal * p_rd * Carg(1), setroutine) * p_np + (1-p_nd))^1 local p_filtershapes = -- /foo <n> RD <n encrypted bytes> ND (1-charstrings)^0 * charstrings * spaces * Cmt(cardinal,initialize) @@ -175,7 +184,33 @@ do -- if one of first 4 not 0-9A-F then binary else hex - local function loadpfbvector(filename,shapestoo) + local key = spacing * P("/") * R("az","AZ") + local str = spacing * Cs { (P("(")/"") * ((1 - P("\\(") - P("\\)") - S("()")) + V(1))^0 * (P(")")/"") } + local num = spacing * (R("09") + S("+-."))^1 / tonumber + local arr = spacing * Ct (S("[{") * (num)^0 * spacing * S("]}")) + local boo = spacing * (P("true") * Cc(true) + P("false") * Cc(false)) + local nam = spacing * P("/") * Cs(R("az","AZ")^1) + + local p_filtermetadata = ( + P("/") * Carg(1) * ( ( + C("version") * str + + C("Copyright") * str + + C("Notice") * str + + C("FullName") * str + + C("FamilyName") * str + + C("Weight") * str + + C("ItalicAngle") * num + + C("isFixedPitch") * boo + + C("UnderlinePosition") * num + + C("UnderlineThickness") * num + + C("FontName") * nam + + C("FontMatrix") * arr + + C("FontBBox") * arr + ) ) / function(t,k,v) t[lower(k)] = v end + + P(1) + )^0 * Carg(1) + + local function loadpfbvector(filename,shapestoo,streams) -- for the moment limited to encoding only local data = io.loaddata(resolvers.findfile(filename)) @@ -202,10 +237,12 @@ do local names = { } local encoding = lpegmatch(p_filterencoding,ascii) + local metadata = lpegmatch(p_filtermetadata,ascii,1,{}) local glyphs = { } routines, vector, chars = { }, { }, { } - if shapestoo then + if shapestoo or streams then + -- io.savedata("foo.txt",binary) lpegmatch(p_filterroutines,binary,1,filename) lpegmatch(p_filtershapes,binary,1,filename) local data = { @@ -217,7 +254,8 @@ do } }, } - fonts.handlers.otf.readers.parsecharstrings(false,data,glyphs,true,true) + -- only cff 1 in type 1 fonts + fonts.handlers.otf.readers.parsecharstrings(false,data,glyphs,true,"cff",streams) else lpegmatch(p_filternames,binary,1,filename) end @@ -226,7 +264,7 @@ do routines, vector, chars = nil, nil, nil - return names, encoding, glyphs + return names, encoding, glyphs, metadata end diff --git a/tex/context/base/mkiv/font-otr.lua b/tex/context/base/mkiv/font-otr.lua index c7438dd43..8ef1295ab 100644 --- a/tex/context/base/mkiv/font-otr.lua +++ b/tex/context/base/mkiv/font-otr.lua @@ -25,7 +25,7 @@ if not modules then modules = { } end modules ['font-otr'] = { -- are just a unicode string but it doesn't save that much. It will be an option -- some day. --- Optimizing the widths wil be done anyway as it save quite some on a cjk font +-- Optimizing the widths will be done anyway as it save quite some on a cjk font -- and the existing (old) code if okay. -- todo: more messages (only if really needed) @@ -67,6 +67,7 @@ if not modules then modules = { } end modules ['font-otr'] = { local next, type, tonumber = next, type, tonumber local byte, lower, char, gsub = string.byte, string.lower, string.char, string.gsub +local fullstrip = string.fullstrip local floor, round = math.floor, math.round local P, R, S, C, Cs, Cc, Ct, Carg, Cmt = lpeg.P, lpeg.R, lpeg.S, lpeg.C, lpeg.Cs, lpeg.Cc, lpeg.Ct, lpeg.Carg, lpeg.Cmt local lpegmatch = lpeg.match @@ -740,20 +741,30 @@ readers.helpers = helpers local function gotodatatable(f,fontdata,tag,criterium) if criterium and f then - local datatable = fontdata.tables[tag] - if datatable then - local tableoffset = datatable.offset - setposition(f,tableoffset) - return tableoffset + local tables = fontdata.tables + if tables then + local datatable = tables[tag] + if datatable then + local tableoffset = datatable.offset + setposition(f,tableoffset) + return tableoffset + end + else + report("no tables") end end end local function reportskippedtable(f,fontdata,tag,criterium) if criterium and f then - local datatable = fontdata.tables[tag] - if datatable then - report("loading of table %a skipped",tag) + local tables = fontdata.tables + if tables then + local datatable = tables[tag] + if datatable then + report("loading of table %a skipped",tag) + end + else + report("no tables") end end end @@ -785,6 +796,16 @@ local platformnames = { compatiblefullname = true, } +local platformextras = { + uniqueid = true, + version = true, + copyright = true, + license = true, + licenseurl = true, + manufacturer = true, + vendorurl = true, +} + function readers.name(f,fontdata,specification) local tableoffset = gotodatatable(f,fontdata,"name",true) if tableoffset then @@ -855,6 +876,18 @@ function readers.name(f,fontdata,specification) -- and extend when we run into it (todo: proper reverse hash) .. we're only -- interested in english anyway -- + local function decoded(platform,encoding,content) + local decoder = decoders[platform] + if decoder then + decoder = decoder[encoding] + end + if decoder then + return decoder(content) + else + return content + end + end + -- local function filter(platform,e,l) local namelist = namelists[platform] for i=1,#namelist do @@ -866,14 +899,7 @@ function readers.name(f,fontdata,specification) local language = name.language if (not e or encoding == e) and (not l or language == l) then setposition(f,name.offset) - local content = readstring(f,name.length) - local decoder = decoders[platform] - if decoder then - decoder = decoder[encoding] - end - if decoder then - content = decoder(content) - end + local content = decoded(platform,encoding,readstring(f,name.length)) if nametag then names[nametag] = { content = content, @@ -900,23 +926,16 @@ function readers.name(f,fontdata,specification) fontdata.extras = extras -- if specification.platformnames then - local collected = { } + local collected = { } + local platformextras = specification.platformextras and platformextras for platform, namelist in next, namelists do local filtered = false for i=1,#namelist do local entry = namelist[i] local name = entry.name - if platformnames[name] then + if platformnames[name] or (platformextras and platformextras[name]) then setposition(f,entry.offset) - local content = readstring(f,entry.length) - local encoding = entry.encoding - local decoder = decoders[platform] - if decoder then - decoder = decoder[encoding] - end - if decoder then - content = decoder(content) - end + local content = decoded(platform,entry.encoding,readstring(f,entry.length)) if filtered then filtered[name] = content else @@ -959,7 +978,7 @@ readers["os/2"] = function(f,fontdata) local version = readushort(f) local windowsmetrics = { version = version, - averagewidth = readshort(f), + averagewidth = readshort(f), -- ushort? weightclass = readushort(f), widthclass = readushort(f), fstype = readushort(f), @@ -1016,24 +1035,28 @@ end readers.head = function(f,fontdata) local tableoffset = gotodatatable(f,fontdata,"head",true) if tableoffset then + local version = readulong(f) + local fontversion = readulong(f) local fontheader = { - version = readfixed(f), - revision = readfixed(f), - checksum = readulong(f), - magic = readulong(f), - flags = readushort(f), - units = readushort(f), - created = readlongdatetime(f), - modified = readlongdatetime(f), - xmin = readshort(f), - ymin = readshort(f), - xmax = readshort(f), - ymax = readshort(f), - macstyle = readushort(f), - smallpixels = readushort(f), - directionhint = readshort(f), - indextolocformat = readshort(f), - glyphformat = readshort(f), + version = version, + fontversion = number.to16dot16(fontversion), + fontversionnumber = fontversion, + -- checksum = readulong(f), + checksum = readushort(f) * 0x10000 + readushort(f), + magic = readulong(f), + flags = readushort(f), + units = readushort(f), + created = readlongdatetime(f), + modified = readlongdatetime(f), + xmin = readshort(f), + ymin = readshort(f), + xmax = readshort(f), + ymax = readshort(f), + macstyle = readushort(f), + smallpixels = readushort(f), + directionhint = readshort(f), + indextolocformat = readshort(f), + glyphformat = readshort(f), } fontdata.fontheader = fontheader else @@ -1049,7 +1072,7 @@ readers.hhea = function(f,fontdata,specification) local tableoffset = gotodatatable(f,fontdata,"hhea",specification.details) if tableoffset then fontdata.horizontalheader = { - version = readfixed(f), -- two ushorts: major minor + version = readulong(f), ascender = readfword(f), descender = readfword(f), linegap = readfword(f), @@ -1078,7 +1101,7 @@ readers.vhea = function(f,fontdata,specification) local tableoffset = gotodatatable(f,fontdata,"vhea",specification.details) if tableoffset then fontdata.verticalheader = { - version = readfixed(f), + version = readulong(f), ascender = readfword(f), descender = readfword(f), linegap = readfword(f), @@ -1111,15 +1134,15 @@ end readers.maxp = function(f,fontdata,specification) local tableoffset = gotodatatable(f,fontdata,"maxp",specification.details) if tableoffset then - local version = readfixed(f) + local version = readulong(f) local nofglyphs = readushort(f) fontdata.nofglyphs = nofglyphs - if version == 0.5 then + if version == 0x00005000 then fontdata.maximumprofile = { version = version, nofglyphs = nofglyphs, } - elseif version == 1.0 then + elseif version == 0x00010000 then fontdata.maximumprofile = { version = version, nofglyphs = nofglyphs, @@ -1160,15 +1183,14 @@ readers.hmtx = function(f,fontdata,specification) local leftsidebearing = 0 for i=0,nofmetrics-1 do local glyph = glyphs[i] - width = readshort(f) + width = readshort(f) -- readushort leftsidebearing = readshort(f) if width ~= 0 then glyph.width = width end --- for now --- if leftsidebearing ~= 0 then --- glyph.lsb = leftsidebearing --- end + -- if leftsidebearing ~= 0 then + -- glyph.lsb = leftsidebearing + -- end end -- The next can happen in for instance a monospace font or in a cjk font -- with fixed widths. @@ -1181,7 +1203,6 @@ readers.hmtx = function(f,fontdata,specification) -- glyph.lsb = leftsidebearing -- end end - -- hm, there can be a lsb here end end @@ -1231,7 +1252,7 @@ end readers.post = function(f,fontdata,specification) local tableoffset = gotodatatable(f,fontdata,"post",true) if tableoffset then - local version = readfixed(f) + local version = readulong(f) fontdata.postscript = { version = version, italicangle = round(1000*readfixed(f))/1000, @@ -1245,12 +1266,12 @@ readers.post = function(f,fontdata,specification) } if not specification.glyphs then -- enough done - elseif version == 1.0 then + elseif version == 0x00010000 then -- mac encoding (258 glyphs) for index=0,#standardromanencoding do glyphs[index].name = standardromanencoding[index] end - elseif version == 2.0 then + elseif version == 0x00020000 then local glyphs = fontdata.glyphs local nofglyphs = readushort(f) local indices = { } @@ -1281,10 +1302,6 @@ readers.post = function(f,fontdata,specification) end end end - elseif version == 2.5 then - -- depricated, will be done when needed - elseif version == 3.0 then - -- no ps name information end else fontdata.postscript = { } @@ -1947,14 +1964,16 @@ local function getinfo(maindata,sub,platformnames,rawfamilynames,metricstoo,inst designsize = fontdata.designsize, minsize = fontdata.minsize, maxsize = fontdata.maxsize, + boundingbox = fontheader and { fontheader.xmin or 0, fontheader.ymin or 0, fontheader.xmax or 0, fontheader.ymax or 0 } or nil, monospaced = (tonumber(postscript.monospaced or 0) > 0) or metrics.panosewidth == "monospaced", averagewidth = metrics.averagewidth, - xheight = metrics.xheight, - capheight = metrics.capheight, -- not always present and probably crap + xheight = metrics.xheight, -- can be missing + capheight = metrics.capheight or fontdata.maxy, -- can be missing ascender = metrics.typoascender, descender = metrics.typodescender, platformnames = platformnames or nil, instancenames = instancenames or nil, + tableoffsets = fontdata.tableoffsets, } if metricstoo then local keys = { @@ -2016,7 +2035,8 @@ local function loadtables(f,specification,offset) } for i=1,fontdata.noftables do local tag = lower(stripstring(readstring(f,4))) - local checksum = readulong(f) -- not used + -- local checksum = readulong(f) -- not used + local checksum = readushort(f) * 0x10000 + readushort(f) local offset = readulong(f) local length = readulong(f) if offset + length > filesize then @@ -2028,13 +2048,14 @@ local function loadtables(f,specification,offset) length = length, } end +-- inspect(tables) fontdata.foundtables = sortedkeys(tables) if tables.cff or tables.cff2 then fontdata.format = "opentype" else fontdata.format = "truetype" end - return fontdata + return fontdata, tables end local function prepareglyps(fontdata) @@ -2063,7 +2084,7 @@ local variablefonts_supported = (context and true) or (logs and logs.application local function readdata(f,offset,specification) - local fontdata = loadtables(f,specification,offset) + local fontdata, tables = loadtables(f,specification,offset) if specification.glyphs then prepareglyps(fontdata) @@ -2202,10 +2223,20 @@ local function readdata(f,offset,specification) readtable("math",f,fontdata,specification) fontdata.locations = nil - fontdata.tables = nil fontdata.cidmaps = nil fontdata.dictionaries = nil -- fontdata.cff = nil + + if specification.tableoffsets then + fontdata.tableoffsets = tables + setmetatableindex(tables, { + version = fontdata.version, + noftables = fontdata.noftables, + searchrange = fontdata.searchrange, + entryselector = fontdata.entryselector, + rangeshift = fontdata.rangeshift, + }) + end return fontdata end @@ -2313,12 +2344,13 @@ local function loadfont(specification,n,instance) specification.instance = specification.instance or instance end local function message(str) - report("fatal error in file %a: %s\n%s",specification.filename,str,debug.traceback()) + report("fatal error in file %a: %s\n%s",specification.filename,str,debug and debug.traceback()) end local ok, result = xpcall(loadfontdata,message,specification) if ok then return result end +-- return loadfontdata(specification) end -- we need even less, but we can have a 'detail' variant @@ -2340,13 +2372,26 @@ function readers.loadshapes(filename,n,instance,streams) v.math = nil -- v.name = nil end + local names = fontdata.names + if names then + for k, v in next, names do + names[k] = fullstrip(v.content) + end + end end return fontdata and { - -- version = 0.123 -- todo - filename = filename, - format = fontdata.format, - glyphs = fontdata.glyphs, - units = fontdata.fontheader.units, + -- version = 0.123 -- todo + filename = filename, + format = fontdata.format, + glyphs = fontdata.glyphs, + units = fontdata.fontheader.units, + cffinfo = fontdata.cffinfo, + fontheader = fontdata.fontheader, + horizontalheader = fontdata.horizontalheader, + verticalheader = fontdata.verticalheader, + maximumprofile = fontdata.maximumprofile, + names = fontdata.names, + postscript = fontdata.postscript, } or { filename = filename, format = "unknown", @@ -2417,10 +2462,12 @@ function readers.getinfo(filename,specification) -- string, nil|number|table local platformnames = false local rawfamilynames = false local instancenames = true + local tableoffsets = false if type(specification) == "table" then subfont = tonumber(specification.subfont) platformnames = specification.platformnames rawfamilynames = specification.rawfamilynames + tableoffsets = specification.tableoffsets else subfont = tonumber(specification) end @@ -2429,6 +2476,7 @@ function readers.getinfo(filename,specification) -- string, nil|number|table details = true, platformnames = platformnames, instancenames = true, + tableoffsets = tableoffsets, -- rawfamilynames = rawfamilynames, } if fontdata then diff --git a/tex/context/base/mkiv/font-ots.lua b/tex/context/base/mkiv/font-ots.lua index e3389b9da..880fbcc1f 100644 --- a/tex/context/base/mkiv/font-ots.lua +++ b/tex/context/base/mkiv/font-ots.lua @@ -784,23 +784,17 @@ function handlers.gsub_ligature(head,start,dataset,sequence,ligature,rlmode,skip -- ok, goto next lookup end end - else -- is the check for disc still valid here ? and why only replace then + else local discfound = false - local lastdisc = nil local hasmarks = marks[startchar] while current do local char, id = ischar(current,currentfont) if char then if skiphash and skiphash[char] then current = getnext(current) - -- if stop then stop = current end -- ? - else -- ligature is a tree - local lg = ligature[char] -- can there be multiple in a row? maybe in a bad font + else + local lg = ligature[char] if lg then - if not discfound and lastdisc then - discfound = lastdisc - lastdisc = nil - end if marks[char] then hasmarks = true end @@ -815,58 +809,89 @@ function handlers.gsub_ligature(head,start,dataset,sequence,ligature,rlmode,skip -- kind of weird break elseif id == disc_code then - -- - -- Kai: see chainprocs, we probably could do the same here or was there a reason - -- why we kept the replace check here. - -- - -- if not discfound then - -- discfound = current - -- end - -- if current == stop then - -- break -- okay? or before the disc - -- else - -- current = getnext(current) - -- end - -- - local replace = getfield(current,"replace") -- hm: pre and post - if replace then - -- of{f-}{}{f}e o{f-}{}{f}fe o{-}{}{ff}e (oe and ff ligature) - -- we can end up here when we have a start run .. testruns start at a disc but - -- so here we have the other case: char + disc - while replace do - local char, id = ischar(replace,currentfont) - if char then - local lg = ligature[char] -- can there be multiple in a row? maybe in a bad font - if lg then - if marks[char] then - hasmarks = true -- very unlikely - end - ligature = lg - replace = getnext(replace) - else - return head, start, false, false - end - else - return head, start, false, false - end - end - stop = current - end - lastdisc = current - current = getnext(current) + discfound = current + break else break end end + -- of{f-}{}{f}e o{f-}{}{f}fe o{-}{}{ff}e (oe and ff ligature) + -- we can end up here when we have a start run .. testruns start at a disc but + -- so here we have the other case: char + disc + if discfound then + -- don't assume marks in a disc and we don't run over a disc (for now) + local pre, post, replace = getdisc(discfound) + local match + if replace then + local char = ischar(replace,currentfont) + if char and ligature[char] then + match = true + end + end + if not match and pre then + local char = ischar(pre,currentfont) + if char and ligature[char] then + match = true + end + end + if not match and not pre or not replace then + local n = getnext(discfound) + local char = ischar(n,currentfont) + if char and ligature[char] then + match = true + end + end + if match then + -- we force a restart + local ishead = head == start + local prev = getprev(start) + if stop then + setnext(stop) + local tail = getprev(stop) + local copy = copy_node_list(start) + local liat = find_node_tail(copy) + if pre and replace then + setlink(liat,pre) + end + if replace then + setlink(tail,replace) + end + pre = copy + replace = start + else + setnext(start) + local copy = copy_node(start) + if pre then + setlink(copy,pre) + end + if replace then + setlink(start,replace) + end + pre = copy + replace = start + end + setdisc(discfound,pre,post,replace) + if prev then + setlink(prev,discfound) + else + setprev(discfound) + head = discfound + end + start = discfound + return head, start, true, true + end + end local lig = ligature.ligature if lig then if stop then if trace_ligatures then local stopchar = getchar(stop) - head, start = toligature(head,start,stop,lig,dataset,sequence,skiphash,discfound,hasmarks) + -- head, start = toligature(head,start,stop,lig,dataset,sequence,skiphash,discfound,hasmarks) + head, start = toligature(head,start,stop,lig,dataset,sequence,skiphash,false,hasmarks) logprocess("%s: replacing %s upto %s by ligature %s case 2",pref(dataset,sequence),gref(startchar),gref(stopchar),gref(lig)) else - head, start = toligature(head,start,stop,lig,dataset,sequence,skiphash,discfound,hasmarks) + -- head, start = toligature(head,start,stop,lig,dataset,sequence,skiphash,discfound,hasmarks) + head, start = toligature(head,start,stop,lig,dataset,sequence,skiphash,false,hasmarks) end else -- weird but happens (in some arabic font) @@ -876,12 +901,12 @@ function handlers.gsub_ligature(head,start,dataset,sequence,ligature,rlmode,skip logprocess("%s: replacing %s by (no real) ligature %s case 3",pref(dataset,sequence),gref(startchar),gref(lig)) end end - return head, start, true, discfound + return head, start, true, false else -- weird but happens, pseudo ligatures ... just the components end end - return head, start, false, discfound + return head, start, false, false end function handlers.gpos_single(head,start,dataset,sequence,kerns,rlmode,skiphash,step,injection) @@ -3960,12 +3985,14 @@ do a = true end if a then - local ok - head, start, ok = handler(head,start,dataset,sequence,lookupmatch,rlmode,skiphash,step) + local ok, df + head, start, ok, df = handler(head,start,dataset,sequence,lookupmatch,rlmode,skiphash,step) -- if ok then -- done = true -- end - if start then + if df then +-- print("restart 1",typ) + elseif start then start = getnext(start) end else @@ -4023,6 +4050,7 @@ do a = true end if a then + local ok, df for i=m[1],m[2] do local step = steps[i] -- for i=1,#m do @@ -4031,9 +4059,11 @@ do local lookupmatch = lookupcache[char] if lookupmatch then -- we could move all code inline but that makes things even more unreadable - local ok - head, start, ok = handler(head,start,dataset,sequence,lookupmatch,rlmode,skiphash,step) - if ok then +-- local ok, df + head, start, ok, df = handler(head,start,dataset,sequence,lookupmatch,rlmode,skiphash,step) + if df then + break + elseif ok then -- done = true break elseif not start then @@ -4042,7 +4072,9 @@ do end end end - if start then + if df then +-- print("restart 2",typ) + elseif start then start = getnext(start) end else diff --git a/tex/context/base/mkiv/font-shp.lua b/tex/context/base/mkiv/font-shp.lua index 31971b880..08eda9fdb 100644 --- a/tex/context/base/mkiv/font-shp.lua +++ b/tex/context/base/mkiv/font-shp.lua @@ -12,6 +12,7 @@ local formatters = string.formatters local otf = fonts.handlers.otf local afm = fonts.handlers.afm +local pfb = fonts.handlers.pfb local hashes = fonts.hashes local identifiers = hashes.identifiers @@ -39,7 +40,8 @@ local function packoutlines(data,makesequence) return end if makesequence then - for index=1,#glyphs do +-- for index=1,#glyphs do + for index=0,#glyphs-1 do local glyph = glyphs[index] local segments = glyph.segments if segments then @@ -48,6 +50,7 @@ local function packoutlines(data,makesequence) for i=1,#segments do local segment = segments[i] local nofsegment = #segment + -- why last first ... needs documenting nofsequence = nofsequence + 1 sequence[nofsequence] = segment[nofsegment] for i=1,nofsegment-1 do @@ -64,7 +67,8 @@ local function packoutlines(data,makesequence) local common = { } local reverse = { } local last = 0 - for index=1,#glyphs do +-- for index=1,#glyphs do + for index=0,#glyphs-1 do local segments = glyphs[index].segments if segments then for i=1,#segments do @@ -73,7 +77,8 @@ local function packoutlines(data,makesequence) end end end - for index=1,#glyphs do +-- for index=1,#glyphs do + for index=0,#glyphs-1 do local segments = glyphs[index].segments if segments then for i=1,#segments do @@ -114,7 +119,8 @@ local function unpackoutlines(data) if not glyphs then return end - for index=1,#glyphs do +-- for index=1,#glyphs do + for index=0,#glyphs-1 do local segments = glyphs[index].segments if segments then for i=1,#segments do @@ -131,7 +137,7 @@ end -- todo: loaders per format local readers = otf.readers -local cleanname = readers.helpers.cleanname +local cleanname = otf.readers.helpers.cleanname local function makehash(filename,sub,instance) local name = cleanname(file.basename(filename)) @@ -157,7 +163,7 @@ local function loadoutlines(cache,filename,sub,instance) local hash = makehash(filename,sub,instance) data = containers.read(cache,hash) if not data or data.time ~= time or data.size ~= size then - data = readers.loadshapes(filename,sub,instance) + data = otf.readers.loadshapes(filename,sub,instance) if data then data.size = size data.format = data.format or (kind == "otf" and "opentype") or "truetype" @@ -204,19 +210,16 @@ local function loadstreams(cache,filename,sub,instance) local size = attr and attr.size or 0 local time = attr and attr.modification or 0 local sub = tonumber(sub) - - -- fonts.formats - if size > 0 and (kind == "otf" or kind == "ttf" or kind == "tcc") then local hash = makehash(filename,sub,instance) data = containers.read(cache,hash) if not data or data.time ~= time or data.size ~= size then - data = readers.loadshapes(filename,sub,instance,true) + data = otf.readers.loadshapes(filename,sub,instance,true) if data then local glyphs = data.glyphs local streams = { } if glyphs then - for i=0,#glyphs do + for i=0,#glyphs-1 do streams[i] = glyphs[i].stream or "" end end @@ -229,13 +232,68 @@ local function loadstreams(cache,filename,sub,instance) data = containers.read(cache,hash) -- frees old mem end end + elseif size > 0 and (kind == "pfb") then + local hash = makehash(filename,sub,instance) + data = containers.read(cache,hash) + if not data or data.time ~= time or data.size ~= size then + local names, encoding, streams, metadata = pfb.loadvector(filename,false,true) + if streams then + local fontbbox = metadata.fontbbox or { 0, 0, 0, 0 } + for i=0,#streams do + streams[i] = streams[i].stream or "\14" + end + data = { + filename = filename, + size = size, + time = time, + format = "type1", + streams = streams, + fontheader = { + fontversion = metadata.version, + units = 1000, -- can this be different? + xmin = fontbbox[1], + ymin = fontbbox[2], + xmax = fontbbox[3], + ymax = fontbbox[4], + }, + horizontalheader = { + ascender = 0, + descender = 0, + }, + maximumprofile = { + nofglyphs = #streams + 1, + }, + names = { + copyright = metadata.copyright, + family = metadata.familyname, + fullname = metadata.fullname, + fontname = metadata.fontname, + subfamily = metadata.subfamilyname, + trademark = metadata.trademark, + notice = metadata.notice, + version = metadata.version, + }, + cffinfo = { + familyname = metadata.familyname, + fullname = metadata.fullname, + italicangle = metadata.italicangle, + monospaced = metadata.isfixedpitch and true or false, + underlineposition = metadata.underlineposition, + underlinethickness = metadata.underlinethickness, + weight = metadata.weight, + }, + } + containers.write(cache,hash,data) + data = containers.read(cache,hash) -- frees old mem + end + end else data = { filename = filename, size = 0, time = time, format = "unknown", - glyphs = { } + streams = { } } end return data @@ -265,7 +323,15 @@ hashes.shapes = table.setmetatableindex(function(t,k) end end) -local function loadstreamdata(fontdata,streams) +local function getstreamhash(fontid) + local fontdata = identifiers[fontid] + if fontdata then + local properties = fontdata.properties + return makehash(properties.filename,fontdata.subindex,properties.instance) + end +end + +local function loadstreamdata(fontdata) local properties = fontdata.properties local filename = properties.filename local subindex = fontdata.subindex @@ -289,6 +355,7 @@ end) otf.loadoutlinedata = loadoutlinedata -- not public otf.loadstreamdata = loadstreamdata -- not public otf.loadshapes = loadshapes +otf.getstreamhash = getstreamhash -- not public, might move to other namespace -- experimental code, for me only ... unsupported (todo: use %N) diff --git a/tex/context/base/mkiv/font-tfm.lua b/tex/context/base/mkiv/font-tfm.lua index 9f78f2c0a..12e499216 100644 --- a/tex/context/base/mkiv/font-tfm.lua +++ b/tex/context/base/mkiv/font-tfm.lua @@ -9,6 +9,7 @@ if not modules then modules = { } end modules ['font-tfm'] = { local next, type = next, type local match, format = string.match, string.format local concat, sortedhash = table.concat, table.sortedhash +local idiv = number.idiv local trace_defining = false trackers.register("fonts.defining", function(v) trace_defining = v end) local trace_features = false trackers.register("tfm.features", function(v) trace_features = v end) @@ -117,7 +118,6 @@ local depth = { } -- table.setmetatableindex("number") -- -- So "czechdqcheat=yes" is then a valid feature. And yes, it's a cheat. - local function read_from_tfm(specification) local filename = specification.filename local size = specification.size @@ -140,28 +140,29 @@ local function read_from_tfm(specification) tfmdata = newtfmdata end - local resources = tfmdata.resources or { } - local properties = tfmdata.properties or { } - local parameters = tfmdata.parameters or { } - local shared = tfmdata.shared or { } + local resources = tfmdata.resources or { } + local properties = tfmdata.properties or { } + local parameters = tfmdata.parameters or { } + local shared = tfmdata.shared or { } -- - shared.features = features - shared.resources = resources + shared.features = features + shared.resources = resources -- - properties.name = tfmdata.name -- todo: fallback - properties.fontname = tfmdata.fontname -- todo: fallback - properties.psname = tfmdata.psname -- todo: fallback - properties.fullname = tfmdata.fullname -- todo: fallback - properties.filename = specification.filename -- todo: fallback - properties.format = fonts.formats.tfm -- better than nothing + properties.name = tfmdata.name -- todo: fallback + properties.fontname = tfmdata.fontname -- todo: fallback + properties.psname = tfmdata.psname -- todo: fallback + properties.fullname = tfmdata.fullname -- todo: fallback + properties.filename = specification.filename -- todo: fallback + properties.format = tfmdata.format or fonts.formats.tfm -- better than nothing + properties.usedbitmap = tfmdata.usedbitmap -- - tfmdata.properties = properties - tfmdata.resources = resources - tfmdata.parameters = parameters - tfmdata.shared = shared + tfmdata.properties = properties + tfmdata.resources = resources + tfmdata.parameters = parameters + tfmdata.shared = shared -- - shared.rawdata = { resources = resources } - shared.features = features + shared.rawdata = { resources = resources } + shared.features = features -- -- The next branch is only entered when we have a proper encoded file i.e. -- unicodes and such. It really nakes no sense to do feature juggling when @@ -235,6 +236,9 @@ local function read_from_tfm(specification) -- shared.processes = next(features) and tfm.setfeatures(tfmdata,features) or nil -- +if size < 0 then + size = idiv(65536 * -size,100) +end parameters.factor = 1 -- already scaled parameters.size = size parameters.slant = parameters.slant or parameters[1] or 0 @@ -441,7 +445,7 @@ do local originals = tfmdata.characters local indices = { } local parentfont = { "font", 1 } - local private = tfmdata or fonts.constructors.privateoffset + local private = tfmdata.privateoffset or fonts.constructors.privateoffset local reported = encdone[tfmfile][encfile] -- create characters table @@ -466,7 +470,7 @@ do indices[index] = unicode original.name = name -- so one can lookup weird names if backmap then - original.index = backmap[name] + original.index = backmap[name] else -- probably bitmap original.commands = { parentfont, charcommand[index] } -- or "slot" original.oindex = index @@ -515,6 +519,7 @@ do tfmdata.psname = file.nameonly(pfbfile or tfmdata.name) tfmdata.filename = pfbfile tfmdata.encodingbytes = 2 + -- tfmdata.format = bitmap and "type3" or "type1" tfmdata.format = "type1" tfmdata.tounicode = 1 tfmdata.embedding = "subset" @@ -551,24 +556,18 @@ end end ]] - local flushstreamobject = lpdf and lpdf.flushstreamobject - local setfontattributes = pdf.setfontattributes + local flushstreamobject = lpdf and lpdf.flushstreamobject -- context + local setfontattributes = lpdf and lpdf.setfontattributes -- context - if flushstreamobject then - -- we're in context - else + if not flushstreamobject then flushstreamobject = function(data) - return pdf.obj { - immediate = true, - type = "stream", - string = data, - } + return pdf.obj { immediate = true, type = "stream", string = data } -- generic end end if not setfontattributes then setfontattributes = function(id,data) - print(format("your luatex is too old so no tounicode bitmap font%i",id)) + return pdf.setfontattributes(id,data) -- generic end end @@ -596,7 +595,7 @@ end -- Now we implement the regular features handlers. We need to convert the -- tfm specific structures to opentype structures. In basemode they are --- converted back so that is a bti of a waste but it's fast enough. +-- converted back so that is a bit of a waste but it's fast enough. do diff --git a/tex/context/base/mkiv/font-ttf.lua b/tex/context/base/mkiv/font-ttf.lua index bdfa3e859..58e999e26 100644 --- a/tex/context/base/mkiv/font-ttf.lua +++ b/tex/context/base/mkiv/font-ttf.lua @@ -35,8 +35,10 @@ if not modules then modules = { } end modules ['font-ttf'] = { local next, type, unpack = next, type, unpack local band, rshift = bit32.band, bit32.rshift local sqrt, round = math.sqrt, math.round -local char = string.char +local char, rep = string.char, string.rep local concat = table.concat +local idiv = number.idiv +local setmetatableindex = table.setmetatableindex local report = logs.reporter("otf reader","ttf") @@ -115,22 +117,41 @@ local function mergecomposites(glyphs,shapes) local yscale = matrix[4] local xoffset = matrix[5] local yoffset = matrix[6] - for i=1,#subpoints do - local p = subpoints[i] - local x = p[1] - local y = p[2] - nofpoints = nofpoints + 1 - points[nofpoints] = { - xscale * x + xrotate * y + xoffset, - yscale * y + yrotate * x + yoffset, - p[3] - } + local count = #subpoints + if xscale == 1 and yscale == 1 and xrotate == 0 and yrotate == 0 then + for i=1,count do + local p = subpoints[i] + nofpoints = nofpoints + 1 + points[nofpoints] = { + p[1] + xoffset, + p[2] + yoffset, + p[3] + } + end + else + for i=1,count do + local p = subpoints[i] + local x = p[1] + local y = p[2] + nofpoints = nofpoints + 1 + points[nofpoints] = { + xscale * x + xrotate * y + xoffset, + yscale * y + yrotate * x + yoffset, + p[3] + } + end end - for i=1,#subcontours do + local subcount = #subcontours + if subcount == 1 then nofcontours = nofcontours + 1 - contours[nofcontours] = offset + subcontours[i] + contours[nofcontours] = offset + subcontours[1] + else + for i=1,#subcontours do + nofcontours = nofcontours + 1 + contours[nofcontours] = offset + subcontours[i] + end end - offset = offset + #subpoints + offset = offset + count else report("missing contours composite %s, component %s of %s, glyph %s",index,i,#components,subindex) end @@ -141,7 +162,8 @@ local function mergecomposites(glyphs,shapes) return contours, points end - for index=1,#glyphs do +-- for index=1,#glyphs do + for index=0,#glyphs-1 do local shape = shapes[index] if shape then local components = shape.components @@ -153,7 +175,7 @@ local function mergecomposites(glyphs,shapes) end -local function readnothing(f,nofcontours) +local function readnothing(f) return { type = "nothing", } @@ -284,7 +306,8 @@ end local quadratic = false local function contours2outlines_normal(glyphs,shapes) -- maybe accept the bbox overhead - for index=1,#glyphs do +-- for index=1,#glyphs do + for index=0,#glyphs-1 do local shape = shapes[index] if shape then local glyph = glyphs[index] @@ -404,7 +427,8 @@ local function contours2outlines_normal(glyphs,shapes) -- maybe accept the bbox end local function contours2outlines_shaped(glyphs,shapes,keepcurve) - for index=1,#glyphs do +-- for index=1,#glyphs do + for index=0,#glyphs-1 do local shape = shapes[index] if shape then local glyph = glyphs[index] @@ -583,8 +607,13 @@ end local c_zero = char(0) local s_zero = char(0,0) +-- local shorthash = setmetatableindex(function(t,k) +-- t[k] = char(band(rshift(k,8),0xFF),band(k,0xFF)) return t[k] +-- end) + local function toushort(n) return char(band(rshift(n,8),0xFF),band(n,0xFF)) + -- return shorthash[n] end local function toshort(n) @@ -592,124 +621,151 @@ local function toshort(n) n = n + 0x10000 end return char(band(rshift(n,8),0xFF),band(n,0xFF)) + -- return shorthash[n] end -- todo: we can reuse result, xpoints and ypoints +local chars = setmetatableindex(function(t,k) + for i=0,255 do local v = char(i) t[i] = v end return t[k] +end) + local function repackpoints(glyphs,shapes) local noboundingbox = { 0, 0, 0, 0 } local result = { } -- reused - for index=1,#glyphs do + local xpoints = { } -- reused + local ypoints = { } -- reused + for index=0,#glyphs-1 do local shape = shapes[index] if shape then local r = 0 local glyph = glyphs[index] - if false then -- shape.type == "composite" - -- we merged them - else - local contours = shape.contours - local nofcontours = contours and #contours or 0 - local boundingbox = glyph.boundingbox or noboundingbox - r = r + 1 result[r] = toshort(nofcontours) - r = r + 1 result[r] = toshort(boundingbox[1]) -- xmin - r = r + 1 result[r] = toshort(boundingbox[2]) -- ymin - r = r + 1 result[r] = toshort(boundingbox[3]) -- xmax - r = r + 1 result[r] = toshort(boundingbox[4]) -- ymax - if nofcontours > 0 then - for i=1,nofcontours do - r = r + 1 result[r] = toshort(contours[i]-1) - end - r = r + 1 result[r] = s_zero -- no instructions - local points = shape.points - local currentx = 0 - local currenty = 0 - local xpoints = { } - local ypoints = { } - local x = 0 - local y = 0 - local lastflag = nil - local nofflags = 0 - for i=1,#points do - local pt = points[i] - local px = pt[1] - local py = pt[2] - local fl = pt[3] and 0x01 or 0x00 - if px == currentx then - fl = fl + 0x10 + local contours = shape.contours + local nofcontours = contours and #contours or 0 + local boundingbox = glyph.boundingbox or noboundingbox + r = r + 1 result[r] = toshort(nofcontours) + r = r + 1 result[r] = toshort(boundingbox[1]) -- xmin + r = r + 1 result[r] = toshort(boundingbox[2]) -- ymin + r = r + 1 result[r] = toshort(boundingbox[3]) -- xmax + r = r + 1 result[r] = toshort(boundingbox[4]) -- ymax + if nofcontours > 0 then + for i=1,nofcontours do + r = r + 1 result[r] = toshort(contours[i]-1) + end + r = r + 1 result[r] = s_zero -- no instructions + local points = shape.points + local currentx = 0 + local currenty = 0 + -- local xpoints = { } + -- local ypoints = { } + local x = 0 + local y = 0 + local lastflag = nil + local nofflags = 0 + for i=1,#points do + local pt = points[i] + local px = pt[1] + local py = pt[2] + local fl = pt[3] and 0x01 or 0x00 + if px == currentx then + fl = fl + 0x10 + else + local dx = round(px - currentx) + x = x + 1 + if dx < -255 or dx > 255 then + xpoints[x] = toshort(dx) + elseif dx < 0 then + fl = fl + 0x02 + -- xpoints[x] = char(-dx) + xpoints[x] = chars[-dx] + elseif dx > 0 then + fl = fl + 0x12 + -- xpoints[x] = char(dx) + xpoints[x] = chars[dx] else - local dx = round(px - currentx) - if dx < -255 or dx > 255 then - x = x + 1 xpoints[x] = toshort(dx) - elseif dx < 0 then - fl = fl + 0x02 - x = x + 1 xpoints[x] = char(-dx) - elseif dx > 0 then - fl = fl + 0x12 - x = x + 1 xpoints[x] = char(dx) - else - fl = fl + 0x02 - x = x + 1 xpoints[x] = c_zero - end + fl = fl + 0x02 + xpoints[x] = c_zero end - if py == currenty then - fl = fl + 0x20 + end + if py == currenty then + fl = fl + 0x20 + else + local dy = round(py - currenty) + y = y + 1 + if dy < -255 or dy > 255 then + ypoints[y] = toshort(dy) + elseif dy < 0 then + fl = fl + 0x04 + -- ypoints[y] = char(-dy) + ypoints[y] = chars[-dy] + elseif dy > 0 then + fl = fl + 0x24 + -- ypoints[y] = char(dy) + ypoints[y] = chars[dy] else - local dy = round(py - currenty) - if dy < -255 or dy > 255 then - y = y + 1 ypoints[y] = toshort(dy) - elseif dy < 0 then - fl = fl + 0x04 - y = y + 1 ypoints[y] = char(-dy) - elseif dy > 0 then - fl = fl + 0x24 - y = y + 1 ypoints[y] = char(dy) - else - fl = fl + 0x04 - y = y + 1 ypoints[y] = c_zero - end - end - currentx = px - currenty = py - if lastflag == fl then - nofflags = nofflags + 1 - else -- if > 255 - if nofflags == 1 then - r = r + 1 result[r] = char(lastflag) - elseif nofflags == 2 then - r = r + 1 result[r] = char(lastflag,lastflag) - elseif nofflags > 2 then - lastflag = lastflag + 0x08 - r = r + 1 result[r] = char(lastflag,nofflags-1) - end - nofflags = 1 - lastflag = fl + fl = fl + 0x04 + ypoints[y] = c_zero end end - if nofflags == 1 then - r = r + 1 result[r] = char(lastflag) - elseif nofflags == 2 then - r = r + 1 result[r] = char(lastflag,lastflag) - elseif nofflags > 2 then - lastflag = lastflag + 0x08 - r = r + 1 result[r] = char(lastflag,nofflags-1) + currentx = px + currenty = py + if lastflag == fl then + nofflags = nofflags + 1 + else -- if > 255 + if nofflags == 1 then + -- r = r + 1 result[r] = char(lastflag) + r = r + 1 result[r] = chars[lastflag] + elseif nofflags == 2 then + r = r + 1 result[r] = char(lastflag,lastflag) + elseif nofflags > 2 then + lastflag = lastflag + 0x08 + r = r + 1 result[r] = char(lastflag,nofflags-1) + end + nofflags = 1 + lastflag = fl end - r = r + 1 result[r] = concat(xpoints) - r = r + 1 result[r] = concat(ypoints) end + if nofflags == 1 then + -- r = r + 1 result[r] = char(lastflag) + r = r + 1 result[r] = chars[lastflag] + elseif nofflags == 2 then + r = r + 1 result[r] = char(lastflag,lastflag) + elseif nofflags > 2 then + lastflag = lastflag + 0x08 + r = r + 1 result[r] = char(lastflag,nofflags-1) + end + -- r = r + 1 result[r] = concat(xpoints) + -- r = r + 1 result[r] = concat(ypoints) + r = r + 1 result[r] = concat(xpoints,"",1,x) + r = r + 1 result[r] = concat(ypoints,"",1,y) end - glyph.stream = concat(result,"",1,r) - else - -- fatal + -- can be helper or delegated to user + local stream = concat(result,"",1,r) + local length = #stream + local padding = idiv(length+3,4) * 4 - length + if padding > 0 then + -- stream = stream .. rep("\0",padding) -- can be a repeater + if padding == 1 then + padding = "\0" + elseif padding == 2 then + padding = "\0\0" + else + padding = "\0\0\0" + end + padding = stream .. padding + end + glyph.stream = stream end end end -- end of converter +local flags = { } + local function readglyph(f,nofcontours) -- read deltas here, saves space local points = { } - local instructions = { } - local flags = { } + -- local instructions = { } local contours = { } -- readintegertable(f,nofcontours,short) for i=1,nofcontours do contours[i] = readshort(f) + 1 @@ -724,9 +780,15 @@ local function readglyph(f,nofcontours) -- read deltas here, saves space local flag = readbyte(f) flags[i] = flag if band(flag,0x08) ~= 0 then - for j=1,readbyte(f) do + local n = readbyte(f) + if n == 1 then i = i + 1 flags[i] = flag + else + for j=1,n do + i = i + 1 + flags[i] = flag + end end end i = i + 1 @@ -735,16 +797,16 @@ local function readglyph(f,nofcontours) -- read deltas here, saves space -- can be repeated local x = 0 for i=1,nofpoints do - local flag = flags[i] - local short = band(flag,0x02) ~= 0 - local same = band(flag,0x10) ~= 0 - if short then - if same then + local flag = flags[i] + -- local short = band(flag,0x04) ~= 0 + -- local same = band(flag,0x20) ~= 0 + if band(flag,0x02) ~= 0 then + if band(flag,0x10) ~= 0 then x = x + readbyte(f) else x = x - readbyte(f) end - elseif same then + elseif band(flag,0x10) ~= 0 then -- copy else x = x + readshort(f) @@ -753,16 +815,16 @@ local function readglyph(f,nofcontours) -- read deltas here, saves space end local y = 0 for i=1,nofpoints do - local flag = flags[i] - local short = band(flag,0x04) ~= 0 - local same = band(flag,0x20) ~= 0 - if short then - if same then + local flag = flags[i] + -- local short = band(flag,0x04) ~= 0 + -- local same = band(flag,0x20) ~= 0 + if band(flag,0x04) ~= 0 then + if band(flag,0x20) ~= 0 then y = y + readbyte(f) else y = y - readbyte(f) end - elseif same then + elseif band(flag,0x20) ~= 0 then -- copy else y = y + readshort(f) @@ -858,7 +920,7 @@ local function readcomposite(f) if band(flags,0x0100) ~= 0 then instructions = true end - if not band(flags,0x0020) ~= 0 then -- f_more + if band(flags,0x0020) == 0 then -- f_more break end end @@ -883,21 +945,27 @@ function readers.loca(f,fontdata,specification) -- locations are relative to the glypdata table (glyf) local offset = fontdata.tables.glyf.offset local format = fontdata.fontheader.indextolocformat + local profile = fontdata.maximumprofile + local nofglyphs = profile and profile.nofglyphs local locations = { } setposition(f,datatable.offset) if format == 1 then - local nofglyphs = datatable.length/4 - 2 + if not nofglyphs then + nofglyphs = idiv(datatable.length,4) - 1 + end for i=0,nofglyphs do locations[i] = offset + readulong(f) end fontdata.nofglyphs = nofglyphs else - local nofglyphs = datatable.length/2 - 2 + if not nofglyphs then + nofglyphs = idiv(datatable.length,2) - 1 + end for i=0,nofglyphs do locations[i] = offset + readushort(f) * 2 end - fontdata.nofglyphs = nofglyphs end + fontdata.nofglyphs = nofglyphs fontdata.locations = locations end end @@ -913,15 +981,16 @@ function readers.glyf(f,fontdata,specification) -- part goes to cff module local filesize = fontdata.filesize local nothing = { 0, 0, 0, 0 } local shapes = { } - local loadshapes = specification.shapes or specification.instance - for index=0,nofglyphs do + local loadshapes = specification.shapes or specification.instance or specification.streams + for index=0,nofglyphs-1 do local location = locations[index] + local length = locations[index+1] - location if location >= filesize then report("discarding %s glyphs due to glyph location bug",nofglyphs-index+1) fontdata.nofglyphs = index - 1 fontdata.badfont = true break - elseif location > 0 then + elseif length > 0 then setposition(f,location) local nofcontours = readshort(f) glyphs[index].boundingbox = { @@ -933,7 +1002,7 @@ function readers.glyf(f,fontdata,specification) -- part goes to cff module if not loadshapes then -- save space elseif nofcontours == 0 then - shapes[index] = readnothing(f,nofcontours) + shapes[index] = readnothing(f) elseif nofcontours > 0 then shapes[index] = readglyph(f,nofcontours) else @@ -941,7 +1010,7 @@ function readers.glyf(f,fontdata,specification) -- part goes to cff module end else if loadshapes then - shapes[index] = { } + shapes[index] = readnothing(f) end glyphs[index].boundingbox = nothing end @@ -958,7 +1027,13 @@ function readers.glyf(f,fontdata,specification) -- part goes to cff module contours2outlines_shaped(glyphs,shapes,specification.shapes) end elseif specification.shapes then - contours2outlines_normal(glyphs,shapes) + if specification.streams then + repackpoints(glyphs,shapes) + else + contours2outlines_normal(glyphs,shapes) + end + elseif specification.streams then + repackpoints(glyphs,shapes) end end end @@ -1259,10 +1334,6 @@ function readers.gvar(f,fontdata,specification,glyphdata,shapedata) end end if shape.type == "glyph" then --- if glyph.name == "u1f31d" then --- if glyph.unicode == 127773 then --- inspect(deltas) --- end applyaxis(glyph,shape,deltas,dowidth) else -- todo: args_are_xy_values mess .. i have to be really bored diff --git a/tex/context/base/mkiv/grph-inc.lua b/tex/context/base/mkiv/grph-inc.lua index a41d3a3f6..909df86bc 100644 --- a/tex/context/base/mkiv/grph-inc.lua +++ b/tex/context/base/mkiv/grph-inc.lua @@ -6,6 +6,11 @@ if not modules then modules = { } end modules ['grph-inc'] = { license = "see context related readme files" } +-- todo: in pdfe: pdfe.copyappearance(document,objnum) +-- +-- local im = createimage { filename = fullname } +-- local on = images.flushobject(im,document.__xrefs__[AP]) + -- todo: files are sometimes located twice -- todo: empty filename or only suffix always false (not found) -- lowercase types @@ -40,11 +45,11 @@ run TeX code from within Lua. Some more functionality will move to Lua. -- todo: store loaded pages per pdf file someplace -local tonumber, tostring, next = tonumber, tostring, next +local tonumber, tostring, next, unpack = tonumber, tostring, next, unpack local format, lower, find, match, gsub = string.format, string.lower, string.find, string.match, string.gsub local longtostring = string.longtostring local contains = table.contains -local sortedhash = table.sortedhash +local sortedhash, sortedkeys = table.sortedhash, table.sortedkeys local concat, insert, remove = table.concat, table.insert, table.remove local todimen = string.todimen local collapsepath = file.collapsepath @@ -62,7 +67,8 @@ local replacetemplate = utilities.templates.replace -- local bpfactor = number.dimenfactors.bp -local images = img +images = images or { } +local images = images local hasscheme = url.hasscheme local urlhashed = url.hashed @@ -106,7 +112,7 @@ local v_local = variables["local"] local v_default = variables.default local v_auto = variables.auto -local maxdimen = 0x3FFFFFFF -- 2^30-1 +local maxdimen = tex.magicconstants.maxdimen -- 0x3FFFFFFF -- 2^30-1 local ctx_doscalefigure = context.doscalefigure local ctx_relocateexternalfigure = context.relocateexternalfigure @@ -152,14 +158,108 @@ function checkimage(figure) end end ---- some extra img functions --- can become luat-img.lua +--- begin of mapping / this will become graphics & code|nodeinjections but not this year + +local __img__ = img or setmetatableindex(function() report_inclusion("no img lib present") end) +images.__img__ = img + +local img_new = img.new +local img_scan = img.scan +local img_copy = img.copy +local img_wrap = img.node +local img_embed = img.immediatewrite + +updaters.register("backend.update",function() + local img = images.__img__ + img_new = img.new + img_scan = img.scan + img_copy = img.copy + img_wrap = img.wrap + img_embed = img.embed +end) + +local imagekeys = { -- only relevant ones + "width", "height", "depth", "bbox", + "colordepth", "colorspace", + "filename", "filepath", "visiblefilename", + "imagetype", "stream", + "index", "objnum", + "pagebox", "page", "pages", + "rotation", "transform", + "xsize", "ysize", "xres", "yres", +} + +local imagesizes = { + art = true, bleed = true, crop = true, + media = true, none = true, trim = true, +} + +local imagetypes = { [0] = + "none", + "pdf", "png", "jpg", "jp2", "jbig2", + "stream", "memstream", +} + +imagetypes = table.swapped(imagetypes,imagetypes) + +images.keys = imagekeys +images.types = imagetypes +images.sizes = imagesizes + +-- new interface + +local function createimage(specification) + return img_new(specification) +end + +local function copyimage(specification) + return img_copy(specification) +end + +local function scanimage(specification) + return img_scan(specification) +end + +local function embedimage(specification) + -- write the image to file + return img_embed(specification) +end + +local function wrapimage(specification) + -- create an image rule + return img_wrap(specification) +end + +images.create = createimage +images.scan = scanimage +images.copy = copyimage +images.wrap = wrapimage +images.embed = embedimage -local allimagekeys = images.keys() +-- now we reimplement img: + +img = { + new = createimage, + scan = scanimage, + copy = copyimage, + node = wrapimage, + write = function(specification) context(wrapimage(specification)) end, + immediatewrite = embedimage, + immediatewriteobject = function() end, -- not upported, experimental anyway + boxes = function() return sortedkeys(imagesizes) end, + fields = function() return imagekeys end, + types = function() return { unpack(imagetypes,0,#imagetypes) } end, +} + +-- end of copies / mapping local function imagetotable(imgtable) + if type(imgtable) == "table" then + return copy(imgtable) + end local result = { } - for k=1,#allimagekeys do - local key = allimagekeys[k] + for k=1,#imagekeys do + local key = imagekeys[k] result[key] = imgtable[key] end return result @@ -173,41 +273,24 @@ function images.print(i,...) return table.print(imagetotable(i),...) end -function images.clone(i,data) - i.width = data.width or i.width - i.height = data.height or i.height - -- attr etc - return i -end - -local validsizes = table.tohash(images.boxes()) -local validtypes = table.tohash(images.types()) - local function checkimagesize(size) if size then size = gsub(size,"box","") - return validsizes[size] and size or "crop" + return imagesizes[size] and size or "crop" else return "crop" end end -local newimage = images.new -local scanimage = images.scan -local copyimage = images.copy -local cloneimage = images.clone -local imagetonode = images.node +images.check = checkimage +images.checksize = checkimagesize +images.totable = imagetotable -images.check = checkimage -images.checksize = checkimagesize -images.tonode = imagetonode -images.totable = imagetotable - -local indexed = { } - -function images.ofindex(n) - return indexed[n] -end +-- local indexed = { } +-- +-- function images.ofindex(n) +-- return indexed[n] +-- end --- we can consider an grph-ini file @@ -829,7 +912,7 @@ local function register(askedname,specification) end elseif io.exists(oldname) then report_inclusion("file %a is bugged",oldname) - if format and validtypes[format] then + if format and imagetypes[format] then specification.fullname = oldname end specification.converted = false @@ -838,13 +921,13 @@ local function register(askedname,specification) end end if format then - local found = figures_suffixes[format] -- validtypes[format] + local found = figures_suffixes[format] if not found then specification.found = false if trace_figures then report_inclusion("format %a is not supported",format) end - elseif validtypes[format] then + elseif imagetypes[format] then specification.found = true if trace_figures then report_inclusion("format %a natively supported by backend",format) @@ -1407,7 +1490,7 @@ function checkers.generic(data) -- local figure = figures_loaded[hash] if figure == nil then - figure = newimage { + figure = createimage { filename = name, page = page, pagebox = dr.size, @@ -1419,14 +1502,14 @@ function checkers.generic(data) codeinjections.setfigurecolorspace(data,figure) codeinjections.setfiguremask(data,figure) if figure then - -- new, bonus check + -- new, bonus check (a bogus check in lmtx) if page and page > 1 then - local f = scanimage{ + local f = scanimage { filename = name, userpassword = userpassword, ownerpassword = ownerpassword, } - if f.page and f.pages < page then + if f and f.page and f.pages < page then report_inclusion("no page %i in %a, using page 1",page,name) page = 1 figure.page = page @@ -1439,6 +1522,10 @@ function checkers.generic(data) ds.found = false ds.error = true end + if figure.attr and not f.attr then + -- tricky as img doesn't allow it + f.attr = figure.attr + end figure = f end local f, d = codeinjections.setfigurealternative(data,figure) @@ -1492,13 +1579,14 @@ function includers.generic(data) -- width = dr.width, -- height = dr.height, -- } - local copyimage = dr.copyimage or copyimage - local cloneimage = dr.cloneimage or cloneimage if figure == nil then - figure = ds.private + figure = ds.private -- the img object if figure then - figure = copyimage(figure) - figure = figure and cloneimage(figure,data.request) or false + figure = (dr.copyimage or copyimage)(figure) + if figure then + figure.width = dr.width or figure.width + figure.height = dr.height or figure.height + end end figures_used[hash] = figure end @@ -1506,16 +1594,17 @@ function includers.generic(data) local nr = figures.boxnumber nofimages = nofimages + 1 ds.pageindex = nofimages - local image = imagetonode(figure) + local image = wrapimage(figure) local pager = new_latelua(function() pofimages[nofimages] = pofimages[nofimages] or tex.count.realpageno -- so when reused we register the first one only end) image.next = pager pager.prev = image - local box = hpack(image) -- imagetonode(figure) not longer valid - - indexed[figure.index] = figure - box.width, box.height, box.depth = figure.width, figure.height, 0 -- new, hm, tricky, we need to do that in tex (yet) + local box = hpack(image) + -- indexed[figure.index] = figure + box.width = figure.width + box.height = figure.height + box.depth = 0 texsetbox(nr,box) ds.objectnumber = figure.objnum ctx_relocateexternalfigure() @@ -2092,45 +2181,52 @@ local function pdf_checker(data) -- pdfdoc.nofcopiedpages = 0 -- - local info = querypdf(pdfdoc,request.page) - local bbox = info and info.boundingbox or { 0, 0, 0, 0 } - local height = bbox[4] - bbox[2] - local width = bbox[3] - bbox[1] - local rotation = info.rotation or 0 - if rotation == 90 then - rotation, height, width = 3, width, height - elseif rotation == 180 then - rotation = 2 - elseif rotation == 270 then - rotation, height, width = 1, width, height - elseif rotation == 1 or rotation == 3 then - height, width = width, height - else - rotation = 0 + local info = querypdf(pdfdoc,request.page) + if info then + local bbox = info and info.boundingbox or { 0, 0, 0, 0 } + local height = bbox[4] - bbox[2] + local width = bbox[3] - bbox[1] + local rotation = info.rotation or 0 + if rotation == 90 then + rotation, height, width = 3, width, height + elseif rotation == 180 then + rotation = 2 + elseif rotation == 270 then + rotation, height, width = 1, width, height + elseif rotation == 1 or rotation == 3 then + height, width = width, height + else + rotation = 0 + end + return { + filename = filename, + -- page = 1, + pages = pdfdoc.nofpages, + width = width, + height = height, + depth = 0, + colordepth = 0, + xres = 0, + yres = 0, + xsize = width, + ysize = height, + rotation = rotation, + pdfdoc = pdfdoc, + } end - return { - filename = filename, - -- page = 1, - pages = pdfdoc.nofpages, - width = width, - height = height, - depth = 0, - colordepth = 0, - xres = 0, - yres = 0, - xsize = width, - ysize = height, - rotation = rotation, - } end end request.copyimage = function(t) + if not pdfdoc then + pdfdoc = t.pdfdoc + end if pdfdoc then - local result = copypage(pdfdoc,request.page,nil,request.compact) + local result = copypage(pdfdoc,request.page,nil,request.compact,request.width,request.height,request.attr) pdfdoc.nofcopiedpages = pdfdoc.nofcopiedpages + 1 if pdfdoc.nofcopiedpages >= pdfdoc.nofpages then closepdf(pdfdoc) pdfdoc = nil + t.pdfdoc = nil end return result else @@ -2331,19 +2427,29 @@ function bitmaps.new(xsize,ysize,colorspace,colordepth,mask) end local function flush(bitmap) - return img.node(lpdf.injectors.bitmap(bitmap)) + return wrapimage(lpdf.injectors.bitmap(bitmap)) end bitmaps.flush = flush -function bitmaps.tocontext(bitmap) - context.scale ( - { - width = bitmap.xsize .. "bp", - height = bitmap.ysize .. "bp", - }, - flush(bitmap) - ) +function bitmaps.tocontext(bitmap,width,height) + if type(width) == "number" then + width = width .. "sp" + end + if type(height) == "number" then + height = height .. "sp" + end + if width or height then + context.scale ( + { + width = width, + height = height, + }, + flush(bitmap) + ) + else + context(flush(bitmap)) + end end diff --git a/tex/context/base/mkiv/grph-inc.mkiv b/tex/context/base/mkiv/grph-inc.mkiv index cefb114e9..4668b6f48 100644 --- a/tex/context/base/mkiv/grph-inc.mkiv +++ b/tex/context/base/mkiv/grph-inc.mkiv @@ -596,9 +596,9 @@ \def\grph_include_set_mode {\ifcase\figurestatus - \global\resetsystemmode\v!figure % todo, also: \v!resource + \globalresetsystemmode\v!figure % todo, also: \v!resource \else - \global\setsystemmode \v!figure % todo, also: \v!resource + \globalsetsystemmode \v!figure % todo, also: \v!resource \fi} \appendtoks diff --git a/tex/context/base/mkiv/grph-swf.lua b/tex/context/base/mkiv/grph-swf.lua index 30089cdc4..a9297d48d 100644 --- a/tex/context/base/mkiv/grph-swf.lua +++ b/tex/context/base/mkiv/grph-swf.lua @@ -37,9 +37,10 @@ local function getheader(name) buffer = f:read(20) -- ('*a') end f:close() + -- can be done better now that we have stream readers buffer = { match(buffer,"(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)") } for i=1,9 do - buffer[i] = tobitstring(byte(buffer[i])) + buffer[i] = tobitstring(byte(buffer[i]),8,8) end local framebits = concat(buffer,"",1,9) local n = tonumber(sub(framebits,1,5),2) diff --git a/tex/context/base/mkiv/l-number.lua b/tex/context/base/mkiv/l-number.lua index dc4a93b0e..9fd2f82f7 100644 --- a/tex/context/base/mkiv/l-number.lua +++ b/tex/context/base/mkiv/l-number.lua @@ -81,13 +81,14 @@ if bit32 then "0", "0", "0", "0", "0", "0", "0", "0", } - function number.tobitstring(b,m) - -- if really needed we can speed this one up - -- because small numbers need less extraction - local n = 32 - for i=0,31 do + function number.tobitstring(b,m,w) + if not w then + w = 32 + end + local n = w + for i=0,w-1 do local v = bextract(b,i) - local k = 32 - i + local k = w - i if v == 1 then n = k t[k] = "1" @@ -95,12 +96,14 @@ if bit32 then t[k] = "0" end end - if m then + if w then + return concat(t,"",1,w) + elseif m then m = 33 - m * 8 if m < 1 then m = 1 end - return concat(t,"",m) + return concat(t,"",1,m) elseif n < 8 then return concat(t) elseif n < 16 then diff --git a/tex/context/base/mkiv/l-sandbox.lua b/tex/context/base/mkiv/l-sandbox.lua index 2ecec0023..c2e1753d3 100644 --- a/tex/context/base/mkiv/l-sandbox.lua +++ b/tex/context/base/mkiv/l-sandbox.lua @@ -190,6 +190,9 @@ end function sandbox.enable() if not sandboxed then + debug = { + traceback = debug.traceback, + } for i=1,#initializers do initializers[i].action() end diff --git a/tex/context/base/mkiv/l-table.lua b/tex/context/base/mkiv/l-table.lua index 69f45d9b4..eae135139 100644 --- a/tex/context/base/mkiv/l-table.lua +++ b/tex/context/base/mkiv/l-table.lua @@ -11,7 +11,6 @@ local table, string = table, string local concat, sort, insert, remove = table.concat, table.sort, table.insert, table.remove local format, lower, dump = string.format, string.lower, string.dump local getmetatable, setmetatable = getmetatable, setmetatable -local getinfo = debug.getinfo local lpegmatch, patterns = lpeg.match, lpeg.patterns local floor = math.floor @@ -830,22 +829,25 @@ local function do_serialize(root,name,depth,level,indexed) end elseif tv == "function" then if functions then - local f = getinfo(v).what == "C" and dump(dummy) or dump(v) -- maybe strip - -- local f = getinfo(v).what == "C" and dump(function(...) return v(...) end) or dump(v) -- maybe strip - if tk == "number" then - if hexify then - handle(format("%s [0x%X]=load(%q),",depth,k,f)) + local getinfo = debug and debug.getinfo + if getinfo then + local f = getinfo(v).what == "C" and dump(dummy) or dump(v) -- maybe strip + -- local f = getinfo(v).what == "C" and dump(function(...) return v(...) end) or dump(v) -- maybe strip + if tk == "number" then + if hexify then + handle(format("%s [0x%X]=load(%q),",depth,k,f)) + else + handle(format("%s [%s]=load(%q),",depth,k,f)) + end + elseif tk == "boolean" then + handle(format("%s [%s]=load(%q),",depth,k and "true" or "false",f)) + elseif tk ~= "string" then + -- ignore + elseif noquotes and not reserved[k] and lpegmatch(propername,k) then + handle(format("%s %s=load(%q),",depth,k,f)) else - handle(format("%s [%s]=load(%q),",depth,k,f)) + handle(format("%s [%q]=load(%q),",depth,k,f)) end - elseif tk == "boolean" then - handle(format("%s [%s]=load(%q),",depth,k and "true" or "false",f)) - elseif tk ~= "string" then - -- ignore - elseif noquotes and not reserved[k] and lpegmatch(propername,k) then - handle(format("%s %s=load(%q),",depth,k,f)) - else - handle(format("%s [%q]=load(%q),",depth,k,f)) end end else diff --git a/tex/context/base/mkiv/lpdf-ano.lua b/tex/context/base/mkiv/lpdf-ano.lua index 857e53775..c69e9742a 100644 --- a/tex/context/base/mkiv/lpdf-ano.lua +++ b/tex/context/base/mkiv/lpdf-ano.lua @@ -18,6 +18,7 @@ local rep, format, find = string.rep, string.format, string.find local min = math.min local lpegmatch = lpeg.match local formatters = string.formatters +local sortedkeys = table.sortedkeys local backends, lpdf = backends, lpdf @@ -70,7 +71,10 @@ local new_latelua = nodepool.latelua local texgetcount = tex.getcount --- can change: +-- local codeinjections = backends.codeinjections +-- local getpos = codeinjections.getpos +-- local gethpos = codeinjections.gethpos +-- local getvpos = codeinjections.getvpos local getpos = lpdf.getpos local gethpos = lpdf.gethpos @@ -147,9 +151,9 @@ end -- thin without dashing lines. This is as far as I'm prepared to go. This way -- it can also be used as a debug feature. -local pdf_border_style = pdfarray { 0, 0, 0 } -- radius radius linewidth -local pdf_border_color = nil -local set_border = false +local pdf_border_style = pdfarray { 0, 0, 0 } -- radius radius linewidth +local pdf_border_color = nil +local set_border = false local function pdfborder() set_border = true @@ -264,7 +268,7 @@ local function pdfnametree(destinations) if not next(destinations) then return end - local sorted = table.sortedkeys(destinations) + local sorted = sortedkeys(destinations) local size = #sorted if size <= 1.5*maxslice then @@ -274,11 +278,12 @@ local function pdfnametree(destinations) for i=1,size,maxslice do local amount = min(i+maxslice-1,size) local names = pdfarray { } + local n = 0 for j=i,amount do local destination = sorted[j] local pagenumber = destinations[destination] - names[#names+1] = tostring(destination) -- tostring is a safeguard - names[#names+1] = pdfreference(pagenumber) + n = n + 1 ; names[n] = tostring(destination) -- tostring is a safeguard + n = n + 1 ; names[n] = pdfreference(pagenumber) end local first = sorted[i] local last = sorted[amount] @@ -300,6 +305,7 @@ local function pdfnametree(destinations) local l = slices[last] if f and l then local k = pdfarray() + local n = 0 local d = pdfdictionary { Kids = k, Limits = pdfarray { @@ -308,7 +314,7 @@ local function pdfnametree(destinations) }, } for i=first,last do - k[#k+1] = slices[i].reference + n = n + 1 ; k[n] = slices[i].reference end return d end @@ -626,7 +632,7 @@ local function pdffilelink(filename,destination,page,actions) end filename = file.addsuffix(filename,"pdf") if (not destination or destination == "") or (references.outermethod == v_page) then - destination = pdfarray { (page or 0) - 1, pdf_fit } + destination = pdfarray { (page or 1) - 1, pdf_fit } end return pdfdictionary { S = pdf_gotor, -- can also be pdf_launch diff --git a/tex/context/base/mkiv/lpdf-epa.lua b/tex/context/base/mkiv/lpdf-epa.lua index 9c4444181..570d73881 100644 --- a/tex/context/base/mkiv/lpdf-epa.lua +++ b/tex/context/base/mkiv/lpdf-epa.lua @@ -52,6 +52,9 @@ local pdfcopyinteger = lpdf.copyinteger local pdfcopystring = lpdf.copystring local pdfcopyconstant = lpdf.copyconstant +local createimage = images.create +local embedimage = images.embed + local hpack_node = nodes.hpack local loadpdffile = lpdf.epdf.load @@ -74,13 +77,7 @@ local layerspec = { -- predefining saves time "epdfcontent" } --- can change: - -local pdfgetpos = lpdf.getpos - -updaters.register("backend.update",function() - pdfgetpos = lpdf.getpos -end) +local getpos = function() getpos = backends.codeinjections.getpos return getpos () end local collected = allocate() local tobesaved = allocate() @@ -807,8 +804,13 @@ function codeinjections.mergefields(specification) -- direct local AP = annotation.AP or (parent and parent.AP) if AP then - local im = img.new { filename = fullname } - AP = img.immediatewriteobject(im,document.__xrefs__[AP]) + local a = document.__xrefs__[AP] + if a and pdfe.copyappearance then + local o = pdfe.copyappearance(document,a) + if o then + AP = pdfreference(o) + end + end end local dictionary = pdfdictionary { Subtype = pdfconstant("Widget"), diff --git a/tex/context/base/mkiv/lpdf-epd.lua b/tex/context/base/mkiv/lpdf-epd.lua index 5ecb12c47..a5eab016f 100644 --- a/tex/context/base/mkiv/lpdf-epd.lua +++ b/tex/context/base/mkiv/lpdf-epd.lua @@ -1103,7 +1103,7 @@ if img then do local factor = 65536 / (7200/7227) -- 1/number.dimenfactors.bp - local newimage = img.new + local createimage = images.create local function scaledbbox(b) return { b[1]*factor, b[2]*factor, b[3]*factor, b[4]*factor } @@ -1293,7 +1293,7 @@ if img then do page[k] = v -- maybe nested end end - return newimage { + return createimage { bbox = pageinfo.boundingbox, stream = contents(), attr = xobject(), diff --git a/tex/context/base/mkiv/lpdf-fmt.lua b/tex/context/base/mkiv/lpdf-fmt.lua index 0830d2d8d..35c7f46a2 100644 --- a/tex/context/base/mkiv/lpdf-fmt.lua +++ b/tex/context/base/mkiv/lpdf-fmt.lua @@ -753,7 +753,9 @@ function codeinjections.setformat(s) majorversion,minorversion) end -- - pdf.setomitcidset(formatspecification.include_cidsets == false and 1 or 0) + -- cid sets are always omitted now: + -- + -- pdf.setomitcidset(formatspecification.include_cidsets == false and 1 or 0) -- -- context.setupcolors { -- not this way -- cmyk = spec.cmyk_colors and variables.yes or variables.no, diff --git a/tex/context/base/mkiv/lpdf-fnt.lua b/tex/context/base/mkiv/lpdf-fnt.lua index 601e20de3..b759174a9 100644 --- a/tex/context/base/mkiv/lpdf-fnt.lua +++ b/tex/context/base/mkiv/lpdf-fnt.lua @@ -194,3 +194,9 @@ else end lpdf.registerdocumentfinalizer(lpdf.finalizefonts) + +-- already defined in font-ocl but the context variatn will go here +-- +-- function lpdf.vfimage(wd,ht,dp,data,name) +-- return { "image", { filename = name, width = wd, height = ht, depth = dp } } +-- end diff --git a/tex/context/base/mkiv/lpdf-grp.lua b/tex/context/base/mkiv/lpdf-grp.lua index ee6aa5d84..49cc76871 100644 --- a/tex/context/base/mkiv/lpdf-grp.lua +++ b/tex/context/base/mkiv/lpdf-grp.lua @@ -29,6 +29,10 @@ local pdfboolean = lpdf.boolean local pdfreference = lpdf.reference local pdfflushobject = lpdf.flushobject +local createimage = images.create +local wrapimage = images.wrap +local embedimage = images.embed + -- can also be done indirectly: -- -- 12 : << /AntiAlias false /ColorSpace 8 0 R /Coords [ 0.0 0.0 1.0 0.0 ] /Domain [ 0.0 1.0 ] /Extend [ true true ] /Function 22 0 R /ShadingType 2 >> @@ -153,13 +157,18 @@ function nodeinjections.injectbitmap(t) elseif height == 0 then height = width * yresolution / xresolution end - local image = img.new { + local a = pdfdictionary { + BBox = pdfarray { 0, 0, urx * basepoints, ury * basepoints } + } + local image = createimage { stream = formatters[template](d(),t.data), width = width, height = height, bbox = { 0, 0, urx, ury }, + attr = a(), + nobbox = true, } - return img.node(image) + return wrapimage(image) end -- general graphic helpers @@ -181,7 +190,7 @@ function codeinjections.setfigurealternative(data,figure) local displayfigure = figures.check() if displayfigure then -- figure.aform = true - img.immediatewrite(figure) + embedimage(figure) local a = pdfarray { pdfdictionary { Image = pdfreference(figure.objnum), @@ -215,14 +224,14 @@ function codeinjections.getpreviewfigure(request) end local image = figure.status.private if image then - img.immediatewrite(image) + embedimage(image) end return figure end function codeinjections.setfiguremask(data,figure) -- mark local request = data.request - local mask = request.mask + local mask = request.mask if mask and mask ~= "" then figures.push { name = mask, @@ -233,15 +242,16 @@ function codeinjections.setfiguremask(data,figure) -- mark width = request.width, height = request.height, } - figures.identify() - local maskfigure = figures.check() - if maskfigure then - local image = maskfigure.status.private + mask = figures.identify() + mask = figures.check(mask) + if mask then + local image = mask.status.private if image then - img.immediatewrite(image) + figures.include(mask) + embedimage(image) local d = pdfdictionary { Interpolate = false, - SMask = pdfreference(image.objnum), + SMask = pdfreference(mask.status.objectnumber), } figure.attr = d() end @@ -250,46 +260,16 @@ function codeinjections.setfiguremask(data,figure) -- mark end end --- temp hack +-- experimental (q Q is not really needed) -local f_image = formatters["%.6F 0 0 %.6F 0 0 cm /%s Do"] -local f_pattern = formatters["q /Pattern cs /%s scn 0 0 %.6F %.6F re f Q"] -- q Q is not really needed +local f_pattern = formatters["q /Pattern cs /%s scn 0 0 %.6F %.6F re f Q"] directives.register("pdf.stripzeros",function() - f_image = formatters["%.6N 0 0 %.6N 0 0 cm /%s Do"] f_pattern = formatters["q /Pattern cs /%s scn 0 0 %.6N %.6N re f Q"] end) -function img.package(image) -- see lpdf-u3d ** - local boundingbox = image.bbox - local imagetag = "Im" .. image.index - local resources = pdfdictionary { - ProcSet = pdfarray { - pdfconstant("PDF"), - pdfconstant("ImageC") - }, - Resources = pdfdictionary { - XObject = pdfdictionary { - [imagetag] = pdfreference(image.objnum) - } - } - } - local width = boundingbox[3] - local height = boundingbox[4] - local xform = img.scan { - attr = resources(), - stream = f_image(width,height,imagetag), - bbox = { 0, 0, width/basepoints, height/basepoints }, - } - img.immediatewrite(xform) - return xform -end - --- experimental - -local nofpatterns = 0 - -local texsavebox = tex.saveboxresource +local saveboxresource = tex.boxresources.save +local nofpatterns = 0 function lpdf.registerpattern(specification) nofpatterns = nofpatterns + 1 @@ -306,10 +286,11 @@ function lpdf.registerpattern(specification) (specification.voffset or 0) * basepoints, }, } + local resources = lpdf.collectedresources{ patterns = false } local attributes = d() local onlybounds = 1 - local patternobj = texsavebox(specification.number,attributes,resources,true,onlybounds) + local patternobj = saveboxresource(specification.number,attributes,resources,true,onlybounds) lpdf.adddocumentpattern("Pt" .. nofpatterns,lpdf.reference(patternobj )) return nofpatterns end diff --git a/tex/context/base/mkiv/lpdf-img.lua b/tex/context/base/mkiv/lpdf-img.lua index 11aa00787..01a995d21 100644 --- a/tex/context/base/mkiv/lpdf-img.lua +++ b/tex/context/base/mkiv/lpdf-img.lua @@ -31,7 +31,7 @@ local pdfreference = lpdf.reference local pdfmajorversion = lpdf.majorversion local pdfminorversion = lpdf.minorversion -local newimage = img.new +local createimage = images.create local trace = false @@ -61,7 +61,6 @@ do return end local colorspace = specification.colorspace or jpg_gray - local attributes = specification.attr local decodearray = nil ----- procset = colorspace == 0 and "image b" or "image c" if colorspace == 1 then @@ -80,7 +79,7 @@ do local xobject = pdfdictionary { Type = pdfconstant("XObject"), Subtype = pdfconstant("Image"), - BBox = pdfarray { 0, 0, xsize, ysize }, + -- BBox = pdfarray { 0, 0, xsize, ysize }, Width = xsize, Height = ysize, BitsPerComponent = colordepth, @@ -88,14 +87,11 @@ do ColorSpace = pdfconstant(colorspace), Decode = decodearray, Length = #content, -- specification.length - } - if attributes then - -- todo: add attributes to d - end + } + specification.attr if trace then report_jpg("%s: width %i, height %i, colordepth %i, size %i",filename,xsize,ysize,colordepth,#content) end - return newimage { + return createimage { bbox = { 0, 0, specification.width/xsize, specification.height/ysize }, -- mandate nolength = true, nobbox = true, @@ -117,7 +113,6 @@ do if not filename then return end - local attributes = specification.attr -- todo: set filename local xsize = specification.xsize local ysize = specification.ysize @@ -130,14 +125,11 @@ do Height = ysize, Filter = pdfconstant("JPXDecode"), Length = #content, -- specification.length - } - if attributes then - -- todo: add attributes to d - end + } + specification.attr if trace then report_jp2("%s: width %i, height %i, size %i",filename,xsize,ysize,#content) end - return newimage { + return createimage { bbox = { 0, 0, specification.width/xsize, specification.height/ysize }, -- mandate nolength = true, nobbox = true, @@ -918,14 +910,14 @@ t[n] = 0 -- not needed local xobject = pdfdictionary { Type = pdfconstant("XObject"), Subtype = pdfconstant("Image"), - BBox = pdfarray { 0, 0, xsize, ysize }, + -- BBox = pdfarray { 0, 0, xsize, ysize }, Width = xsize, Height = ysize, BitsPerComponent = colordepth, Filter = pdfconstant("FlateDecode"), ColorSpace = palette or pdfconstant(colorspace), Length = #content, - } + } + specification.attr if mask then local d = pdfdictionary { Type = pdfconstant("XObject"), @@ -945,13 +937,10 @@ t[n] = 0 -- not needed Predictor = 15, } end - if attributes then - -- todo: add attributes to d - end if trace then report_png("%s: width %i, height %i, colordepth: %i, size: %i, palette %l, mask: %l, transparent %l, decode %l",filename,xsize,ysize,colordepth,#content,palette,mask,transparent,decode) end - return newimage { + return createimage { bbox = { 0, 0, specification.width/xsize, specification.height/ysize }, -- mandate nolength = true, nobbox = true, @@ -1050,7 +1039,7 @@ do } xobject.SMask = pdfreference(pdfflushstreamobject(pack(specification,"mask"),d())) end - return newimage { + return createimage { bbox = { 0, 0, specification.width/xsize, specification.height/ysize }, -- mandate -- nolength = true, nobbox = true, diff --git a/tex/context/base/mkiv/lpdf-ini.lua b/tex/context/base/mkiv/lpdf-ini.lua index f19245f06..a6702cd35 100644 --- a/tex/context/base/mkiv/lpdf-ini.lua +++ b/tex/context/base/mkiv/lpdf-ini.lua @@ -32,65 +32,61 @@ local context = context -- encoded utf16 string type between <>. We could probably save some bytes by using -- strings between () but then we end up with escaped ()\ too. --- gethpos : used --- getpos : used --- getvpos : used --- --- getmatrix : used --- hasmatrix : used --- --- mapfile : used in font-ctx.lua --- mapline : used in font-ctx.lua --- --- maxobjnum : not used --- obj : used --- immediateobj : used --- objtype : not used --- pageref : used --- print : can be used --- refobj : used --- registerannot : not to be used --- reserveobj : used - --- pdf.catalog : used --- pdf.info : used --- pdf.trailer : used --- pdf.names : not to be used - --- pdf.setinfo : used --- pdf.setcatalog : used --- pdf.setnames : not to be used --- pdf.settrailer : used - --- pdf.getinfo : used --- pdf.getcatalog : used --- pdf.getnames : not to be used --- pdf.gettrailer : used - -local pdf = pdf -local factor = number.dimenfactors.bp - -local pdfsetinfo = pdf.setinfo -local pdfsetcatalog = pdf.setcatalog ------ pdfsettrailerid = pdf.settrailerid ------ pdfsetnames = pdf.setnames ------ pdfsettrailer = pdf.settrailer - -local pdfsetpageresources = pdf.setpageresources -local pdfsetpageattributes = pdf.setpageattributes -local pdfsetpagesattributes = pdf.setpagesattributes - -local pdfgetpos = pdf.getpos -local pdfgethpos = pdf.gethpos -local pdfgetvpos = pdf.getvpos -local pdfgetmatrix = pdf.getmatrix -local pdfhasmatrix = pdf.hasmatrix -local pdfprint = pdf.print - -local pdfreserveobject = pdf.reserveobj -local pdfimmediateobject = pdf.immediateobj -local pdfdeferredobject = pdf.obj -local pdfreferenceobject = pdf.refobj +local pdf = pdf +local factor = number.dimenfactors.bp + +local codeinjections = { } +local nodeinjections = { } + +local backends = backends + +local pdfbackend = { + comment = "backend for directly generating pdf output", + nodeinjections = nodeinjections, + codeinjections = codeinjections, + registrations = { }, + tables = { }, +} + +backends.pdf = pdfbackend + +lpdf = lpdf or { } +local lpdf = lpdf +lpdf.flags = lpdf.flags or { } -- will be filled later + +local pdfsetinfo = pdf.setinfo +local pdfsetcatalog = pdf.setcatalog +----- pdfsetnames = pdf.setnames +----- pdfsettrailer = pdf.settrailer +local pdfsettrailerid = pdf.settrailerid +----- pdfsetomitcidset = pdf.setomitcidset + +local pdfsetpageresources = pdf.setpageresources +local pdfsetpageattributes = pdf.setpageattributes +local pdfsetpagesattributes = pdf.setpagesattributes + +local pdfreserveobject = pdf.reserveobj +local pdfimmediateobject = pdf.immediateobj +local pdfdeferredobject = pdf.obj +local pdfreferenceobject = pdf.refobj + +local pdfgetfontname = pdf.getfontname +local pdfgetfontobjnum = pdf.getfontobjnum +local pdfgetxformname = pdf.getxformname +local pdfincludeimage = pdf.includeimage +local pdfincludechar = pdf.includechar +local pdfgetpagereference = pdf.getpageref or pdf.pageref -- tex.pdfpageref is obsolete +local pdfsetfontattributes = pdf.setfontattributes + +local setmajorversion = pdf.setmajorversion +local setminorversion = pdf.setminorversion +local getmajorversion = pdf.getmajorversion +local getminorversion = pdf.getminorversion + +local setcompresslevel = pdf.setcompresslevel +local setobjectcompresslevel = pdf.setobjcompresslevel +local getcompresslevel = pdf.getcompresslevel +local getobjectcompresslevel = pdf.getobjcompresslevel local function pdfdisablecommand(command) pdf[command] = function() report_blocked("'pdf.%s' is not supported",command) end @@ -100,175 +96,206 @@ pdfdisablecommand("setinfo") pdfdisablecommand("setcatalog") pdfdisablecommand("setnames") pdfdisablecommand("settrailer") +pdfdisablecommand("settrailerid") +pdfdisablecommand("setomitcidset") pdfdisablecommand("setpageresources") pdfdisablecommand("setpageattributes") pdfdisablecommand("setpagesattributes") pdfdisablecommand("registerannot") +pdfdisablecommand("reserveobj") pdf.disablecommand = pdfdisablecommand +updaters.register("backend.update.lpdf",function() + + pdfsetinfo = pdf.setinfo + pdfsetcatalog = pdf.setcatalog + pdfsettrailerid = pdf.settrailerid + + pdfreserveobject = pdf.reserveobj + pdfimmediateobject = pdf.immediateobj + pdfdeferredobject = pdf.obj + pdfreferenceobject = pdf.refobj + pdfsetfontattributes = pdf.setfontattributes + + pdfgetfontname = pdf.getfontname + pdfgetfontobjnum = pdf.getfontobjnum + pdfgetxformname = pdf.getxformname + pdfincludeimage = pdf.includeimage + pdfincludechar = pdf.includechar + pdfgetpagereference = pdf.getpageref + + + setmajorversion = pdf.setmajorversion + setminorversion = pdf.setminorversion + getmajorversion = pdf.getmajorversion + getminorversion = pdf.getminorversion + + setcompresslevel = pdf.setcompresslevel + setobjectcompresslevel = pdf.setobjcompresslevel + getcompresslevel = pdf.getcompresslevel + getobjectcompresslevel = pdf.getobjcompresslevel + + pdfdisablecommand("setinfo") + pdfdisablecommand("setcatalog") + pdfdisablecommand("settrailerid") + + pdfdisablecommand("reserveobj") + pdfdisablecommand("getfontname") + pdfdisablecommand("getfontobjnum") +end) + local trace_finalizers = false trackers.register("backend.finalizers", function(v) trace_finalizers = v end) local trace_resources = false trackers.register("backend.resources", function(v) trace_resources = v end) local trace_objects = false trackers.register("backend.objects", function(v) trace_objects = v end) local trace_detail = false trackers.register("backend.detail", function(v) trace_detail = v end) -local backends = backends -local pdfbackend = { - comment = "backend for directly generating pdf output", - nodeinjections = { }, - codeinjections = { }, - registrations = { }, - tables = { }, -} -backends.pdf = pdfbackend -lpdf = lpdf or { } -local lpdf = lpdf - -lpdf.flags = lpdf.flags or { } -- will be filled later +function lpdf.settrailerid(id) + pdfsettrailerid(id) +end -do +function lpdf.setversion(major,minor) + setmajorversion(major or 1) + setminorversion(minor or 7) +end - local setmajorversion = pdf.setmajorversion - local setminorversion = pdf.setminorversion - local getmajorversion = pdf.getmajorversion - local getminorversion = pdf.getminorversion +function lpdf.getversion(major,minor) + return getmajorversion(), getminorversion() +end - if not setmajorversion then +function lpdf.majorversion() return getmajorversion() end +function lpdf.minorversion() return getminorversion() end - setmajorversion = function() end - getmajorversion = function() return 1 end +function lpdf.getfontname (id) return pdfgetfontname (id) end +function lpdf.getfontobjnumber(id) return pdfgetfontobjnum(id) end - pdf.setmajorversion = setmajorversion - pdf.getmajorversion = getmajorversion +function lpdf.getxformname(id) return pdfgetxformname(id) end +function lpdf.includeimage(id) return pdfincludeimage(id) end - end +function lpdf.includechar (f,c) pdfincludechar(f,c) end +function lpdf.includecharlist(f,c) pdfincludechar(f,c) end -- can be disabled - function lpdf.setversion(major,minor) - setmajorversion(major or 1) - setminorversion(minor or 7) - end +local frozen = false - function lpdf.getversion(major,minor) - return getmajorversion(), getminorversion() +function lpdf.setcompression(level,objectlevel,freeze) + if not frozen then + setcompresslevel(level or 3) + setobjectcompresslevel(objectlevel or level or 3) + frozen = freeze end +end - lpdf.majorversion = getmajorversion - lpdf.minorversion = getminorversion - +function lpdf.getcompression() + return getcompresslevel(), getobjectcompresslevel() end -do +function lpdf.compresslevel () return getcompresslevel () end +function lpdf.objectcompresslevel() return getobjectcompresslevel() end - local setcompresslevel = pdf.setcompresslevel - local setobjectcompresslevel = pdf.setobjcompresslevel - local getcompresslevel = pdf.getcompresslevel - local getobjectcompresslevel = pdf.getobjcompresslevel +do - local frozen = false + local pdfgetpos = pdf.getpos + local pdfgethpos = pdf.gethpos + local pdfgetvpos = pdf.getvpos + local pdfgetmatrix = pdf.getmatrix + local pdfhasmatrix = pdf.hasmatrix + local pdfprint = pdf.print - function lpdf.setcompression(level,objectlevel,freeze) - if not frozen then - setcompresslevel(level or 3) - setobjectcompresslevel(objectlevel or level or 3) - frozen = freeze - end + function lpdf.getpos() + return pdfgetpos() end - function lpdf.getcompression() - return getcompresslevel(), getobjectcompresslevel() + function lpdf.gethpos() + return pdfgethpos() end - lpdf.compresslevel = getcompresslevel - lpdf.objectcompresslevel = getobjectcompresslevel - -end + function lpdf.getvpos() + return pdfgetvpos() + end -local codeinjections = pdfbackend.codeinjections -local nodeinjections = pdfbackend.nodeinjections + pdfbackend.codeinjections.getpos = lpdf.getpos + pdfbackend.codeinjections.gethpos = lpdf.gethpos + pdfbackend.codeinjections.getvpos = lpdf.getvpos --- can change: + updaters.register("backend.update.lpdf",function() + pdfgetpos = pdf.getpos + pdfgethpos = pdf.gethpos + pdfgetvpos = pdf.getvpos + end) -pdfbackend.codeinjections.getpos = pdfgetpos -pdfbackend.codeinjections.gethpos = pdfgethpos -pdfbackend.codeinjections.getvpos = pdfgetvpos + -- todo -lpdf.getpos = pdfgetpos -lpdf.gethpos = pdfgethpos -lpdf.getvpos = pdfgetvpos -lpdf.print = pdfprint + function lpdf.print(...) + return pdfprint(...) + end -updaters.register("backend.update.pdf",function() + pdfbackend.codeinjections.print = lpdf.print - pdfgetpos = pdf.getpos - pdfgethpos = pdf.gethpos - pdfgetvpos = pdf.getvpos - pdfhasmatrix = pdf.hasmatrix - pdfgetmatrix = pdf.getmatrix - pdfprint = pdf.print + updaters.register("backend.update.lpdf",function() + pdfprint = pdf.print + end) - pdfbackend.codeinjections.getpos = pdfgetpos - pdfbackend.codeinjections.gethpos = pdfgethpos - pdfbackend.codeinjections.getvpos = pdfgetvpos + -- todo - lpdf.getpos = pdfgetpos - lpdf.gethpos = pdfgethpos - lpdf.getvpos = pdfgetvpos - lpdf.print = pdfprint + updaters.register("backend.update.lpdf",function() + pdfhasmatrix = pdf.hasmatrix + pdfgetmatrix = pdf.getmatrix + end) -end) + -- local function transform(llx,lly,urx,ury,rx,sx,sy,ry) + -- local x1 = llx * rx + lly * sy + -- local y1 = llx * sx + lly * ry + -- local x2 = llx * rx + ury * sy + -- local y2 = llx * sx + ury * ry + -- local x3 = urx * rx + lly * sy + -- local y3 = urx * sx + lly * ry + -- local x4 = urx * rx + ury * sy + -- local y4 = urx * sx + ury * ry + -- llx = min(x1,x2,x3,x4); + -- lly = min(y1,y2,y3,y4); + -- urx = max(x1,x2,x3,x4); + -- ury = max(y1,y2,y3,y4); + -- return llx, lly, urx, ury + -- end + -- + -- function lpdf.transform(llx,lly,urx,ury) -- not yet used so unchecked + -- if pdfhasmatrix() then + -- local sx, rx, ry, sy = pdfgetmatrix() + -- local w, h = urx - llx, ury - lly + -- return llx, lly, llx + sy*w - ry*h, lly + sx*h - rx*w + -- -- return transform(llx,lly,urx,ury,sx,rx,ry,sy) + -- else + -- return llx, lly, urx, ury + -- end + -- end --- local function transform(llx,lly,urx,ury,rx,sx,sy,ry) --- local x1 = llx * rx + lly * sy --- local y1 = llx * sx + lly * ry --- local x2 = llx * rx + ury * sy --- local y2 = llx * sx + ury * ry --- local x3 = urx * rx + lly * sy --- local y3 = urx * sx + lly * ry --- local x4 = urx * rx + ury * sy --- local y4 = urx * sx + ury * ry --- llx = min(x1,x2,x3,x4); --- lly = min(y1,y2,y3,y4); --- urx = max(x1,x2,x3,x4); --- ury = max(y1,y2,y3,y4); --- return llx, lly, urx, ury --- end --- --- function lpdf.transform(llx,lly,urx,ury) -- not yet used so unchecked --- if pdfhasmatrix() then --- local sx, rx, ry, sy = pdfgetmatrix() --- local w, h = urx - llx, ury - lly --- return llx, lly, llx + sy*w - ry*h, lly + sx*h - rx*w --- -- return transform(llx,lly,urx,ury,sx,rx,ry,sy) --- else --- return llx, lly, urx, ury --- end --- end + -- funny values for tx and ty --- funny values for tx and ty - -function lpdf.rectangle(width,height,depth,offset) - local tx, ty = pdfgetpos() - if offset then - tx = tx - offset - ty = ty + offset - width = width + 2*offset - height = height + offset - depth = depth + offset - end - if pdfhasmatrix() then - local rx, sx, sy, ry = pdfgetmatrix() - return - factor * tx, - factor * (ty - ry*depth + sx*width), - factor * (tx + rx*width - sy*height), - factor * (ty + ry*height - sx*width) - else - return - factor * tx, - factor * (ty - depth), - factor * (tx + width), - factor * (ty + height) + function lpdf.rectangle(width,height,depth,offset) + local tx, ty = pdfgetpos() + if offset then + tx = tx - offset + ty = ty + offset + width = width + 2*offset + height = height + offset + depth = depth + offset + end + if pdfhasmatrix() then + local rx, sx, sy, ry = pdfgetmatrix() + return + factor * tx, + factor * (ty - ry*depth + sx*width), + factor * (tx + rx*width - sy*height), + factor * (ty + ry*height - sx*width) + else + return + factor * tx, + factor * (ty - depth), + factor * (tx + width), + factor * (ty + height) + end end + end -- we could use a hash of predefined unicodes @@ -462,10 +489,14 @@ do tostring_d = function(t,contentonly,key) if next(t) then - local r, n = { }, 0 - for k in next, t do - n = n + 1 - r[n] = k + local r, n, e = { }, 0 + for k, v in next, t do + if k == "__extra__" then + e = v + else + n = n + 1 + r[n] = k + end end sort(r) for i=1,n do @@ -495,6 +526,9 @@ do r[i] = f_key_value(k,tostring(v)) end end + if e then + r[n+1] = e + end if contentonly then return concat(r," ") elseif key then @@ -540,6 +574,10 @@ do r[k] = tostring(v) end end + local e = t.__extra__ + if e then + r[tn+1] = e + end if contentonly then return concat(r, " ") elseif key then @@ -605,11 +643,45 @@ local function value_r(t) return t[1] or 0 end -- null local function value_v(t) return t[1] end local function value_l(t) return t[1] end +local function add_to_d(t,v) + local k = type(v) + if k == "string" then + if t.__extra__ then + t.__extra__ = t.__extra__ .. " " .. v + else + t.__extra__ = v + end + elseif k == "table" then + for k, v in next, v do + t[k] = v + end + end + return t +end + +local function add_to_a(t,v) + local k = type(v) + if k == "string" then + if t.__extra__ then + t.__extra__ = t.__extra__ .. " " .. v + else + t.__extra__ = v + end + elseif k == "table" then + local n = #t + for i=1,#v do + n = n + 1 + t[n] = v[i] + end + end + return t +end + local function add_x(t,k,v) rawset(t,k,tostring(v)) end local mt_x = { __lpdftype = "stream", __tostring = tostring_x, __call = value_x, __newindex = add_x } -local mt_d = { __lpdftype = "dictionary", __tostring = tostring_d, __call = value_d } -local mt_a = { __lpdftype = "array", __tostring = tostring_a, __call = value_a } +local mt_d = { __lpdftype = "dictionary", __tostring = tostring_d, __call = value_d, __add = add_to_d } +local mt_a = { __lpdftype = "array", __tostring = tostring_a, __call = value_a, __add = add_to_a } local mt_u = { __lpdftype = "unicode", __tostring = tostring_u, __call = value_u } local mt_s = { __lpdftype = "string", __tostring = tostring_s, __call = value_s } local mt_p = { __lpdftype = "docstring", __tostring = tostring_p, __call = value_p } @@ -666,60 +738,66 @@ local function pdfliteral(str,hex) -- can also produce a hex <> instead of () li return setmetatable({ str, hex },mt_l) end -local cache = { } -- can be weak +local pdfnumber, pdfconstant -local function pdfnumber(n,default) -- 0-10 - if not n then - n = default - end - local c = cache[n] - if not c then - c = setmetatable({ n },mt_n) - -- cache[n] = c -- too many numbers - end - return c -end +do -for i=-1,9 do cache[i] = pdfnumber(i) end - -local replacer = S("\0\t\n\r\f ()[]{}/%%#\\") / { - ["\00"]="#00", - ["\09"]="#09", - ["\10"]="#0a", - ["\12"]="#0c", - ["\13"]="#0d", - [ " " ]="#20", - [ "#" ]="#23", - [ "%" ]="#25", - [ "(" ]="#28", - [ ")" ]="#29", - [ "/" ]="#2f", - [ "[" ]="#5b", - [ "\\"]="#5c", - [ "]" ]="#5d", - [ "{" ]="#7b", - [ "}" ]="#7d", -} + P(1) - -local escaped = Cs(Cc("/") * replacer^0) - -local cache = table.setmetatableindex(function(t,k) - local v = setmetatable({ lpegmatch(escaped,k) }, mt_c) - t[k] = v - return v -end) + local cache = { } -- can be weak -local function pdfconstant(str,default) - if not str then - str = default or "none" + pdfnumber = function(n,default) -- 0-10 + if not n then + n = default + end + local c = cache[n] + if not c then + c = setmetatable({ n },mt_n) + -- cache[n] = c -- too many numbers + end + return c + end + + for i=-1,9 do cache[i] = pdfnumber(i) end + + local replacer = S("\0\t\n\r\f ()[]{}/%%#\\") / { + ["\00"]="#00", + ["\09"]="#09", + ["\10"]="#0a", + ["\12"]="#0c", + ["\13"]="#0d", + [ " " ]="#20", + [ "#" ]="#23", + [ "%" ]="#25", + [ "(" ]="#28", + [ ")" ]="#29", + [ "/" ]="#2f", + [ "[" ]="#5b", + [ "\\"]="#5c", + [ "]" ]="#5d", + [ "{" ]="#7b", + [ "}" ]="#7d", + } + P(1) + + local escaped = Cs(Cc("/") * replacer^0) + + local cache = table.setmetatableindex(function(t,k) + local v = setmetatable({ lpegmatch(escaped,k) }, mt_c) + t[k] = v + return v + end) + + pdfconstant = function(str,default) + if not str then + str = default or "none" + end + return cache[str] end - return cache[str] -end -local escaped = Cs(replacer^0) + local escaped = Cs(replacer^0) + + function lpdf.escaped(str) + return lpegmatch(escaped,str) or str + end -function lpdf.escaped(str) - return lpegmatch(escaped,str) or str end local pdfnull, pdfboolean, pdfreference, pdfverbose @@ -800,13 +878,7 @@ function lpdf.reserveobject(name) return r end --- lpdf.reserveobject = pdfreserveobject --- lpdf.immediateobject = pdfimmediateobject --- lpdf.deferredobject = pdfdeferredobject --- lpdf.referenceobject = pdfreferenceobject - -local pagereference = pdf.getpageref or pdf.pageref -- tex.pdfpageref is obsolete -local nofpages = 0 +local nofpages = 0 function lpdf.pagereference(n) if nofpages == 0 then @@ -816,9 +888,9 @@ function lpdf.pagereference(n) end end if n > nofpages then - return pagereference(nofpages) -- or 1, could be configureable + return pdfgetpagereference(nofpages) -- or 1, could be configureable else - return pagereference(n) + return pdfgetpagereference(n) end end @@ -826,6 +898,14 @@ function lpdf.nofpages() return structures.pages.nofpages end +function lpdf.obj(...) + pdfdeferredobject(...) +end + +function lpdf.immediateobj(...) + pdfimmediateobject(...) +end + function lpdf.delayedobject(data,n) if n then pdfdeferredobject(n,data) @@ -1030,7 +1110,7 @@ function lpdf.finalizedocument() if not environment.initex then run(documentfinalizers,"document") function lpdf.finalizedocument() - report_finalizing("serious error: the document is finalized multiple times") + -- report_finalizing("serious error: the document is finalized multiple times") function lpdf.finalizedocument() end end end @@ -1061,18 +1141,16 @@ do local info = pdfdictionary { Type = pdfconstant("Info") } -- nicer, but when we assign we nil the Type ----- names = pdfdictionary { Type = pdfconstant("Names") } -- nicer, but when we assign we nil the Type - local function flushcatalog() + local function checkcatalog() if not environment.initex then trace_flush("catalog") - catalog.Type = nil - pdfsetcatalog(catalog()) + return true end end - local function flushinfo() + local function checkinfo() if not environment.initex then trace_flush("info") - info.Type = nil if lpdf.majorversion() > 1 then for k, v in next, info do if k == "CreationDate" or k == "ModDate" then @@ -1082,17 +1160,35 @@ do end end end + return true + end + end + + local function flushcatalog() + if checkcatalog() then + catalog.Type = nil + pdfsetcatalog(catalog()) + end + end + + local function flushinfo() + if checkinfo() then + info.Type = nil pdfsetinfo(info()) end end - -- local function flushnames() - -- if not environment.initex then - -- trace_flush("names") - -- names.Type = nil - -- pdfsetnames(names()) - -- end - -- end + function lpdf.getcatalog() + if checkcatalog() then + return pdfreference(pdfimmediateobject(tostring(catalog))) + end + end + + function lpdf.getinfo() + if checkinfo() then + return pdfreference(pdfimmediateobject(tostring(info))) + end + end function lpdf.addtocatalog(k,v) if not (lpdf.protectresources and catalog[k]) then @@ -1134,20 +1230,19 @@ do end end - local r_extgstates, d_extgstates = pdfreserveobject(), pdfdictionary() local p_extgstates = pdfreference(r_extgstates) - local r_colorspaces, d_colorspaces = pdfreserveobject(), pdfdictionary() local p_colorspaces = pdfreference(r_colorspaces) - local r_patterns, d_patterns = pdfreserveobject(), pdfdictionary() local p_patterns = pdfreference(r_patterns) - local r_shades, d_shades = pdfreserveobject(), pdfdictionary() local p_shades = pdfreference(r_shades) + local r_extgstates, r_colorspaces, r_patterns, r_shades + local d_extgstates, d_colorspaces, d_patterns, d_shades + local p_extgstates, p_colorspaces, p_patterns, p_shades - local function checkextgstates () if next(d_extgstates ) then addtopageresources("ExtGState", p_extgstates ) end end - local function checkcolorspaces() if next(d_colorspaces) then addtopageresources("ColorSpace",p_colorspaces) end end - local function checkpatterns () if next(d_patterns ) then addtopageresources("Pattern", p_patterns ) end end - local function checkshades () if next(d_shades ) then addtopageresources("Shading", p_shades ) end end + local function checkextgstates () if d_extgstates then addtopageresources("ExtGState", p_extgstates ) end end + local function checkcolorspaces() if d_colorspaces then addtopageresources("ColorSpace",p_colorspaces) end end + local function checkpatterns () if d_patterns then addtopageresources("Pattern", p_patterns ) end end + local function checkshades () if d_shades then addtopageresources("Shading", p_shades ) end end - local function flushextgstates () if next(d_extgstates ) then trace_flush("extgstates") pdfimmediateobject(r_extgstates, tostring(d_extgstates )) end end - local function flushcolorspaces() if next(d_colorspaces) then trace_flush("colorspaces") pdfimmediateobject(r_colorspaces,tostring(d_colorspaces)) end end - local function flushpatterns () if next(d_patterns ) then trace_flush("patterns") pdfimmediateobject(r_patterns, tostring(d_patterns )) end end - local function flushshades () if next(d_shades ) then trace_flush("shades") pdfimmediateobject(r_shades, tostring(d_shades )) end end + local function flushextgstates () if d_extgstates then trace_flush("extgstates") pdfimmediateobject(r_extgstates, tostring(d_extgstates )) end end + local function flushcolorspaces() if d_colorspaces then trace_flush("colorspaces") pdfimmediateobject(r_colorspaces,tostring(d_colorspaces)) end end + local function flushpatterns () if d_patterns then trace_flush("patterns") pdfimmediateobject(r_patterns, tostring(d_patterns )) end end + local function flushshades () if d_shades then trace_flush("shades") pdfimmediateobject(r_shades, tostring(d_shades )) end end -- patterns are special as they need resources to so we can get recursive references and in that case -- acrobat doesn't show anything (other viewers handle it well) @@ -1156,10 +1251,10 @@ do -- todo: force when not yet set function lpdf.collectedresources(options) - local ExtGState = next(d_extgstates ) and p_extgstates - local ColorSpace = next(d_colorspaces) and p_colorspaces - local Pattern = next(d_patterns ) and p_patterns - local Shading = next(d_shades ) and p_shades + local ExtGState = d_extgstates and next(d_extgstates ) and p_extgstates + local ColorSpace = d_colorspaces and next(d_colorspaces) and p_colorspaces + local Pattern = d_patterns and next(d_patterns ) and p_patterns + local Shading = d_shades and next(d_shades ) and p_shades if options and options.patterns == false then Pattern = nil end @@ -1176,14 +1271,49 @@ do return collected() end else - return "" + if options and options.serialize == false then + return pdfdictionary { } + else + return "" + end + end + end + + function lpdf.adddocumentextgstate (k,v) + if not d_extgstates then + r_extgstates = pdfreserveobject() + d_extgstates = pdfdictionary() + p_extgstates = pdfreference(r_extgstates) end + d_extgstates[k] = v end - function lpdf.adddocumentextgstate (k,v) d_extgstates [k] = v end - function lpdf.adddocumentcolorspace(k,v) d_colorspaces[k] = v end - function lpdf.adddocumentpattern (k,v) d_patterns [k] = v end - function lpdf.adddocumentshade (k,v) d_shades [k] = v end + function lpdf.adddocumentcolorspace(k,v) + if not d_colorspaces then + r_colorspaces = pdfreserveobject() + d_colorspaces = pdfdictionary() + p_colorspaces = pdfreference(r_colorspaces) + end + d_colorspaces[k] = v + end + + function lpdf.adddocumentpattern(k,v) + if not d_patterns then + r_patterns = pdfreserveobject() + d_patterns = pdfdictionary() + p_patterns = pdfreference(r_patterns) + end + d_patterns[k] = v + end + + function lpdf.adddocumentshade(k,v) + if not d_shades then + r_shades = pdfreserveobject() + d_shades = pdfdictionary() + p_shades = pdfreference(r_shades) + end + d_shades[k] = v + end registerdocumentfinalizer(flushextgstates,3,"extended graphic states") registerdocumentfinalizer(flushcolorspaces,3,"color spaces") @@ -1320,7 +1450,6 @@ function lpdf.checkedvalue(value,variant) -- code not shared end end end - -- return nil end function lpdf.limited(n,min,max,default) @@ -1340,60 +1469,6 @@ function lpdf.limited(n,min,max,default) end end --- if not pdfreferenceobject then --- --- local delayed = { } --- --- local function flush() --- local n = 0 --- for k,v in next, delayed do --- pdfimmediateobject(k,v) --- n = n + 1 --- end --- if trace_objects then --- report_objects("%s objects flushed",n) --- end --- delayed = { } --- end --- --- lpdf.registerdocumentfinalizer(flush,3,"objects") -- so we need a final flush too --- lpdf.registerpagefinalizer (flush,3,"objects") -- somehow this lags behind .. I need to look into that some day --- --- function lpdf.delayedobject(data) --- local n = pdfreserveobject() --- delayed[n] = data --- return n --- end --- --- end - --- setmetatable(pdf, { --- __index = function(t,k) --- if k == "info" then return pdf.getinfo() --- elseif k == "catalog" then return pdf.getcatalog() --- elseif k == "names" then return pdf.getnames() --- elseif k == "trailer" then return pdf.gettrailer() --- elseif k == "pageattribute" then return pdf.getpageattribute() --- elseif k == "pageattributes" then return pdf.getpageattributes() --- elseif k == "pageresources" then return pdf.getpageresources() --- elseif --- return nil --- end --- end, --- __newindex = function(t,k,v) --- if k == "info" then return pdf.setinfo(v) --- elseif k == "catalog" then return pdf.setcatalog(v) --- elseif k == "names" then return pdf.setnames(v) --- elseif k == "trailer" then return pdf.settrailer(v) --- elseif k == "pageattribute" then return pdf.setpageattribute(v) --- elseif k == "pageattributes" then return pdf.setpageattributes(v) --- elseif k == "pageresources" then return pdf.setpageresources(v) --- else --- rawset(t,k,v) --- end --- end, --- }) - -- The next variant of ActualText is what Taco and I could come up with -- eventually. As of September 2013 Acrobat copies okay, Sumatra copies a -- question mark, pdftotext injects an extra space and Okular adds a @@ -1547,5 +1622,57 @@ function lpdf.copystring(v) end end -lpdf.includechar = pdf.includechar -lpdf.includefont = pdf.includefont +do + + local pdf_includechar = pdf.includechar + local pdf_includefont = pdf.includefont + local pdf_setmapfile = pdf.mapfile + local pdf_setmapline = pdf.mapline + + updaters.register("backend.update.lpdf",function() + pdf_includechar = pdf.includechar + pdf_includefont = pdf.includefont + pdf_setmapfile = pdf.mapfile + pdf_setmapline = pdf.mapline + end) + + function lpdf.includechar(...) pdf_includechar(...) end + function lpdf.includefont(...) pdf_includefont(...) end + + function lpdf.setmapfile(...) pdf_setmapfile(...) end + function lpdf.setmapline(...) pdf_setmapline(...) end + +end + +do + + -- This is obsolete but old viewers might still use it as directive + -- for what to send to a postscript printer. + + local a_procset, d_procset + + function lpdf.procset(dict) + if not a_procset then + a_procset = pdfreference(pdfimmediateobject(pdfarray { + pdfconstant("PDF"), + pdfconstant("Text"), + pdfconstant("ImageB"), + pdfconstant("ImageC"), + pdfconstant("ImageI"), + })) + end + if dict then + if not d_procset then + d_procset = pdfreference(pdfimmediateobject(pdfdictionary { + ProcSet = a_procset + })) + end + return d_procset + else + return a_procset + end + end + +end + + diff --git a/tex/context/base/mkiv/lpdf-nod.lua b/tex/context/base/mkiv/lpdf-nod.lua index 2f9282a10..29c3765be 100644 --- a/tex/context/base/mkiv/lpdf-nod.lua +++ b/tex/context/base/mkiv/lpdf-nod.lua @@ -14,6 +14,11 @@ local nodecodes = nodes.nodecodes local whatsit_code = nodecodes.whatsit local whatsitcodes = nodes.whatsitcodes +local pdfliteralcode = whatsitcodes.pdfliteral +local pdfsavecode = whatsitcodes.pdfsave +local pdfrestorecode = whatsitcodes.pdfrestore +local pdfsetmatrixcode = whatsitcodes.pdfsetmatrix + local nodeinjections = backends.nodeinjections local nuts = nodes.nuts @@ -29,31 +34,55 @@ local nodepool = nuts.pool local register = nodepool.register local literalvalues = nodes.literalvalues +local originliteral = literalvalues.origin +local pageliteral = literalvalues.page +local directliteral = literalvalues.direct +local rawliteral = literalvalues.raw -local pdforiginliteral = register(new_node(whatsit_code, whatsitcodes.pdfliteral)) setfield(pdforiginliteral,"mode",literalvalues.origin) -local pdfpageliteral = register(new_node(whatsit_code, whatsitcodes.pdfliteral)) setfield(pdfpageliteral, "mode",literalvalues.page) -local pdfdirectliteral = register(new_node(whatsit_code, whatsitcodes.pdfliteral)) setfield(pdfdirectliteral,"mode",literalvalues.direct) -local pdfrawliteral = register(new_node(whatsit_code, whatsitcodes.pdfliteral)) setfield(pdfrawliteral, "mode",literalvalues.raw) - -local pdfsave = register(new_node(whatsit_code, whatsitcodes.pdfsave)) -local pdfrestore = register(new_node(whatsit_code, whatsitcodes.pdfrestore)) -local pdfsetmatrix = register(new_node(whatsit_code, whatsitcodes.pdfsetmatrix)) ------ pdfdest = register(new_node(whatsit_code, whatsitcodes.pdfdest)) setfield(pdfdest,"named_id",1) -- xyz_zoom untouched ------ pdfannot = register(new_node(whatsit_code, whatsitcodes.pdfannot)) +local pdforiginliteral = register(new_node(whatsit_code, pdfliteralcode)) setfield(pdforiginliteral,"mode",originliteral) +local pdfpageliteral = register(new_node(whatsit_code, pdfliteralcode)) setfield(pdfpageliteral, "mode",pageliteral) +local pdfdirectliteral = register(new_node(whatsit_code, pdfliteralcode)) setfield(pdfdirectliteral,"mode",directliteral) +local pdfrawliteral = register(new_node(whatsit_code, pdfliteralcode)) setfield(pdfrawliteral, "mode",rawliteral) -local variables = interfaces.variables +local pdfsave = register(new_node(whatsit_code, pdfsavecode)) +local pdfrestore = register(new_node(whatsit_code, pdfrestorecode)) +local pdfsetmatrix = register(new_node(whatsit_code, pdfsetmatrixcode)) --- function nodepool.pdforiginliteral(str) local t = copy_node(pdforiginliteral) setfield(t,"data",str) return t end --- function nodepool.pdfpageliteral (str) local t = copy_node(pdfpageliteral ) setfield(t,"data",str) return t end --- function nodepool.pdfdirectliteral(str) local t = copy_node(pdfdirectliteral) setfield(t,"data",str) return t end --- function nodepool.pdfrawliteral (str) local t = copy_node(pdfrawliteral ) setfield(t,"data",str) return t end +local variables = interfaces.variables function nodepool.pdforiginliteral(str) local t = copy_node(pdforiginliteral) setdata(t,str) return t end function nodepool.pdfpageliteral (str) local t = copy_node(pdfpageliteral ) setdata(t,str) return t end function nodepool.pdfdirectliteral(str) local t = copy_node(pdfdirectliteral) setdata(t,str) return t end function nodepool.pdfrawliteral (str) local t = copy_node(pdfrawliteral ) setdata(t,str) return t end -nodepool.pdfliteral = nodepool.pdfpageliteral -- best is to use a specific one: origin | page | direct | raw +-- best is to use a specific one: origin | page | direct | raw + +-- nodepool.pdfliteral = nodepool.pdfpageliteral -- or is origin the default ? + +local pdfliterals = { + -- by number + [originliteral] = pdforiginliteral, + [pageliteral] = pdfpageliteral, + [directliteral] = pdfdirectliteral, + [rawliteral] = pdfrawliteral, + -- by name + [literalvalues[originliteral]] = pdforiginliteral, + [literalvalues[pageliteral]] = pdfpageliteral, + [literalvalues[directliteral]] = pdfdirectliteral, + [literalvalues[rawliteral]] = pdfrawliteral, +} + +function nodepool.pdfliteral(mode,str) + if str then + local t = copy_node(pdfliterals[mode] or pdfpageliteral) + setdata(t,str) + return t + else + local t = copy_node(pdfpageliteral) + setdata(t,mode) + return t + end +end function nodepool.pdfsave() return copy_node(pdfsave) diff --git a/tex/context/base/mkiv/lpdf-pda.xml b/tex/context/base/mkiv/lpdf-pda.xml index efdfc4d7d..4bef927b0 100644 --- a/tex/context/base/mkiv/lpdf-pda.xml +++ b/tex/context/base/mkiv/lpdf-pda.xml @@ -100,40 +100,70 @@ <pdfaSchema:property> <rdf:Seq> <rdf:li rdf:parseType="Resource"> - <pdfaProperty:category>external</pdfaProperty:category> - <pdfaProperty:description>Name of the ConTeXt job</pdfaProperty:description> - <pdfaProperty:name>ConTeXt.Jobname</pdfaProperty:name> - <pdfaProperty:valueType>Text</pdfaProperty:valueType> + <pdfaProperty:category>external</pdfaProperty:category> + <pdfaProperty:description>Name of the ConTeXt job</pdfaProperty:description> + <pdfaProperty:name>ConTeXt.Jobname</pdfaProperty:name> + <pdfaProperty:valueType>Text</pdfaProperty:valueType> </rdf:li> <rdf:li rdf:parseType="Resource"> - <pdfaProperty:category>external</pdfaProperty:category> - <pdfaProperty:description>Time stamp of ConTeXt version</pdfaProperty:description> - <pdfaProperty:name>ConTeXt.Time</pdfaProperty:name> - <pdfaProperty:valueType>Text</pdfaProperty:valueType> + <pdfaProperty:category>external</pdfaProperty:category> + <pdfaProperty:description>Time stamp of ConTeXt version</pdfaProperty:description> + <pdfaProperty:name>ConTeXt.Time</pdfaProperty:name> + <pdfaProperty:valueType>Text</pdfaProperty:valueType> </rdf:li> <rdf:li rdf:parseType="Resource"> - <pdfaProperty:category>external</pdfaProperty:category> - <pdfaProperty:description>ConTeXt website</pdfaProperty:description> - <pdfaProperty:name>ConTeXt.Url</pdfaProperty:name> - <pdfaProperty:valueType>Text</pdfaProperty:valueType> + <pdfaProperty:category>external</pdfaProperty:category> + <pdfaProperty:description>ConTeXt website</pdfaProperty:description> + <pdfaProperty:name>ConTeXt.Url</pdfaProperty:name> + <pdfaProperty:valueType>Text</pdfaProperty:valueType> </rdf:li> <rdf:li rdf:parseType="Resource"> - <pdfaProperty:category>external</pdfaProperty:category> - <pdfaProperty:description>ConTeXt version</pdfaProperty:description> - <pdfaProperty:name>ConTeXt.Version</pdfaProperty:name> - <pdfaProperty:valueType>Text</pdfaProperty:valueType> + <pdfaProperty:category>external</pdfaProperty:category> + <pdfaProperty:description>ConTeXt support</pdfaProperty:description> + <pdfaProperty:name>ConTeXt.Support</pdfaProperty:name> + <pdfaProperty:valueType>Text</pdfaProperty:valueType> </rdf:li> <rdf:li rdf:parseType="Resource"> - <pdfaProperty:category>external</pdfaProperty:category> - <pdfaProperty:description>Banner of pdftex or one of its successors</pdfaProperty:description> - <pdfaProperty:name>PTEX.Fullbanner</pdfaProperty:name> - <pdfaProperty:valueType>Text</pdfaProperty:valueType> + <pdfaProperty:category>external</pdfaProperty:category> + <pdfaProperty:description>ConTeXt version</pdfaProperty:description> + <pdfaProperty:name>ConTeXt.Version</pdfaProperty:name> + <pdfaProperty:valueType>Text</pdfaProperty:valueType> </rdf:li> <rdf:li rdf:parseType="Resource"> - <pdfaProperty:category>external</pdfaProperty:category> - <pdfaProperty:description>Document identifier</pdfaProperty:description> - <pdfaProperty:name>ID</pdfaProperty:name> - <pdfaProperty:valueType>Text</pdfaProperty:valueType> + <pdfaProperty:category>external</pdfaProperty:category> + <pdfaProperty:description>TeX support</pdfaProperty:description> + <pdfaProperty:name>TeX.Support</pdfaProperty:name> + <pdfaProperty:valueType>Text</pdfaProperty:valueType> + </rdf:li> + <rdf:li rdf:parseType="Resource"> + <pdfaProperty:category>external</pdfaProperty:category> + <pdfaProperty:description>LuaTeX version</pdfaProperty:description> + <pdfaProperty:name>LuaTeX.Version</pdfaProperty:name> + <pdfaProperty:valueType>Text</pdfaProperty:valueType> + </rdf:li> + <rdf:li rdf:parseType="Resource"> + <pdfaProperty:category>external</pdfaProperty:category> + <pdfaProperty:description>LuaTeX functionality</pdfaProperty:description> + <pdfaProperty:name>LuaTeX.Functionality</pdfaProperty:name> + <pdfaProperty:valueType>Text</pdfaProperty:valueType> + </rdf:li> + <rdf:li rdf:parseType="Resource"> + <pdfaProperty:category>external</pdfaProperty:category> + <pdfaProperty:description>LuaTeX Lua version</pdfaProperty:description> + <pdfaProperty:name>LuaTeX.LuaVersion</pdfaProperty:name> + <pdfaProperty:valueType>Text</pdfaProperty:valueType> + </rdf:li> + <rdf:li rdf:parseType="Resource"> + <pdfaProperty:category>external</pdfaProperty:category> + <pdfaProperty:description>LuaTeX platform</pdfaProperty:description> + <pdfaProperty:name>LuaTeX.Platform</pdfaProperty:name> + <pdfaProperty:valueType>Text</pdfaProperty:valueType> + </rdf:li> + <rdf:li rdf:parseType="Resource"> + <pdfaProperty:category>external</pdfaProperty:category> + <pdfaProperty:description>Document identifier</pdfaProperty:description> + <pdfaProperty:name>ID</pdfaProperty:name> + <pdfaProperty:valueType>Text</pdfaProperty:valueType> </rdf:li> </rdf:Seq> </pdfaSchema:property> diff --git a/tex/context/base/mkiv/lpdf-pde.lua b/tex/context/base/mkiv/lpdf-pde.lua index d7aa9f40c..907db0b13 100644 --- a/tex/context/base/mkiv/lpdf-pde.lua +++ b/tex/context/base/mkiv/lpdf-pde.lua @@ -67,6 +67,7 @@ local lpdf_epdf = { } lpdf.epdf = lpdf_epdf local openPDF = epdf.open +local newPDF = epdf.new local closePDF = epdf.close local getcatalog = epdf.getcatalog @@ -430,14 +431,17 @@ end local loaded = { } local nofloaded = 0 -function lpdf_epdf.load(filename,userpassword,ownerpassword) +function lpdf_epdf.load(filename,userpassword,ownerpassword,fromstring) local document = loaded[filename] if not document then statistics.starttiming(lpdf_epdf) - local __data__ = openPDF(filename) -- maybe resolvers.find_file + local __data__ + if fromstring then + __data__ = newPDF(filename,#filename) + else + __data__ = openPDF(filename) + end if __data__ then --- nofloaded = nofloaded + 1 --- report_epdf("%04i opened: %s",nofloaded,filename) if userpassword and getstatus(__data__) < 0 then unencrypt(__data__,userpassword,nil) end @@ -815,7 +819,7 @@ if img then do local factor = 65536 / (7200/7227) -- 1/number.dimenfactors.bp - local newimage = img.new + local createimage = images.create directives.register("graphics.pdf.recompress", function(v) recompress = v end) directives.register("graphics.pdf.stripmarked", function(v) stripmarked = v end) @@ -995,6 +999,10 @@ if img then do local openpdf = lpdf_epdf.load local closepdf = lpdf_epdf.unload + local function newpdf(str,userpassword,ownerpassword) + return openpdf(str,userpassword,ownerpassword,true) + end + local function querypdf(pdfdoc,pagenumber) if pdfdoc then if not pagenumber then @@ -1017,12 +1025,14 @@ if img then do trimbox = page.TrimBox or cropbox, artbox = page.ArtBox or cropbox, rotation = page.Rotate or 0, + xsize = cropbox[3] - cropbox[1], + ysize = cropbox[4] - cropbox[2], } end end end - local function copypage(pdfdoc,pagenumber,attributes,compact) + local function copypage(pdfdoc,pagenumber,attributes,compact,width,height,attr) if pdfdoc then local root = pdfdoc.Catalog local page = pdfdoc.pages[pagenumber or 1] @@ -1033,14 +1043,17 @@ if img then do if compact and lpdf_epdf.plugin then plugins = lpdf_epdf.plugin(pdfdoc,xref,copied,page) end - local xobject = pdfdictionary { + local xobject = pdfdictionary { + Type = pdfconstant("XObject"), + Subtype = pdfconstant("Form"), + FormType = 1, Group = copyobject(xref,copied,page,"Group"), LastModified = copyobject(xref,copied,page,"LastModified"), Metadata = copyobject(xref,copied,page,"Metadata"), PieceInfo = copyobject(xref,copied,page,"PieceInfo"), Resources = copyresources(pdfdoc,xref,copied,page), SeparationInfo = copyobject(xref,copied,page,"SeparationInfo"), - } + } + attr if attributes then for k, v in expanded(attributes) do page[k] = v -- maybe nested @@ -1094,12 +1107,22 @@ if img then do elseif rotation > 1 and rotation < 4 then transform = rotation end - return newimage { + xobject.BBox = pdfarray { + boundingbox[1] * bpfactor, + boundingbox[2] * bpfactor, + boundingbox[3] * bpfactor, + boundingbox[4] * bpfactor, + } + -- maybe like bitmaps + return createimage { -- beware: can be a img.new or a dummy bbox = boundingbox, transform = transform, nolength = nolength, + nobbox = true, + notype = true, stream = content, -- todo: no compress, pass directly also length, filter etc attr = xobject(), + -- type = images.types.stream, } end end @@ -1107,10 +1130,17 @@ if img then do lpdf_epdf.image = { open = openpdf, close = closepdf, + new = newpdf, query = querypdf, copy = copypage, } +-- lpdf.injectors.pdf = function(specification) +-- local d = lpdf_epdf.load(specification.filename) +-- print(d) +-- end + + end end -- local d = lpdf_epdf.load("e:/tmp/oeps.pdf") diff --git a/tex/context/base/mkiv/lpdf-pua.xml b/tex/context/base/mkiv/lpdf-pua.xml index f985b54d3..24f05951d 100644 --- a/tex/context/base/mkiv/lpdf-pua.xml +++ b/tex/context/base/mkiv/lpdf-pua.xml @@ -112,14 +112,44 @@ </rdf:li> <rdf:li rdf:parseType="Resource"> <pdfaProperty:category>external</pdfaProperty:category> + <pdfaProperty:description>ConTeXt support</pdfaProperty:description> + <pdfaProperty:name>ConTeXt.Support</pdfaProperty:name> + <pdfaProperty:valueType>Text</pdfaProperty:valueType> + </rdf:li> + <rdf:li rdf:parseType="Resource"> + <pdfaProperty:category>external</pdfaProperty:category> <pdfaProperty:description>ConTeXt version</pdfaProperty:description> <pdfaProperty:name>ConTeXt.Version</pdfaProperty:name> <pdfaProperty:valueType>Text</pdfaProperty:valueType> </rdf:li> <rdf:li rdf:parseType="Resource"> <pdfaProperty:category>external</pdfaProperty:category> - <pdfaProperty:description>Banner of pdftex or one of its successors</pdfaProperty:description> - <pdfaProperty:name>PTEX.Fullbanner</pdfaProperty:name> + <pdfaProperty:description>TeX support</pdfaProperty:description> + <pdfaProperty:name>TeX.Support</pdfaProperty:name> + <pdfaProperty:valueType>Text</pdfaProperty:valueType> + </rdf:li> + <rdf:li rdf:parseType="Resource"> + <pdfaProperty:category>external</pdfaProperty:category> + <pdfaProperty:description>LuaTeX version</pdfaProperty:description> + <pdfaProperty:name>LuaTeX.Version</pdfaProperty:name> + <pdfaProperty:valueType>Text</pdfaProperty:valueType> + </rdf:li> + <rdf:li rdf:parseType="Resource"> + <pdfaProperty:category>external</pdfaProperty:category> + <pdfaProperty:description>LuaTeX functionality</pdfaProperty:description> + <pdfaProperty:name>LuaTeX.Functionality</pdfaProperty:name> + <pdfaProperty:valueType>Text</pdfaProperty:valueType> + </rdf:li> + <rdf:li rdf:parseType="Resource"> + <pdfaProperty:category>external</pdfaProperty:category> + <pdfaProperty:description>LuaTeX Lua version</pdfaProperty:description> + <pdfaProperty:name>LuaTeX.LuaVersion</pdfaProperty:name> + <pdfaProperty:valueType>Text</pdfaProperty:valueType> + </rdf:li> + <rdf:li rdf:parseType="Resource"> + <pdfaProperty:category>external</pdfaProperty:category> + <pdfaProperty:description>LuaTeX platform</pdfaProperty:description> + <pdfaProperty:name>LuaTeX.Platform</pdfaProperty:name> <pdfaProperty:valueType>Text</pdfaProperty:valueType> </rdf:li> <rdf:li rdf:parseType="Resource"> diff --git a/tex/context/base/mkiv/lpdf-res.lua b/tex/context/base/mkiv/lpdf-res.lua index 8b00835ef..87d3d42f5 100644 --- a/tex/context/base/mkiv/lpdf-res.lua +++ b/tex/context/base/mkiv/lpdf-res.lua @@ -17,12 +17,15 @@ local setlist = nuts.setlist local new_hlist = nuts.pool.hlist -local saveboxresource = tex.saveboxresource -local useboxresource = tex.useboxresource -local getboxresource = tex.getboxresourcedimensions +local boxresources = tex.boxresources +local saveboxresource = boxresources.save +local useboxresource = boxresources.use +local getboxresourcedimensions = boxresources.getdimensions + +local pdfcollectedresources = lpdf.collectedresources function codeinjections.registerboxresource(n,offset) - local r = saveboxresource(n,nil,lpdf.collectedresources(),true,0,offset or 0) -- direct, todo: accept functions as attr/resources + local r = saveboxresource(n,nil,pdfcollectedresources(),true,0,offset or 0) -- direct, todo: accept functions as attr/resources return r end @@ -35,5 +38,5 @@ function codeinjections.restoreboxresource(index) end function codeinjections.boxresourcedimensions(index) - return getboxresource(index) + return getboxresourcedimensions(index) end diff --git a/tex/context/base/mkiv/lpdf-swf.lua b/tex/context/base/mkiv/lpdf-swf.lua index 7d76efc73..44e42dc5f 100644 --- a/tex/context/base/mkiv/lpdf-swf.lua +++ b/tex/context/base/mkiv/lpdf-swf.lua @@ -11,6 +11,7 @@ if not modules then modules = { } end modules ['lpdf-swf'] = { local format, gsub = string.format, string.gsub local concat = table.concat +local formatters = string.formatters local backends = backends local lpdf = lpdf @@ -33,6 +34,43 @@ local trace_swf = false trackers.register("backend.swf", function(v) trace_swf local report_swf = logs.reporter("backend","swf") +-------------------------------------------------------------------------------------- + +local createimage = images.create +local embedimage = images.embed + +local basepoints = number.dimenfactors.bp + +local f_image = formatters["%.6F 0 0 %.6F 0 0 cm /%s Do"] + +directives.register("pdf.stripzeros",function() + f_image = formatters["%.6N 0 0 %.6N 0 0 cm /%s Do"] +end) + +local function package(image) -- see lpdf-u3d ** + local boundingbox = image.bbox + local imagetag = "Im" .. image.index -- this is not ok + local resources = pdfdictionary { + ProcSet = lpdf.procset(), + Resources = pdfdictionary { + XObject = pdfdictionary { + [imagetag] = pdfreference(image.objnum) + } + } + } + local width = boundingbox[3] + local height = boundingbox[4] + local xform = createimage { + attr = resources(), + stream = f_image(width,height,imagetag), + bbox = { 0, 0, width/basepoints, height/basepoints }, + } + embedimage(xform) + return xform +end + +-------------------------------------------------------------------------------------- + local activations = { click = "XA", page = "PO", @@ -279,7 +317,7 @@ local function insertswf(spec) end end if figure then - local image = img.package(figure.status.private) + local image = package(figure.status.private) appearance = pdfdictionary { N = pdfreference(image.objnum) } if trace_swf then report_swf("using preview %s",preview) diff --git a/tex/context/base/mkiv/lpdf-tag.lua b/tex/context/base/mkiv/lpdf-tag.lua index 534519c8a..d57da4ccd 100644 --- a/tex/context/base/mkiv/lpdf-tag.lua +++ b/tex/context/base/mkiv/lpdf-tag.lua @@ -71,14 +71,13 @@ local tosequence = nuts.tosequence local nextnode = nuts.traversers.node -local structure_stack = { } -local structure_kids = pdfarray() -local structure_ref = pdfreserveobject() -local parent_ref = pdfreserveobject() -local root = { pref = pdfreference(structure_ref), kids = structure_kids } +local structure_kids -- delayed +local structure_ref -- delayed +local parent_ref -- delayed +local root -- delayed local tree = { } local elements = { } -local names = pdfarray() +local names = false -- delayed local structurestags = structures.tags local taglist = structurestags.taglist @@ -112,7 +111,7 @@ local usedmapping = { } -- end local function finishstructure() - if #structure_kids > 0 then + if root and names and #structure_kids > 0 then local nums, n = pdfarray(), 0 for i=1,#tree do n = n + 1 ; nums[n] = i - 1 @@ -259,8 +258,13 @@ local function makeelement(fulltag,parent) } local s = pdfreference(pdfflushobject(d)) if id then - names[#names+1] = id - names[#names+1] = s + if names then + local size = #names + names[size+1] = id + names[size+2] = s + else + names= { id, s } + end end local kids = parent.kids kids[#kids+1] = s @@ -329,6 +333,13 @@ function nodeinjections.addtags(head) local ranges = { } local range = nil + if not root then + structure_kids = pdfarray() + structure_ref = pdfreserveobject() + parent_ref = pdfreserveobject() + root = { pref = pdfreference(structure_ref), kids = structure_kids } + end + local function collectranges(head,list) for n, id in nextnode, head do if id == glyph_code then diff --git a/tex/context/base/mkiv/lpdf-u3d.lua b/tex/context/base/mkiv/lpdf-u3d.lua index 2a45a1eb5..fff89dc0f 100644 --- a/tex/context/base/mkiv/lpdf-u3d.lua +++ b/tex/context/base/mkiv/lpdf-u3d.lua @@ -39,6 +39,8 @@ local pdfflushstreamfileobject = lpdf.flushstreamfileobject local checkedkey = lpdf.checkedkey local limited = lpdf.limited +local embedimage = images.embed + local schemes = table.tohash { "Artwork", "None", "White", "Day", "Night", "Hard", "Primary", "Blue", "Red", "Cube", "CAD", "Headlamp", @@ -437,7 +439,7 @@ local function insert3d(spec) -- width, height, factor, display, controls, label local tag = formatters["%s:%s:%s"](label,stream,preview) local ref = stored_pr[tag] if not ref then - local figure = img.immediatewrite { + local figure = embedimage { filename = preview, width = width, height = height @@ -453,6 +455,7 @@ local function insert3d(spec) -- width, height, factor, display, controls, label FormType = one, BBox = pdfarray { zero, zero, pdfnumber(factor*width), pdfnumber(factor*height) }, Matrix = pdfarray { one, zero, zero, one, zero, zero }, + ProcSet = lpdf.procset(), Resources = pdfdictionary { XObject = pdfdictionary { IM = pdfreference(ref) @@ -465,7 +468,6 @@ local function insert3d(spec) -- width, height, factor, display, controls, label ca = one, } }, - ProcSet = pdfarray { pdfconstant("PDF"), pdfconstant("ImageC") }, } local pwd = pdfflushstreamobject(f_image(factor*width,factor*height),pw) annot.AP = pdfdictionary { diff --git a/tex/context/base/mkiv/lpdf-xmp.lua b/tex/context/base/mkiv/lpdf-xmp.lua index ac07e4a3d..3693df2a8 100644 --- a/tex/context/base/mkiv/lpdf-xmp.lua +++ b/tex/context/base/mkiv/lpdf-xmp.lua @@ -11,6 +11,7 @@ local tostring, type = tostring, type local format, gsub = string.format, string.gsub local utfchar = utf.char local xmlfillin = xml.fillin +local md5HEX = md5.HEX local trace_xmp = false trackers.register("backend.xmp", function(v) trace_xmp = v end) local trace_info = false trackers.register("backend.info", function(v) trace_info = v end) @@ -33,7 +34,7 @@ local pdfgetmetadata = lpdf.getmetadata -- XMP-Toolkit-SDK-CC201607.zip. So we hardcode the id. local xpacket = format ( [[ -<?xpacket begin="%s" id="W5M0MpCehiHzreSzNTczkc9d"?> +<?xpacket begin="%s" id="W5M0MpCehiHzreSzNTczkc9d"?> %%s @@ -104,16 +105,13 @@ pdf.setsuppressoptionalinfo( ) local included = backends.included - -local pdfsettrailerid = pdf.settrailerid - -local lpdfid = lpdf.id +local lpdfid = lpdf.id function lpdf.id() -- overload of ini return lpdfid(included.date) end -pdf.disablecommand("settrailerid") +local pdfsettrailerid = lpdf.settrailerid -- this is the wrapped one function lpdf.settrailerid(v) if v then @@ -123,7 +121,7 @@ function lpdf.settrailerid(v) else v = tostring(v) end - local h = md5.HEX(v) + local h = md5HEX(v) if b then report_info("using frozen trailer id") else @@ -313,7 +311,7 @@ local function flushxmpinfo() commands.poprandomseed() -- hack end --- his will be enabled when we can inhibit compression for a stream at the lua end +-- this will be enabled when we can inhibit compression for a stream at the lua end lpdf.registerdocumentfinalizer(flushxmpinfo,1,"metadata") diff --git a/tex/context/base/mkiv/luat-fio.lua b/tex/context/base/mkiv/luat-fio.lua index 806caefe6..1a9ebe40b 100644 --- a/tex/context/base/mkiv/luat-fio.lua +++ b/tex/context/base/mkiv/luat-fio.lua @@ -70,6 +70,8 @@ if not resolvers.initialized() then return okay or "" end + resolvers.findpk = findpk + -- register('process_jobname' , function(name) return name end, true) register('find_read_file' , function(id,name) return findtexfile(name) end, true) diff --git a/tex/context/base/mkiv/lxml-ini.mkiv b/tex/context/base/mkiv/lxml-ini.mkiv index c4d6176ec..a06a9ed6e 100644 --- a/tex/context/base/mkiv/lxml-ini.mkiv +++ b/tex/context/base/mkiv/lxml-ini.mkiv @@ -405,7 +405,7 @@ \c!entities=\v!no] % load big entity file \appendtoks - \doif{\directxmlparameter\c!entities}\clf_xmlloadentities + \doif{\directxmlparameter\c!entities}\v!yes\clf_xmlloadentities \to \everysetupxml \def\xmlmapvalue #1#2#3{\setvalue{\??xmlmapvalue#1:#2}{#3}} % keep #3 to grab spaces diff --git a/tex/context/base/mkiv/mlib-lua.lua b/tex/context/base/mkiv/mlib-lua.lua index 09169e155..c155d7733 100644 --- a/tex/context/base/mkiv/mlib-lua.lua +++ b/tex/context/base/mkiv/mlib-lua.lua @@ -317,84 +317,84 @@ do end end - -- local function mp_path(f2,f6,t,connector,cycle) - -- if type(t) == "table" then - -- local tn = #t - -- if tn > 0 then - -- if connector == true then - -- connector = "--" - -- cycle = true - -- elseif not connector then - -- connector = "--" - -- end - -- local ti = t[1] - -- n = n + 1 ; - -- if #ti == 6 then - -- local tn = t[2] or t[1] - -- buffer[n] = f6(ti[1],ti[2],ti[5],ti[6],tn[3],tn[4]) - -- else - -- buffer[n] = f2(ti[1],ti[2]) - -- end - -- for i=2,tn do - -- local ti = t[i] - -- n = n + 1 ; buffer[n] = connector - -- n = n + 1 ; - -- if #ti == 6 and (i < tn or cycle) then - -- local tn = t[i+1] or t[1] - -- buffer[n] = f6(ti[1],ti[2],ti[5],ti[6],tn[3],tn[4]) - -- else - -- buffer[n] = f2(ti[1],ti[2]) - -- end - -- end - -- if cycle then - -- n = n + 1 ; buffer[n] = connector - -- n = n + 1 ; buffer[n] = "cycle" - -- end - -- end - -- end - -- end + -- we have three kind of connectors: + -- + -- .. ... -- (true) local function mp_path(f2,f6,t,connector,cycle) if type(t) == "table" then local tn = #t - if tn > 0 then - if connector == true then - connector = "--" - cycle = true - elseif not connector then + if tn == 1 then + local t1 = t[1] + n = n + 1 ; buffer[n] = f2(t1[1],t1[2]) + elseif tn > 0 then + if connector == true or connector == nil then + connector = ".." + elseif connector == false then connector = "--" end - local ti = t[1] - n = n + 1 ; - if #ti == 6 then - buffer[n] = f6(ti[1],ti[2],ti[3],ti[4],ti[5],ti[6]) + if cycle == nil then + cycle = t.cycle + if cycle == nil then + cycle = true + end + end + local six = connector == ".." -- otherwise we use whatever gets asked for + local controls = connector -- whatever + local a = t[1] + local b = t[2] + n = n + 1 + if six and #a == 6 and #b == 6 then + buffer[n] = f6(a[1],a[2],a[5],a[6],b[3],b[4]) + controls = ".." else - buffer[n] = f2(ti[1],ti[2]) + buffer[n] = f2(a[1],a[2]) + controls = connector end - for i=2,tn do - local ti = t[i] - n = n + 1 ; buffer[n] = connector - n = n + 1 ; - if #ti == 6 then - buffer[n] = f6(ti[1],ti[2],ti[3],ti[4],ti[5],ti[6]) + for i=2,tn-1 do + a = b + b = t[i+1] + n = n + 1 + buffer[n] = connector + n = n + 1 + if six and #a == 6 and #b == 6 then + buffer[n] = f6(a[1],a[2],a[5],a[6],b[3],b[4]) + controls = ".." else - buffer[n] = f2(ti[1],ti[2]) + buffer[n] = f2(a[1],a[2]) + controls = connector end end + n = n + 1 + buffer[n] = connector + a = b + b = t[1] + n = n + 1 if cycle then - n = n + 1 ; buffer[n] = connector - n = n + 1 ; buffer[n] = "cycle" + if six and #a == 6 and #b == 6 then + buffer[n] = f6(a[1],a[2],a[5],a[6],b[3],b[4]) + controls = ".." + else + buffer[n] = f2(a[1],a[2]) + controls = connector + end + n = n + 1 + buffer[n] = connector + n = n + 1 + buffer[n] = "cycle" + else + buffer[n] = f2(a[1],a[2]) end end end end local function mppath(...) - mp_path(f_pair,f_pair_ctrl,...) + mp_path(f_pair,f_ctrl,...) end local function mppathpoints(...) - mp_path(f_pair_pt,f_pair_pt_ctrl,...) + mp_path(f_pair_pt,f_ctrl_pt,...) end local function mpsize(t) diff --git a/tex/context/base/mkiv/mlib-pdf.lua b/tex/context/base/mkiv/mlib-pdf.lua index b461e11e4..c3c8c00da 100644 --- a/tex/context/base/mkiv/mlib-pdf.lua +++ b/tex/context/base/mkiv/mlib-pdf.lua @@ -46,7 +46,8 @@ metapost.optimize = true -- false local experiment = true -- uses context(node) that already does delayed nodes local savedliterals = nil -- needs checking -local mpsliteral = nodes.pool.register(node.new("whatsit",nodes.whatsitcodes.pdfliteral)) -- pdfliteral.mode = 1 +----- mpsliteral = nodes.pool.register(node.new("whatsit",nodes.whatsitcodes.pdfliteral)) +local mpsliteral = nodes.pool.pdforiginliteral local f_f = formatters["%.6F"] local f_m = formatters["%.6F %.6F m"] @@ -86,11 +87,11 @@ trackers.register("metapost.forcestroke",function(v) force_stroke = v end) -local pdfliteral = function(pdfcode) - local literal = copy_node(mpsliteral) - literal.data = pdfcode - return literal -end +-- local pdfliteral = function(pdfcode) +-- local literal = copy_node(mpsliteral) +-- literal.data = pdfcode +-- return literal +-- end -- Because in MKiV we always have two passes, we save the objects. When an extra -- mp run is done (due to for instance texts identifier in the parse pass), we @@ -142,9 +143,10 @@ end function metapost.flushliteral(d) if savedliterals then - local literal = copy_node(mpsliteral) - literal.data = savedliterals[d] - write_node(literal) +-- local literal = copy_node(mpsliteral) +-- literal.data = savedliterals[d] +-- write_node(literal) + write_node(mpsliteral(savedliterals[d])) else report_metapost("problem flushing literal %a",d) end @@ -158,7 +160,8 @@ function pdfflusher.comment(message) if message then message = formatters["%% mps graphic %s: %s"](metapost.n,message) if experiment then - context(pdfliteral(message)) + -- context(pdfliteral(message)) + context(mpsliteral(message)) elseif savedliterals then local last = #savedliterals + 1 savedliterals[last] = message @@ -187,7 +190,8 @@ function pdfflusher.flushfigure(pdfliterals) -- table if #pdfliterals > 0 then pdfliterals = concat(pdfliterals,"\n") if experiment then - context(pdfliteral(pdfliterals)) + -- context(pdfliteral(pdfliterals)) + context(mpsliteral(pdfliterals)) else if savedliterals then local last = #savedliterals + 1 diff --git a/tex/context/base/mkiv/mtx-context-fonts.tex b/tex/context/base/mkiv/mtx-context-fonts.tex new file mode 100644 index 000000000..f1f74c9e9 --- /dev/null +++ b/tex/context/base/mkiv/mtx-context-fonts.tex @@ -0,0 +1,98 @@ +%D \module +%D [ file=mtx-context-fonts, +%D version=2018.10.10, +%D title=\CONTEXT\ Extra Trickry, +%D subtitle=Show Font Info, +%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. + +% begin help +% +% usage: context --extra=fonts [options] name +% +% --topspace=dimension : distance above first line +% --backspace=dimension : distance before left margin +% --paperformat=spec : paper*print or paperxprint +% --compact : small margins, 8pt font +% --verycompact : small margins, 7pt font +% +% example: context --extra=fonts --name=dejavu-serif +% end help + +\input mtx-context-common.tex + +\usemodule[fonts-charts] +\usemodule[fonts-tables] + +\input mtx-context-common.tex + +\doifdocumentargument {compact} { + \setdocumentargument{topspace} {5mm} + \setdocumentargument{backspace}{5mm} + \setdocumentargument{bodyfont} {8pt} +} + +\doifdocumentargument {verycompact} { + \setdocumentargument{topspace} {5mm} + \setdocumentargument{backspace}{5mm} + \setdocumentargument{bodyfont} {7pt} +} + +\setupbodyfont + [dejavu,9pt,tt,\getdocumentargument{bodyfont}] % dejavu is more complete + +\setuplayout + [header=0cm, + footer=1.5cm, + topspace=\getdocumentargumentdefault{topspace}{1.5cm}, + backspace=\getdocumentargumentdefault{backspace}{1.5cm}, + width=middle, + height=middle] + +\setuppapersize + [\getdocumentargument{paperformat_paper}] + [\getdocumentargument{paperformat_print}] + +\starttexdefinition unexpanded showfontdetails [#1] + \starttitle[title=#1] + \startsubject[title=Properties] + \showfontproperties[#1] + \stopsubject + \startsubject[title=Parameters] + \showfontparameters[#1] + \stopsubject + \startsubject[title=Positionings] + \showfontpositionings[#1] + \stopsubject + \startsubject[title=Substitutions] + \showfontsubstitutions[#1] + \stopsubject + \startsubject[title=Unicodevariants] + \showfontunicodevariants[#1] + \stopsubject + \startsubject[title=Ligatures] + \showfontligatures[#1] + \stopsubject + \showfontchart[#1,page=yes] + \stoptitle +\stoptexdefinition + +\starttext + + \startluacode + local files = document.files + if #files > 0 then + for i=1,#files do + context.showfontdetails { name = files[i] .. "*default" } + end + else + context("No font name(s) given.") + end + \stopluacode + +\stoptext diff --git a/tex/context/base/mkiv/mult-low.lua b/tex/context/base/mkiv/mult-low.lua index 9eaaa1850..1630429b7 100644 --- a/tex/context/base/mkiv/mult-low.lua +++ b/tex/context/base/mkiv/mult-low.lua @@ -162,6 +162,7 @@ return { -- "newmode", "setmode", "resetmode", "newsystemmode", "setsystemmode", "resetsystemmode", "pushsystemmode", "popsystemmode", + "globalsetmode", "globalresetmode", "globalsetsystemmode", "globalresetsystemmode", "booleanmodevalue", -- "newcount", "newdimen", "newskip", "newmuskip", "newbox", "newtoks", "newread", "newwrite", "newmarks", "newinsert", "newattribute", "newif", diff --git a/tex/context/base/mkiv/node-ini.lua b/tex/context/base/mkiv/node-ini.lua index f7f815222..e4011ef59 100644 --- a/tex/context/base/mkiv/node-ini.lua +++ b/tex/context/base/mkiv/node-ini.lua @@ -70,6 +70,12 @@ local formatcolumns = utilities.formatters.formatcolumns local getsubtypes = node.subtypes local getvalues = node.values +tex.magicconstants = { -- we use tex.constants for something else + running = -1073741824, + maxdimen = 1073741823, -- 0x3FFFFFFF or 2^30-1 + trueinch = 4736286, +} + -- local listcodes = allocate { -- [0] = "unknown", -- [1] = "line", diff --git a/tex/context/base/mkiv/node-ltp.lua b/tex/context/base/mkiv/node-ltp.lua index 4044dc105..a8de4d783 100644 --- a/tex/context/base/mkiv/node-ltp.lua +++ b/tex/context/base/mkiv/node-ltp.lua @@ -995,7 +995,7 @@ local function initialize_line_break(head,display) double_hyphen_demerits = tex.doublehyphendemerits or 0, final_hyphen_demerits = tex.finalhyphendemerits or 0, - first_line = 0, -- tex.nest[tex.nest.ptr].modeline, -- 0, -- cur_list.pg_field + first_line = 0, -- texnest[texnest.ptr].modeline, -- 0, -- cur_list.pg_field -- each_line_height = tex.pdfeachlineheight or 0, -- this will go away -- each_line_depth = tex.pdfeachlinedepth or 0, -- this will go away diff --git a/tex/context/base/mkiv/node-res.lua b/tex/context/base/mkiv/node-res.lua index 1434e51dd..983899c1b 100644 --- a/tex/context/base/mkiv/node-res.lua +++ b/tex/context/base/mkiv/node-res.lua @@ -30,7 +30,12 @@ local gluecodes = nodes.gluecodes local boundarycodes = nodes.boundarycodes local usercodes = nodes.usercodes -local glyph_code = nodecodes.glyph + +local glyphcode = nodecodes.glyph +local rulecode = nodecodes.rule +local kerncode = nodecodes.kern +local gluecode = nodecodes.glue +local whatsitcode = nodecodes.whatsit local currentfont = font.current @@ -154,21 +159,22 @@ nutpool.register = register_node -- could be register_nut -- so far local disc = register_nut(new_nut(nodecodes.disc)) -local kern = register_nut(new_nut(nodecodes.kern,kerncodes.userkern)) -local fontkern = register_nut(new_nut(nodecodes.kern,kerncodes.fontkern)) -local italickern = register_nut(new_nut(nodecodes.kern,kerncodes.italiccorrection)) +local kern = register_nut(new_nut(kerncode,kerncodes.userkern)) +local fontkern = register_nut(new_nut(kerncode,kerncodes.fontkern)) +local italickern = register_nut(new_nut(kerncode,kerncodes.italiccorrection)) local penalty = register_nut(new_nut(nodecodes.penalty)) -local glue = register_nut(new_nut(nodecodes.glue)) -- glue.spec = nil +local glue = register_nut(new_nut(gluecode)) -- glue.spec = nil local glue_spec = register_nut(new_nut(nodecodes.gluespec)) -local glyph = register_nut(new_nut(nodecodes.glyph,0)) +local glyph = register_nut(new_nut(glyphcode,0)) local textdir = register_nut(new_nut(nodecodes.dir)) -local latelua = register_nut(new_nut(nodecodes.whatsit,whatsitcodes.latelua)) -local special = register_nut(new_nut(nodecodes.whatsit,whatsitcodes.special)) +local latelua = register_nut(new_nut(whatsitcode,whatsitcodes.latelua)) +local special = register_nut(new_nut(whatsitcode,whatsitcodes.special)) +local savepos = register_nut(new_nut(whatsitcode,whatsitcodes.savepos)) -local user_node = new_nut(nodecodes.whatsit,whatsitcodes.userdefined) +local user_node = new_nut(whatsitcode,whatsitcodes.userdefined) local user_number = register_nut(copy_nut(user_node)) setfield(user_number, "type",usercodes.number) local user_nodes = register_nut(copy_nut(user_node)) setfield(user_nodes, "type",usercodes.node) @@ -180,10 +186,10 @@ local user_attributes = register_nut(copy_nut(user_node)) setfield(user_attrib local left_margin_kern = register_nut(new_nut(nodecodes.marginkern,0)) local right_margin_kern = register_nut(new_nut(nodecodes.marginkern,1)) -local lineskip = register_nut(new_nut(nodecodes.glue,skipcodes.lineskip)) -local baselineskip = register_nut(new_nut(nodecodes.glue,skipcodes.baselineskip)) -local leftskip = register_nut(new_nut(nodecodes.glue,skipcodes.leftskip)) -local rightskip = register_nut(new_nut(nodecodes.glue,skipcodes.rightskip)) +local lineskip = register_nut(new_nut(gluecode,skipcodes.lineskip)) +local baselineskip = register_nut(new_nut(gluecode,skipcodes.baselineskip)) +local leftskip = register_nut(new_nut(gluecode,skipcodes.leftskip)) +local rightskip = register_nut(new_nut(gluecode,skipcodes.rightskip)) local temp = register_nut(new_nut(nodecodes.temp,0)) @@ -206,11 +212,11 @@ local cleader = register_nut(copy_nut(glue)) setsubtype(cleader,glueco -- the dir field needs to be set otherwise crash: -local rule = register_nut(new_nut(nodecodes.rule)) setdir(rule, "TLT") -local emptyrule = register_nut(new_nut(nodecodes.rule,rulecodes.empty)) setdir(rule, "TLT") -local userrule = register_nut(new_nut(nodecodes.rule,rulecodes.user)) setdir(rule, "TLT") -local hlist = register_nut(new_nut(nodecodes.hlist)) setdir(hlist,"TLT") -local vlist = register_nut(new_nut(nodecodes.vlist)) setdir(vlist,"TLT") +local rule = register_nut(new_nut(rulecode)) setdir(rule, "TLT") +local emptyrule = register_nut(new_nut(rulecode,rulecodes.empty)) setdir(rule, "TLT") +local userrule = register_nut(new_nut(rulecode,rulecodes.user)) setdir(rule, "TLT") +local hlist = register_nut(new_nut(nodecodes.hlist)) setdir(hlist,"TLT") +local vlist = register_nut(new_nut(nodecodes.vlist)) setdir(vlist,"TLT") function nutpool.glyph(fnt,chr) local n = copy_nut(glyph) @@ -241,7 +247,6 @@ end function nutpool.boundary(v) local n = copy_nut(boundary) if v and v ~= 0 then - -- setfield(n,"value",v) setvalue(n,v) end return n @@ -250,7 +255,6 @@ end function nutpool.wordboundary(v) local n = copy_nut(wordboundary) if v and v ~= 0 then - -- setfield(n,"value",v) setvalue(n,v) end return n @@ -397,7 +401,7 @@ function nutpool.userrule(width,height,depth,dir) -- w/h/d == nil will let them return n end -local outlinerule = register_nut(new_nut(nodecodes.rule,rulecodes.outline)) setdir(rule, "TLT") +local outlinerule = register_nut(new_nut(rulecode,rulecodes.outline)) setdir(rule, "TLT") function nutpool.outlinerule(width,height,depth,line,dir) -- w/h/d == nil will let them adapt local n = copy_nut(outlinerule) @@ -424,9 +428,12 @@ function nutpool.leader(width,list) return n end +function nutpool.savepos() + return copy_nut(savepos) +end + function nutpool.latelua(code) local n = copy_nut(latelua) - -- setfield(n,"string",code) setdata(n,code) return n end @@ -437,7 +444,7 @@ function nutpool.leftmarginkern(glyph,width) local n = copy_nut(left_margin_kern) if not glyph then report_nodes("invalid pointer to left margin glyph node") - elseif getid(glyph) ~= glyph_code then + elseif getid(glyph) ~= glyphcode then report_nodes("invalid node type %a for %s margin glyph node",nodecodes[glyph],"left") else setfield(n,"glyph",glyph) @@ -452,7 +459,7 @@ function nutpool.rightmarginkern(glyph,width) local n = copy_nut(right_margin_kern) if not glyph then report_nodes("invalid pointer to right margin glyph node") - elseif getid(glyph) ~= glyph_code then + elseif getid(glyph) ~= glyphcode then report_nodes("invalid node type %a for %s margin glyph node",nodecodes[p],"right") else setfield(n,"glyph",glyph) diff --git a/tex/context/base/mkiv/pack-com.mkiv b/tex/context/base/mkiv/pack-com.mkiv index badda0127..1c6f2de73 100644 --- a/tex/context/base/mkiv/pack-com.mkiv +++ b/tex/context/base/mkiv/pack-com.mkiv @@ -73,7 +73,7 @@ \newsystemmode{combination} \appendtoks - \global\resetsystemmode{combination}% + \globalresetsystemmode{combination}% \to \everyinsidefloat \newcount\c_pack_combinations_nesting % local @@ -113,7 +113,7 @@ \setbox\b_pack_combinations_content_saved \box\b_pack_combinations_content \setbox\b_pack_combinations_caption_saved \box\b_pack_combinations_caption \else - \global\setsystemmode{combination}% why global + \globalsetsystemmode{combination}% why global \fi} \def\pack_combinations_pop @@ -126,7 +126,7 @@ \setbox\b_pack_combinations_content \box\b_pack_combinations_content_saved \setbox\b_pack_combinations_caption \box\b_pack_combinations_caption_saved \else - \global\resetsystemmode{combination}% why global + \globalresetsystemmode{combination}% why global \fi \advance\c_pack_combinations_nesting\minusone} @@ -656,7 +656,7 @@ \newsystemmode{pairedbox} \appendtoks - \global\resetsystemmode{pairedbox}% + \globalresetsystemmode{pairedbox}% \to \everyinsidefloat \installcorenamespace {pairedbox} @@ -720,7 +720,7 @@ \let\startcaption\pack_common_caption_start \let\stopcaption \pack_common_caption_stop % - \global\setsystemmode{pairedbox}% + \globalsetsystemmode{pairedbox}% \pack_pairedboxes_before \assumelongusagecs\pack_pairedboxes_first_pickup} diff --git a/tex/context/base/mkiv/pack-mrl.mkiv b/tex/context/base/mkiv/pack-mrl.mkiv index bef790536..665d245b3 100644 --- a/tex/context/base/mkiv/pack-mrl.mkiv +++ b/tex/context/base/mkiv/pack-mrl.mkiv @@ -587,7 +587,7 @@ \setvalue{\??textrulealternatives\v!bottom}#1% {\blank[\v!samepage,\v!nowhite]% - \pack_textrule_following_yes{#1}% + \pack_textrule_following{#1}% \blank[\v!samepage,\v!nowhite]% \directtextrulesparameter\c!after\relax \page[\v!preference]} @@ -595,7 +595,7 @@ \setvalue{\??textrulealternatives\v!middle}#1% {\blank[\v!samepage,\v!nowhite]% \directtextrulesparameter\c!inbetween\relax - \pack_textrule_following_yes{#1}% + \pack_textrule_following{#1}% \blank[\v!samepage,\v!nowhite]% \directtextrulesparameter\c!inbetween\relax \page[\v!preference]} diff --git a/tex/context/base/mkiv/pack-obj.lua b/tex/context/base/mkiv/pack-obj.lua index 479c234b4..3d2048218 100644 --- a/tex/context/base/mkiv/pack-obj.lua +++ b/tex/context/base/mkiv/pack-obj.lua @@ -13,9 +13,11 @@ reusable components.</p> local context = context local codeinjections = backends.codeinjections - local ctx_doifelse = commands.doifelse +local report = logs.reporter("objects") +local trace = false trackers.register("objects",function(v) trace = v end) + local nuts = nodes.nuts local setlink = nuts.setlink @@ -125,7 +127,8 @@ objects = { local objects = objects function objects.register(ns,id,b,referenced,offset,mode) - objects.n = objects.n + 1 + local n = objects.n + 1 + objects.n = n nodes.handlers.finalizebox(b) if mode == 0 then -- tex @@ -144,6 +147,9 @@ function objects.register(ns,id,b,referenced,offset,mode) mode, } end + if trace then + report("registering object %a (n=%i)",id,n) + end end function objects.restore(ns,id) -- why not just pass a box number here too (ok, we also set offset) @@ -167,6 +173,9 @@ function objects.restore(ns,id) -- why not just pass a box number here too (ok, setbox("objectbox",nil) settexdimen("objectoff",0) -- for good old times end + if trace then + report("restoring object %a",id) + end end function objects.dimensions(index) diff --git a/tex/context/base/mkiv/pack-obj.mkiv b/tex/context/base/mkiv/pack-obj.mkiv index 605dfdb02..d08c66494 100644 --- a/tex/context/base/mkiv/pack-obj.mkiv +++ b/tex/context/base/mkiv/pack-obj.mkiv @@ -51,7 +51,8 @@ \newdimen\objectht \def\objectheight{\the\objectht} \newdimen\objectdp \def\objectdepth {\the\objectdp} -%D If I have time I will use the unreferenced variant for e.g. mp reuse. +%D If I have time I will use the unreferenced variant for e.g. mp reuse. This can be +%D rewritten in \LUA\ anyway. \unexpanded\def\setreferencedobject #1#2{\begingroup\synctexpause\objectoff\objectoffset\inobjecttrue\dowithnextbox{\pack_objects_set_yes{#1}{#2}}} \unexpanded\def\settightreferencedobject #1#2{\begingroup\synctexpause\objectoff\zeropoint \inobjecttrue\dowithnextbox{\pack_objects_set_yes{#1}{#2}}} diff --git a/tex/context/base/mkiv/pack-rul.mkiv b/tex/context/base/mkiv/pack-rul.mkiv index af93ac41d..249c4f99b 100644 --- a/tex/context/base/mkiv/pack-rul.mkiv +++ b/tex/context/base/mkiv/pack-rul.mkiv @@ -3153,4 +3153,16 @@ \let\themaxboxwidth\clf_themaxboxwidth +%D New: slow but ok for most cases: + +\unexpanded\def\doifelseframed#1% + {\ifcase\numexpr\zerocount + \immediateassignment\edef\tempstring{#1\c!frame }\ifx\tempstring\v!on +\plusone\fi + \immediateassignment\edef\tempstring{#1\c!topframe }\ifx\tempstring\v!on +\plusone\fi + \immediateassignment\edef\tempstring{#1\c!bottomframe}\ifx\tempstring\v!on +\plusone\fi + \immediateassignment\edef\tempstring{#1\c!leftframe }\ifx\tempstring\v!on +\plusone\fi + \immediateassignment\edef\tempstring{#1\c!rightframe }\ifx\tempstring\v!on +\plusone\fi + \immediateassignment\edef\tempstring{#1\c!background }\ifx\tempstring\empty\else+\plusone\fi + \relax\expandafter\secondoftwoarguments\else\expandafter\firstoftwoarguments\fi} + \protect \endinput diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf Binary files differindex e2c84f900..2c0642736 100644 --- a/tex/context/base/mkiv/status-files.pdf +++ b/tex/context/base/mkiv/status-files.pdf diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf Binary files differindex 6875b27e6..6d2294748 100644 --- a/tex/context/base/mkiv/status-lua.pdf +++ b/tex/context/base/mkiv/status-lua.pdf diff --git a/tex/context/base/mkiv/strc-doc.mkiv b/tex/context/base/mkiv/strc-doc.mkiv index 7e7ad7e7d..516d87efe 100644 --- a/tex/context/base/mkiv/strc-doc.mkiv +++ b/tex/context/base/mkiv/strc-doc.mkiv @@ -19,6 +19,16 @@ %D This will move: +% \unexpanded\def\setstructuresynchronization#1% todo: use ctxcontext +% {\clf_setinternalreference +% prefix {\currentstructurereferenceprefix}% +% reference {\currentstructurereference} +% internal \locationcount +% view {\interactionparameter\c!focus}% +% \relax +% \xdef\currentstructureattribute {\the\lastdestinationattribute}% +% \xdef\currentstructuresynchronize{\strc_lists_inject_enhance{#1}}} + \unexpanded\def\setstructuresynchronization#1% todo: use ctxcontext {\clf_setinternalreference prefix {\currentstructurereferenceprefix}% @@ -26,8 +36,11 @@ internal \locationcount view {\interactionparameter\c!focus}% \relax - \xdef\currentstructureattribute {\the\lastdestinationattribute}% - \xdef\currentstructuresynchronize{\strc_lists_inject_enhance{#1}}} + \xdef\currentstructureattribute + {\the\lastdestinationattribute}% + \xdef\currentstructuresynchronize + {\currentstructuresynchronize + \strc_lists_inject_enhance{#1}}} \unexpanded\def\setstructurecomponentsynchronization#1% todo: use ctxcontext {\clf_setinternalreference diff --git a/tex/context/base/mkiv/strc-flt.mkvi b/tex/context/base/mkiv/strc-flt.mkvi index 28fa950c7..4ca7d3fbf 100644 --- a/tex/context/base/mkiv/strc-flt.mkvi +++ b/tex/context/base/mkiv/strc-flt.mkvi @@ -61,9 +61,11 @@ \installcorenamespace{float} \installcorenamespace{floatbuilder} \installcorenamespace{floatcaption} +\installcorenamespace{floatframed} \installframedcommandhandler \??float {float} \??float \installframedcommandhandler \??floatcaption {floatcaption} \??floatcaption +\installframedcommandhandler \??floatframed {floatframed} \??floatframed \let\setupfloats \setupfloat \let\setupcaption \setupfloatcaption @@ -97,6 +99,8 @@ \c!textcolor=, \c!align=, \c!number=\v!yes, + \c!offset=\v!overlay, + \c!frame=\v!off, % \c!expansion=, % \c!prefix=, % \c!prefixconnector=, @@ -171,6 +175,11 @@ \c!sidethreshold=.5\strutdp, % set to "old" to check with old method \c!numbering=\v!yes] +\setupfloatframed + [\c!frame=\v!off, + \c!offset=\v!overlay, + \c!strut=\v!no] + %D Individial settings: \installcounterassociation{floatcaption} @@ -207,6 +216,7 @@ \def\strc_floats_define_a[#1][#2][#3]% name names parent {\definefloatcaption[#1][#3]% + \definefloatframed[#1][#3]% \definecounter[#1][#3]% \definelist[#1][#3]% \copylabeltext[#1=#3]% @@ -215,6 +225,7 @@ \def\strc_floats_define_b[#1][#2][#3]% name parent settings {\definefloatcaption[#1][#2]% + \definefloatframed[#1][#2]% \definecounter[#1][#2]% \definelist[#1][#2]% \copylabeltext[#1=#2]% @@ -224,6 +235,7 @@ \def\strc_floats_define_c[#1][#2]% name names {\registerfloatcaptioncounter{#1}% \definefloatcaption[#1]% + \definefloatframed[#1]% \definecounter[#1]% \definelist[#1]% \presetlabeltext[#1=\Word{#1}~]% @@ -332,6 +344,7 @@ \def\strc_floats_make_complete_caption {\doifsomething{\floatcaptionparameter\c!spacebefore}{\blank[\floatcaptionparameter\c!spacebefore]}% + \strc_floats_make_complete_caption_before \synchronizedisplaydirection % temp hack, till we have a proper model \noindent \gdef\lastcaptiontag{\strut\thecurrentfloatnumber}% was xdef ... needs checking @@ -361,8 +374,26 @@ \thecurrentfloatcaption\endgraf \fi \endgroup + \strc_floats_make_complete_caption_after \doifsomething{\floatcaptionparameter\c!spaceafter}{\blank[\floatcaptionparameter\c!spaceafter]}} +%let\strc_floats_make_complete_caption_before\relax +\let\strc_floats_make_complete_caption_after \relax + +\def\strc_floats_make_complete_caption_before + {\doifelseframed\floatcaptionparameter\strc_floats_make_complete_caption_before_indeed\relax} + +\def\strc_floats_make_complete_caption_before_indeed + {\edef\m_strc_align{\floatcaptionparameter\c!align}% + \edef\m_strc_strut{\floatcaptionparameter\c!strut}% + \letfloatcaptionparameter\c!align\v!normal + \letfloatcaptionparameter\c!strut\v!no + \inheritedfloatcaptionframed + \bgroup + \letfloatcaptionparameter\c!align\m_strc_align + \letfloatcaptionparameter\c!strut\m_strc_strut + \let\strc_floats_make_complete_caption_after\egroup} + % \definefloat [figure-1] [figure] % \definefloat [figure-2] [figure] % \setupfloat [figure-1] [location=left,leftmargin=10mm] @@ -1953,10 +1984,9 @@ \unexpanded\def\installfloatboxbuilder#1#2{\setvalue{\??floatbuilder#1}{#2}} -\let\strc_floats_mark_box_as_free\relax - \def\strc_floats_build_box - {\global\setbox\floatbox\vbox % pack ? probably not + {\strc_floats_build_box_before + \global\setbox\floatbox\vbox % pack ? probably not {\strc_floats_set_local_hsize \forgetall \ifconditional\c_floats_store_minimal_package @@ -1970,7 +2000,34 @@ \else \strc_floats_build_box_default \fi - \fi}} + \fi}% + \strc_floats_build_box_after} + +% \let\strc_floats_build_box_before\relax +% \let\strc_floats_build_box_after \relax + +\def\strc_floats_build_box_before + {\let\currentfloatframed\currentfloat + \floatwidth\wd + \ifdim\wd\b_strc_floats_content>\wd\b_strc_floats_caption + \b_strc_floats_content\else\b_strc_floats_caption + \fi} + +\def\strc_floats_build_box_after + {\doifelseframed\floatframedparameter\strc_floats_build_box_after_indeed\relax} + +\def\strc_floats_build_box_after_indeed + {\global\setbox\floatbox\hpack + {\edef\m_width{\floatframedparameter\c!width}% + \ifx\m_width\v!fit + \let\m_width\floatwidth + \else\ifx\m_width\v!broad + \let\m_width\v!fit + \fi\fi + \letfloatframedparameter\c!strut\v!no + \letfloatframedparameter\c!width\m_width + \inheritedfloatframedframed + {\box\floatbox}}} % special purpose: used in floatcombinations diff --git a/tex/context/base/mkiv/strc-sec.mkiv b/tex/context/base/mkiv/strc-sec.mkiv index cff73718a..4066a1f38 100644 --- a/tex/context/base/mkiv/strc-sec.mkiv +++ b/tex/context/base/mkiv/strc-sec.mkiv @@ -773,8 +773,15 @@ \newtoks\everyheadsynchronization +% \appendtoks +% \currentstructuresynchronize +% \to \everyheadsynchronization + +\let\currentstructuresynchronize\donothing + \appendtoks \currentstructuresynchronize + \glet\currentstructuresynchronize\donothing \to \everyheadsynchronization \unexpanded\def\theheadsynchonization diff --git a/tex/context/base/mkiv/symb-imp-fontawesome.mkiv b/tex/context/base/mkiv/symb-imp-fontawesome.mkiv index 13a8fc678..c638998ab 100644 --- a/tex/context/base/mkiv/symb-imp-fontawesome.mkiv +++ b/tex/context/base/mkiv/symb-imp-fontawesome.mkiv @@ -749,7 +749,6 @@ \stopsymbolset - \definefontsynonym [FontAwesomeBrands] [file:fontawesome5brandsregular400.otf] \definefontsynonym [FontAwesomeRegular] [file:fontawesome5freeregular400.otf] \definefontsynonym [FontAwesomeSolid] [file:fontawesome5freesolid900.otf] diff --git a/tex/context/base/mkiv/tabl-xtb.lua b/tex/context/base/mkiv/tabl-xtb.lua index 524ca109c..a8a32ec21 100644 --- a/tex/context/base/mkiv/tabl-xtb.lua +++ b/tex/context/base/mkiv/tabl-xtb.lua @@ -892,7 +892,7 @@ function xtables.construct() size, i < nofrange and rowdistance > 0 and rowdistance or false, -- might move false, - rp and rp.samepage or false, + rp or false, } end end @@ -901,7 +901,7 @@ function xtables.construct() result[1] [5] = false result[nofr][5] = false for i=2,nofr-1 do - local r = result[i] + local r = result[i][5] if r == v_both or r == v_before then result[i-1][5] = true elseif r == v_after then diff --git a/tex/context/base/mkiv/task-ini.lua b/tex/context/base/mkiv/task-ini.lua index 48aa65baa..67a17109d 100644 --- a/tex/context/base/mkiv/task-ini.lua +++ b/tex/context/base/mkiv/task-ini.lua @@ -116,7 +116,7 @@ appendaction("math", "builders", "typesetters.directions.processmath" appendaction("math", "builders", "noads.handlers.makeup", nil, "nonut", "disabled" ) appendaction("math", "builders", "noads.handlers.align", nil, "nonut", "enabled" ) -appendaction("finalizers", "lists", "typesetters.paragraphs.normalize", nil, "nut", "disabled" ) +appendaction("finalizers", "lists", "typesetters.paragraphs.normalize", nil, "nut", "enabled" ) -- "disabled" appendaction("finalizers", "lists", "typesetters.margins.localhandler", nil, "nut", "disabled" ) appendaction("finalizers", "lists", "builders.paragraphs.keeptogether", nil, "nut", "disabled" ) appendaction("finalizers", "fonts", "builders.paragraphs.solutions.splitters.optimize", nil, "nut", "disabled" ) diff --git a/tex/context/base/mkiv/util-deb.lua b/tex/context/base/mkiv/util-deb.lua index 9488a728b..f396fcf7a 100644 --- a/tex/context/base/mkiv/util-deb.lua +++ b/tex/context/base/mkiv/util-deb.lua @@ -10,9 +10,6 @@ if not modules then modules = { } end modules ['util-deb'] = { -- bound to a variable, like node.new, node.copy etc (contrary to for instance -- node.has_attribute which is bound to a has_attribute local variable in mkiv) -local debug = require "debug" - -local getinfo, sethook = debug.getinfo, debug.sethook local type, next, tostring, tonumber = type, next, tostring, tonumber local format, find, sub, gsub = string.format, string.find, string.sub, string.gsub local insert, remove, sort = table.insert, table.remove, table.sort @@ -240,6 +237,31 @@ function debugger.showstats(printer,threshold) -- table.save("luatex-profile.lua",names) end +local getinfo = nil +local sethook = nil + +local function getdebug() + if sethook and getinfo then + return + end + if not debug then + local okay + okay, debug = pcall(require,"debug") + end + if type(debug) ~= "table" then + return + end + getinfo = debug.getinfo + sethook = debug.sethook + if type(getinfo) ~= "function" then + getinfo = nil + end + if type(sethook) ~= "function" then + sethook = nil + end +end + + function debugger.savestats(filename,threshold) local f = io.open(filename,'w') if f then @@ -249,7 +271,8 @@ function debugger.savestats(filename,threshold) end function debugger.enable() - if nesting == 0 then + getdebug() + if sethook and getinfo and nesting == 0 then running = true if initialize then initialize() @@ -271,7 +294,7 @@ function debugger.disable() if nesting > 0 then nesting = nesting - 1 end - if nesting == 0 then + if sethook and getinfo and nesting == 0 then sethook() end end @@ -294,20 +317,25 @@ end -- from the lua book: local function showtraceback(rep) -- from lua site / adapted - local level = 2 -- we don't want this function to be reported - local reporter = rep or report - while true do - local info = getinfo(level, "Sl") - if not info then - break - elseif info.what == "C" then - reporter("%2i : %s",level-1,"C function") - else - reporter("%2i : %s : %s",level-1,info.short_src,info.currentline) + getdebug() + if getinfo then + local level = 2 -- we don't want this function to be reported + local reporter = rep or report + while true do + local info = getinfo(level, "Sl") + if not info then + break + elseif info.what == "C" then + reporter("%2i : %s",level-1,"C function") + else + reporter("%2i : %s : %s",level-1,info.short_src,info.currentline) + end + level = level + 1 end - level = level + 1 end end debugger.showtraceback = showtraceback -- debug.showtraceback = showtraceback + +-- showtraceback() diff --git a/tex/context/base/mkiv/util-evo.lua b/tex/context/base/mkiv/util-evo.lua index 19c394c79..e77b7963a 100644 --- a/tex/context/base/mkiv/util-evo.lua +++ b/tex/context/base/mkiv/util-evo.lua @@ -535,27 +535,29 @@ local function gettemperatures(presets) for i=1,#data do local gateways = data[i].gateways local locationinfo = data[i].locationInfo - local locationid = locationinfo.locationId - if gateways then - local status = getstatus(presets,locationid,locationinfo.name) - if status then - for i=1,#gateways do - local g = status.gateways[i] - local gateway = gateways[i] - local systems = gateway.temperatureControlSystems - if systems then - local s = g.temperatureControlSystems - for i=1,#systems do - local zones = systems[i].zones - if zones then - local z = s[i].zones - for i=1,#zones do - local zone = zones[i] - if validzonetypes[zone.zoneType] then - local z = z[i] - if z.name == zone.name then - zone.temperatureStatus = z.temperatureStatus - updated = true + if locationinfo then + local locationid = locationinfo.locationId + if gateways then + local status = getstatus(presets,locationid,locationinfo.name) + if status then + for i=1,#gateways do + local g = status.gateways[i] + local gateway = gateways[i] + local systems = gateway.temperatureControlSystems + if systems then + local s = g.temperatureControlSystems + for i=1,#systems do + local zones = systems[i].zones + if zones then + local z = s[i].zones + for i=1,#zones do + local zone = zones[i] + if validzonetypes[zone.zoneType] then + local z = z[i] + if z.name == zone.name then + zone.temperatureStatus = z.temperatureStatus + updated = true + end end end end @@ -563,7 +565,11 @@ local function gettemperatures(presets) end end end + else + report("no gateways") end + else + report("no location info") end end if updated then diff --git a/tex/context/base/mkiv/util-fil.lua b/tex/context/base/mkiv/util-fil.lua index d568a2e1f..9f96a01b9 100644 --- a/tex/context/base/mkiv/util-fil.lua +++ b/tex/context/base/mkiv/util-fil.lua @@ -6,6 +6,7 @@ if not modules then modules = { } end modules ['util-fil'] = { license = "see context related readme files" } +local tonumber = tonumber local byte = string.byte local char = string.char @@ -196,41 +197,23 @@ function files.readinteger4le(f) end end --- function files.readfixed2(f) --- local a, b = byte(f:read(2),1,2) --- if a >= 0x80 then --- return (0x100 * a + b - 0x10000)/256.0 --- else --- return (0x100 * a + b)/256.0 --- end --- end - function files.readfixed2(f) local a, b = byte(f:read(2),1,2) if a >= 0x80 then - return (a - 0x100) + b/0x100 + tonumber((a - 0x100) .. "." .. b) else - return (a ) + b/0x100 + tonumber(( a ) .. "." .. b) end end --- (real) (n>>16) + ((n&0xffff)/65536.0)) - --- function files.readfixed4(f) --- local a, b, c, d = byte(f:read(4),1,4) --- if a >= 0x80 then --- return (0x1000000 * a + 0x10000 * b + 0x100 * c + d - 0x100000000)/65536.0 --- else --- return (0x1000000 * a + 0x10000 * b + 0x100 * c + d)/65536.0 --- end --- end +-- (real) (n>>16) + ((n&0xffff)/65536.0)) but no cast in lua (we could use unpack) function files.readfixed4(f) local a, b, c, d = byte(f:read(4),1,4) if a >= 0x80 then - return (0x100 * a + b - 0x10000) + (0x100 * c + d)/0x10000 + tonumber((0x100 * a + b - 0x10000) .. "." .. (0x100 * c + d)) else - return (0x100 * a + b ) + (0x100 * c + d)/0x10000 + tonumber((0x100 * a + b ) .. "." .. (0x100 * c + d)) end end diff --git a/tex/context/base/mkiv/util-sac.lua b/tex/context/base/mkiv/util-sac.lua index 62ce6bc1c..dc8ba72f1 100644 --- a/tex/context/base/mkiv/util-sac.lua +++ b/tex/context/base/mkiv/util-sac.lua @@ -10,19 +10,23 @@ if not modules then modules = { } end modules ['util-sac'] = { -- with bytes) local byte, sub = string.byte, string.sub -local extract = bit32 and bit32.extract +local tonumber = tonumber utilities = utilities or { } local streams = { } utilities.streams = streams function streams.open(filename,zerobased) - local f = io.loaddata(filename) - return { f, 1, #f, zerobased or false } + local f = filename and io.loaddata(filename) + if f then + return { f, 1, #f, zerobased or false } + end end function streams.openstring(f,zerobased) - return { f, 1, #f, zerobased or false } + if f then + return { f, 1, #f, zerobased or false } + end end function streams.close() @@ -237,31 +241,31 @@ function streams.readinteger4le(f) end end -function streams.readfixed4(f) +function streams.readfixed2(f) local i = f[2] - local j = i + 3 + local j = i + 1 f[2] = j + 1 - local a, b, c, d = byte(f[1],i,j) + local a, b = byte(f[1],i,j) if a >= 0x80 then - return (0x100 * a + b - 0x10000) + (0x100 * c + d)/0x10000 + tonumber((a - 0x100) .. "." .. b) else - return (0x100 * a + b ) + (0x100 * c + d)/0x10000 + tonumber((a ) .. "." .. b) end end -function streams.readfixed2(f) +function streams.readfixed4(f) local i = f[2] - local j = i + 1 + local j = i + 3 f[2] = j + 1 - local a, b = byte(f[1],i,j) + local a, b, c, d = byte(f[1],i,j) if a >= 0x80 then - return (a - 0x100) + b/0x100 + tonumber((0x100 * a + b - 0x10000) .. "." .. (0x100 * c + d)) else - return (a ) + b/0x100 + tonumber((0x100 * a + b ) .. "." .. (0x100 * c + d)) end end -if extract then +if bit32 then local extract = bit32.extract local band = bit32.band diff --git a/tex/context/base/mkiv/util-sql-imp-ffi.lua b/tex/context/base/mkiv/util-sql-imp-ffi.lua index 77d32a693..3731933f1 100644 --- a/tex/context/base/mkiv/util-sql-imp-ffi.lua +++ b/tex/context/base/mkiv/util-sql-imp-ffi.lua @@ -17,6 +17,7 @@ local format, byte = string.format, string.byte local lpegmatch = lpeg.match local setmetatable, type = setmetatable, type local sleep = os.sleep +local formatters = string.formatters local trace_sql = false trackers.register("sql.trace", function(v) trace_sql = v end) local trace_queries = false trackers.register("sql.queries",function(v) trace_queries = v end) diff --git a/tex/context/base/mkiv/util-str.lua b/tex/context/base/mkiv/util-str.lua index f090bce55..508d32d71 100644 --- a/tex/context/base/mkiv/util-str.lua +++ b/tex/context/base/mkiv/util-str.lua @@ -1415,3 +1415,11 @@ function strings.newcollector() end end end + +-- + +local f_16_16 = formatters["%0.5N"] + +function number.to16dot16(n) + return f_16_16(n/65536.0) +end diff --git a/tex/context/fonts/mkiv/type-imp-lucida-typeone.mkiv b/tex/context/fonts/mkiv/type-imp-lucida-typeone.mkiv index 5f28b9eed..59d167a1b 100644 --- a/tex/context/fonts/mkiv/type-imp-lucida-typeone.mkiv +++ b/tex/context/fonts/mkiv/type-imp-lucida-typeone.mkiv @@ -11,6 +11,8 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. +\writestatus{fonts}{Lucida Type 1 support can be broken due to wrong files!} + \starttypescriptcollection[lucida-typeone] \starttypescript [\s!serif] [lucida] diff --git a/tex/context/fonts/mkiv/type-imp-source.mkiv b/tex/context/fonts/mkiv/type-imp-source.mkiv index 91396f965..ab94727e8 100644 --- a/tex/context/fonts/mkiv/type-imp-source.mkiv +++ b/tex/context/fonts/mkiv/type-imp-source.mkiv @@ -17,38 +17,38 @@ \starttypescript [\s!serif] [source] [\s!name] \setups[\s!font:\s!fallback:\s!serif] - \definefontsynonym [\s!Serif] [\s!file:SourceSerifPro-Regular.ttf] [\s!features=\s!default] - \definefontsynonym [\s!SerifBold] [\s!file:SourceSerifPro-Bold.ttf] [\s!features=\s!default] - % \definefontsynonym [\s!SerifBold] [\s!file:SourceSerifPro-Semibold.ttf] [\s!features=\s!default] - \definefontsynonym [\s!SerifItalic] [\s!file:SourceSerifPro-Regular.ttf] [\s!features={\s!default,source-serif-slanted}] - \definefontsynonym [\s!SerifBoldItalic] [\s!file:SourceSerifPro-Bold.ttf] [\s!features={\s!default,source-serif-slanted}] + \definefontsynonym [\s!Serif] [\s!file:SourceSerifPro-Regular] [\s!features=\s!default] + \definefontsynonym [\s!SerifBold] [\s!file:SourceSerifPro-Bold] [\s!features=\s!default] + % \definefontsynonym [\s!SerifBold] [\s!file:SourceSerifPro-Semibold] [\s!features=\s!default] + \definefontsynonym [\s!SerifItalic] [\s!file:SourceSerifPro-Regular] [\s!features={\s!default,source-serif-slanted}] + \definefontsynonym [\s!SerifBoldItalic] [\s!file:SourceSerifPro-Bold] [\s!features={\s!default,source-serif-slanted}] \stoptypescript \starttypescript [\s!sans] [source] [\s!name] \setups[\s!font:\s!fallback:\s!sans] - % \definefontsynonym [\s!Sans] [\s!file:SourceSansPro-ExtraLight.ttf] [\s!features=\s!default] - % \definefontsynonym [\s!Sans] [\s!file:SourceSansPro-Light.ttf] [\s!features=\s!default] - \definefontsynonym [\s!Sans] [\s!file:SourceSansPro-Regular.ttf] [\s!features=\s!default] - % \definefontsynonym [\s!SansBold] [\s!file:SourceSansPro-Semibold.ttf] [\s!features=\s!default] - \definefontsynonym [\s!SansBold] [\s!file:SourceSansPro-Bold.ttf] [\s!features=\s!default] - % \definefontsynonym [\s!SansBold] [\s!file:SourceSansPro-Black.ttf] [\s!features=\s!default] - % \definefontsynonym [\s!SansItalic] [\s!file:SourceSansPro-ExtraLightItalic.ttf] [\s!features=\s!default] - % \definefontsynonym [\s!SansItalic] [\s!file:SourceSansPro-LightItalic.ttf] [\s!features=\s!default] - \definefontsynonym [\s!SansItalic] [\s!file:SourceSansPro-Italic.ttf] [\s!features=\s!default] - % \definefontsynonym [\s!SansBoldItalic] [\s!file:SourceSansPro-SemiboldItalic.ttf] [\s!features=\s!default] - \definefontsynonym [\s!SansBoldItalic] [\s!file:SourceSansPro-BoldItalic.ttf] [\s!features=\s!default] - % \definefontsynonym [\s!SansBoldItalic] [\s!file:SourceSansPro-BlackItalic.ttf] [\s!features=\s!default] + % \definefontsynonym [\s!Sans] [\s!file:SourceSansPro-ExtraLight] [\s!features=\s!default] + % \definefontsynonym [\s!Sans] [\s!file:SourceSansPro-Light] [\s!features=\s!default] + \definefontsynonym [\s!Sans] [\s!file:SourceSansPro-Regular] [\s!features=\s!default] + % \definefontsynonym [\s!SansBold] [\s!file:SourceSansPro-Semibold] [\s!features=\s!default] + \definefontsynonym [\s!SansBold] [\s!file:SourceSansPro-Bold] [\s!features=\s!default] + % \definefontsynonym [\s!SansBold] [\s!file:SourceSansPro-Black] [\s!features=\s!default] + % \definefontsynonym [\s!SansItalic] [\s!file:SourceSansPro-ExtraLightItalic] [\s!features=\s!default] + % \definefontsynonym [\s!SansItalic] [\s!file:SourceSansPro-LightItalic] [\s!features=\s!default] + \definefontsynonym [\s!SansItalic] [\s!file:SourceSansPro-Italic] [\s!features=\s!default] + % \definefontsynonym [\s!SansBoldItalic] [\s!file:SourceSansPro-SemiboldItalic] [\s!features=\s!default] + \definefontsynonym [\s!SansBoldItalic] [\s!file:SourceSansPro-BoldItalic] [\s!features=\s!default] + % \definefontsynonym [\s!SansBoldItalic] [\s!file:SourceSansPro-BlackItalic] [\s!features=\s!default] \stoptypescript \starttypescript [\s!mono] [source] [\s!name] \setups[\s!font:\s!fallback:\s!mono] - % \definefontsynonym [\s!Mono] [\s!file:SourceCodePro-ExtraLight.ttf] [\s!features=\s!none] - % \definefontsynonym [\s!Mono] [\s!file:SourceCodePro-Light.ttf] [\s!features=\s!none] - \definefontsynonym [\s!Mono] [\s!file:SourceCodePro-Regular.ttf] [\s!features=\s!none] - % \definefontsynonym [\s!MonoBold] [\s!file:SourceCodePro-Medium.ttf] [\s!features=\s!none] - % \definefontsynonym [\s!MonoBold] [\s!file:SourceCodePro-Semibold.ttf] [\s!features=\s!none] - \definefontsynonym [\s!MonoBold] [\s!file:SourceCodePro-Bold.ttf] [\s!features=\s!none] - % \definefontsynonym [\s!MonoBold] [\s!file:SourceCodePro-Black.ttf] [\s!features=\s!none] + % \definefontsynonym [\s!Mono] [\s!file:SourceCodePro-ExtraLight] [\s!features=\s!none] + % \definefontsynonym [\s!Mono] [\s!file:SourceCodePro-Light] [\s!features=\s!none] + \definefontsynonym [\s!Mono] [\s!file:SourceCodePro-Regular] [\s!features=\s!none] + % \definefontsynonym [\s!MonoBold] [\s!file:SourceCodePro-Medium] [\s!features=\s!none] + % \definefontsynonym [\s!MonoBold] [\s!file:SourceCodePro-Semibold] [\s!features=\s!none] + \definefontsynonym [\s!MonoBold] [\s!file:SourceCodePro-Bold] [\s!features=\s!none] + % \definefontsynonym [\s!MonoBold] [\s!file:SourceCodePro-Black] [\s!features=\s!none] \stoptypescript \starttypescript [\s!math][source][\s!name] diff --git a/tex/context/interface/mkii/keys-nl.xml b/tex/context/interface/mkii/keys-nl.xml index bfb8b1809..d00978a6c 100644 --- a/tex/context/interface/mkii/keys-nl.xml +++ b/tex/context/interface/mkii/keys-nl.xml @@ -1247,6 +1247,7 @@ <cd:constant name='textstyle' value='tekstletter'/> <cd:constant name='textwidth' value='tekstbreedte'/> <cd:constant name='threshold' value='threshold'/> + <cd:constant name='time' value='tijd'/> <cd:constant name='title' value='titel'/> <cd:constant name='titlecolor' value='titelkleur'/> <cd:constant name='titlecommand' value='titelcommando'/> diff --git a/tex/context/interface/mkiv/i-context.pdf b/tex/context/interface/mkiv/i-context.pdf Binary files differindex 5af37d839..94584fd03 100644 --- a/tex/context/interface/mkiv/i-context.pdf +++ b/tex/context/interface/mkiv/i-context.pdf diff --git a/tex/context/interface/mkiv/i-readme.pdf b/tex/context/interface/mkiv/i-readme.pdf Binary files differindex 003bdabaf..a06625a9a 100644 --- a/tex/context/interface/mkiv/i-readme.pdf +++ b/tex/context/interface/mkiv/i-readme.pdf diff --git a/tex/context/modules/common/s-abbreviations-logos.tex b/tex/context/modules/common/s-abbreviations-logos.tex index 668dbc015..8cc342cc4 100644 --- a/tex/context/modules/common/s-abbreviations-logos.tex +++ b/tex/context/modules/common/s-abbreviations-logos.tex @@ -157,6 +157,7 @@ \logo [LINUX] {linux} \logo [LISP] {Lisp} \logo [LMX] {lmx} +\logo [LMTX] {lmtx} \logo [LPEG] {lpeg} \logo [LUA] {Lua} \logo [LUAJIT] {LuaJIT} diff --git a/tex/context/modules/mkiv/s-fonts-charts.mkiv b/tex/context/modules/mkiv/s-fonts-charts.mkiv index d8d0975de..3123cc0d0 100644 --- a/tex/context/modules/mkiv/s-fonts-charts.mkiv +++ b/tex/context/modules/mkiv/s-fonts-charts.mkiv @@ -87,7 +87,7 @@ local settings = utilities.parsers.settings_to_hash(settings) - local filename = settings.filename or "" + local filename = settings.filename or settings.name or "" local fontid = true local newpage = settings.page == interfaces.variables.yes @@ -169,8 +169,9 @@ \starttext + \showfontchart[filename=aegean,page=yes] % \showfontchart[filename=veramono.ttf,page=yes] - \showfontchart[filename=CoelacanthSubhdHeavy.otf,page=yes] +% \showfontchart[filename=CoelacanthSubhdHeavy.otf,page=yes] % \showfontchart[filename=LucidaBrightOT.otf,page=yes] % \showfontchart[filename=LucidaBrightOT-Demi.otf,page=yes] diff --git a/tex/context/modules/mkiv/s-fonts-features.lua b/tex/context/modules/mkiv/s-fonts-features.lua index 6f4032948..6c676ce2d 100644 --- a/tex/context/modules/mkiv/s-fonts-features.lua +++ b/tex/context/modules/mkiv/s-fonts-features.lua @@ -11,7 +11,7 @@ moduledata.fonts.features = moduledata.fonts.features or { } -- for the moment only otf -local sortedhash = table.sortedhash +local insert, remove, sortedhash = table.insert, table.remove, table.sortedhash local v_yes = interfaces.variables.yes local v_no = interfaces.variables.no @@ -87,66 +87,35 @@ local function collectkerns(tfmdata,feature) local lookuphash = resources.lookuphash local feature = feature or "kern" if sequences then - - if true then - - for i=1,#sequences do - local sequence = sequences[i] - if sequence.features and sequence.features[feature] then - local steps = sequence.steps - for i=1,#steps do - local step = steps[i] - local format = step.format - for unicode, hash in table.sortedhash(step.coverage) do - local kerns = combinations[unicode] - if not kerns then - kerns = { } - combinations[unicode] = kerns - end - for otherunicode, kern in table.sortedhash(hash) do - if format == "pair" then - local f = kern[1] - local s = kern[2] - if f then - if s then - -- todo - else - if not kerns[otherunicode] and f[3] ~= 0 then - kerns[otherunicode] = f[3] - end - end - elseif s then - -- todo - end - elseif format == "kern" then - if not kerns[otherunicode] and kern ~= 0 then - kerns[otherunicode] = kern - end - end - end - end - end - end - end - end - - else -- old loader - for i=1,#sequences do local sequence = sequences[i] if sequence.features and sequence.features[feature] then - local lookuplist = sequence.subtables - if lookuplist then - for l=1,#lookuplist do - local lookupname = lookuplist[l] - local lookupdata = lookuphash[lookupname] - for unicode, data in next, lookupdata do - local kerns = combinations[unicode] - if not kerns then - kerns = { } - combinations[unicode] = kerns - end - for otherunicode, kern in next, data do + local steps = sequence.steps + for i=1,#steps do + local step = steps[i] + local format = step.format + for unicode, hash in table.sortedhash(step.coverage) do + local kerns = combinations[unicode] + if not kerns then + kerns = { } + combinations[unicode] = kerns + end + for otherunicode, kern in table.sortedhash(hash) do + if format == "pair" then + local f = kern[1] + local s = kern[2] + if f then + if s then + -- todo + else + if not kerns[otherunicode] and f[3] ~= 0 then + kerns[otherunicode] = f[3] + end + end + elseif s then + -- todo + end + elseif format == "kern" then if not kerns[otherunicode] and kern ~= 0 then kerns[otherunicode] = kern end @@ -156,7 +125,6 @@ local function collectkerns(tfmdata,feature) end end end - end return combinations @@ -230,3 +198,90 @@ function moduledata.fonts.features.showfeatureset(specification) end end end + +local function collectligatures(tfmdata) + local sequences = tfmdata.resources.sequences + + if not sequences then + return + end + + local series = { } + local stack = { } + local max = 0 + + local function make(tree) + for k, v in sortedhash(tree) do + if k == "ligature" then + local n = #stack + if n > max then + max = n + end + series[#series+1] = { v, unpack(stack) } + else + insert(stack,k) + make(v) + remove(stack) + end + end + end + + for i=1,#sequences do + local sequence = sequences[i] + if sequence.type == "gsub_ligature" then + local steps = sequence.steps + for i=1,#steps do + local step = steps[i] + local coverage = step.coverage + if coverage then + make(coverage) + end + end + end + end + + return series, max +end + +function moduledata.fonts.features.showallligatures(specification) + specification = interfaces.checkedspecification(specification) + local id, cs = fonts.definers.internal(specification,"<module:fonts:features:font>") + local tfmdata = fonts.hashes.identifiers[id] + local allligatures, + max = collectligatures(tfmdata) + local characters = tfmdata.characters + local descriptions = tfmdata.descriptions + if #allligatures > 0 then + context.starttabulate { "|T|" .. string.rep("|",max) .. "|T|T|" } + for i=1,#allligatures do + local s = allligatures[i] + local n = #s + local u = s[1] + local c = characters[u] + local d = descriptions[u] + NC() + context("%U",u) + NC() + context("\\setfontid%i\\relax",id) + context.char(u) + NC() + context("\\setfontid%i\\relax",id) + for i=2,n do + context.char(s[i]) + NC() + end + for i=n+1,max do + NC() + end + context(d.name) + NC() + context(c.tounicode) + NC() + NR() + end + context.stoptabulate() + else + context("no ligatures found") + context.par() + end +end diff --git a/tex/context/modules/mkiv/s-fonts-features.mkiv b/tex/context/modules/mkiv/s-fonts-features.mkiv index 2dca059ff..2390c44df 100644 --- a/tex/context/modules/mkiv/s-fonts-features.mkiv +++ b/tex/context/modules/mkiv/s-fonts-features.mkiv @@ -18,6 +18,7 @@ \installmodulecommandluasingle \showusedfeatures {moduledata.fonts.features.showused} \installmodulecommandluasingle \showallkerns {moduledata.fonts.features.showallkerns} \installmodulecommandluasingle \showbasekerns {moduledata.fonts.features.showbasekerns} +\installmodulecommandluasingle \showallligatures {moduledata.fonts.features.showallligatures} \installmodulecommandluasingle \showfeatureset {moduledata.fonts.features.showfeatureset} \def\kernpairheight{.8\strutht} diff --git a/tex/context/modules/mkiv/s-fonts-tables.lua b/tex/context/modules/mkiv/s-fonts-tables.lua index c32f4628c..33cbc924c 100644 --- a/tex/context/modules/mkiv/s-fonts-tables.lua +++ b/tex/context/modules/mkiv/s-fonts-tables.lua @@ -6,18 +6,45 @@ if not modules then modules = { } end modules ['s-fonts-tables'] = { license = "see context related readme files" } -moduledata.fonts = moduledata.fonts or { } -moduledata.fonts.tables = moduledata.fonts.tables or { } - -local setmetatableindex = table.setmetatableindex -local sortedhash = table.sortedhash -local sortedkeys = table.sortedkeys -local format = string.format -local concat = table.concat - -local tabletracers = moduledata.fonts.tables - -local context = context +moduledata.fonts = moduledata.fonts or { } +moduledata.fonts.tables = moduledata.fonts.tables or { } + +local setmetatableindex = table.setmetatableindex +local sortedhash = table.sortedhash +local sortedkeys = table.sortedkeys +local concat = table.concat +local insert = table.insert +local remove = table.remove +local formatters = string.formatters + +local tabletracers = moduledata.fonts.tables + +local new_glyph = nodes.pool.glyph +local copy_node = nodes.copy +local setlink = nodes.setlink +local hpack = nodes.hpack +local applyvisuals = nodes.applyvisuals + +local handle_positions = fonts.handlers.otf.datasetpositionprocessor +local handle_injections = nodes.injections.handler + +local context = context +local ctx_sequence = context.formatted.sequence +local ctx_char = context.char +local ctx_setfontid = context.setfontid +local ctx_type = context.formatted.type +local ctx_dontleavehmode = context.dontleavehmode +local ctx_startPair = context.startPair +local ctx_stopPair = context.stopPair +local ctx_startSingle = context.startSingle +local ctx_stopSingle = context.stopSingle +local ctx_startSingleKern = context.startSingleKern +local ctx_stopSingleKern = context.stopSingleKern +local ctx_startPairKern = context.startPairKern +local ctx_stopPairKern = context.stopPairKern + +local ctx_NC = context.NC +local ctx_NR = context.NR local digits = { dflt = { @@ -106,53 +133,73 @@ setmetatableindex(digits.dflt, function(t,k) return rawget(t,"dflt") end) setmetatableindex(symbols.dflt, function(t,k) return rawget(t,"dflt") end) setmetatableindex(punctuation.dflt, function(t,k) return rawget(t,"dflt") end) -local function typesettable(t,keys,synonyms,nesting,prefix) - if t then +-- scaled boolean string scale string float cardinal + +local function checked(specification) + specification = interfaces.checkedspecification(specification) + local id, cs = fonts.definers.internal(specification,"<module:fonts:features:font>") + local tfmdata = fonts.hashes.identifiers[id] + local resources = tfmdata.resources + return tfmdata, id, resources +end + +local function nothing() + context("no entries") + context.par() +end + +local function typesettable(t,keys,synonyms,nesting,prefix,depth) + if t and next(keys) then if not prefix then context.starttabulate { "|Tl|Tl|Tl|" } end for k, v in sortedhash(keys) do if k == "synonyms" then elseif type(v) ~= "table" then - context.NC() + ctx_NC() if prefix then context("%s.%s",prefix,k) else context(k) end - context.NC() + ctx_NC() + -- print(v) local tk = t[k] - if v == "boolean" then + if v == "<boolean>" then context(tostring(tk or false)) elseif not tk then context("<unset>") - elseif v == "filename" then + elseif k == "filename" then context(file.basename(tk)) - elseif v == "basepoints" then - context("%sbp",tk) - elseif v == "scaledpoints" then + -- elseif v == "basepoints" then + -- context("%sbp",tk) + elseif v == "<scaled>" then context("%p",tk) - elseif v == "table" then + elseif v == "<table>" then context("<table>") - else -- if v == "integerscale" then + else context(tostring(tk)) end - context.NC() - local synonym = (not prefix and synonyms[k]) or (prefix and synonyms[format("%s.%s",prefix,k)]) + ctx_NC() + local synonym = (not prefix and synonyms[k]) or (prefix and synonyms[formatters["%s.%s"](prefix,k)]) if synonym then - context(format("(%s)",concat(synonym," "))) + context("(% t)",synonym) end - context.NC() - context.NR() + ctx_NC() + ctx_NR() elseif nesting == false then context("<table>") - else -- true or nil - typesettable(t[k],v,synonyms,nesting,k) + elseif next(v) then + typesettable(t[k],v,synonyms,nesting,k,true) end end if not prefix then context.stoptabulate() end + return + end + if not depth then + nothing() end end @@ -175,51 +222,342 @@ end tabletracers.typeset = typeset -function tabletracers.showproperties(nesting) - local tfmdata = fonts.hashes.identifiers[font.current()] - typeset(tfmdata.properties,fonts.constructors.keys.properties,nesting) +-- function tabletracers.showproperties(nesting) +-- local tfmdata = fonts.hashes.identifiers[true] +-- typeset(tfmdata.properties,fonts.constructors.keys.properties,nesting) +-- end + +-- function tabletracers.showparameters(nesting) +-- local tfmdata = fonts.hashes.identifiers[true] +-- typeset(tfmdata.parameters,fonts.constructors.keys.parameters,nesting) +-- end + +function tabletracers.showproperties(specification) + local tfmdata = checked(specification) + if tfmdata then + typeset(tfmdata.properties,fonts.constructors.keys.properties) + else + nothing() + end +end + +function tabletracers.showparameters(specification) + local tfmdata = checked(specification) + if tfmdata then + typeset(tfmdata.parameters,fonts.constructors.keys.parameters) + else + nothing() + end end -function tabletracers.showparameters(nesting) - local tfmdata = fonts.hashes.identifiers[font.current()] - typeset(tfmdata.parameters,fonts.constructors.keys.parameters,nesting) +local f_u = formatters["%U"] +local f_p = formatters["%p"] + +local function morept(t) + local r = { } + for i=1,t do + r[i] = f_p(t[i]) + end + return concat(r," ") end -function tabletracers.showpositionings() - local tfmdata = fonts.hashes.resources[font.current()] - local resources = tfmdata.resources +local function noprefix(kind) + kind = string.gsub(kind,"^gpos_","") + kind = string.gsub(kind,"^gsub_","") + return kind +end + +local function banner(index,i,format,kind,order,chain) + if chain then + ctx_sequence("sequence: %i, step %i, format: %s, kind: %s, features: % t, chain: %s", + index,i,format,noprefix(kind),order,noprefix(chain)) + else + ctx_sequence("sequence: %i, step %i, format: %s, kind: %s, features: % t", + index,i,format,noprefix(kind),order) + end +end + +function tabletracers.showpositionings(specification) + + local tfmdata, fontid, resources = checked(specification) + 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 sortedhash(gpos) do - for script, languages in sortedhash(scripts) do - context.NC() - context(feature) - context.NC() - context(script) - context.NC() - context(concat(sortedkeys(languages)," ")) - context.NC() - context.NR() + + local direction = "TLT" + + local sequences = resources.sequences + local marks = resources.marks + + if tonumber(direction) == -1 or direction == "TRT" then + direction = "TRT" + else + direction = "TLT" + end + + local visuals = "fontkern,glyph,box" + + local datasets = fonts.handlers.otf.dataset(tfmdata,fontid,0) + + local function process(dataset,sequence,kind,order,chain) + local steps = sequence.steps + local order = sequence.order or order + local index = sequence.index + for i=1,#steps do + local step = steps[i] + local format = step.format + banner(index,i,format,kind,order,chain) + if kind == "gpos_pair" then + local format = step.format + if "kern" or format == "move" then + for first, seconds in sortedhash(step.coverage) do + local done = false + local zero = 0 + for second, kern in sortedhash(seconds) do + if kern == 0 then + zero = zero + 1 + else + if not done then + ctx_startPairKern() + end + local one = new_glyph(fontid,first) + local two = new_glyph(fontid,second) + local raw = setlink(copy_node(one),copy_node(two)) + local pos = setlink(done and one or copy_node(one),copy_node(two)) + pos, okay = handle_positions(pos,fontid,direction,dataset) + pos = handle_injections(pos) + applyvisuals(raw,visuals) + applyvisuals(pos,visuals) + pos = hpack(pos,"exact",nil,direction) + raw = hpack(raw,"exact",nil,direction) + ctx_NC() if not done then context(f_u(first)) end + ctx_NC() if not done then ctx_dontleavehmode() context(one) end + ctx_NC() context(f_u(second)) + ctx_NC() ctx_dontleavehmode() context(two) + ctx_NC() context("%p",kern) + ctx_NC() ctx_dontleavehmode() context(raw) + ctx_NC() ctx_dontleavehmode() context(pos) + ctx_NC() ctx_NR() + done = true + end + end + if done then + ctx_stopPairKern() + end + if zero > 0 then + ctx_type("zero: %s",zero) + end + end + elseif format == "pair" then + for first, seconds in sortedhash(step.coverage) do + local done = false + local allnull = 0 + local allzero = 0 + local zeronull = 0 + local nullzero = 0 + for second, pair in sortedhash(seconds) do + local pfirst = pair[1] + local psecond = pair[2] + if not pfirst and not psecond then + allnull = allnull + 1 + elseif pfirst == true and psecond == true then + allzero = allzero + 1 + elseif pfirst == true and not psecond then + zeronull = zeronull + 1 + elseif not pfirst and psecond == true then + nullzero = nullzero + 1 + else + if pfirst == true then + pfirst = "all zero" + elseif pfirst then + pfirst = morept(pfirst) + else + pfirst = "no first" + end + if psecond == true then + psecond = "all zero" + elseif psecond then + psecond = morept(psecond) + else + psecond = "no second" + end + if not done then + ctx_startPair() + end + local one = new_glyph(fontid,first) + local two = new_glyph(fontid,second) + local raw = setlink(copy_node(one),copy_node(two)) + local pos = setlink(done and one or copy_node(one),copy_node(two)) + pos, okay = handle_positions(pos,fontid,direction,dataset) + pos = handle_injections(pos) + applyvisuals(raw,visuals) + applyvisuals(pos,visuals) + pos = hpack(pos,"exact",nil,direction) + raw = hpack(raw,"exact",nil,direction) + ctx_NC() if not done then context(f_u(first)) end + ctx_NC() if not done then ctx_dontleavehmode() context(one) end + ctx_NC() context(f_u(second)) + ctx_NC() ctx_dontleavehmode() context(two) + ctx_NC() context(pfirst) + ctx_NC() context(psecond) + ctx_NC() ctx_dontleavehmode() context(raw) + ctx_NC() ctx_dontleavehmode() context(pos) + ctx_NC() ctx_NR() + done = true + end + end + if done then + ctx_stopPair() + end + if allnull > 0 or allzero > 0 or zeronull > 0 or nullzero > 0 then + ctx_type("both null: %s, both zero: %s, zero and null: %s, null and zero: %s", + allnull,allzero,zeronull,nullzero) + end + end + else + -- maybe + end + elseif kind == "gpos_single" then + local format = step.format + if format == "kern" or format == "move" then + local done = false + local zero = 0 + for first, kern in sortedhash(step.coverage) do + if kern == 0 then + zero = zero + 1 + else + if not done then + ctx_startSingleKern() + end + local one = new_glyph(fontid,first) + local raw = copy_node(one) + local pos = copy_node(one) + pos, okay = handle_positions(pos,fontid,direction,dataset) + pos = handle_injections(pos) + applyvisuals(raw,visuals) + applyvisuals(pos,visuals) + pos = hpack(pos,"exact",nil,direction) + raw = hpack(raw,"exact",nil,direction) + ctx_NC() context(f_u(first)) + ctx_NC() ctx_dontleavehmode() context(one) + ctx_NC() context("%p",kern) + ctx_NC() ctx_dontleavehmode() context(raw) + ctx_NC() ctx_dontleavehmode() context(pos) + ctx_NC() ctx_NR() + done = true + end + end + if done then + ctx_stopSingleKern() + end + if zero > 0 then + ctx_type("zero: %i",zero) + end + elseif format == "single" then + local done = false + local zero = 0 + local null = 0 + for first, single in sortedhash(step.coverage) do + if single == false then + null = null + 1 + elseif single == true then + zero = zero + 1 + else + single = morept(single) + if not done then + ctx_startSingle() + end + local one = new_glyph(fontid,first) + local raw = copy_node(one) + local pos = copy_node(one) + pos, okay = handle_positions(pos,fontid,direction,dataset) + pos = handle_injections(pos) + applyvisuals(raw,visuals) + applyvisuals(pos,visuals) + raw = hpack(raw,"exact",nil,direction) + pos = hpack(pos,"exact",nil,direction) + ctx_NC() context(f_u(first)) + ctx_NC() ctx_dontleavehmode() context(one) + ctx_NC() context(single) + ctx_NC() ctx_dontleavehmode() context(raw) + ctx_NC() ctx_dontleavehmode() context(pos) + ctx_NC() ctx_NR() + done = true + end + end + if done then + ctx_stopSingle() + end + if null > 0 then + if zero > 0 then + ctx_type("null: %i, zero: %i",null,zero) + else + ctx_type("null: %i",null) + end + else + if null > 0 then + ctx_type("both zero: %i",zero) + end + end + else + -- todo end end - context.stoptabulate() - else - context("no entries") - context.par() end end + + local done = false + + for d=1,#datasets do + local dataset = datasets[d] + local sequence = dataset[3] + local kind = sequence.type + if kind == "gpos_contextchain" or kind == "gpos_context" then + local steps = sequence.steps + for i=1,#steps do + local step = steps[i] + local rules = step.rules + if rules then + for i=1,#rules do + local rule = rules[i] + local lookups = rule.lookups + if lookups then + for i=1,#lookups do + local lookup = lookups[i] + if lookup then + local look = lookup[1] + local dnik = look.type + if dnik == "gpos_pair" or dnik == "gpos_single" then + process(dataset,look,dnik,sequence.order,kind) + end + end + end + end + end + end + end + done = true + elseif kind == "gpos_pair" or kind == "gpos_single" then + process(dataset,sequence,kind) + done = true + end + end + + if done then + return + end + end + + nothing() + end local dynamics = true -function tabletracers.showsubstitutions() - local tfmdata = fonts.hashes.identifiers[font.current()] - local resources = tfmdata.resources +function tabletracers.showsubstitutions(specification) + + local tfmdata, fontid, resources = checked(specification) + if resources then local features = resources.features if features then @@ -229,8 +567,8 @@ function tabletracers.showsubstitutions() for feature, scripts in sortedhash(gsub) do for script, languages in sortedhash(scripts) do for language in sortedhash(languages) do - local tag = format("dummy-%s-%s-%s",feature,script,language) - local fnt = format("file:%s*%s",file.basename(tfmdata.properties.filename),tag) + local tag = formatters["dummy-%s-%s-%s"](feature,script,language) + local fnt = formatters["file:%s*%s"](file.basename(tfmdata.properties.filename),tag) context.definefontfeature ( { tag }, { @@ -259,13 +597,13 @@ function tabletracers.showsubstitutions() local data = makes_sense[i] local script = data.script local language = data.language - context.NC() + ctx_NC() context(data.feature) - context.NC() + ctx_NC() context(script) - context.NC() + ctx_NC() context(language) - context.NC() + ctx_NC() if not dynamics then context.startfont { data.fontname } else @@ -279,85 +617,160 @@ function tabletracers.showsubstitutions() if not dynamics then context.stopfont() end - context.NC() - context.NR() + ctx_NC() + ctx_NR() end context.stoptabulate() - else - context("no entries") - context.par() + return end end end end + + nothing() + end -function tabletracers.showunicodevariants() +function tabletracers.showunicodevariants(specification) + + local tfmdata, fontid, resources = checked(specification) - local variants = fonts.hashes.variants[true] + if resources then - if variants then - context.starttabulate { "|c|c|c|c|c|c|c|" } - for selector, unicodes in sortedhash(variants) do - local done = false - for unicode, variant in sortedhash(unicodes) do - context.NC() - if not done then - context("%U",selector) - done = true + local variants = fonts.hashes.variants[fontid] + + if variants then + context.starttabulate { "|c|c|c|c|c|c|c|" } + for selector, unicodes in sortedhash(variants) do + local done = false + for unicode, variant in sortedhash(unicodes) do + ctx_NC() + if not done then + context("%U",selector) + done = true + end + ctx_NC() + context("%U",unicode) + ctx_NC() + context("%c",unicode) + ctx_NC() + context("%U",variant) + ctx_NC() + context("%c",variant) + ctx_NC() + context("%c%c",unicode,selector) + ctx_NC() + context.startoverlay() + context("{\\color[trace:r]{%c}}{\\color[trace:ds]{%c}}",unicode,variant) + context.stopoverlay() + ctx_NC() + ctx_NR() end - context.NC() - context("%U",unicode) - context.NC() - context("%c",unicode) - context.NC() - context("%U",variant) - context.NC() - context("%c",variant) - context.NC() - context("%c%c",unicode,selector) - context.NC() - context.startoverlay() - context("{\\color[trace:r]{%c}}{\\color[trace:ds]{%c}}",unicode,variant) - context.stopoverlay() - context.NC() - context.NR() end + context.stoptabulate() + return end - context.stoptabulate() + end + nothing() + end -function tabletracers.showall(specification) -- not interfaced - specification = interfaces.checkedspecification(specification) - if specification.title then - context.starttitle { title = specification.title } +local function collectligatures(steps) + + local series = { } + local stack = { } + local max = 0 + + local function make(tree) + for k, v in sortedhash(tree) do + if k == "ligature" then + local n = #stack + if n > max then + max = n + end + series[#series+1] = { v, unpack(stack) } + else + insert(stack,k) + make(v) + remove(stack) + end + end end - context.startsubject { title = "Properties" } - tabletracers.showproperties() - context.stopsubject() + for i=1,#steps do + local step = steps[i] + local coverage = step.coverage + if coverage then + make(coverage) + end + end - context.startsubject { title = "Parameters" } - tabletracers.showparameters() - context.stopsubject() + return series, max +end - context.startsubject { title = "Positioning features" } - tabletracers.showpositionings() - context.stopsubject() +local function banner(index,kind,order) + ctx_sequence("sequence: %i, kind: %s, features: % t",index,noprefix(kind),order) +end + +function tabletracers.showligatures(specification) - context.startsubject { title = "Substitution features" } - tabletracers.showsubstitutions() - context.stopsubject() + local tfmdata, fontid, resources = checked(specification) - context.startsubject { title = "Unicode variants" } - tabletracers.showunicodevariants() - context.stopsubject() + if resources then - if title then - context.stoptitle() + local characters = tfmdata.characters + local descriptions = tfmdata.descriptions + local sequences = resources.sequences + if sequences then + local done = true + for index=1,#sequences do + local sequence = sequences[index] + local kind = sequence.type + if kind == "gsub_ligature" then + local list, max = collectligatures(sequence.steps) + if #list > 0 then + banner(index,kind,sequence.order or { }) + context.starttabulate { "|T|" .. string.rep("|",max) .. "|T|T|" } + for i=1,#list do + local s = list[i] + local n = #s + local u = s[1] + local c = characters[u] + local d = descriptions[u] + ctx_NC() + context("%U",u) + ctx_NC() + ctx_setfontid(fontid) + ctx_char(u) + ctx_NC() + ctx_setfontid(fontid) + for i=2,n do + ctx_char(s[i]) + ctx_NC() + end + for i=n+1,max do + ctx_NC() + end + context(d.name) + ctx_NC() + context(c.tounicode) + ctx_NC() + ctx_NR() + end + context.stoptabulate() + done = true + end + end + end + if done then + return + end + end end + nothing() + end diff --git a/tex/context/modules/mkiv/s-fonts-tables.mkiv b/tex/context/modules/mkiv/s-fonts-tables.mkiv index 64fe76f0e..f1340c3ea 100644 --- a/tex/context/modules/mkiv/s-fonts-tables.mkiv +++ b/tex/context/modules/mkiv/s-fonts-tables.mkiv @@ -17,10 +17,28 @@ \registerctxluafile{s-fonts-tables}{} -\installmodulecommandluasingle \showfonttables {moduledata.fonts.tables.showall} +\definetabulate[Pair] [|T|cw(3em)|T|cw(3em)|Tw(10em)|Tw(10em)|cw(4em)|cw(4em)|] +\definetabulate[Single] [|T|cw(3em)|Tw(10em)|cw(4em)|cw(4em)|] +\definetabulate[SingleKern][|T|cw(3em)|Trw(5em)|cw(4em)|cw(4em)|] +\definetabulate[PairKern] [|T|cw(3em)|T|cw(3em)|Trw(5em)|cw(4em)|cw(4em)|] + +\definehead + [sequence] + [subsubject] + [style=\ttbf] + +\definecolor + [bbcolor] + [t=.5,a=1,s=.5] + +\definefontfeature + [boundingbox] + [boundingbox={background,bbcolor}] + \installmodulecommandluasingle \showfontproperties {moduledata.fonts.tables.showproperties} \installmodulecommandluasingle \showfontparameters {moduledata.fonts.tables.showparameters} \installmodulecommandluasingle \showfontpositionings {moduledata.fonts.tables.showpositionings} +\installmodulecommandluasingle \showfontligatures {moduledata.fonts.tables.showligatures} \installmodulecommandluasingle \showfontsubstitutions {moduledata.fonts.tables.showsubstitutions} \installmodulecommandluasingle \showfontunicodevariants{moduledata.fonts.tables.showunicodevariants} @@ -34,5 +52,5 @@ [cambria] \starttext - \showfonttables[title=Cambria] + \showfontproperties[name=cambria] \stoptext diff --git a/tex/context/modules/mkiv/s-fonts-variable.mkiv b/tex/context/modules/mkiv/s-fonts-variable.mkiv index d1bf8b69d..bc4b4a9b6 100644 --- a/tex/context/modules/mkiv/s-fonts-variable.mkiv +++ b/tex/context/modules/mkiv/s-fonts-variable.mkiv @@ -72,28 +72,28 @@ \char983040\relax\par \stopbuffer - \showfontvariations - [font=file:adobevfprototype.otf] +% \showfontvariations +% [font=file:adobevfprototype.otf] - \showfontvariations - [font=file:avenirnextvariable.ttf] +% \showfontvariations +% [font=file:avenirnextvariable.ttf] - \showfontvariations - [font=file:DecoVar-VF.ttf] +% \showfontvariations +% [font=file:DecoVar-VF.ttf] % \showfontvariations % [font=file:VotoSerifGX.ttf, % max=15] - \showfontvariations - [font=file:Selawik-Variable.ttf] +% \showfontvariations +% [font=file:Selawik-Variable.ttf] - \showfontvariations - [font=file:LibreFranklinGX-Romans.ttf] +% \showfontvariations +% [font=file:LibreFranklinGX-Romans.ttf] - \showfontvariations - [font=file:Zycon.ttf, - sample={\getbuffer[zycon]}] +% \showfontvariations +% [font=file:Zycon.ttf, +% sample={\getbuffer[zycon]}] % \showfontvariations % [font=file:kairossansvariable.ttf] diff --git a/tex/context/modules/mkiv/x-setups-basics.mkiv b/tex/context/modules/mkiv/x-setups-basics.mkiv index 422877bc2..028c9e5a5 100644 --- a/tex/context/modules/mkiv/x-setups-basics.mkiv +++ b/tex/context/modules/mkiv/x-setups-basics.mkiv @@ -66,6 +66,13 @@ \unprotect +% We might apply this locally! + +\setupxml + [\c!entities=\v!yes] + +% So far. + \defineregister [texmacro] diff --git a/tex/generic/context/luatex/luatex-basics-gen.lua b/tex/generic/context/luatex/luatex-basics-gen.lua index 64f3be218..ee0367fa4 100644 --- a/tex/generic/context/luatex/luatex-basics-gen.lua +++ b/tex/generic/context/luatex/luatex-basics-gen.lua @@ -18,6 +18,7 @@ local match, gmatch, gsub, lower = string.match, string.gmatch, string.gsub, str local formatters, split, format, dump = string.formatters, string.split, string.format, string.dump local loadfile, type = loadfile, type local setmetatable, getmetatable, collectgarbage = setmetatable, getmetatable, collectgarbage +local floor = math.floor local dummyfunction = function() end @@ -405,3 +406,11 @@ if arg then end end end + +-- another one + +if not number.idiv then + function number.idiv(i,d) + return floor(i/d) -- i//d in 5.3 + end +end diff --git a/tex/generic/context/luatex/luatex-core.lua b/tex/generic/context/luatex/luatex-core.lua index 7fcfb8100..35518c0e8 100644 --- a/tex/generic/context/luatex/luatex-core.lua +++ b/tex/generic/context/luatex/luatex-core.lua @@ -54,7 +54,7 @@ local function luatex_io_open(name,how) end local function luatex_io_open_readonly(name,how) - if how then + if not how then how = 'r' else how = gsub(how,'[^rb]','') @@ -174,6 +174,8 @@ if saferoption == 1 then lfs.rmdir = installdummy("lfs.rmdir") lfs.mkdir = installdummy("lfs.mkdir") + debug = nil + end if saferoption == 1 or shellescape ~= 1 then diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 0a14e6082..5499f8f18 100644 --- a/tex/generic/context/luatex/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : c:/data/develop/context/sources/luatex-fonts-merged.lua -- parent file : c:/data/develop/context/sources/luatex-fonts.lua --- merge date : 10/18/18 00:07:52 +-- merge date : 11/18/18 14:07:44 do -- begin closure to overcome local limits and interference @@ -1107,7 +1107,6 @@ local table,string=table,string local concat,sort,insert,remove=table.concat,table.sort,table.insert,table.remove local format,lower,dump=string.format,string.lower,string.dump local getmetatable,setmetatable=getmetatable,setmetatable -local getinfo=debug.getinfo local lpegmatch,patterns=lpeg.match,lpeg.patterns local floor=math.floor local stripper=patterns.stripper @@ -1669,20 +1668,23 @@ local function do_serialize(root,name,depth,level,indexed) end elseif tv=="function" then if functions then - local f=getinfo(v).what=="C" and dump(dummy) or dump(v) - if tk=="number" then - if hexify then - handle(format("%s [0x%X]=load(%q),",depth,k,f)) + local getinfo=debug and debug.getinfo + if getinfo then + local f=getinfo(v).what=="C" and dump(dummy) or dump(v) + if tk=="number" then + if hexify then + handle(format("%s [0x%X]=load(%q),",depth,k,f)) + else + handle(format("%s [%s]=load(%q),",depth,k,f)) + end + elseif tk=="boolean" then + handle(format("%s [%s]=load(%q),",depth,k and "true" or "false",f)) + elseif tk~="string" then + elseif noquotes and not reserved[k] and lpegmatch(propername,k) then + handle(format("%s %s=load(%q),",depth,k,f)) else - handle(format("%s [%s]=load(%q),",depth,k,f)) + handle(format("%s [%q]=load(%q),",depth,k,f)) end - elseif tk=="boolean" then - handle(format("%s [%s]=load(%q),",depth,k and "true" or "false",f)) - elseif tk~="string" then - elseif noquotes and not reserved[k] and lpegmatch(propername,k) then - handle(format("%s %s=load(%q),",depth,k,f)) - else - handle(format("%s [%q]=load(%q),",depth,k,f)) end end else @@ -4649,6 +4651,10 @@ function strings.newcollector() end end end +local f_16_16=formatters["%0.5N"] +function number.to16dot16(n) + return f_16_16(n/65536.0) +end end -- closure @@ -4661,6 +4667,7 @@ if not modules then modules={} end modules ['util-fil']={ copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files" } +local tonumber=tonumber local byte=string.byte local char=string.char utilities=utilities or {} @@ -4819,17 +4826,17 @@ end function files.readfixed2(f) local a,b=byte(f:read(2),1,2) if a>=0x80 then - return (a-0x100)+b/0x100 + tonumber((a-0x100).."."..b) else - return (a )+b/0x100 + tonumber((a ).."."..b) end end function files.readfixed4(f) local a,b,c,d=byte(f:read(4),1,4) if a>=0x80 then - return (0x100*a+b-0x10000)+(0x100*c+d)/0x10000 + tonumber((0x100*a+b-0x10000).."."..(0x100*c+d)) else - return (0x100*a+b )+(0x100*c+d)/0x10000 + tonumber((0x100*a+b ).."."..(0x100*c+d)) end end if bit32 then @@ -4963,6 +4970,7 @@ local match,gmatch,gsub,lower=string.match,string.gmatch,string.gsub,string.lowe local formatters,split,format,dump=string.formatters,string.split,string.format,string.dump local loadfile,type=loadfile,type local setmetatable,getmetatable,collectgarbage=setmetatable,getmetatable,collectgarbage +local floor=math.floor local dummyfunction=function() end local dummyreporter=function(c) @@ -5273,6 +5281,11 @@ if arg then end end end +if not number.idiv then + function number.idiv(i,d) + return floor(i/d) + end +end end -- closure @@ -9921,23 +9934,20 @@ function constructors.finalize(tfmdata) if not properties.virtualized then properties.virtualized=tfmdata.type=="virtual" end - if not tfmdata.properties then - tfmdata.properties={ - fontname=tfmdata.fontname, - filename=tfmdata.filename, - fullname=tfmdata.fullname, - name=tfmdata.name, - psname=tfmdata.psname, - encodingbytes=tfmdata.encodingbytes or 1, - embedding=tfmdata.embedding or "subset", - tounicode=tfmdata.tounicode or 1, - cidinfo=tfmdata.cidinfo or nil, - format=tfmdata.format or "type1", - direction=tfmdata.direction or 0, - writingmode=tfmdata.writingmode or "horizontal", - identity=tfmdata.identity or "horizontal", - } - end + properties.fontname=tfmdata.fontname + properties.filename=tfmdata.filename + properties.fullname=tfmdata.fullname + properties.name=tfmdata.name + properties.psname=tfmdata.psname + properties.encodingbytes=tfmdata.encodingbytes or 1 + properties.embedding=tfmdata.embedding or "subset" + properties.tounicode=tfmdata.tounicode or 1 + properties.cidinfo=tfmdata.cidinfo or nil + properties.format=tfmdata.format or "type1" + properties.direction=tfmdata.direction or 0 + properties.writingmode=tfmdata.writingmode or "horizontal" + properties.identity=tfmdata.identity or "horizontal" + properties.usedbitmap=tfmdata.usedbitmap if not tfmdata.resources then tfmdata.resources={} end @@ -11244,6 +11254,7 @@ if not modules then modules={} end modules ['font-otr']={ } local next,type,tonumber=next,type,tonumber local byte,lower,char,gsub=string.byte,string.lower,string.char,string.gsub +local fullstrip=string.fullstrip local floor,round=math.floor,math.round local P,R,S,C,Cs,Cc,Ct,Carg,Cmt=lpeg.P,lpeg.R,lpeg.S,lpeg.C,lpeg.Cs,lpeg.Cc,lpeg.Ct,lpeg.Carg,lpeg.Cmt local lpegmatch=lpeg.match @@ -11520,19 +11531,29 @@ local helpers={} readers.helpers=helpers local function gotodatatable(f,fontdata,tag,criterium) if criterium and f then - local datatable=fontdata.tables[tag] - if datatable then - local tableoffset=datatable.offset - setposition(f,tableoffset) - return tableoffset + local tables=fontdata.tables + if tables then + local datatable=tables[tag] + if datatable then + local tableoffset=datatable.offset + setposition(f,tableoffset) + return tableoffset + end + else + report("no tables") end end end local function reportskippedtable(f,fontdata,tag,criterium) if criterium and f then - local datatable=fontdata.tables[tag] - if datatable then - report("loading of table %a skipped",tag) + local tables=fontdata.tables + if tables then + local datatable=tables[tag] + if datatable then + report("loading of table %a skipped",tag) + end + else + report("no tables") end end end @@ -11556,6 +11577,15 @@ local platformnames={ typographicsubfamily=true, compatiblefullname=true, } +local platformextras={ + uniqueid=true, + version=true, + copyright=true, + license=true, + licenseurl=true, + manufacturer=true, + vendorurl=true, +} function readers.name(f,fontdata,specification) local tableoffset=gotodatatable(f,fontdata,"name",true) if tableoffset then @@ -11608,6 +11638,17 @@ function readers.name(f,fontdata,specification) local names={} local done={} local extras={} + local function decoded(platform,encoding,content) + local decoder=decoders[platform] + if decoder then + decoder=decoder[encoding] + end + if decoder then + return decoder(content) + else + return content + end + end local function filter(platform,e,l) local namelist=namelists[platform] for i=1,#namelist do @@ -11619,14 +11660,7 @@ function readers.name(f,fontdata,specification) local language=name.language if (not e or encoding==e) and (not l or language==l) then setposition(f,name.offset) - local content=readstring(f,name.length) - local decoder=decoders[platform] - if decoder then - decoder=decoder[encoding] - end - if decoder then - content=decoder(content) - end + local content=decoded(platform,encoding,readstring(f,name.length)) if nametag then names[nametag]={ content=content, @@ -11650,22 +11684,15 @@ function readers.name(f,fontdata,specification) fontdata.extras=extras if specification.platformnames then local collected={} + local platformextras=specification.platformextras and platformextras for platform,namelist in next,namelists do local filtered=false for i=1,#namelist do local entry=namelist[i] local name=entry.name - if platformnames[name] then + if platformnames[name] or (platformextras and platformextras[name]) then setposition(f,entry.offset) - local content=readstring(f,entry.length) - local encoding=entry.encoding - local decoder=decoders[platform] - if decoder then - decoder=decoder[encoding] - end - if decoder then - content=decoder(content) - end + local content=decoded(platform,entry.encoding,readstring(f,entry.length)) if filtered then filtered[name]=content else @@ -11748,10 +11775,13 @@ end readers.head=function(f,fontdata) local tableoffset=gotodatatable(f,fontdata,"head",true) if tableoffset then + local version=readulong(f) + local fontversion=readulong(f) local fontheader={ - version=readfixed(f), - revision=readfixed(f), - checksum=readulong(f), + version=version, + fontversion=number.to16dot16(fontversion), + fontversionnumber=fontversion, + checksum=readushort(f)*0x10000+readushort(f), magic=readulong(f), flags=readushort(f), units=readushort(f), @@ -11777,7 +11807,7 @@ readers.hhea=function(f,fontdata,specification) local tableoffset=gotodatatable(f,fontdata,"hhea",specification.details) if tableoffset then fontdata.horizontalheader={ - version=readfixed(f), + version=readulong(f), ascender=readfword(f), descender=readfword(f), linegap=readfword(f), @@ -11805,7 +11835,7 @@ readers.vhea=function(f,fontdata,specification) local tableoffset=gotodatatable(f,fontdata,"vhea",specification.details) if tableoffset then fontdata.verticalheader={ - version=readfixed(f), + version=readulong(f), ascender=readfword(f), descender=readfword(f), linegap=readfword(f), @@ -11832,15 +11862,15 @@ end readers.maxp=function(f,fontdata,specification) local tableoffset=gotodatatable(f,fontdata,"maxp",specification.details) if tableoffset then - local version=readfixed(f) + local version=readulong(f) local nofglyphs=readushort(f) fontdata.nofglyphs=nofglyphs - if version==0.5 then + if version==0x00005000 then fontdata.maximumprofile={ version=version, nofglyphs=nofglyphs, } - elseif version==1.0 then + elseif version==0x00010000 then fontdata.maximumprofile={ version=version, nofglyphs=nofglyphs, @@ -11877,7 +11907,7 @@ readers.hmtx=function(f,fontdata,specification) local leftsidebearing=0 for i=0,nofmetrics-1 do local glyph=glyphs[i] - width=readshort(f) + width=readshort(f) leftsidebearing=readshort(f) if width~=0 then glyph.width=width @@ -11923,7 +11953,7 @@ end readers.post=function(f,fontdata,specification) local tableoffset=gotodatatable(f,fontdata,"post",true) if tableoffset then - local version=readfixed(f) + local version=readulong(f) fontdata.postscript={ version=version, italicangle=round(1000*readfixed(f))/1000, @@ -11936,11 +11966,11 @@ readers.post=function(f,fontdata,specification) maxmemtype1=readulong(f), } if not specification.glyphs then - elseif version==1.0 then + elseif version==0x00010000 then for index=0,#standardromanencoding do glyphs[index].name=standardromanencoding[index] end - elseif version==2.0 then + elseif version==0x00020000 then local glyphs=fontdata.glyphs local nofglyphs=readushort(f) local indices={} @@ -11971,8 +12001,6 @@ readers.post=function(f,fontdata,specification) end end end - elseif version==2.5 then - elseif version==3.0 then end else fontdata.postscript={} @@ -12529,14 +12557,16 @@ local function getinfo(maindata,sub,platformnames,rawfamilynames,metricstoo,inst designsize=fontdata.designsize, minsize=fontdata.minsize, maxsize=fontdata.maxsize, + boundingbox=fontheader and { fontheader.xmin or 0,fontheader.ymin or 0,fontheader.xmax or 0,fontheader.ymax or 0 } or nil, monospaced=(tonumber(postscript.monospaced or 0)>0) or metrics.panosewidth=="monospaced", averagewidth=metrics.averagewidth, xheight=metrics.xheight, - capheight=metrics.capheight, + capheight=metrics.capheight or fontdata.maxy, ascender=metrics.typoascender, descender=metrics.typodescender, platformnames=platformnames or nil, instancenames=instancenames or nil, + tableoffsets=fontdata.tableoffsets, } if metricstoo then local keys={ @@ -12594,7 +12624,7 @@ local function loadtables(f,specification,offset) } for i=1,fontdata.noftables do local tag=lower(stripstring(readstring(f,4))) - local checksum=readulong(f) + local checksum=readushort(f)*0x10000+readushort(f) local offset=readulong(f) local length=readulong(f) if offset+length>filesize then @@ -12612,7 +12642,7 @@ local function loadtables(f,specification,offset) else fontdata.format="truetype" end - return fontdata + return fontdata,tables end local function prepareglyps(fontdata) local glyphs=setmetatableindex(function(t,k) @@ -12633,7 +12663,7 @@ local function readtable(tag,f,fontdata,specification,...) end local variablefonts_supported=(context and true) or (logs and logs.application and true) or false local function readdata(f,offset,specification) - local fontdata=loadtables(f,specification,offset) + local fontdata,tables=loadtables(f,specification,offset) if specification.glyphs then prepareglyps(fontdata) end @@ -12743,9 +12773,18 @@ local function readdata(f,offset,specification) readtable("gpos",f,fontdata,specification) readtable("math",f,fontdata,specification) fontdata.locations=nil - fontdata.tables=nil fontdata.cidmaps=nil fontdata.dictionaries=nil + if specification.tableoffsets then + fontdata.tableoffsets=tables + setmetatableindex(tables,{ + version=fontdata.version, + noftables=fontdata.noftables, + searchrange=fontdata.searchrange, + entryselector=fontdata.entryselector, + rangeshift=fontdata.rangeshift, + }) + end return fontdata end local function loadfontdata(specification) @@ -12849,7 +12888,7 @@ local function loadfont(specification,n,instance) specification.instance=specification.instance or instance end local function message(str) - report("fatal error in file %a: %s\n%s",specification.filename,str,debug.traceback()) + report("fatal error in file %a: %s\n%s",specification.filename,str,debug and debug.traceback()) end local ok,result=xpcall(loadfontdata,message,specification) if ok then @@ -12871,12 +12910,25 @@ function readers.loadshapes(filename,n,instance,streams) v.index=nil v.math=nil end + local names=fontdata.names + if names then + for k,v in next,names do + names[k]=fullstrip(v.content) + end + end end return fontdata and { filename=filename, format=fontdata.format, glyphs=fontdata.glyphs, units=fontdata.fontheader.units, + cffinfo=fontdata.cffinfo, + fontheader=fontdata.fontheader, + horizontalheader=fontdata.horizontalheader, + verticalheader=fontdata.verticalheader, + maximumprofile=fontdata.maximumprofile, + names=fontdata.names, + postscript=fontdata.postscript, } or { filename=filename, format="unknown", @@ -12940,10 +12992,12 @@ function readers.getinfo(filename,specification) local platformnames=false local rawfamilynames=false local instancenames=true + local tableoffsets=false if type(specification)=="table" then subfont=tonumber(specification.subfont) platformnames=specification.platformnames rawfamilynames=specification.rawfamilynames + tableoffsets=specification.tableoffsets else subfont=tonumber(specification) end @@ -12952,6 +13006,7 @@ function readers.getinfo(filename,specification) details=true, platformnames=platformnames, instancenames=true, + tableoffsets=tableoffsets, } if fontdata then local subfonts=fontdata.subfonts @@ -14219,7 +14274,7 @@ if not modules then modules={} end modules ['font-cff']={ copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files" } -local next,type,tonumber=next,type,tonumber +local next,type,tonumber,rawget=next,type,tonumber,rawget local byte,char,gmatch=string.byte,string.char,string.gmatch local concat,remove,unpack=table.concat,table.remove,table.unpack local floor,abs,round,ceil,min,max=math.floor,math.abs,math.round,math.ceil,math.min,math.max @@ -14227,6 +14282,8 @@ local P,C,R,S,C,Cs,Ct=lpeg.P,lpeg.C,lpeg.R,lpeg.S,lpeg.C,lpeg.Cs,lpeg.Ct local lpegmatch=lpeg.match local formatters=string.formatters local bytetable=string.bytetable +local idiv=number.idiv +local rshift,band,extract=bit32.rshift,bit32.band,bit32.extract local readers=fonts.handlers.otf.readers local streamreader=readers.streamreader local readstring=streamreader.readstring @@ -14421,8 +14478,25 @@ do end+P("\05")/function() result.fontbbox={ unpack(stack,1,4) } top=0 - end -+P("\13")/function() + end+P("\06")/function() + result.bluevalues={ unpack(stack,1,top) } + top=0 + end+P("\07")/function() + result.otherblues={ unpack(stack,1,top) } + top=0 + end+P("\08")/function() + result.familyblues={ unpack(stack,1,top) } + top=0 + end+P("\09")/function() + result.familyotherblues={ unpack(stack,1,top) } + top=0 + end+P("\10")/function() + result.strhw=stack[top] + top=0 + end+P("\11")/function() + result.strvw=stack[top] + top=0 + end+P("\13")/function() result.uniqueid=stack[top] top=0 end+P("\14")/function() @@ -14488,6 +14562,21 @@ do end+P("\08")/function() result.strokewidth=stack[top] top=0 + end+P("\09")/function() + result.bluescale=stack[top] + top=0 + end+P("\10")/function() + result.bluesnap=stack[top] + top=0 + end+P("\11")/function() + result.bluefuzz=stack[top] + top=0 + end+P("\12")/function() + result.stemsnaph={ unpack(stack,1,top) } + top=0 + end+P("\13")/function() + result.stemsnapv={ unpack(stack,1,top) } + top=0 end+P("\20")/function() result.syntheticbase=stack[top] top=0 @@ -14531,24 +14620,24 @@ do top=0 end ) - local p_last=P("\x0F")/"0"+P("\x1F")/"1"+P("\x2F")/"2"+P("\x3F")/"3"+P("\x4F")/"4"+P("\x5F")/"5"+P("\x6F")/"6"+P("\x7F")/"7"+P("\x8F")/"8"+P("\x9F")/"9"+P("\xAF")/""+P("\xBF")/""+P("\xCF")/""+P("\xDF")/""+P("\xEF")/""+R("\xF0\xFF")/"" local remap={ ["\x00"]="00",["\x01"]="01",["\x02"]="02",["\x03"]="03",["\x04"]="04",["\x05"]="05",["\x06"]="06",["\x07"]="07",["\x08"]="08",["\x09"]="09",["\x0A"]="0.",["\x0B"]="0E",["\x0C"]="0E-",["\x0D"]="0",["\x0E"]="0-",["\x0F"]="0", - ["\x10"]="10",["\x11"]="11",["\x12"]="12",["\x13"]="13",["\x14"]="14",["\x15"]="15",["\x16"]="16",["\x17"]="17",["\x18"]="18",["\x19"]="19",["\x1A"]="0.",["\x1B"]="0E",["\x1C"]="0E-",["\x1D"]="0",["\x1E"]="0-",["\x1F"]="0", - ["\x20"]="20",["\x21"]="21",["\x22"]="22",["\x23"]="23",["\x24"]="24",["\x25"]="25",["\x26"]="26",["\x27"]="27",["\x28"]="28",["\x29"]="29",["\x2A"]="0.",["\x2B"]="0E",["\x2C"]="0E-",["\x2D"]="0",["\x2E"]="0-",["\x2F"]="0", - ["\x30"]="30",["\x31"]="31",["\x32"]="32",["\x33"]="33",["\x34"]="34",["\x35"]="35",["\x36"]="36",["\x37"]="37",["\x38"]="38",["\x39"]="39",["\x3A"]="0.",["\x3B"]="0E",["\x3C"]="0E-",["\x3D"]="0",["\x3E"]="0-",["\x3F"]="0", - ["\x40"]="40",["\x41"]="41",["\x42"]="42",["\x43"]="43",["\x44"]="44",["\x45"]="45",["\x46"]="46",["\x47"]="47",["\x48"]="48",["\x49"]="49",["\x4A"]="0.",["\x4B"]="0E",["\x4C"]="0E-",["\x4D"]="0",["\x4E"]="0-",["\x4F"]="0", - ["\x50"]="50",["\x51"]="51",["\x52"]="52",["\x53"]="53",["\x54"]="54",["\x55"]="55",["\x56"]="56",["\x57"]="57",["\x58"]="58",["\x59"]="59",["\x5A"]="0.",["\x5B"]="0E",["\x5C"]="0E-",["\x5D"]="0",["\x5E"]="0-",["\x5F"]="0", - ["\x60"]="60",["\x61"]="61",["\x62"]="62",["\x63"]="63",["\x64"]="64",["\x65"]="65",["\x66"]="66",["\x67"]="67",["\x68"]="68",["\x69"]="69",["\x6A"]="0.",["\x6B"]="0E",["\x6C"]="0E-",["\x6D"]="0",["\x6E"]="0-",["\x6F"]="0", - ["\x70"]="70",["\x71"]="71",["\x72"]="72",["\x73"]="73",["\x74"]="74",["\x75"]="75",["\x76"]="76",["\x77"]="77",["\x78"]="78",["\x79"]="79",["\x7A"]="0.",["\x7B"]="0E",["\x7C"]="0E-",["\x7D"]="0",["\x7E"]="0-",["\x7F"]="0", - ["\x80"]="80",["\x81"]="81",["\x82"]="82",["\x83"]="83",["\x84"]="84",["\x85"]="85",["\x86"]="86",["\x87"]="87",["\x88"]="88",["\x89"]="89",["\x8A"]="0.",["\x8B"]="0E",["\x8C"]="0E-",["\x8D"]="0",["\x8E"]="0-",["\x8F"]="0", - ["\x90"]="90",["\x91"]="91",["\x92"]="92",["\x93"]="93",["\x94"]="94",["\x95"]="95",["\x96"]="96",["\x97"]="97",["\x98"]="98",["\x99"]="99",["\x9A"]="0.",["\x9B"]="0E",["\x9C"]="0E-",["\x9D"]="0",["\x9E"]="0-",["\x9F"]="0", + ["\x10"]="10",["\x11"]="11",["\x12"]="12",["\x13"]="13",["\x14"]="14",["\x15"]="15",["\x16"]="16",["\x17"]="17",["\x18"]="18",["\x19"]="19",["\x1A"]="1.",["\x1B"]="1E",["\x1C"]="1E-",["\x1D"]="1",["\x1E"]="1-",["\x1F"]="1", + ["\x20"]="20",["\x21"]="21",["\x22"]="22",["\x23"]="23",["\x24"]="24",["\x25"]="25",["\x26"]="26",["\x27"]="27",["\x28"]="28",["\x29"]="29",["\x2A"]="2.",["\x2B"]="2E",["\x2C"]="2E-",["\x2D"]="2",["\x2E"]="2-",["\x2F"]="2", + ["\x30"]="30",["\x31"]="31",["\x32"]="32",["\x33"]="33",["\x34"]="34",["\x35"]="35",["\x36"]="36",["\x37"]="37",["\x38"]="38",["\x39"]="39",["\x3A"]="3.",["\x3B"]="3E",["\x3C"]="3E-",["\x3D"]="3",["\x3E"]="3-",["\x3F"]="3", + ["\x40"]="40",["\x41"]="41",["\x42"]="42",["\x43"]="43",["\x44"]="44",["\x45"]="45",["\x46"]="46",["\x47"]="47",["\x48"]="48",["\x49"]="49",["\x4A"]="4.",["\x4B"]="4E",["\x4C"]="4E-",["\x4D"]="4",["\x4E"]="4-",["\x4F"]="4", + ["\x50"]="50",["\x51"]="51",["\x52"]="52",["\x53"]="53",["\x54"]="54",["\x55"]="55",["\x56"]="56",["\x57"]="57",["\x58"]="58",["\x59"]="59",["\x5A"]="5.",["\x5B"]="5E",["\x5C"]="5E-",["\x5D"]="5",["\x5E"]="5-",["\x5F"]="5", + ["\x60"]="60",["\x61"]="61",["\x62"]="62",["\x63"]="63",["\x64"]="64",["\x65"]="65",["\x66"]="66",["\x67"]="67",["\x68"]="68",["\x69"]="69",["\x6A"]="6.",["\x6B"]="6E",["\x6C"]="6E-",["\x6D"]="6",["\x6E"]="6-",["\x6F"]="6", + ["\x70"]="70",["\x71"]="71",["\x72"]="72",["\x73"]="73",["\x74"]="74",["\x75"]="75",["\x76"]="76",["\x77"]="77",["\x78"]="78",["\x79"]="79",["\x7A"]="7.",["\x7B"]="7E",["\x7C"]="7E-",["\x7D"]="7",["\x7E"]="7-",["\x7F"]="7", + ["\x80"]="80",["\x81"]="81",["\x82"]="82",["\x83"]="83",["\x84"]="84",["\x85"]="85",["\x86"]="86",["\x87"]="87",["\x88"]="88",["\x89"]="89",["\x8A"]="8.",["\x8B"]="8E",["\x8C"]="8E-",["\x8D"]="8",["\x8E"]="8-",["\x8F"]="8", + ["\x90"]="90",["\x91"]="91",["\x92"]="92",["\x93"]="93",["\x94"]="94",["\x95"]="95",["\x96"]="96",["\x97"]="97",["\x98"]="98",["\x99"]="99",["\x9A"]="9.",["\x9B"]="9E",["\x9C"]="9E-",["\x9D"]="9",["\x9E"]="9-",["\x9F"]="9", ["\xA0"]=".0",["\xA1"]=".1",["\xA2"]=".2",["\xA3"]=".3",["\xA4"]=".4",["\xA5"]=".5",["\xA6"]=".6",["\xA7"]=".7",["\xA8"]=".8",["\xA9"]=".9",["\xAA"]="..",["\xAB"]=".E",["\xAC"]=".E-",["\xAD"]=".",["\xAE"]=".-",["\xAF"]=".", ["\xB0"]="E0",["\xB1"]="E1",["\xB2"]="E2",["\xB3"]="E3",["\xB4"]="E4",["\xB5"]="E5",["\xB6"]="E6",["\xB7"]="E7",["\xB8"]="E8",["\xB9"]="E9",["\xBA"]="E.",["\xBB"]="EE",["\xBC"]="EE-",["\xBD"]="E",["\xBE"]="E-",["\xBF"]="E", ["\xC0"]="E-0",["\xC1"]="E-1",["\xC2"]="E-2",["\xC3"]="E-3",["\xC4"]="E-4",["\xC5"]="E-5",["\xC6"]="E-6",["\xC7"]="E-7",["\xC8"]="E-8",["\xC9"]="E-9",["\xCA"]="E-.",["\xCB"]="E-E",["\xCC"]="E-E-",["\xCD"]="E-",["\xCE"]="E--",["\xCF"]="E-", ["\xD0"]="-0",["\xD1"]="-1",["\xD2"]="-2",["\xD3"]="-3",["\xD4"]="-4",["\xD5"]="-5",["\xD6"]="-6",["\xD7"]="-7",["\xD8"]="-8",["\xD9"]="-9",["\xDA"]="-.",["\xDB"]="-E",["\xDC"]="-E-",["\xDD"]="-",["\xDE"]="--",["\xDF"]="-", } - local p_nibbles=P("\30")*Cs(((1-p_last)/remap)^0+p_last)/function(n) + local p_last=S("\x0F\x1F\x2F\x3F\x4F\x5F\x6F\x7F\x8F\x9F\xAF\xBF")+R("\xF0\xFF") + local p_nibbles=P("\30")*Cs(((1-p_last)/remap)^0*(P(1)/remap))/function(n) top=top+1 stack[top]=tonumber(n) or 0 end @@ -15169,7 +15258,7 @@ do if trace_charstrings then showstate("stem") end - stems=stems+top/2 + stems=stems+idiv(top,2) top=0 end local function getmask() @@ -15188,13 +15277,13 @@ do if trace_charstrings then showstate(operator==19 and "hintmark" or "cntrmask") end - stems=stems+top/2 + stems=stems+idiv(top,2) top=0 if stems==0 then elseif stems<=8 then return 1 else - return floor((stems+7)/8) + return idiv(stems+7,8) end end local function unsupported(t) @@ -15233,7 +15322,7 @@ do local function hsbw() if version==1 then if trace_charstrings then - showstate("dotsection") + showstate("hsbw") end width=stack[top] end @@ -15419,76 +15508,98 @@ do [036]=hflex1, [037]=flex1, } - local c_endchar=char(14) - local passon do - local rshift=bit32.rshift - local band=bit32.band - local round=math.round - local encode=table.setmetatableindex(function(t,i) - for i=-2048,-1130 do - t[i]=char(28,band(rshift(i,8),0xFF),band(i,0xFF)) - end - for i=-1131,-108 do - local v=0xFB00-i-108 - t[i]=char(band(rshift(v,8),0xFF),band(v,0xFF)) - end - for i=-107,107 do - t[i]=char(i+139) - end - for i=108,1131 do - local v=0xF700+i-108 - t[i]=char(band(rshift(v,8),0xFF),band(v,0xFF)) - end - for i=1132,2048 do - t[i]=char(28,band(rshift(i,8),0xFF),band(i,0xFF)) - end - return t[i] - end) - local function setvsindex() - local vsindex=stack[top] - updateregions(vsindex) - top=top-1 + local chars=setmetatableindex(function (t,k) + local v=char(k) + t[k]=v + return v + end) + local c_endchar=chars[14] + local encode={} + setmetatableindex(encode,function(t,i) + for i=-2048,-1130 do + t[i]=char(28,band(rshift(i,8),0xFF),band(i,0xFF)) end - local function blend() - local n=stack[top] - top=top-1 - if not axis then - elseif n==1 then - top=top-nofregions - local v=stack[top] + for i=-1131,-108 do + local v=0xFB00-i-108 + t[i]=char(band(rshift(v,8),0xFF),band(v,0xFF)) + end + for i=-107,107 do + t[i]=chars[i+139] + end + for i=108,1131 do + local v=0xF700+i-108 + t[i]=char(extract(v,8,8),extract(v,0,8)) + end + for i=1132,2048 do + t[i]=char(28,band(rshift(i,8),0xFF),band(i,0xFF)) + end + setmetatableindex(encode,function(t,k) + local r=round(k) + local v=rawget(t,r) + if v then + return v + end + local v1=floor(k) + local v2=floor((k-v1)*0x10000) + return char(255,extract(v1,8,8),extract(v1,0,8),extract(v2,8,8),extract(v2,0,8)) + end) + return t[i] + end) + readers.cffencoder=encode + local function p_setvsindex() + local vsindex=stack[top] + updateregions(vsindex) + top=top-1 + end + local function p_blend() + local n=stack[top] + top=top-1 + if not axis then + elseif n==1 then + top=top-nofregions + local v=stack[top] + for r=1,nofregions do + v=v+stack[top+r]*factors[r] + end + stack[top]=round(v) + else + top=top-nofregions*n + local d=top + local k=top-n + for i=1,n do + k=k+1 + local v=stack[k] for r=1,nofregions do - v=v+stack[top+r]*factors[r] - end - stack[top]=round(v) - else - top=top-nofregions*n - local d=top - local k=top-n - for i=1,n do - k=k+1 - local v=stack[k] - for r=1,nofregions do - v=v+stack[d+r]*factors[r] - end - stack[k]=round(v) - d=d+nofregions + v=v+stack[d+r]*factors[r] end + stack[k]=round(v) + d=d+nofregions end end - passon=function(operation) - if operation==15 then - setvsindex() - elseif operation==16 then - blend() - else - for i=1,top do - r=r+1 - result[r]=encode[stack[i]] - end - r=r+1 - result[r]=char(operation) - top=0 - end + end + local function p_getstem() + local n=0 + if top%2~=0 then + n=1 + end + if top>n then + stems=stems+idiv(top-n,2) + end + end + local function p_getmask() + local n=0 + if top%2~=0 then + n=1 + end + if top>n then + stems=stems+idiv(top-n,2) + end + if stems==0 then + return 0 + elseif stems<=8 then + return 1 + else + return idiv(stems+7,8) end end local process @@ -15576,19 +15687,90 @@ do elseif t==12 then i=i+1 local t=tab[i] - local a=subactions[t] - if a then - a(t) + if justpass then + if t>=34 or t<=37 then + for i=1,top do + r=r+1;result[r]=encode[stack[i]] + end + r=r+1;result[r]=chars[12] + r=r+1;result[r]=chars[t] + top=0 + else + local a=subactions[t] + if a then + a(t) + else + top=0 + end + end else - if trace_charstrings then - showvalue("<subaction>",t) + local a=subactions[t] + if a then + a(t) + else + if trace_charstrings then + showvalue("<subaction>",t) + end + top=0 end - top=0 end i=i+1 elseif justpass then - passon(t) - i=i+1 + if t==15 then + p_setvsindex() + i=i+1 + elseif t==16 then + local s=p_blend() or 0 + i=i+s+1 + elseif t==1 or t==3 or t==18 or operation==23 then + p_getstem() +if true then + if top>0 then + for i=1,top do + r=r+1;result[r]=encode[stack[i]] + end + top=0 + end + r=r+1;result[r]=chars[t] +else + top=0 +end + i=i+1 + elseif t==19 or t==20 then + local s=p_getmask() or 0 +if true then + if top>0 then + for i=1,top do + r=r+1;result[r]=encode[stack[i]] + end + top=0 + end + r=r+1;result[r]=chars[t] + for j=1,s do + i=i+1 + r=r+1;result[r]=chars[tab[i]] + end +else + i=i+s + top=0 +end + i=i+1 + elseif t==9 then + top=0 + i=i+1 + elseif t==13 then + local s=hsbw() or 0 + i=i+s+1 + else + if top>0 then + for i=1,top do + r=r+1;result[r]=encode[stack[i]] + end + top=0 + end + r=r+1;result[r]=chars[t] + i=i+1 + end else local a=actions[t] if a then @@ -15609,18 +15791,20 @@ do end end local function setbias(globals,locals) - if version==1 then - return - false, - false - else local g,l=#globals,#locals return ((g<1240 and 107) or (g<33900 and 1131) or 32768)+1, ((l<1240 and 107) or (l<33900 and 1131) or 32768)+1 - end end local function processshape(tab,index) + if not tab then + glyphs[index]={ + boundingbox={ 0,0,0,0 }, + width=0, + name=charset and charset[index] or nil, + } + return + end tab=bytetable(tab) x=0 y=0 @@ -15733,15 +15917,18 @@ do glyphs=glphs or {} globalbias,localbias=setbias(globals,locals) nominalwidth,defaultwidth=setwidths(dictionary.private) - startparsing(fontdata,data,streams) - for index=1,#charstrings do - processshape(charstrings[index],index-1) - charstrings[index]=nil + if charstrings then + startparsing(fontdata,data,streams) + for index=1,#charstrings do + processshape(charstrings[index],index-1) + end + stopparsing(fontdata,data) + else + report("no charstrings") end - stopparsing(fontdata,data) return glyphs end - parsecharstring=function(fontdata,data,dictionary,tab,glphs,index,doshapes,tversion) + parsecharstring=function(fontdata,data,dictionary,tab,glphs,index,doshapes,tversion,streams) keepcurve=doshapes version=tversion strings=data.strings @@ -15750,6 +15937,7 @@ do charset=false vsindex=dictionary.vsindex or 0 glyphs=glphs or {} + justpass=streams==true globalbias,localbias=setbias(globals,locals) nominalwidth,defaultwidth=setwidths(dictionary.private) processshape(tab,index-1) @@ -15903,7 +16091,7 @@ local function readfdselect(f,fontdata,data,glyphs,doshapes,version,streams) local format=readbyte(f) if format==1 then for i=0,nofglyphs do - local index=readbyte(i) + local index=readbyte(f) fdindex[i]=index if index>maxindex then maxindex=index @@ -15932,30 +16120,33 @@ local function readfdselect(f,fontdata,data,glyphs,doshapes,version,streams) end if maxindex>=0 then local cidarray=cid.fdarray - setposition(f,header.offset+cidarray) - local dictionaries=readlengths(f) - for i=1,#dictionaries do - dictionaries[i]=readstring(f,dictionaries[i]) - end - parsedictionaries(data,dictionaries) - cid.dictionaries=dictionaries - readcidprivates(f,data) - for i=1,#dictionaries do - readlocals(f,data,dictionaries[i]) - end - startparsing(fontdata,data,streams) - for i=1,#charstrings do - parsecharstring(fontdata,data,dictionaries[fdindex[i]+1],charstrings[i],glyphs,i,doshapes,version) - charstrings[i]=nil + if cidarray then + setposition(f,header.offset+cidarray) + local dictionaries=readlengths(f) + for i=1,#dictionaries do + dictionaries[i]=readstring(f,dictionaries[i]) + end + parsedictionaries(data,dictionaries) + cid.dictionaries=dictionaries + readcidprivates(f,data) + for i=1,#dictionaries do + readlocals(f,data,dictionaries[i]) + end + startparsing(fontdata,data,streams) + for i=1,#charstrings do + parsecharstring(fontdata,data,dictionaries[fdindex[i]+1],charstrings[i],glyphs,i,doshapes,version,streams) + end + stopparsing(fontdata,data) + else + report("no cid array") end - stopparsing(fontdata,data) end end local gotodatatable=readers.helpers.gotodatatable local function cleanup(data,dictionaries) end function readers.cff(f,fontdata,specification) - local tableoffset=gotodatatable(f,fontdata,"cff",specification.details) + local tableoffset=gotodatatable(f,fontdata,"cff",specification.details or specification.glyphs) if tableoffset then local header=readheader(f) if header.major~=1 then @@ -15976,14 +16167,16 @@ function readers.cff(f,fontdata,specification) parsedictionaries(data,dictionaries,"cff") local dic=dictionaries[1] local cid=dic.cid - fontdata.cffinfo={ - familynamename=dic.familyname, + local cffinfo={ + familyname=dic.familyname, fullname=dic.fullname, boundingbox=dic.boundingbox, weight=dic.weight, italicangle=dic.italicangle, underlineposition=dic.underlineposition, underlinethickness=dic.underlinethickness, + defaultwidth=dic.defaultwidthx, + nominalwidth=dic.nominalwidthx, monospaced=dic.monospaced, } fontdata.cidinfo=cid and { @@ -15991,12 +16184,30 @@ function readers.cff(f,fontdata,specification) ordering=cid.ordering, supplement=cid.supplement, } - if specification.glyphs then - local all=specification.shapes or false + fontdata.cffinfo=cffinfo + local all=specification.shapes or specification.streams or false + if specification.glyphs or all then if cid and cid.fdselect then - readfdselect(f,fontdata,data,glyphs,all,"cff") + readfdselect(f,fontdata,data,glyphs,all,"cff",specification.streams) else - readnoselect(f,fontdata,data,glyphs,all,"cff") + readnoselect(f,fontdata,data,glyphs,all,"cff",specification.streams) + end + end + local private=dic.private + if private then + local data=private.data + if type(data)=="table" then + cffinfo.defaultwidth=data.defaultwidth or cffinfo.defaultwidth + cffinfo.nominalwidth=data.nominalwidth or cffinfo.nominalwidth + cffinfo.bluevalues=data.bluevalues + cffinfo.otherblues=data.otherblues + cffinfo.familyblues=data.familyblues + cffinfo.familyotherblues=data.familyotherblues + cffinfo.bluescale=data.bluescale + cffinfo.blueshift=data.blueshift + cffinfo.bluefuzz=data.bluefuzz + cffinfo.stdhw=data.stdhw + cffinfo.stdvw=data.stdvw end end cleanup(data,dictionaries) @@ -16030,7 +16241,7 @@ function readers.cff2(f,fontdata,specification) end data.factors=specification.factors local cid=data.dictionaries[1].cid - local all=specification.shapes or false + local all=specification.shapes or specification.streams or false if cid and cid.fdselect then readfdselect(f,fontdata,data,glyphs,all,"cff2",specification.streams) else @@ -16060,7 +16271,7 @@ function readers.cffcheck(filename) dictionaries=dictionaries, strings=strings, glyphs=glyphs, - nofglyphs=4, + nofglyphs=0, } parsedictionaries(data,dictionaries,"cff") local cid=data.dictionaries[1].cid @@ -16087,8 +16298,10 @@ if not modules then modules={} end modules ['font-ttf']={ local next,type,unpack=next,type,unpack local band,rshift=bit32.band,bit32.rshift local sqrt,round=math.sqrt,math.round -local char=string.char +local char,rep=string.char,string.rep local concat=table.concat +local idiv=number.idiv +local setmetatableindex=table.setmetatableindex local report=logs.reporter("otf reader","ttf") local trace_deltas=false local readers=fonts.handlers.otf.readers @@ -16153,22 +16366,41 @@ local function mergecomposites(glyphs,shapes) local yscale=matrix[4] local xoffset=matrix[5] local yoffset=matrix[6] - for i=1,#subpoints do - local p=subpoints[i] - local x=p[1] - local y=p[2] - nofpoints=nofpoints+1 - points[nofpoints]={ - xscale*x+xrotate*y+xoffset, - yscale*y+yrotate*x+yoffset, - p[3] - } + local count=#subpoints + if xscale==1 and yscale==1 and xrotate==0 and yrotate==0 then + for i=1,count do + local p=subpoints[i] + nofpoints=nofpoints+1 + points[nofpoints]={ + p[1]+xoffset, + p[2]+yoffset, + p[3] + } + end + else + for i=1,count do + local p=subpoints[i] + local x=p[1] + local y=p[2] + nofpoints=nofpoints+1 + points[nofpoints]={ + xscale*x+xrotate*y+xoffset, + yscale*y+yrotate*x+yoffset, + p[3] + } + end end - for i=1,#subcontours do + local subcount=#subcontours + if subcount==1 then nofcontours=nofcontours+1 - contours[nofcontours]=offset+subcontours[i] + contours[nofcontours]=offset+subcontours[1] + else + for i=1,#subcontours do + nofcontours=nofcontours+1 + contours[nofcontours]=offset+subcontours[i] + end end - offset=offset+#subpoints + offset=offset+count else report("missing contours composite %s, component %s of %s, glyph %s",index,i,#components,subindex) end @@ -16178,7 +16410,7 @@ local function mergecomposites(glyphs,shapes) shape.components=nil return contours,points end - for index=1,#glyphs do + for index=0,#glyphs-1 do local shape=shapes[index] if shape then local components=shape.components @@ -16188,7 +16420,7 @@ local function mergecomposites(glyphs,shapes) end end end -local function readnothing(f,nofcontours) +local function readnothing(f) return { type="nothing", } @@ -16282,8 +16514,8 @@ local function applyaxis(glyph,shape,deltas,dowidth) end end local quadratic=false -local function contours2outlines_normal(glyphs,shapes) - for index=1,#glyphs do +local function contours2outlines_normal(glyphs,shapes) + for index=0,#glyphs-1 do local shape=shapes[index] if shape then local glyph=glyphs[index] @@ -16398,7 +16630,7 @@ local function contours2outlines_normal(glyphs,shapes) end end local function contours2outlines_shaped(glyphs,shapes,keepcurve) - for index=1,#glyphs do + for index=0,#glyphs-1 do local shape=shapes[index] if shape then local glyph=glyphs[index] @@ -16577,115 +16809,128 @@ local function toshort(n) end return char(band(rshift(n,8),0xFF),band(n,0xFF)) end +local chars=setmetatableindex(function(t,k) + for i=0,255 do local v=char(i) t[i]=v end return t[k] +end) local function repackpoints(glyphs,shapes) local noboundingbox={ 0,0,0,0 } local result={} - for index=1,#glyphs do + local xpoints={} + local ypoints={} + for index=0,#glyphs-1 do local shape=shapes[index] if shape then local r=0 local glyph=glyphs[index] - if false then - else - local contours=shape.contours - local nofcontours=contours and #contours or 0 - local boundingbox=glyph.boundingbox or noboundingbox - r=r+1 result[r]=toshort(nofcontours) - r=r+1 result[r]=toshort(boundingbox[1]) - r=r+1 result[r]=toshort(boundingbox[2]) - r=r+1 result[r]=toshort(boundingbox[3]) - r=r+1 result[r]=toshort(boundingbox[4]) - if nofcontours>0 then - for i=1,nofcontours do - r=r+1 result[r]=toshort(contours[i]-1) - end - r=r+1 result[r]=s_zero - local points=shape.points - local currentx=0 - local currenty=0 - local xpoints={} - local ypoints={} - local x=0 - local y=0 - local lastflag=nil - local nofflags=0 - for i=1,#points do - local pt=points[i] - local px=pt[1] - local py=pt[2] - local fl=pt[3] and 0x01 or 0x00 - if px==currentx then - fl=fl+0x10 + local contours=shape.contours + local nofcontours=contours and #contours or 0 + local boundingbox=glyph.boundingbox or noboundingbox + r=r+1 result[r]=toshort(nofcontours) + r=r+1 result[r]=toshort(boundingbox[1]) + r=r+1 result[r]=toshort(boundingbox[2]) + r=r+1 result[r]=toshort(boundingbox[3]) + r=r+1 result[r]=toshort(boundingbox[4]) + if nofcontours>0 then + for i=1,nofcontours do + r=r+1 result[r]=toshort(contours[i]-1) + end + r=r+1 result[r]=s_zero + local points=shape.points + local currentx=0 + local currenty=0 + local x=0 + local y=0 + local lastflag=nil + local nofflags=0 + for i=1,#points do + local pt=points[i] + local px=pt[1] + local py=pt[2] + local fl=pt[3] and 0x01 or 0x00 + if px==currentx then + fl=fl+0x10 + else + local dx=round(px-currentx) + x=x+1 + if dx<-255 or dx>255 then + xpoints[x]=toshort(dx) + elseif dx<0 then + fl=fl+0x02 + xpoints[x]=chars[-dx] + elseif dx>0 then + fl=fl+0x12 + xpoints[x]=chars[dx] else - local dx=round(px-currentx) - if dx<-255 or dx>255 then - x=x+1 xpoints[x]=toshort(dx) - elseif dx<0 then - fl=fl+0x02 - x=x+1 xpoints[x]=char(-dx) - elseif dx>0 then - fl=fl+0x12 - x=x+1 xpoints[x]=char(dx) - else - fl=fl+0x02 - x=x+1 xpoints[x]=c_zero - end + fl=fl+0x02 + xpoints[x]=c_zero end - if py==currenty then - fl=fl+0x20 + end + if py==currenty then + fl=fl+0x20 + else + local dy=round(py-currenty) + y=y+1 + if dy<-255 or dy>255 then + ypoints[y]=toshort(dy) + elseif dy<0 then + fl=fl+0x04 + ypoints[y]=chars[-dy] + elseif dy>0 then + fl=fl+0x24 + ypoints[y]=chars[dy] else - local dy=round(py-currenty) - if dy<-255 or dy>255 then - y=y+1 ypoints[y]=toshort(dy) - elseif dy<0 then - fl=fl+0x04 - y=y+1 ypoints[y]=char(-dy) - elseif dy>0 then - fl=fl+0x24 - y=y+1 ypoints[y]=char(dy) - else - fl=fl+0x04 - y=y+1 ypoints[y]=c_zero - end - end - currentx=px - currenty=py - if lastflag==fl then - nofflags=nofflags+1 - else - if nofflags==1 then - r=r+1 result[r]=char(lastflag) - elseif nofflags==2 then - r=r+1 result[r]=char(lastflag,lastflag) - elseif nofflags>2 then - lastflag=lastflag+0x08 - r=r+1 result[r]=char(lastflag,nofflags-1) - end - nofflags=1 - lastflag=fl + fl=fl+0x04 + ypoints[y]=c_zero end end - if nofflags==1 then - r=r+1 result[r]=char(lastflag) - elseif nofflags==2 then - r=r+1 result[r]=char(lastflag,lastflag) - elseif nofflags>2 then - lastflag=lastflag+0x08 - r=r+1 result[r]=char(lastflag,nofflags-1) - end - r=r+1 result[r]=concat(xpoints) - r=r+1 result[r]=concat(ypoints) + currentx=px + currenty=py + if lastflag==fl then + nofflags=nofflags+1 + else + if nofflags==1 then + r=r+1 result[r]=chars[lastflag] + elseif nofflags==2 then + r=r+1 result[r]=char(lastflag,lastflag) + elseif nofflags>2 then + lastflag=lastflag+0x08 + r=r+1 result[r]=char(lastflag,nofflags-1) + end + nofflags=1 + lastflag=fl + end + end + if nofflags==1 then + r=r+1 result[r]=chars[lastflag] + elseif nofflags==2 then + r=r+1 result[r]=char(lastflag,lastflag) + elseif nofflags>2 then + lastflag=lastflag+0x08 + r=r+1 result[r]=char(lastflag,nofflags-1) + end + r=r+1 result[r]=concat(xpoints,"",1,x) + r=r+1 result[r]=concat(ypoints,"",1,y) + end + local stream=concat(result,"",1,r) + local length=#stream + local padding=idiv(length+3,4)*4-length + if padding>0 then + if padding==1 then + padding="\0" + elseif padding==2 then + padding="\0\0" + else + padding="\0\0\0" end + padding=stream..padding end - glyph.stream=concat(result,"",1,r) - else + glyph.stream=stream end end end +local flags={} local function readglyph(f,nofcontours) local points={} - local instructions={} - local flags={} local contours={} for i=1,nofcontours do contours[i]=readshort(f)+1 @@ -16698,9 +16943,15 @@ local function readglyph(f,nofcontours) local flag=readbyte(f) flags[i]=flag if band(flag,0x08)~=0 then - for j=1,readbyte(f) do + local n=readbyte(f) + if n==1 then i=i+1 flags[i]=flag + else + for j=1,n do + i=i+1 + flags[i]=flag + end end end i=i+1 @@ -16708,15 +16959,13 @@ local function readglyph(f,nofcontours) local x=0 for i=1,nofpoints do local flag=flags[i] - local short=band(flag,0x02)~=0 - local same=band(flag,0x10)~=0 - if short then - if same then + if band(flag,0x02)~=0 then + if band(flag,0x10)~=0 then x=x+readbyte(f) else x=x-readbyte(f) end - elseif same then + elseif band(flag,0x10)~=0 then else x=x+readshort(f) end @@ -16725,15 +16974,13 @@ local function readglyph(f,nofcontours) local y=0 for i=1,nofpoints do local flag=flags[i] - local short=band(flag,0x04)~=0 - local same=band(flag,0x20)~=0 - if short then - if same then + if band(flag,0x04)~=0 then + if band(flag,0x20)~=0 then y=y+readbyte(f) else y=y-readbyte(f) end - elseif same then + elseif band(flag,0x20)~=0 then else y=y+readshort(f) end @@ -16816,7 +17063,7 @@ local function readcomposite(f) if band(flags,0x0100)~=0 then instructions=true end - if not band(flags,0x0020)~=0 then + if band(flags,0x0020)==0 then break end end @@ -16831,21 +17078,27 @@ function readers.loca(f,fontdata,specification) if datatable then local offset=fontdata.tables.glyf.offset local format=fontdata.fontheader.indextolocformat + local profile=fontdata.maximumprofile + local nofglyphs=profile and profile.nofglyphs local locations={} setposition(f,datatable.offset) if format==1 then - local nofglyphs=datatable.length/4-2 + if not nofglyphs then + nofglyphs=idiv(datatable.length,4)-1 + end for i=0,nofglyphs do locations[i]=offset+readulong(f) end fontdata.nofglyphs=nofglyphs else - local nofglyphs=datatable.length/2-2 + if not nofglyphs then + nofglyphs=idiv(datatable.length,2)-1 + end for i=0,nofglyphs do locations[i]=offset+readushort(f)*2 end - fontdata.nofglyphs=nofglyphs end + fontdata.nofglyphs=nofglyphs fontdata.locations=locations end end @@ -16860,15 +17113,16 @@ function readers.glyf(f,fontdata,specification) local filesize=fontdata.filesize local nothing={ 0,0,0,0 } local shapes={} - local loadshapes=specification.shapes or specification.instance - for index=0,nofglyphs do + local loadshapes=specification.shapes or specification.instance or specification.streams + for index=0,nofglyphs-1 do local location=locations[index] + local length=locations[index+1]-location if location>=filesize then report("discarding %s glyphs due to glyph location bug",nofglyphs-index+1) fontdata.nofglyphs=index-1 fontdata.badfont=true break - elseif location>0 then + elseif length>0 then setposition(f,location) local nofcontours=readshort(f) glyphs[index].boundingbox={ @@ -16879,7 +17133,7 @@ function readers.glyf(f,fontdata,specification) } if not loadshapes then elseif nofcontours==0 then - shapes[index]=readnothing(f,nofcontours) + shapes[index]=readnothing(f) elseif nofcontours>0 then shapes[index]=readglyph(f,nofcontours) else @@ -16887,7 +17141,7 @@ function readers.glyf(f,fontdata,specification) end else if loadshapes then - shapes[index]={} + shapes[index]=readnothing(f) end glyphs[index].boundingbox=nothing end @@ -16904,7 +17158,13 @@ function readers.glyf(f,fontdata,specification) contours2outlines_shaped(glyphs,shapes,specification.shapes) end elseif specification.shapes then - contours2outlines_normal(glyphs,shapes) + if specification.streams then + repackpoints(glyphs,shapes) + else + contours2outlines_normal(glyphs,shapes) + end + elseif specification.streams then + repackpoints(glyphs,shapes) end end end @@ -19117,7 +19377,7 @@ do end local function loadvariations(f,fontdata,variationsoffset,lookuptypes,featurehash,featureorder) setposition(f,variationsoffset) - local version=readulong(f) + local version=readulong(f) local nofrecords=readulong(f) local records={} for i=1,nofrecords do @@ -19986,8 +20246,7 @@ function readers.avar(f,fontdata,specification) end return false end - local majorversion=readushort(f) - local minorversion=readushort(f) + local version=readulong(f) local reserved=readushort(f) local nofaxis=readushort(f) local segments={} @@ -26345,22 +26604,17 @@ function handlers.gsub_ligature(head,start,dataset,sequence,ligature,rlmode,skip else end end - else + else local discfound=false - local lastdisc=nil local hasmarks=marks[startchar] while current do local char,id=ischar(current,currentfont) if char then if skiphash and skiphash[char] then current=getnext(current) - else - local lg=ligature[char] + else + local lg=ligature[char] if lg then - if not discfound and lastdisc then - discfound=lastdisc - lastdisc=nil - end if marks[char] then hasmarks=true end @@ -26374,42 +26628,82 @@ function handlers.gsub_ligature(head,start,dataset,sequence,ligature,rlmode,skip elseif char==false then break elseif id==disc_code then - local replace=getfield(current,"replace") - if replace then - while replace do - local char,id=ischar(replace,currentfont) - if char then - local lg=ligature[char] - if lg then - if marks[char] then - hasmarks=true - end - ligature=lg - replace=getnext(replace) - else - return head,start,false,false - end - else - return head,start,false,false - end - end - stop=current - end - lastdisc=current - current=getnext(current) + discfound=current + break else break end end + if discfound then + local pre,post,replace=getdisc(discfound) + local match + if replace then + local char=ischar(replace,currentfont) + if char and ligature[char] then + match=true + end + end + if not match and pre then + local char=ischar(pre,currentfont) + if char and ligature[char] then + match=true + end + end + if not match and not pre or not replace then + local n=getnext(discfound) + local char=ischar(n,currentfont) + if char and ligature[char] then + match=true + end + end + if match then + local ishead=head==start + local prev=getprev(start) + if stop then + setnext(stop) + local tail=getprev(stop) + local copy=copy_node_list(start) + local liat=find_node_tail(copy) + if pre and replace then + setlink(liat,pre) + end + if replace then + setlink(tail,replace) + end + pre=copy + replace=start + else + setnext(start) + local copy=copy_node(start) + if pre then + setlink(copy,pre) + end + if replace then + setlink(start,replace) + end + pre=copy + replace=start + end + setdisc(discfound,pre,post,replace) + if prev then + setlink(prev,discfound) + else + setprev(discfound) + head=discfound + end + start=discfound + return head,start,true,true + end + end local lig=ligature.ligature if lig then if stop then if trace_ligatures then local stopchar=getchar(stop) - head,start=toligature(head,start,stop,lig,dataset,sequence,skiphash,discfound,hasmarks) + head,start=toligature(head,start,stop,lig,dataset,sequence,skiphash,false,hasmarks) logprocess("%s: replacing %s upto %s by ligature %s case 2",pref(dataset,sequence),gref(startchar),gref(stopchar),gref(lig)) else - head,start=toligature(head,start,stop,lig,dataset,sequence,skiphash,discfound,hasmarks) + head,start=toligature(head,start,stop,lig,dataset,sequence,skiphash,false,hasmarks) end else resetinjection(start) @@ -26418,11 +26712,11 @@ function handlers.gsub_ligature(head,start,dataset,sequence,ligature,rlmode,skip logprocess("%s: replacing %s by (no real) ligature %s case 3",pref(dataset,sequence),gref(startchar),gref(lig)) end end - return head,start,true,discfound + return head,start,true,false else end end - return head,start,false,discfound + return head,start,false,false end function handlers.gpos_single(head,start,dataset,sequence,kerns,rlmode,skiphash,step,injection) local startchar=getchar(start) @@ -28901,9 +29195,10 @@ do a=true end if a then - local ok - head,start,ok=handler(head,start,dataset,sequence,lookupmatch,rlmode,skiphash,step) - if start then + local ok,df + head,start,ok,df=handler(head,start,dataset,sequence,lookupmatch,rlmode,skiphash,step) + if df then + elseif start then start=getnext(start) end else @@ -28957,21 +29252,24 @@ do a=true end if a then + local ok,df for i=m[1],m[2] do local step=steps[i] local lookupcache=step.coverage local lookupmatch=lookupcache[char] if lookupmatch then - local ok - head,start,ok=handler(head,start,dataset,sequence,lookupmatch,rlmode,skiphash,step) - if ok then + head,start,ok,df=handler(head,start,dataset,sequence,lookupmatch,rlmode,skiphash,step) + if df then + break + elseif ok then break elseif not start then break end end end - if start then + if df then + elseif start then start=getnext(start) end else @@ -31472,7 +31770,7 @@ do done=f_used(n) hashed[pdf]=done end - return nil,done,nil + return done end else local openpdf=pdfe.new @@ -31485,7 +31783,7 @@ do done=f_used(n) hashed[pdf]=done end - return nil,done,nil + return done end end end @@ -31506,6 +31804,10 @@ local function pdftovirtual(tfmdata,pdfshapes,kind) local b,e=getactualtext(tounicode(0xFFFD)) local actualb={ "pdf","page",b } local actuale={ "pdf","page",e } + local vfimage=lpdf and lpdf.vfimage or function(wd,ht,dp,data,name) + local name=storepdfdata(data) + return { "image",{ filename=name,width=wd,height=ht,depth=dp } } + end for unicode,character in sortedhash(characters) do local index=character.index if index then @@ -31524,21 +31826,18 @@ local function pdftovirtual(tfmdata,pdfshapes,kind) dy=0 end if data then - local setcode,name,nilcode=storepdfdata(data) - if name then - local bt=unicode and getactualtext(unicode) - local wd=character.width or 0 - local ht=character.height or 0 - local dp=character.depth or 0 - character.commands={ - not unicode and actualb or { "pdf","page",(getactualtext(unicode)) }, - downcommand[dp+dy*hfactor], - rightcommand[dx*hfactor], - { "image",{ filename=name,width=wd,height=ht,depth=dp } }, - actuale, - } - character[kind]=true - end + local bt=unicode and getactualtext(unicode) + local wd=character.width or 0 + local ht=character.height or 0 + local dp=character.depth or 0 + character.commands={ + not unicode and actualb or { "pdf","page",(getactualtext(unicode)) }, + downcommand[dp+dy*hfactor], + rightcommand[dx*hfactor], + vfimage(wd,ht,dp,data,name), + actuale, + } + character[kind]=true end end end @@ -32508,7 +32807,7 @@ local match,lower,gsub,strip,find=string.match,string.lower,string.gsub,string.s local char,byte,sub=string.char,string.byte,string.sub local abs=math.abs local bxor,rshift=bit32.bxor,bit32.rshift -local P,S,R,Cmt,C,Ct,Cs,Carg,Cf,Cg=lpeg.P,lpeg.S,lpeg.R,lpeg.Cmt,lpeg.C,lpeg.Ct,lpeg.Cs,lpeg.Carg,lpeg.Cf,lpeg.Cg +local P,S,R,V,Cmt,C,Ct,Cs,Carg,Cf,Cg,Cc=lpeg.P,lpeg.S,lpeg.R,lpeg.V,lpeg.Cmt,lpeg.C,lpeg.Ct,lpeg.Cs,lpeg.Carg,lpeg.Cf,lpeg.Cg,lpeg.Cc local lpegmatch,patterns=lpeg.match,lpeg.patterns local trace_indexing=false trackers.register("afm.indexing",function(v) trace_indexing=v end) local trace_loading=false trackers.register("afm.loading",function(v) trace_loading=v end) @@ -32551,14 +32850,21 @@ do local routines,vector,chars,n,m local initialize=function(str,position,size) n=0 - m=size + m=size return position+1 end local setroutine=function(str,position,index,size,filename) - local forward=position+tonumber(size) + if routines[index] then + return false + end + local forward=position+size local stream=decrypt(sub(str,position+1,forward),4330,4) routines[index]={ byte(stream,1,#stream) } - return forward + n=n+1 + if n>=m then + return #str + end + return forward+1 end local setvector=function(str,position,name,size,filename) local forward=position+tonumber(size) @@ -32598,7 +32904,7 @@ do local p_np=spacing*(P("NP")+P("|")) local p_nd=spacing*(P("ND")+P("|")) local p_filterroutines= - (1-subroutines)^0*subroutines*spaces*Cmt(cardinal,initialize)*(Cmt(cardinal*spaces*cardinal*p_rd*Carg(1),setroutine)*p_np+P(1))^1 + (1-subroutines)^0*subroutines*spaces*Cmt(cardinal,initialize)*(Cmt(cardinal*spaces*cardinal*p_rd*Carg(1),setroutine)*p_np+(1-p_nd))^1 local p_filtershapes= (1-charstrings)^0*charstrings*spaces*Cmt(cardinal,initialize)*(Cmt(name*spaces*cardinal*p_rd*Carg(1),setshapes)*p_nd+P(1))^1 local p_filternames=Ct ( @@ -32607,7 +32913,18 @@ do local p_filterencoding=(1-encoding)^0*encoding*spaces*digits*spaces*array*(1-dup)^0*Cf( Ct("")*Cg(spacing*dup*spaces*cardinal*spaces*name*spaces*put)^1 ,rawset) - local function loadpfbvector(filename,shapestoo) + local key=spacing*P("/")*R("az","AZ") + local str=spacing*Cs { (P("(")/"")*((1-P("\\(")-P("\\)")-S("()"))+V(1))^0*(P(")")/"") } + local num=spacing*(R("09")+S("+-."))^1/tonumber + local arr=spacing*Ct (S("[{")*(num)^0*spacing*S("]}")) + local boo=spacing*(P("true")*Cc(true)+P("false")*Cc(false)) + local nam=spacing*P("/")*Cs(R("az","AZ")^1) + local p_filtermetadata=( + P("/")*Carg(1)*(( + C("version")*str+C("Copyright")*str+C("Notice")*str+C("FullName")*str+C("FamilyName")*str+C("Weight")*str+C("ItalicAngle")*num+C("isFixedPitch")*boo+C("UnderlinePosition")*num+C("UnderlineThickness")*num+C("FontName")*nam+C("FontMatrix")*arr+C("FontBBox")*arr + ) )/function(t,k,v) t[lower(k)]=v end+P(1) + )^0*Carg(1) + local function loadpfbvector(filename,shapestoo,streams) local data=io.loaddata(resolvers.findfile(filename)) if not data then report_pfb("no data in %a",filename) @@ -32625,9 +32942,10 @@ do binary=decrypt(binary,55665,4) local names={} local encoding=lpegmatch(p_filterencoding,ascii) + local metadata=lpegmatch(p_filtermetadata,ascii,1,{}) local glyphs={} routines,vector,chars={},{},{} - if shapestoo then + if shapestoo or streams then lpegmatch(p_filterroutines,binary,1,filename) lpegmatch(p_filtershapes,binary,1,filename) local data={ @@ -32639,13 +32957,13 @@ do } }, } - fonts.handlers.otf.readers.parsecharstrings(false,data,glyphs,true,true) + fonts.handlers.otf.readers.parsecharstrings(false,data,glyphs,true,"cff",streams) else lpegmatch(p_filternames,binary,1,filename) end names=vector routines,vector,chars=nil,nil,nil - return names,encoding,glyphs + return names,encoding,glyphs,metadata end local pfb=handlers.pfb or {} handlers.pfb=pfb @@ -33731,6 +34049,7 @@ if not modules then modules={} end modules ['font-tfm']={ local next,type=next,type local match,format=string.match,string.format local concat,sortedhash=table.concat,table.sortedhash +local idiv=number.idiv local trace_defining=false trackers.register("fonts.defining",function(v) trace_defining=v end) local trace_features=false trackers.register("tfm.features",function(v) trace_features=v end) local report_defining=logs.reporter("fonts","defining") @@ -33793,7 +34112,8 @@ local function read_from_tfm(specification) properties.psname=tfmdata.psname properties.fullname=tfmdata.fullname properties.filename=specification.filename - properties.format=fonts.formats.tfm + properties.format=tfmdata.format or fonts.formats.tfm + properties.usedbitmap=tfmdata.usedbitmap tfmdata.properties=properties tfmdata.resources=resources tfmdata.parameters=parameters @@ -33837,6 +34157,9 @@ local function read_from_tfm(specification) end end shared.processes=next(features) and tfm.setfeatures(tfmdata,features) or nil +if size<0 then + size=idiv(65536*-size,100) +end parameters.factor=1 parameters.size=size parameters.slant=parameters.slant or parameters[1] or 0 @@ -33994,7 +34317,7 @@ do local originals=tfmdata.characters local indices={} local parentfont={ "font",1 } - local private=tfmdata or fonts.constructors.privateoffset + local private=tfmdata.privateoffset or fonts.constructors.privateoffset local reported=encdone[tfmfile][encfile] local backmap=vector and table.swapped(vector) local done={} @@ -34084,21 +34407,16 @@ CMapName currentdict /CMap defineresource pop end end end ]] - local flushstreamobject=lpdf and lpdf.flushstreamobject - local setfontattributes=pdf.setfontattributes - if flushstreamobject then - else + local flushstreamobject=lpdf and lpdf.flushstreamobject + local setfontattributes=lpdf and lpdf.setfontattributes + if not flushstreamobject then flushstreamobject=function(data) - return pdf.obj { - immediate=true, - type="stream", - string=data, - } + return pdf.obj { immediate=true,type="stream",string=data } end end if not setfontattributes then setfontattributes=function(id,data) - print(format("your luatex is too old so no tounicode bitmap font%i",id)) + return pdf.setfontattributes(id,data) end end function tfm.addtounicode(tfmdata) |