diff options
-rw-r--r-- | scripts/context/lua/mtx-server-ctx-fonttest.lua | 294 | ||||
-rw-r--r-- | scripts/context/lua/mtx-server.lua | 6 | ||||
-rw-r--r-- | scripts/context/lua/mtxrun.lua | 11 | ||||
-rw-r--r-- | scripts/context/stubs/mswin/mtxrun.lua | 11 | ||||
-rw-r--r-- | scripts/context/stubs/unix/mtxrun | 11 | ||||
-rw-r--r-- | tex/context/base/buff-ini.lua | 2 | ||||
-rw-r--r-- | tex/context/base/cont-new.mkiv | 2 | ||||
-rw-r--r-- | tex/context/base/context-version.pdf | bin | 4107 -> 4103 bytes | |||
-rw-r--r-- | tex/context/base/context.mkiv | 2 | ||||
-rw-r--r-- | tex/context/base/font-ini.mkvi | 2 | ||||
-rw-r--r-- | tex/context/base/font-syn.lua | 2 | ||||
-rw-r--r-- | tex/context/base/l-url.lua | 16 | ||||
-rw-r--r-- | tex/context/base/math-noa.lua | 2 | ||||
-rw-r--r-- | tex/context/base/page-mix.lua | 2 | ||||
-rw-r--r-- | tex/context/base/status-files.pdf | bin | 24739 -> 24743 bytes | |||
-rw-r--r-- | tex/context/base/status-lua.log | 2 | ||||
-rw-r--r-- | tex/generic/context/luatex/luatex-fonts-merged.lua | 2 |
17 files changed, 231 insertions, 136 deletions
diff --git a/scripts/context/lua/mtx-server-ctx-fonttest.lua b/scripts/context/lua/mtx-server-ctx-fonttest.lua index a8d7edf41..da87fe9e8 100644 --- a/scripts/context/lua/mtx-server-ctx-fonttest.lua +++ b/scripts/context/lua/mtx-server-ctx-fonttest.lua @@ -20,44 +20,62 @@ dofile(resolvers.findfile("font-mis.lua","tex")) local format, gsub, concat, match, find = string.format, string.gsub, table.concat, string.match, string.find -local report = logs.reporter("ctx-fonttest") +local formatters = string.formatters -local sample_line = "This is a sample line!" -local tempname = "mtx-server-ctx-fonttest-temp" -local temppath = caches.setfirstwritablefile("temp","mtx-server-ctx-fonttest") -local basename = "mtx-server-ctx-fonttest-data.lua" -local basepath = temppath +local report = logs.reporter("ctx-fonttest") + +local sample_line = "This is a sample line!" +local tempname = "mtx-server-ctx-fonttest-temp" +local temppath = caches.setfirstwritablefile("temp","mtx-server-ctx-fonttest") +local basename = "mtx-server-ctx-fonttest-data.lua" +local basepath = temppath local remove_suffixes = { "tex", "pdf", "log" } -local what_options = { "trace", "basemode" } +local what_options = { "trace", "basemode" } for i=1,#remove_suffixes do os.remove(file.join(temppath,file.addsuffix(tempname,remove_suffixes[i]))) end +local foolcache = 0 + +local function makename(name,new) + if new then + foolcache = foolcache > 25 and 1 or foolcache + 1 + end + return formatters["%s-%02i"](name,foolcache) +end + +-- nowadays i would use the more advanced template mechanism with named variables + local process_templates = { } -process_templates.default = [[ +-- %\definedfont[name:%s*sample] + +process_templates.default = formatters [ [[ \starttext - \setupdirections[bidi=global] + \setupdirections[bidi=one] \definefontfeature[sample][analyze=yes,%s] - \definedfont[name:%s*sample] + \definedfont[name:%s*none] \startTEXpage[offset=3pt] \detokenize{%s} + \blank + \definedfont[name:%s*sample] + \detokenize{%s} \stopTEXpage \stoptext -]] +]] ] -process_templates.cache = [[ +process_templates.cache = formatters [ [[ \starttext \definedfont[name:%s] \startTEXpage[offset=3pt] cached: \detokenize{%s} \stopTEXpage \stoptext -]] +]] ] -process_templates.trace = [[ +process_templates.trace = formatters [ [[ \usemodule[fnt-20] \definefontfeature[sample][%s] @@ -73,9 +91,9 @@ process_templates.trace = [[ direction=0, features=sample, sample={\detokenize{%s}}] -]] +]] ] -local javascripts = [[ +local javascripts = formatters [ [[ function selected_radio(name) { var form = document.forms["main-form"] ; var script = form.elements[name] ; @@ -151,7 +169,28 @@ function check_language() { function check_feature() { // not needed } -]] +]] ] + +local jitmode = false -- assumes local use (one user as shared) + +local run_context_normal = formatters["mtxrun --path=%q --script context --once --batchmode %q"] +local run_context_jitted = formatters["mtxrun --path=%q --script context --once --batchmode --jit %q"] + +local function runcontext(temppath,filename) + local start = os.clock() + local command = (jitmode and run_context_jitted or run_context_normal)(temppath,filename) + report("temppath: %s",temppath) + report("filename: %s",filename) + report("command: %s",command) + os.execute(command) + return os.clock() - start +end + +local function identifyfonts() + local command = "mtxrun --script font --reload" + report("command: %s",command) + os.execute(command) +end local cache = { } @@ -163,8 +202,9 @@ local function showfeatures(f) features = fonts.helpers.getfeatures(resolvers.findfile(f)) if not features then report("building cache for '%s'",f) - io.savedata(file.join(temppath,file.addsuffix(tempname,"tex")),format(process_templates.cache,f,f)) - os.execute(format("mtxrun --path=%s --script context --once --batchmode %s",temppath,tempname)) + local usedname = file.addsuffix(tempname,"tex") + io.savedata(file.join(temppath,usedname),process_templates.cache(f,f)) + runcontext(temppath,usedname) features = fonts.helpers.getfeatures(f) end cache[f] = features or false @@ -206,14 +246,15 @@ local function showfeatures(f) for what, v in table.sortedhash(features) do show(what) end + -- we could json this local stupid = { } stupid[#stupid+1] = "var feature_hash = new Array ;" for s, sr in next, rev do - stupid[#stupid+1] = format("feature_hash['%s'] = new Array ;",s) + stupid[#stupid+1] = formatters["feature_hash['%s'] = new Array ;"](s) for l, lr in next, sr do - stupid[#stupid+1] = format("feature_hash['%s']['%s'] = new Array ;",s,l) + stupid[#stupid+1] = formatters["feature_hash['%s']['%s'] = new Array ;"](s,l) for f, fr in next, lr do - stupid[#stupid+1] = format("feature_hash['%s']['%s']['%s'] = true ;",s,l,f) + stupid[#stupid+1] = formatters["feature_hash['%s']['%s']['%s'] = true ;"](s,l,f) end end end @@ -228,7 +269,7 @@ local function showfeatures(f) end end -local template_h = [[ +local template_h = formatters [ [[ <tr> <th>safe name </th> <th>family name </th> @@ -236,9 +277,9 @@ local template_h = [[ <th>font name </th> <th>weight </th> <th>filename</th> -</tr>]] +</tr>]] ] -local template_d = [[ +local template_d = formatters [ [[ <tr> <td><a href='mtx-server-ctx-fonttest.lua?selection=%s'>%s</a> </td> <td>%s </td> @@ -246,19 +287,22 @@ local template_d = [[ <td>%s </td> <td>%s </td> <td>%s</td> -</tr>]] +</tr>]] ] local function select_font() local t = fonts.names.list(".*",false,true) if t then local listoffonts = { } + listoffonts[#listoffonts+1] = "<h1>Fonts</h1><br/>" listoffonts[#listoffonts+1] = "<table>" - listoffonts[#listoffonts+1] = template_h + listoffonts[#listoffonts+1] = template_h() for k, v in table.sortedhash(t) do local kind = v.format if kind == "otf" or kind == "ttf" or kind == "ttc" then local fontname = v.fontname - listoffonts[#listoffonts+1] = format(template_d, fontname, fontname, + listoffonts[#listoffonts+1] = template_d( + fontname, + fontname, v.familyname or "", t.variant or "normal", t.weight or "normal", @@ -276,25 +320,32 @@ local function select_font() return "<b>no fonts</b>" end -local edit_template = [[ +local edit_template = formatters [ [[ <textarea name='sampletext' rows='5' cols='100'>%s</textarea> <br/> <br/>name: <input type='text' name='name' size='20' value=%q/> title: <input type='text' name='title' size='40' value=%q/> <br/> <br/>scripts: %s <br/> <br/>languages: %s <br/> <br/>features: %s <br/> <br/>options: %s -]] +]] ] -- <embed src="%s#toolbar=0&navpanes=0&scrollbar=0" width="100%%"/> -local result_template = [[ +local result_template = formatters [ [[ <br/> <br/> <embed src="%s#view=Fit&toolbar=0&navpanes=0&scrollbar=0" width="100%%"/> - <br/> <br/> results: - <a href='%s' target="source">tex file</a> - <a href='%s' target="result">pdf file</a> + <br/> <br/> results: + <a href='%s' target="source">tex file</a> + <a href='%s' target="result">pdf file</a> + (runtime: %s) <br/> <br/> -]] +]] ] + +local main_template = formatters [ [[ + <h1>Font: %s</h1><br/> + %s + %s +]] ] scripts.webserver.registerpath(temppath) @@ -302,7 +353,7 @@ local function get_specification(name) return fonts.names.resolvedspecification(name or "") end -local function edit_font(currentfont,detail,tempname) +local function edit_font(currentfont,detail,tempname,runtime) report("entering edit mode for '%s'",currentfont) local specification = get_specification(currentfont) if specification then @@ -314,9 +365,9 @@ local function edit_font(currentfont,detail,tempname) local v = sorted[k] local s = fonts.handlers.otf.tables.scripts[v] or v if detail and v == detail.script then - scripts[#scripts+1] = format("<input title='%s' id='s-%s' type='radio' name='script' value='%s' onclick='check_script()' checked='checked'/> <span id='t-s-%s'>%s</span>",s,v,v,v,v) + scripts[#scripts+1] = formatters["<input title='%s' id='s-%s' type='radio' name='script' value='%s' onclick='check_script()' checked='checked'/> <span id='t-s-%s'>%s</span>"](s,v,v,v,v) else - scripts[#scripts+1] = format("<input title='%s' id='s-%s' type='radio' name='script' value='%s' onclick='check_script()' /> <span id='t-s-%s'>%s</span>",s,v,v,v,v) + scripts[#scripts+1] = formatters["<input title='%s' id='s-%s' type='radio' name='script' value='%s' onclick='check_script()' /> <span id='t-s-%s'>%s</span>"](s,v,v,v,v) end end local sorted = table.sortedkeys(htmldata.languages) @@ -324,9 +375,9 @@ local function edit_font(currentfont,detail,tempname) local v = sorted[k] local l = fonts.handlers.otf.tables.languages[v] or v if detail and v == detail.language then - languages[#languages+1] = format("<input title='%s' id='l-%s' type='radio' name='language' value='%s' onclick='check_language()' checked='checked'/> <span id='t-l-%s'>%s</span>",l,v,v,v,v) + languages[#languages+1] = formatters["<input title='%s' id='l-%s' type='radio' name='language' value='%s' onclick='check_language()' checked='checked'/> <span id='t-l-%s'>%s</span>"](l,v,v,v,v) else - languages[#languages+1] = format("<input title='%s' id='l-%s' type='radio' name='language' value='%s' onclick='check_language()' /> <span id='t-l-%s'>%s</span>",l,v,v,v,v) + languages[#languages+1] = formatters["<input title='%s' id='l-%s' type='radio' name='language' value='%s' onclick='check_language()' /> <span id='t-l-%s'>%s</span>"](l,v,v,v,v) end end local sorted = table.sortedkeys(htmldata.features) @@ -334,28 +385,34 @@ local function edit_font(currentfont,detail,tempname) local v = sorted[k] local f = fonts.handlers.otf.tables.features[v] or v if detail and detail["f-"..v] then - features[#features+1] = format("<input title='%s' id='f-%s' type='checkbox' name='f-%s' onclick='check_feature()' checked='checked'/> <span id='t-f-%s'>%s</span>",f,v,v,v,v) + features[#features+1] = formatters["<input title='%s' id='f-%s' type='checkbox' name='f-%s' onclick='check_feature()' checked='checked'/> <span id='t-f-%s'>%s</span>"](f,v,v,v,v) else - features[#features+1] = format("<input title='%s' id='f-%s' type='checkbox' name='f-%s' onclick='check_feature()' /> <span id='t-f-%s'>%s</span>",f,v,v,v,v) + features[#features+1] = formatters["<input title='%s' id='f-%s' type='checkbox' name='f-%s' onclick='check_feature()' /> <span id='t-f-%s'>%s</span>"](f,v,v,v,v) end end for k=1,#what_options do local v = what_options[k] if detail and detail["o-"..v] then - options[#options+1] = format("<input id='o-%s' type='checkbox' name='o-%s' checked='checked'/> %s",v,v,v) + options[#options+1] = formatters["<input id='o-%s' type='checkbox' name='o-%s' checked='checked'/> %s"](v,v,v) else - options[#options+1] = format("<input id='o-%s' type='checkbox' name='o-%s'/> %s",v,v,v) + options[#options+1] = formatters["<input id='o-%s' type='checkbox' name='o-%s'/> %s"](v,v,v) end end - local e = format(edit_template, - (detail and detail.sampletext) or sample_line,(detail and detail.name) or "no name",(detail and detail.title) or "", - concat(scripts," "),concat(languages," "),concat(features," "),concat(options," ")) + local e = edit_template( + detail and detail.sampletext or sample_line, + detail and detail.name or "no name", + detail and detail.title or "", + concat(scripts," "), + concat(languages," "), + concat(features," "), + concat(options," ") + ) if tempname then - local pdffile, texfile = file.addsuffix(tempname,"pdf"), file.addsuffix(tempname,"tex") - local r = format(result_template,pdffile,texfile,pdffile) - return e .. r, htmldata.javascript or "" + local pdffile, texfile = file.replacesuffix(tempname,"pdf"), file.replacesuffix(tempname,"tex") + local r = result_template(pdffile,texfile,pdffile,runtime and formatters["%0.3f"](runtime) or "-") + return main_template(currentfont,e,r), htmldata.javascript or "" else - return e, htmldata.javascript or "" + return main_template(currentfont,e,""), htmldata.javascript or "" end else return "error, nothing set up yet" @@ -368,13 +425,13 @@ end local function process_font(currentfont,detail) -- maybe just fontname local features = { "mode=node", - format("language=%s",detail.language or "dflt"), - format("script=%s",detail.script or "dflt"), + formatters["language=%s"](detail.language or "dflt"), + formatters["script=%s"](detail.script or "dflt"), } for k,v in next, detail do local f = match(k,"^f%-(.*)$") if f then - features[#features+1] = format("%s=yes",f) + features[#features+1] = formatters["%s=yes"](f) end end local variant = process_templates.default @@ -385,69 +442,76 @@ local function process_font(currentfont,detail) -- maybe just fontname if sample == "" then sample = sample_line end report("sample text: %s",sample) dir.mkdirs(temppath) - local fullname = file.join(temppath,file.addsuffix(tempname,"tex")) - local data = format(variant,concat(features,","),currentfont,sample) - local command = format("mtxrun --path=%q --script context --once --batchmode %q",temppath,tempname) - report("filename: %s",fullname) - report("command: %s",command) + local tempname = makename(tempname,true) + local usedname = file.addsuffix(tempname,"tex") + local fullname = file.join(temppath,usedname) + local data = variant(concat(features,","),currentfont,sample,currentfont,sample) io.savedata(fullname,data) - os.execute(command) - return edit_font(currentfont,detail,tempname) + io.flush() + local runtime = runcontext(temppath,usedname) + return edit_font(currentfont,detail,tempname,runtime) end -local tex_template = [[ +local tex_template = formatters [ [[ +<h1>Font: %s</h1><br/> <pre><tt> %s </tt></pre> -]] +]] ] local function show_source(currentfont,detail) + local tempname = makename(tempname) if tempname and tempname ~= "" then - local data = io.loaddata(file.join(temppath,file.addsuffix(tempname,"tex"))) or "no source yet" - return format(tex_template,data) + local data = io.loaddata(file.join(temppath,file.replacesuffix(tempname,"tex"))) or "no source yet" + return tex_template(currentfont,data) else return "no source file" end end local function show_log(currentfont,detail) + local tempname = makename(tempname) if tempname and tempname ~= "" then - local data = io.loaddata(file.join(temppath,file.addsuffix(tempname,'log'))) or "no log file yet" + local data = io.loaddata(file.join(temppath,file.replacesuffix(tempname,'log'))) or "no log file yet" data = gsub(data,"[%s%%]*begin of optionfile.-end of optionfile[%s%%]*","\n") - return format(tex_template,data) + return tex_template(currentfont,data) else return "no log file" end end +-- much nicer would be an lmx template + local function show_font(currentfont,detail) local specification = get_specification(currentfont) local features = fonts.helpers.getfeatures(specification.filename) local result = { } - result[#result+1] = format("<h1>names</h1>",what) + result[#result+1] = formatters["<h1>Font: %s</h1><br/>"](currentfont) result[#result+1] = "<table>" - result[#result+1] = format("<tr><td class='tc'>fontname: </td><td>%s</td></tr>",currentfont) - result[#result+1] = format("<tr><td class='tc'>fullname: </td><td>%s</td></tr>",specification.fontname or "-") - result[#result+1] = format("<tr><td class='tc'>filename: </td><td>%s</td></tr>",specification.fontfile or "-") - result[#result+1] = format("<tr><td class='tc'>familyname: </td><td>%s</td></tr>",specification.familyname or "-") - result[#result+1] = format("<tr><td class='tc'>fontweight: </td><td>%s</td></tr>",specification.fontweight or "-") - result[#result+1] = format("<tr><td class='tc'>format: </td><td>%s</td></tr>",specification.format or "-") - result[#result+1] = format("<tr><td class='tc'>fullname: </td><td>%s</td></tr>",specification.fullname or "-") - result[#result+1] = format("<tr><td class='tc'>subfamily: </td><td>%s</td></tr>",specification.subfamily or "-") - result[#result+1] = format("<tr><td class='tc'>rawname: </td><td>%s</td></tr>",specification.rawname or "-") - result[#result+1] = format("<tr><td class='tc'>designsize: </td><td>%s</td></tr>",specification.designsize or "-") - result[#result+1] = format("<tr><td class='tc'>minimumsize:</td><td>%s</td></tr>",specification.minsize or "-") - result[#result+1] = format("<tr><td class='tc'>maximumsize:</td><td>%s</td></tr>",specification.maxsize or "-") - result[#result+1] = format("<tr><td class='tc'>style: </td><td>%s</td></tr>",specification.style ~= "" and specification.style or "normal") - result[#result+1] = format("<tr><td class='tc'>variant: </td><td>%s</td></tr>",specification.variant ~= "" and specification.variant or "normal") - result[#result+1] = format("<tr><td class='tc'>weight: </td><td>%s</td></tr>",specification.weight ~= "" and specification.weight or "normal") - result[#result+1] = format("<tr><td class='tc'>width: </td><td>%s</td></tr>",specification.width ~= "" and specification.width or "normal") + result[#result+1] = formatters["<tr><td class='tc' style='width:10em'>fontname </td><td style='width:20em'>%s</td>"] (specification.fontname or "-") + result[#result+1] = formatters[" <td class='tc' style='width:10em'>designsize </td><td style='width:20em'>%s</td></tr>"](specification.designsize or "-") + result[#result+1] = formatters["<tr><td class='tc' style='width:10em'>fullname </td><td style='width:20em'>%s</td>"] (specification.fullname or "-") + result[#result+1] = formatters[" <td class='tc' style='width:10em'>minimumsize</td><td style='width:20em'>%s</td></tr>"](specification.minsize or "-") + result[#result+1] = formatters["<tr><td class='tc' style='width:10em'>filename </td><td style='width:20em'>%s</td>"] (specification.fontfile or "-") + result[#result+1] = formatters[" <td class='tc' style='width:10em'>maximumsize</td><td style='width:20em'>%s</td></tr>"](specification.maxsize or "-") + result[#result+1] = formatters["<tr><td class='tc' style='width:10em'>rawname </td><td style='width:20em'>%s</td>"] (specification.rawname or "-") + result[#result+1] = formatters[" <td class='tc' style='width:10em'>fontweight </td><td style='width:20em'>%s</td></tr>"](specification.fontweight or "-") + result[#result+1] = formatters["<tr><td class='tc' style='width:10em'>familyname </td><td style='width:20em'>%s</td>"] (specification.familyname or "-") + result[#result+1] = formatters[" <td class='tc' style='width:10em'>angle </td><td style='width:20em'>%s</td></tr>"](specification.angle or "-") + result[#result+1] = formatters["<tr><td class='tc' style='width:10em'>subfamily </td><td style='width:20em'>%s</td>"] (specification.subfamily or "-") + result[#result+1] = formatters[" <td class='tc' style='width:10em'>variant </td><td style='width:20em'>%s</td></tr>"](specification.variant ~= "" and specification.variant or "normal") + result[#result+1] = formatters["<tr><td class='tc' style='width:10em'>format </td><td style='width:20em'>%s</td>"] (specification.format or "-") + result[#result+1] = formatters[" <td class='tc' style='width:10em'>style </td><td style='width:20em'>%s</td></tr>"](specification.style ~= "" and specification.style or "normal") + result[#result+1] = formatters["<tr><td class='tc' style='width:10em'>pfmwidth </td><td style='width:20em'>%s</td>"] (specification.pfmwidth ~= "" and specification.pfmwidth or "-") + result[#result+1] = formatters[" <td class='tc' style='width:10em'>weight </td><td style='width:20em'>%s</td></tr>"](specification.weight ~= "" and specification.weight or "normal") + result[#result+1] = formatters["<tr><td class='tc' style='width:10em'>pfmheight </td><td style='width:20em'>%s</td>"] (specification.pfmweight ~= "" and specification.pfmweight or "-") + result[#result+1] = formatters[" <td class='tc' style='width:10em'>width </td><td style='width:20em'>%s</td></tr>"](specification.width ~= "" and specification.width or "normal") result[#result+1] = "</table>" if features then for what, v in table.sortedhash(features) do local data = features[what] if data and next(data) then - result[#result+1] = format("<h1>%s features</h1>",what) + result[#result+1] = formatters["<h1>%s features</h1><br/>"](what) result[#result+1] = "<table>" result[#result+1] = "<tr><th>feature</th><th>tag </th><th>script </th><th>languages </th></tr>" for f,ff in table.sortedhash(data) do @@ -461,7 +525,7 @@ local function show_font(currentfont,detail) done = true end local title = fonts.handlers.otf.tables.features[f] or "" - result[#result+1] = format("<tr><td width='50%%'>%s </td><td><tt>%s </tt></td><td><tt>%s </tt></td><td><tt>%s </tt></td></tr>",title,f,s,concat(table.sortedkeys(ss)," ")) + result[#result+1] = formatters["<tr><td width='50%%'>%s </td><td><tt>%s </tt></td><td><tt>%s </tt></td><td><tt>%s </tt></td></tr>"](title,f,s,concat(table.sortedkeys(ss)," ")) end end result[#result+1] = "</table>" @@ -473,8 +537,7 @@ local function show_font(currentfont,detail) return concat(result,"\n") end - -local info_template = [[ +local info_template = formatters [ [[ <pre><tt> version : %s comment : %s @@ -485,14 +548,14 @@ maillist : ntg-context at ntg.nl webpage : www.pragma-ade.nl wiki : contextgarden.net </tt></pre> -]] +]] ] local function info_about() local m = modules ['mtx-server-ctx-fonttest'] - return format(info_template,m.version,m.comment,m.author,m.copyright) + return info_template(m.version,m.comment,m.author,m.copyright) end -local save_template = [[ +local save_template = formatters [ [[ the current setup has been saved: <br/> <br/> <table> @@ -505,7 +568,7 @@ local save_template = [[ <tr><td class='tc'>options </td><td>%s</td></tr> <tr><td class='tc'>sampletext </td><td>%s</td></tr> </table> -]] +]] ] local function loadbase() local datafile = file.join(basepath,basename) @@ -584,23 +647,23 @@ local function save_font(currentfont,detail) font = currentfont, title = title, script = script, language = language, features = features, options = options, text = text, } savebase(storage,name) - return format(save_template,name,title,currentfont,script,language,concat(table.sortedkeys(features)," "),concat(table.sortedkeys(options)," "),text) + return save_template(name,title,currentfont,script,language,concat(table.sortedkeys(features)," "),concat(table.sortedkeys(options)," "),text) end local function load_font(currentfont) local datafile = file.join(basepath,basename) local storage = loadbase(datafile) local result = {} - result[#result+1] = format("<tr><th>del </th><th>name </th><th>font </th><th>fontname </th><th>script </th><th>language </th><th>features </th><th>title </th><th>sampletext </th></tr>") + result[#result+1] = "<tr><th>del </th><th>name </th><th>font </th><th>fontname </th><th>script </th><th>language </th><th>features </th><th>title </th><th>sampletext </th></tr>" for k,v in table.sortedhash(storage) do local fontname, fontfile = get_specification(v.font) - result[#result+1] = format("<tr><td><a href='mtx-server-ctx-fonttest.lua?deletename=%s'>x</a> </td><td><a href='mtx-server-ctx-fonttest.lua?loadname=%s'>%s</a> </td><td>%s </td<td>%s </td><td>%s </td><td>%s </td><td>%s </td><td>%s </td><td>%s </td></tr>", + result[#result+1] = formatters["<tr><td><a href='mtx-server-ctx-fonttest.lua?deletename=%s'>x</a> </td><td><a href='mtx-server-ctx-fonttest.lua?loadname=%s'>%s</a> </td><td>%s </td<td>%s </td><td>%s </td><td>%s </td><td>%s </td><td>%s </td><td>%s </td></tr>"]( k,k,k,v.font,fontname,v.script,v.language,concat(table.sortedkeys(v.features)," "),v.title or "no title",v.text or "") end if #result == 1 then return "nothing saved yet" else - return format("<table>%s</table>",concat(result,"\n")) + return formatters["<table>%s</table>"](concat(result,"\n")) end end @@ -608,12 +671,12 @@ local function reset_font(currentfont) return edit_font(currentfont) end -local extras_template = [[ +local extras_template = formatters [ [[ <a href='mtx-server-ctx-fonttest.lua?extra=reload'>remake font database</a> (take some time)<br/><br/> -]] +]] ] local function do_extras(detail,currentfont,extra) - return extras_template + return extras_template() end local extras = { } @@ -625,16 +688,13 @@ local function do_extra(detail,currentfont,extra) end function extras.reload() - local command = "mtxrun --script font --reload" - report("run command: %s",command) - os.execute(command) + identifyfonts() return do_extras() end - -local status_template = [[ +local status_template = formatters [ [[ <input type="hidden" name="currentfont" value="%s" /> -]] +]] ] local variables = { ['color-background-one'] = lmx.get('color-background-green'), @@ -643,6 +703,8 @@ local variables = { ['formaction'] = "mtx-server-ctx-fonttest.lua", } +-- todo: use lmx file + function doit(configuration,filename,hashed) local start = os.clock() @@ -653,6 +715,12 @@ function doit(configuration,filename,hashed) local action = detail.action local selection = detail.selection + if action == "luajittex" then + jitmode = true + elseif action == "luatex" then + jitmode = false + end + local loadname = detail.loadname local deletename = detail.deletename local extra = detail.extra @@ -673,30 +741,34 @@ function doit(configuration,filename,hashed) local fontname, fontfile = get_specification(currentfont) if fontfile then - variables.title = format('ConTeXt Font Tester: %s (%s)',fontname,fontfile) + variables.title = formatters['ConTeXt Font Tester: %s (%s)'](fontname,fontfile) else variables.title = 'ConTeXt Font Tester' end + if jitmode then + variables.title = variables.title .. " (using LuaJit vm)" + end + -- lua table and adapt - local buttons = { 'process', 'select', 'save', 'load', 'edit', 'reset', 'features', 'source', 'log', 'info', 'extras'} + report("action: %s",action or "no action") + + local buttons = { 'process', 'select', 'save', 'load', 'edit', 'reset', 'features', 'source', 'log', 'info', 'extras', jitmode and "luatex" or "luajittex" } local menu = { } for i=1,#buttons do local button = buttons[i] - menu[#menu+1] = format("<button name='action' value='%s' type='submit'>%s</button>",button,button) + menu[#menu+1] = formatters["<button name='action' value='%s' type='submit'>%s</button>"](button,button) end variables.menu = concat(menu," ") - variables.status = format(status_template,currentfont or "") + variables.status = status_template(currentfont or "") variables.maintext = "" variables.javascriptdata = "" variables.javascripts = "" variables.javascriptinit = "" - report("action: %s",action or "no action") - local result if action == "select" then diff --git a/scripts/context/lua/mtx-server.lua b/scripts/context/lua/mtx-server.lua index 5ec15de70..5466bfe80 100644 --- a/scripts/context/lua/mtx-server.lua +++ b/scripts/context/lua/mtx-server.lua @@ -43,7 +43,7 @@ scripts.webserver = scripts.webserver or { } dofile(resolvers.findfile("luat-soc.lua","tex")) local socket = socket or require("socket") -local http = http or require("socket.http") -- not needed +----- http = http or require("socket.http") -- not needed local format = string.format -- The following two lists are taken from webrick (ruby) and @@ -197,6 +197,7 @@ function handlers.generic(client,configuration,data,suffix,iscontent) client:send("Connection: close\r\n") client:send(format("Content-Length: %s\r\n",#data)) client:send(format("Content-Type: %s\r\n",(suffix and mimetypes[suffix]) or "text/html")) + client:send("Cache-Control: no-cache, no-store, must-revalidate, max-age=0\r\n") client:send("\r\n") client:send(data) client:send("\r\n") @@ -333,8 +334,9 @@ function scripts.webserver.run(configuration) report("no url") errormessage(client,configuration,404) else + fullurl = url.unescapeget(fullurl) report("requested url: %s",fullurl) - fullurl = socket.url.unescape(fullurl) -- still needed? + -- fullurl = socket.url.unescape(fullurl) -- happens later local hashed = url.hashed(fullurl) local query = url.query(hashed.query) local filename = hashed.path -- hm, not query? diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua index 4106ee608..682425a23 100644 --- a/scripts/context/lua/mtxrun.lua +++ b/scripts/context/lua/mtxrun.lua @@ -3481,7 +3481,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-url"] = package.loaded["l-url"] or true --- original size: 11806, stripped down to: 5417 +-- original size: 11993, stripped down to: 5584 if not modules then modules={} end modules ['l-url']={ version=1.001, @@ -3532,9 +3532,14 @@ setmetatable(escapes,{ __index=function(t,k) end }) local escaper=Cs((R("09","AZ","az")^1+P(" ")/"%%20"+S("-./_")^1+P(1)/escapes)^0) local unescaper=Cs((escapedchar+1)^0) +local getcleaner=Cs((P("+++")/"%%2B"+P("+")/"%%20"+P(1))^1) lpegpatterns.urlunescaped=escapedchar lpegpatterns.urlescaper=escaper lpegpatterns.urlunescaper=unescaper +lpegpatterns.urlgetcleaner=getcleaner +function url.unescapeget(str) + return lpegmatch(getcleaner,str) +end local function split(str) return (type(str)=="string" and lpegmatch(parser,str)) or str end @@ -16541,8 +16546,8 @@ end -- of closure -- used libraries : l-lua.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-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-sto.lua util-prs.lua util-fmt.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-mrg.lua util-tpl.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 : 679172 --- stripped bytes : 240312 +-- original bytes : 679359 +-- stripped bytes : 240332 -- end library merge diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua index 4106ee608..682425a23 100644 --- a/scripts/context/stubs/mswin/mtxrun.lua +++ b/scripts/context/stubs/mswin/mtxrun.lua @@ -3481,7 +3481,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-url"] = package.loaded["l-url"] or true --- original size: 11806, stripped down to: 5417 +-- original size: 11993, stripped down to: 5584 if not modules then modules={} end modules ['l-url']={ version=1.001, @@ -3532,9 +3532,14 @@ setmetatable(escapes,{ __index=function(t,k) end }) local escaper=Cs((R("09","AZ","az")^1+P(" ")/"%%20"+S("-./_")^1+P(1)/escapes)^0) local unescaper=Cs((escapedchar+1)^0) +local getcleaner=Cs((P("+++")/"%%2B"+P("+")/"%%20"+P(1))^1) lpegpatterns.urlunescaped=escapedchar lpegpatterns.urlescaper=escaper lpegpatterns.urlunescaper=unescaper +lpegpatterns.urlgetcleaner=getcleaner +function url.unescapeget(str) + return lpegmatch(getcleaner,str) +end local function split(str) return (type(str)=="string" and lpegmatch(parser,str)) or str end @@ -16541,8 +16546,8 @@ end -- of closure -- used libraries : l-lua.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-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-sto.lua util-prs.lua util-fmt.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-mrg.lua util-tpl.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 : 679172 --- stripped bytes : 240312 +-- original bytes : 679359 +-- stripped bytes : 240332 -- end library merge diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun index 4106ee608..682425a23 100644 --- a/scripts/context/stubs/unix/mtxrun +++ b/scripts/context/stubs/unix/mtxrun @@ -3481,7 +3481,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-url"] = package.loaded["l-url"] or true --- original size: 11806, stripped down to: 5417 +-- original size: 11993, stripped down to: 5584 if not modules then modules={} end modules ['l-url']={ version=1.001, @@ -3532,9 +3532,14 @@ setmetatable(escapes,{ __index=function(t,k) end }) local escaper=Cs((R("09","AZ","az")^1+P(" ")/"%%20"+S("-./_")^1+P(1)/escapes)^0) local unescaper=Cs((escapedchar+1)^0) +local getcleaner=Cs((P("+++")/"%%2B"+P("+")/"%%20"+P(1))^1) lpegpatterns.urlunescaped=escapedchar lpegpatterns.urlescaper=escaper lpegpatterns.urlunescaper=unescaper +lpegpatterns.urlgetcleaner=getcleaner +function url.unescapeget(str) + return lpegmatch(getcleaner,str) +end local function split(str) return (type(str)=="string" and lpegmatch(parser,str)) or str end @@ -16541,8 +16546,8 @@ end -- of closure -- used libraries : l-lua.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-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-sto.lua util-prs.lua util-fmt.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-mrg.lua util-tpl.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 : 679172 --- stripped bytes : 240312 +-- original bytes : 679359 +-- stripped bytes : 240332 -- end library merge diff --git a/tex/context/base/buff-ini.lua b/tex/context/base/buff-ini.lua index 7a92b873e..9d0aa0a6f 100644 --- a/tex/context/base/buff-ini.lua +++ b/tex/context/base/buff-ini.lua @@ -364,7 +364,7 @@ function commands.runbuffer(name,encapsulate) -- we used to compare the saved fi content = formatters["\\starttext\n%s\n\\stoptext\n"](content) end io.savedata(filename,content) - local command = formatters["context %s"](filename) + local command = formatters["context %s %s"](jit and "--jit" or "",filename) report_typeset("running: %s\n",command) os.execute(command) markastypeset(names) diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv index da3e9b66e..61ac09253 100644 --- a/tex/context/base/cont-new.mkiv +++ b/tex/context/base/cont-new.mkiv @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2013.09.20 00:32} +\newcontextversion{2013.09.20 14:01} %D This file is loaded at runtime, thereby providing an excellent place for %D hacks, patches, extensions and new features. diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf Binary files differindex 81208541f..b0cb5c512 100644 --- a/tex/context/base/context-version.pdf +++ b/tex/context/base/context-version.pdf diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index d5dc4f1db..e7f118fdc 100644 --- a/tex/context/base/context.mkiv +++ b/tex/context/base/context.mkiv @@ -25,7 +25,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2013.09.20 00:32} +\edef\contextversion{2013.09.20 14:01} \edef\contextkind {beta} %D For those who want to use this: diff --git a/tex/context/base/font-ini.mkvi b/tex/context/base/font-ini.mkvi index 0d356895e..a627310e0 100644 --- a/tex/context/base/font-ini.mkvi +++ b/tex/context/base/font-ini.mkvi @@ -1524,7 +1524,7 @@ \unexpanded\def\font_basics_define_body_font_name_identifier_a#name#identifier#style% {%\writestatus\m!fonts{[#name:#style] => [##identifier:#style]}% - \ifcsname\csname\??fontdefinitions#name:#style\endcsname + \ifcsname\??fontdefinitions#name:#style\endcsname \expandafter\let\csname\??fontdefinitions#name:#style\expandafter\endcsname\csname\??fontdefinitions#identifier:#style\endcsname \else \expandafter\def\csname\??fontdefinitions#name:#style\endcsname{\csname\??fontdefinitions#identifier:#style\endcsname}% diff --git a/tex/context/base/font-syn.lua b/tex/context/base/font-syn.lua index 34aeb0819..ead571938 100644 --- a/tex/context/base/font-syn.lua +++ b/tex/context/base/font-syn.lua @@ -828,7 +828,7 @@ local function analyzefiles(olddata) local oldindices = olddata and olddata.indices or { } local oldspecifications = olddata and olddata.specifications or { } local oldrejected = olddata and olddata.rejected or { } - local treatmentdata = fonts.treatments.data + local treatmentdata = fonts.treatments and fonts.treatments.data or { } -- when used outside context local function identify(completename,name,suffix,storedname) local pathpart, basepart = splitbase(completename) nofread = nofread + 1 diff --git a/tex/context/base/l-url.lua b/tex/context/base/l-url.lua index 4624a0507..7b7910fa7 100644 --- a/tex/context/base/l-url.lua +++ b/tex/context/base/l-url.lua @@ -79,12 +79,18 @@ setmetatable(escapes, { __index = function(t,k) return v end }) -local escaper = Cs((R("09","AZ","az")^1 + P(" ")/"%%20" + S("-./_")^1 + P(1) / escapes)^0) -- space happens most -local unescaper = Cs((escapedchar + 1)^0) +local escaper = Cs((R("09","AZ","az")^1 + P(" ")/"%%20" + S("-./_")^1 + P(1) / escapes)^0) -- space happens most +local unescaper = Cs((escapedchar + 1)^0) +local getcleaner = Cs((P("+++") / "%%2B" + P("+") / "%%20" + P(1))^1) -lpegpatterns.urlunescaped = escapedchar -lpegpatterns.urlescaper = escaper -lpegpatterns.urlunescaper = unescaper +lpegpatterns.urlunescaped = escapedchar +lpegpatterns.urlescaper = escaper +lpegpatterns.urlunescaper = unescaper +lpegpatterns.urlgetcleaner = getcleaner + +function url.unescapeget(str) + return lpegmatch(getcleaner,str) +end -- todo: reconsider Ct as we can as well have five return values (saves a table) -- so we can have two parsers, one with and one without diff --git a/tex/context/base/math-noa.lua b/tex/context/base/math-noa.lua index f72f568d4..f3987c12f 100644 --- a/tex/context/base/math-noa.lua +++ b/tex/context/base/math-noa.lua @@ -1108,7 +1108,7 @@ local colors = { } classes[math_char] = function(pointer,what,n,parent) - local color = colors[getsubtype(parent)] + local color = colors[parent.subtype] if color then setcolor(pointer,color) else diff --git a/tex/context/base/page-mix.lua b/tex/context/base/page-mix.lua index ef5308546..7a97655d2 100644 --- a/tex/context/base/page-mix.lua +++ b/tex/context/base/page-mix.lua @@ -135,7 +135,7 @@ local function discardtopglue(current,discarded) elseif id == penalty_code then if current.penalty == forcedbreak then discarded[#discarded+1] = current - current = getnext(current) + current = current.next while current and current.id == glue_code do size = size + current.spec.width discarded[#discarded+1] = current diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf Binary files differindex 7a8e96de4..cd0124e77 100644 --- a/tex/context/base/status-files.pdf +++ b/tex/context/base/status-files.pdf diff --git a/tex/context/base/status-lua.log b/tex/context/base/status-lua.log index 325d8a435..ea0c241c1 100644 --- a/tex/context/base/status-lua.log +++ b/tex/context/base/status-lua.log @@ -1,6 +1,6 @@ (cont-yes.mkiv -ConTeXt ver: 2013.09.20 00:32 MKIV beta fmt: 2013.9.20 int: english/english +ConTeXt ver: 2013.09.20 14:01 MKIV beta fmt: 2013.9.20 int: english/english system > 'cont-new.mkiv' loaded (cont-new.mkiv) diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 9df3a35e4..13a42a24f 100644 --- a/tex/generic/context/luatex/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : luatex-fonts-merged.lua -- parent file : luatex-fonts.lua --- merge date : 09/20/13 00:32:07 +-- merge date : 09/20/13 14:01:24 do -- begin closure to overcome local limits and interference |