From 4fc90550eb4fa4fea7a1721f800fcefb4081e24a Mon Sep 17 00:00:00 2001 From: Marius Date: Tue, 8 Jan 2013 20:40:16 +0200 Subject: beta 2013.01.08 19:28 --- tex/context/base/cont-new.mkii | 2 +- tex/context/base/cont-new.mkiv | 2 +- tex/context/base/context-version.pdf | Bin 4124 -> 4129 bytes tex/context/base/context-version.png | Bin 39605 -> 40128 bytes tex/context/base/context.mkii | 2 +- tex/context/base/context.mkiv | 2 +- tex/context/base/grph-inc.lua | 167 ++++++++++++--------- tex/context/base/l-lpeg.lua | 2 + tex/context/base/l-string.lua | 9 +- tex/context/base/math-vfu.lua | 26 +++- tex/context/base/status-files.pdf | Bin 24760 -> 24770 bytes tex/context/base/status-lua.pdf | Bin 208068 -> 208141 bytes tex/generic/context/luatex/luatex-fonts-merged.lua | 13 +- 13 files changed, 144 insertions(+), 81 deletions(-) (limited to 'tex') diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii index 8539351c5..7d8fe2311 100644 --- a/tex/context/base/cont-new.mkii +++ b/tex/context/base/cont-new.mkii @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2013.01.08 01:19} +\newcontextversion{2013.01.08 19:28} %D This file is loaded at runtime, thereby providing an %D excellent place for hacks, patches, extensions and new diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv index d37334dba..6be11d865 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.01.08 01:19} +\newcontextversion{2013.01.08 19:28} %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 index a0a81ef92..953d4925a 100644 Binary files a/tex/context/base/context-version.pdf and b/tex/context/base/context-version.pdf differ diff --git a/tex/context/base/context-version.png b/tex/context/base/context-version.png index f212fc066..cc76b02df 100644 Binary files a/tex/context/base/context-version.png and b/tex/context/base/context-version.png differ diff --git a/tex/context/base/context.mkii b/tex/context/base/context.mkii index 5308be962..42f092e60 100644 --- a/tex/context/base/context.mkii +++ b/tex/context/base/context.mkii @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2013.01.08 01:19} +\edef\contextversion{2013.01.08 19:28} %D For those who want to use this: diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index 9285a841f..a8daeb3fd 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.01.08 01:19} +\edef\contextversion{2013.01.08 19:28} %D For those who want to use this: diff --git a/tex/context/base/grph-inc.lua b/tex/context/base/grph-inc.lua index aee90d2c1..c8a4bcf1a 100644 --- a/tex/context/base/grph-inc.lua +++ b/tex/context/base/grph-inc.lua @@ -44,6 +44,8 @@ local concat, insert, remove = table.concat, table.insert, table.remove local todimen = string.todimen local collapsepath = file.collapsepath local formatters = string.formatters +local longtostring = string.longtostring +local expandfilename = dir.expandname local P, lpegmatch = lpeg.P, lpeg.match @@ -51,6 +53,7 @@ local settings_to_array = utilities.parsers.settings_to_array local settings_to_hash = utilities.parsers.settings_to_hash local allocate = utilities.storage.allocate local setmetatableindex = table.setmetatableindex +local replacetemplate = utilities.templates.replace local variables = interfaces.variables local codeinjections = backends.codeinjections @@ -1212,10 +1215,13 @@ end -- programs.makeoptions = makeoptions -local function runprogram(template,binary,...) - local command = format(template,binary,...) +local function runprogram(binary,argument,variables) local binary = match(binary,"[%S]+") -- to be sure if os.which(binary) then + if type(argument) == "table" then + argument = concat(argument," ") -- for old times sake + end + local command = format("%q %s",binary,replacetemplate(longtostring(argument),variables)) if trace_conversion or trace_programs then report_inclusion("running: %s",command) end @@ -1225,39 +1231,74 @@ local function runprogram(template,binary,...) end end --- -- -- eps -- -- -- +programs.run = runprogram + +-- -- -- eps & pdf -- -- -- +-- +-- \externalfigure[cow.eps] +-- \externalfigure[cow.pdf][conversion=stripped] -local epsconverter = { } +local epsconverter = converters.eps or { } converters.eps = epsconverter converters.ps = epsconverter -programs.gs = { +local epstopdf = { resolutions = { [variables.low] = "screen", [variables.medium] = "ebook", [variables.high] = "prepress", }, - options = { - "-dAutoRotatePages=/None", - "-dPDFSETTINGS=/%s", - "-dEPSCrop", - }, - command = (os.type == "windows" and "gswin32c") or "gs" + command = os.type == "windows" and "gswin32c" or "gs", + argument = [[ + -q + -sDEVICE=pdfwrite + -dNOPAUSE + -dNOCACHE + -dBATCH + -dAutoRotatePages=/None + -dPDFSETTINGS=/%presets% + -dEPSCrop + -sOutputFile=%newname% + %oldname% + -c quit + ]], } +programs.epstopdf = epstopdf +programs.gs = epstopdf + function epsconverter.pdf(oldname,newname,resolution) -- the resolution interface might change - local gs = programs.gs - runprogram ( - '%s -q -sDEVICE=pdfwrite -dNOPAUSE -dNOCACHE -dBATCH %s -sOutputFile="%s" "%s" -c quit', - gs.command, - format(makeoptions(gs.options),gs.resolutions[resolution or ""] or "prepress"), - newname, - oldname - ) + local epstopdf = programs.epstopdf -- can be changed + local presets = epstopdf.resolutions[resolution or ""] or epstopdf.resolutions.high + runprogram(epstopdf.command, epstopdf.argument, { + newname = newname, + oldname = oldname, + presets = presets, + } ) end epsconverter.default = epsconverter.pdf +local pdfconverter = converters.pdf or { } +converters.pdf = pdfconverter + +programs.pdftoeps = { + command = "pdftops", + argument = [[-eps "%oldname%" "%newname%]], +} + +pdfconverter.stripped = function(oldname,newname) + local pdftoeps = programs.pdftoeps -- can be changed + local epstopdf = programs.epstopdf -- can be changed + local presets = epstopdf.resolutions[resolution or ""] or epstopdf.resolutions.high + local tmpname = newname .. ".tmp" + runprogram(pdftoeps.command, pdftoeps.argument, { oldname = oldname, newname = tmpname, presets = presets }) + runprogram(epstopdf.command, epstopdf.argument, { oldname = tmpname, newname = newname, presets = presets }) + os.remove(tmpname) +end + +figures.registersuffix("stripped","pdf") + -- -- -- svg -- -- -- local svgconverter = { } @@ -1267,71 +1308,69 @@ converters.svgz = svgconverter -- inkscape on windows only works with complete paths programs.inkscape = { - options = { - "--export-dpi=600" - }, - command = "inkscape" + command = "inkscape", + pdfargument = [[ + "%oldname%" + --export-dpi=600 + -A + "%newname%" + ]], + pngargument = [[ + "%oldname%" + --export-dpi=600 + --export-png="%newname%" + ]], } function svgconverter.pdf(oldname,newname) - local inkscape = programs.inkscape - local oldname = dir.expandname(oldname) - local newname = dir.expandname(newname) - runprogram ( - '%s "%s" %s -A "%s"', - inkscape.command, oldname, makeoptions(inkscape.options), newname - ) + local inkscape = programs.inkscape -- can be changed + runprogram(inkscape.command, inkscape.pdfargument, { + newname = expandfilename(newname), + oldname = expandfilename(oldname), + } ) end function svgconverter.png(oldname,newname) local inkscape = programs.inkscape - runprogram ( - '%s "%s" --export-png="%s" %s', - inkscape.command, oldname, newname, makeoptions(inkscape.options) - ) + runprogram(inkscape.command, inkscape.pngargument, { + newname = expandfilename(newname), + oldname = expandfilename(oldname), + } ) end svgconverter.default = svgconverter.pdf -- -- -- gif -- -- -- - -local gifconverter = { } -converters.gif = gifconverter - -programs.convert = { - command = "gm convert" -- graphicmagick -} - -function gifconverter.pdf(oldname,newname) - local convert = programs.convert - runprogram ( - "%s %s %s %s", - convert.command, makeoptions(convert.options), oldname, newname - ) -end - -gifconverter.default = gifconverter.pdf - -- -- -- tif -- -- -- --- http://sourceforge.net/projects/gnuwin32/files/tiff/3.8.2-1/tiff-3.8.2-1-bin.zip/download +local gifconverter = converters.gif or { } +local tifconverter = converters.tif or { } +local bmpconverter = converters.bmp or { } -local tifconverter = { } +converters.gif = gifconverter converters.tif = tifconverter +converters.bmp = bmpconverter programs.convert = { - command = "gm convert" -- graphicmagick + command = "gm", -- graphicmagick + argument = [[convert "%oldname%" "%newname%"]], } -function tifconverter.pdf(oldname,newname) +local function converter(oldname,newname) local convert = programs.convert - runprogram ( - "%s %s %s %s", -- "%s %s -z -o %s %s" - convert.command, makeoptions(convert.options), oldname, newname - ) + runprogram(convert.command, convert.gifargument, { + newname = newname, + oldname = oldname, + } ) end -tifconverter.default = tifconverter.pdf +tifconverter.pdf = converter +gifconverter.pdf = converter +bmpconverter.pdf = converter + +gifconverter.default = converter +tifconverter.default = converter +bmpconverter.default = converter -- todo: lowres @@ -1513,12 +1552,6 @@ end -- end, -- } --- figures.converters.bmp = { --- pdf = function(oldname,newname) --- os.execute(string.format("gm convert %s %s",oldname,newname)) --- end --- } - -- local fig = figures.push { name = pdffile } -- figures.identify() -- figures.check() diff --git a/tex/context/base/l-lpeg.lua b/tex/context/base/l-lpeg.lua index b00d02f9f..407532ebf 100644 --- a/tex/context/base/l-lpeg.lua +++ b/tex/context/base/l-lpeg.lua @@ -184,6 +184,8 @@ patterns.propername = R("AZ","az","__") * R("09","AZ","az", "__")^0 * P(-1) patterns.somecontent = (anything - newline - space)^1 -- (utf8char - newline - space)^1 patterns.beginline = #(1-newline) +patterns.longtostring = Cs(whitespace^0/"" * nonwhitespace^0 * ((whitespace^0/" " * (patterns.quoted + nonwhitespace)^1)^0)) + local function anywhere(pattern) --slightly adapted from website return P { P(pattern) + 1 * V(1) } end diff --git a/tex/context/base/l-string.lua b/tex/context/base/l-string.lua index 597ce3462..7a919d189 100644 --- a/tex/context/base/l-string.lua +++ b/tex/context/base/l-string.lua @@ -69,8 +69,9 @@ function string.limit(str,n,sentinel) -- not utf proof end end -local stripper = patterns.stripper -local collapser = patterns.collapser +local stripper = patterns.stripper +local collapser = patterns.collapser +local longtostring = patterns.longtostring function string.strip(str) return lpegmatch(stripper,str) or "" @@ -80,6 +81,10 @@ function string.collapsespaces(str) return lpegmatch(collapser,str) or "" end +function string.longtostring(str) + return lpegmatch(longtostring,str) or "" +end + -- function string.is_empty(str) -- return not find(str,"%S") -- end diff --git a/tex/context/base/math-vfu.lua b/tex/context/base/math-vfu.lua index b5ee71e62..042b3890b 100644 --- a/tex/context/base/math-vfu.lua +++ b/tex/context/base/math-vfu.lua @@ -97,11 +97,27 @@ local function extension(main,characters,id,size,unicode,first,middle,last) if not chr then return -- skip end - local fw = characters[first ].width - local mw = characters[middle].width - local lw = characters[last ].width - if fw == 0 then fw = 1 end - if lw == 0 then lw = 1 end + local fw = characters[first] + if not fw then + return + end + local mw = characters[middle] + if not mw then + return + end + local lw = characters[last] + if not lw then + return + end + fw = fw.width + mw = mw.width + lw = lw.width + if fw == 0 then + fw = 1 + end + if lw == 0 then + lw = 1 + end chr.horiz_variants = { { extender = 0, glyph = first, ["end"] = fw/2, start = 0, advance = fw }, { extender = 1, glyph = middle, ["end"] = mw/2, start = mw/2, advance = mw }, diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf index c5175887c..54021878c 100644 Binary files a/tex/context/base/status-files.pdf and b/tex/context/base/status-files.pdf differ diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf index e66cacae3..9be00e003 100644 Binary files a/tex/context/base/status-lua.pdf and b/tex/context/base/status-lua.pdf differ diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 3fb5a2dae..8b36f4a17 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 : 01/08/13 01:19:52 +-- merge date : 01/08/13 19:28:06 do -- begin closure to overcome local limits and interference @@ -190,6 +190,8 @@ patterns.propername = R("AZ","az","__") * R("09","AZ","az", "__")^0 * P(-1) patterns.somecontent = (anything - newline - space)^1 -- (utf8char - newline - space)^1 patterns.beginline = #(1-newline) +patterns.longtostring = Cs(whitespace^0/"" * nonwhitespace^0 * ((whitespace^0/" " * (patterns.quoted + nonwhitespace)^1)^0)) + local function anywhere(pattern) --slightly adapted from website return P { P(pattern) + 1 * V(1) } end @@ -874,8 +876,9 @@ function string.limit(str,n,sentinel) -- not utf proof end end -local stripper = patterns.stripper -local collapser = patterns.collapser +local stripper = patterns.stripper +local collapser = patterns.collapser +local longtostring = patterns.longtostring function string.strip(str) return lpegmatch(stripper,str) or "" @@ -885,6 +888,10 @@ function string.collapsespaces(str) return lpegmatch(collapser,str) or "" end +function string.longtostring(str) + return lpegmatch(longtostring,str) or "" +end + -- function string.is_empty(str) -- return not find(str,"%S") -- end -- cgit v1.2.3