diff options
author | Context Git Mirror Bot <phg42.2a@gmail.com> | 2016-07-13 16:28:12 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2016-07-13 16:28:12 +0200 |
commit | 5a923dc5ac055164721b40a58e4d1614fc7f2aa1 (patch) | |
tree | b680cfbe5a20a623c6dd2593fd4be474d047adca /tex | |
parent | bf7fc74b4f42f6bc1c57488da72bbc142c47f86a (diff) | |
download | context-5a923dc5ac055164721b40a58e4d1614fc7f2aa1.tar.gz |
2016-07-13 15:15:00
Diffstat (limited to 'tex')
39 files changed, 647 insertions, 435 deletions
diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf Binary files differindex 090dad0cf..39a41087a 100644 --- a/tex/context/base/context-version.pdf +++ b/tex/context/base/context-version.pdf diff --git a/tex/context/base/mkii/mult-de.mkii b/tex/context/base/mkii/mult-de.mkii index 67bacc727..5194402a8 100644 --- a/tex/context/base/mkii/mult-de.mkii +++ b/tex/context/base/mkii/mult-de.mkii @@ -622,6 +622,7 @@ \setinterfaceconstant{anchor}{anchor} \setinterfaceconstant{andtext}{andtext} \setinterfaceconstant{apa}{apa} +\setinterfaceconstant{arguments}{arguments} \setinterfaceconstant{arrow}{pfeil} \setinterfaceconstant{artauthor}{artauthor} \setinterfaceconstant{artauthoretaldisplay}{artauthoretaldisplay} diff --git a/tex/context/base/mkii/mult-en.mkii b/tex/context/base/mkii/mult-en.mkii index ba08baa65..166682419 100644 --- a/tex/context/base/mkii/mult-en.mkii +++ b/tex/context/base/mkii/mult-en.mkii @@ -622,6 +622,7 @@ \setinterfaceconstant{anchor}{anchor} \setinterfaceconstant{andtext}{andtext} \setinterfaceconstant{apa}{apa} +\setinterfaceconstant{arguments}{arguments} \setinterfaceconstant{arrow}{arrow} \setinterfaceconstant{artauthor}{artauthor} \setinterfaceconstant{artauthoretaldisplay}{artauthoretaldisplay} diff --git a/tex/context/base/mkii/mult-fr.mkii b/tex/context/base/mkii/mult-fr.mkii index d80cfe21e..1395b2d40 100644 --- a/tex/context/base/mkii/mult-fr.mkii +++ b/tex/context/base/mkii/mult-fr.mkii @@ -622,6 +622,7 @@ \setinterfaceconstant{anchor}{anchor} \setinterfaceconstant{andtext}{andtext} \setinterfaceconstant{apa}{apa} +\setinterfaceconstant{arguments}{arguments} \setinterfaceconstant{arrow}{fleche} \setinterfaceconstant{artauthor}{artauthor} \setinterfaceconstant{artauthoretaldisplay}{artauthoretaldisplay} diff --git a/tex/context/base/mkii/mult-it.mkii b/tex/context/base/mkii/mult-it.mkii index c038379e8..96eb71a08 100644 --- a/tex/context/base/mkii/mult-it.mkii +++ b/tex/context/base/mkii/mult-it.mkii @@ -622,6 +622,7 @@ \setinterfaceconstant{anchor}{anchor} \setinterfaceconstant{andtext}{andtext} \setinterfaceconstant{apa}{apa} +\setinterfaceconstant{arguments}{arguments} \setinterfaceconstant{arrow}{freccia} \setinterfaceconstant{artauthor}{artauthor} \setinterfaceconstant{artauthoretaldisplay}{artauthoretaldisplay} diff --git a/tex/context/base/mkii/mult-nl.mkii b/tex/context/base/mkii/mult-nl.mkii index dccbfa42d..9696ed009 100644 --- a/tex/context/base/mkii/mult-nl.mkii +++ b/tex/context/base/mkii/mult-nl.mkii @@ -622,6 +622,7 @@ \setinterfaceconstant{anchor}{anker} \setinterfaceconstant{andtext}{andtext} \setinterfaceconstant{apa}{apa} +\setinterfaceconstant{arguments}{argumenten} \setinterfaceconstant{arrow}{pijl} \setinterfaceconstant{artauthor}{artauthor} \setinterfaceconstant{artauthoretaldisplay}{artauthoretaldisplay} diff --git a/tex/context/base/mkii/mult-pe.mkii b/tex/context/base/mkii/mult-pe.mkii index d103eab63..3cfa2adfe 100644 --- a/tex/context/base/mkii/mult-pe.mkii +++ b/tex/context/base/mkii/mult-pe.mkii @@ -622,6 +622,7 @@ \setinterfaceconstant{anchor}{anchor} \setinterfaceconstant{andtext}{andtext} \setinterfaceconstant{apa}{apa} +\setinterfaceconstant{arguments}{arguments} \setinterfaceconstant{arrow}{پیکان} \setinterfaceconstant{artauthor}{artauthor} \setinterfaceconstant{artauthoretaldisplay}{artauthoretaldisplay} diff --git a/tex/context/base/mkii/mult-ro.mkii b/tex/context/base/mkii/mult-ro.mkii index 83d68a61e..ce1cf814a 100644 --- a/tex/context/base/mkii/mult-ro.mkii +++ b/tex/context/base/mkii/mult-ro.mkii @@ -622,6 +622,7 @@ \setinterfaceconstant{anchor}{anchor} \setinterfaceconstant{andtext}{andtext} \setinterfaceconstant{apa}{apa} +\setinterfaceconstant{arguments}{arguments} \setinterfaceconstant{arrow}{sageata} \setinterfaceconstant{artauthor}{artauthor} \setinterfaceconstant{artauthoretaldisplay}{artauthoretaldisplay} diff --git a/tex/context/base/mkiv/colo-ini.lua b/tex/context/base/mkiv/colo-ini.lua index 467ec2c47..f094259e0 100644 --- a/tex/context/base/mkiv/colo-ini.lua +++ b/tex/context/base/mkiv/colo-ini.lua @@ -477,6 +477,11 @@ end colors.isblack = isblack +-- local m, c, t = attributes.colors.namedcolorattributes(parent) +-- if c and c > 1 then -- 1 is black +-- local v = attributes.colors.values[c] + + local function definespotcolor(name,parent,str,global) if parent == "" or find(parent,"=",1,true) then colors.registerspotcolor(name, parent) -- does that work? no attr @@ -817,6 +822,10 @@ end local function spotcolorname(ca,default) local cv, v = colorvalues[ca], "unknown" + if not cv and type(ca) == "string" then + ca = resolvedname(ca) -- we could metatable colorvalues + cv = colorvalues[ca] + end if cv and cv[1] == 5 then v = cv[10] end @@ -825,6 +834,10 @@ end local function spotcolorparent(ca,default) local cv, v = colorvalues[ca], "unknown" + if not cv and type(ca) == "string" then + ca = resolvedname(ca) -- we could metatable colorvalues + cv = colorvalues[ca] + end if cv and cv[1] == 5 then v = cv[12] if v == "" then @@ -836,6 +849,10 @@ end local function spotcolorvalue(ca,default) local cv, v = colorvalues[ca], 0 + if not cv and type(ca) == "string" then + ca = resolvedname(ca) -- we could metatable colorvalues + cv = colorvalues[ca] + end if cv and cv[1] == 5 then v = cv[13] end @@ -1085,9 +1102,9 @@ implement { implement { name = "spotcolorname", actions = { spotcolorname, context }, arguments = "integer" } implement { name = "spotcolorparent", actions = { spotcolorparent, context }, arguments = "integer" } implement { name = "spotcolorvalue", actions = { spotcolorvalue, context }, arguments = "integer" } -implement { name = "colorcomponents", actions = { colorcomponents, context }, arguments = "integer" } -implement { name = "transparencycomponents", actions = { transparencycomponents, context }, arguments = "integer" } -implement { name = "processcolorcomponents", actions = { processcolorcomponents, context }, arguments = "integer" } +implement { name = "colorcomponents", actions = { colorcomponents, context }, arguments = { "integer", tokens.constant(",") } } +implement { name = "transparencycomponents", actions = { transparencycomponents, context }, arguments = { "integer", tokens.constant(",") } } +implement { name = "processcolorcomponents", actions = { processcolorcomponents, context }, arguments = { "integer", tokens.constant(",") } } implement { name = "formatcolor", actions = { formatcolor, context }, arguments = { "integer", "string" } } implement { name = "formatgray", actions = { formatgray, context }, arguments = { "integer", "string" } } @@ -1196,5 +1213,9 @@ function colors.spec(name) } end +function colors.currentnamedmodel() + return models[texgetattribute(a_colormodel)] or "gray" +end + -- inspect(attributes.colors.spec("red")) -- inspect(attributes.colors.spec("red socks")) diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index 0c56f6c58..b67a53313 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{2016.07.12 10:14} +\newcontextversion{2016.07.13 15:09} %D This file is loaded at runtime, thereby providing an excellent place for %D hacks, patches, extensions and new features. diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv index 0fee8b901..891812c86 100644 --- a/tex/context/base/mkiv/context.mkiv +++ b/tex/context/base/mkiv/context.mkiv @@ -39,7 +39,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2016.07.12 10:14} +\edef\contextversion{2016.07.13 15:09} \edef\contextkind {beta} %D For those who want to use this: diff --git a/tex/context/base/mkiv/core-env.mkiv b/tex/context/base/mkiv/core-env.mkiv index e876dc80d..0b8894265 100644 --- a/tex/context/base/mkiv/core-env.mkiv +++ b/tex/context/base/mkiv/core-env.mkiv @@ -119,15 +119,27 @@ {\ifcsname\??mode#1\endcsname\else\syst_modes_new{#1}\fi \syst_mode_prefix\lastnamedcs\preventedmode} +% \def\syst_modes_enable_indeed#1% we can speed it up by moving the new outside +% {\ifcsname\??mode#1\endcsname\else\syst_modes_new{#1}\fi +% \ifnum\csname\??mode#1\endcsname=\preventedmode \else +% \syst_mode_prefix\lastnamedcs\enabledmode +% \fi} +% +% \def\syst_modes_disable_indeed#1% +% {\ifcsname\??mode#1\endcsname\else\syst_modes_new{#1}\fi +% \ifnum\csname\??mode#1\endcsname=\preventedmode \else +% \syst_mode_prefix\lastnamedcs\disabledmode +% \fi} + \def\syst_modes_enable_indeed#1% we can speed it up by moving the new outside {\ifcsname\??mode#1\endcsname\else\syst_modes_new{#1}\fi - \ifnum\csname\??mode#1\endcsname=\preventedmode \else + \ifnum\lastnamedcs=\preventedmode\else \syst_mode_prefix\lastnamedcs\enabledmode \fi} \def\syst_modes_disable_indeed#1% {\ifcsname\??mode#1\endcsname\else\syst_modes_new{#1}\fi - \ifnum\csname\??mode#1\endcsname=\preventedmode \else + \ifnum\lastnamedcs=\preventedmode\else \syst_mode_prefix\lastnamedcs\disabledmode \fi} @@ -146,6 +158,18 @@ \edef\m_modes_asked{#2}% \rawprocesscommacommand[#1]\syst_modes_define_indeed} +% \def\syst_modes_define_indeed#1% +% {\ifcsname\??mode#1\endcsname +% % already set +% \else +% \syst_modes_new{#1} +% \fi +% \ifx\m_modes_asked\v!keep +% % not changes, disabled when undefined +% \else +% \csname\??mode#1\endcsname\ifx\m_modes_asked\v!yes\enabledmode\else\disabledmode\fi +% \fi} + \def\syst_modes_define_indeed#1% {\ifcsname\??mode#1\endcsname % already set @@ -155,7 +179,7 @@ \ifx\m_modes_asked\v!keep % not changes, disabled when undefined \else - \csname\??mode#1\endcsname\ifx\m_modes_asked\v!yes\enabledmode\else\disabledmode\fi + \lastnamedcs\ifx\m_modes_asked\v!yes\enabledmode\else\disabledmode\fi \fi} % handy for mp diff --git a/tex/context/base/mkiv/grph-con.lua b/tex/context/base/mkiv/grph-con.lua new file mode 100644 index 000000000..7cff26d10 --- /dev/null +++ b/tex/context/base/mkiv/grph-con.lua @@ -0,0 +1,359 @@ +if not modules then modules = { } end modules ['grph-con'] = { + version = 1.001, + comment = "companion to grph-inc.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +local P, R, S, Cc, C, Cs, Ct, lpegmatch = lpeg.P, lpeg.R, lpeg.S, lpeg.Cc, lpeg.C, lpeg.Cs, lpeg.Ct, lpeg.match + +local longtostring = string.longtostring +local formatters = string.formatters +local expandfilename = dir.expandname + +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 codeinjections = backends.codeinjections +local nodeinjections = backends.nodeinjections + +local report_figures = logs.reporter("system","graphics") + +local variables = interfaces.variables +local v_high = variables.high +local v_low = variables.low +local v_medium = variables.medium + +local figures = figures + +local converters = figures.converters +local programs = figures.programs + +local runprogram = programs.run +local makeuptions = programs.makeoptions + +do -- eps | ps + + -- \externalfigure[cow.eps] + -- \externalfigure[cow.pdf][conversion=stripped] + + -- todo: colorspace + -- todo: lowres + + local epsconverter = converters.eps + converters.ps = epsconverter + + local epstopdf = { + resolutions = { + [v_low] = "screen", + [v_medium] = "ebook", + [v_high] = "prepress", + }, + command = os.type == "windows" and { "gswin64c", "gswin32c" } or "gs", + -- -dProcessDSCComments=false + argument = longtostring [[ + -q + -sDEVICE=pdfwrite + -dNOPAUSE + -dNOCACHE + -dBATCH + -dAutoRotatePages=/None + -dPDFSETTINGS=/%presets% + -dEPSCrop + -dCompatibilityLevel=%level% + -sOutputFile="%newname%" + %colorspace% + "%oldname%" + -c quit + ]], + } + + programs.epstopdf = epstopdf + programs.gs = epstopdf + + local cleanups = { } + local cleaners = { } + + local whitespace = lpeg.patterns.whitespace + local quadruple = Ct((whitespace^0 * lpeg.patterns.number/tonumber * whitespace^0)^4) + local betterbox = P("%%BoundingBox:") * quadruple + * P("%%HiResBoundingBox:") * quadruple + * P("%AI3_Cropmarks:") * quadruple + * P("%%CropBox:") * quadruple + / function(b,h,m,c) + return formatters["%%%%BoundingBox: %i %i %i %i\n%%%%HiResBoundingBox: %F %F %F %F\n%%%%CropBox: %F %F %F %F\n"]( + m[1],m[2],m[3],m[4], + m[1],m[2],m[3],m[4], + m[1],m[2],m[3],m[4] + ) + end + local nocrap = P("%") / "" * ( + (P("AI9_PrivateDataBegin") * P(1)^0) / "%%%%EOF" + + (P("%EOF") * whitespace^0 * P("%AI9_PrintingDataEnd") * P(1)^0) / "%%%%EOF" + + (P("AI7_Thumbnail") * (1-P("%%EndData"))^0 * P("%%EndData")) / "" + ) + local whatever = nocrap + P(1) + local pattern = Cs((betterbox * whatever^1 + whatever)^1) + + directives.register("graphics.conversion.eps.cleanup.ai",function(v) cleanups.ai = v end) + + cleaners.ai = function(name) + local tmpname = name .. ".tmp" + io.savedata(tmpname,lpegmatch(pattern,io.loaddata(name) or "")) + return tmpname + end + + function epsconverter.pdf(oldname,newname,resolution,colorspace) -- the resolution interface might change + local epstopdf = programs.epstopdf -- can be changed + local presets = epstopdf.resolutions[resolution or "high"] or epstopdf.resolutions.high + local level = codeinjections.getformatoption("pdf_level") or "1.3" + local tmpname = oldname + if not tmpname or tmpname == "" or not lfs.isfile(tmpname) then + return + end + if cleanups.ai then + tmpname = cleaners.ai(oldname) + end + if colorspace == "gray" then + colorspace = "-sColorConversionStrategy=Gray -sProcessColorModel=DeviceGray" + -- colorspace = "-sColorConversionStrategy=Gray" + else + colorspace = nil + end + runprogram(epstopdf.command, epstopdf.argument, { + newname = newname, + oldname = tmpname, + presets = presets, + level = tostring(level), + colorspace = colorspace, + } ) + if tmpname ~= oldname then + os.remove(tmpname) + end + end + + epsconverter["gray.pdf"] = function(oldname,newname,resolution) -- the resolution interface might change + epsconverter.pdf(oldname,newname,resolution,"gray") + end + + epsconverter.default = epsconverter.pdf + +end + +do -- pdf + + local pdfconverter = converters.pdf + + -- 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 level = codeinjections.getformatoption("pdf_level") or "1.3" + -- local tmpname = newname .. ".tmp" + -- runprogram(pdftoeps.command, pdftoeps.argument, { oldname = oldname, newname = tmpname, presets = presets, level = level }) + -- runprogram(epstopdf.command, epstopdf.argument, { oldname = tmpname, newname = newname, presets = presets, level = level }) + -- os.remove(tmpname) + -- end + -- + -- figures.registersuffix("stripped","pdf") + +end + +do -- svg + + local svgconverter = converters.svg + converters.svgz = svgconverter + + -- inkscape on windows only works with complete paths .. did the command line arguments change again? + + programs.inkscape = { + command = "inkscape", + pdfargument = longtostring [[ + "%oldname%" + --export-dpi=600 + -A + --export-pdf="%newname%" + ]], + pngargument = longtostring [[ + "%oldname%" + --export-dpi=600 + --export-png="%newname%" + ]], + } + + function svgconverter.pdf(oldname,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(inkscape.command, inkscape.pngargument, { + newname = expandfilename(newname), + oldname = expandfilename(oldname), + } ) + end + + svgconverter.default = svgconverter.pdf + +end + +do -- gif | tif + + local gifconverter = converters.gif + local tifconverter = converters.tif + local bmpconverter = converters.bmp + + programs.convert = { + command = "gm", -- graphicmagick + argument = [[convert "%oldname%" "%newname%"]], + } + + local function converter(oldname,newname) + local convert = programs.convert + runprogram(convert.command, convert.argument, { + newname = newname, + oldname = oldname, + } ) + end + + tifconverter.pdf = converter + gifconverter.pdf = converter + bmpconverter.pdf = converter + + gifconverter.default = converter + tifconverter.default = converter + bmpconverter.default = converter + +end + +do -- png | jpg | profiles + + -- ecirgb_v2.icc + -- ecirgb_v2_iccv4.icc + -- isocoated_v2_300_eci.icc + -- isocoated_v2_eci.icc + -- srgb.icc + -- srgb_v4_icc_preference.icc + + -- [[convert %?colorspace: -colorspace "%colorspace%" ?%]] + + local rgbprofile = "srgb_v4_icc_preference.icc" -- srgb.icc + local cmykprofile = "isocoated_v2_300_eci.icc" -- isocoated_v2_eci.icc + + directives.register("graphics.conversion.rgbprofile", function(v) rgbprofile = type(v) == "string" and v or rgbprofile end) + directives.register("graphics.conversion.cmykprofile",function(v) cmykprofile = type(v) == "string" and v or cmykprofile end) + + local jpgconverters = converters.jpg + local pngconverters = converters.png + + local function profiles() + if not lfs.isfile(rgbprofile) then + local found = resolvers.findfile(rgbprofile) + if found and found ~= "" then + rgbprofile = found + else + report_figures("unknown profile %a",rgbprofile) + end + end + if not lfs.isfile(cmykprofile) then + local found = resolvers.findfile(cmykprofile) + if found and found ~= "" then + cmykprofile = found + else + report_figures("unknown profile %a",cmykprofile) + end + end + return rgbprofile, cmykprofile + end + + programs.pngtocmykpdf = { + command = "gm", + argument = [[convert -compress Zip -strip +profile "*" -profile "%rgbprofile%" -profile "%cmykprofile%" -sampling-factor 1x1 "%oldname%" "%newname%"]], + } + + programs.jpgtocmykpdf = { + command = "gm", + argument = [[convert -compress JPEG -strip +profile "*" -profile "%rgbprofile%" -profile "%cmykprofile%" -sampling-factor 1x1 "%oldname%" "%newname%"]], + } + + programs.pngtograypdf = { + command = "gm", + argument = [[convert -colorspace gray -compress Zip -sampling-factor 1x1 "%oldname%" "%newname%"]], + } + + programs.jpgtograypdf = { + command = "gm", + argument = [[convert -colorspace gray -compress Zip -sampling-factor 1x1 "%oldname%" "%newname%"]], + } + + pngconverters["cmyk.pdf"] = function(oldname,newname,resolution) + local rgbprofile, cmykprofile = profiles() + runprogram(programs.pngtocmykpdf.command, programs.pngtocmykpdf.argument, { + -- runprogram(programs.pngtocmykpdf, { + rgbprofile = rgbprofile, + cmykprofile = cmykprofile, + oldname = oldname, + newname = newname, + } ) + end + + pngconverters["gray.pdf"] = function(oldname,newname,resolution) + runprogram(programs.pngtograypdf.command, programs.pngtograypdf.argument, { + -- runprogram(programs.pngtograypdf, { + oldname = oldname, + newname = newname, + } ) + end + + jpgconverters["cmyk.pdf"] = function(oldname,newname,resolution) + local rgbprofile, cmykprofile = profiles() + runprogram(programs.jpgtocmykpdf.command, programs.jpgtocmykpdf.argument, { + -- runprogram(programs.jpgtocmykpdf, { + rgbprofile = rgbprofile, + cmykprofile = cmykprofile, + oldname = oldname, + newname = newname, + } ) + end + + jpgconverters["gray.pdf"] = function(oldname,newname,resolution) + runprogram(programs.jpgtograypdf.command, programs.jpgtograypdf.argument, { + -- runprogram(programs.jpgtograypdf, { + oldname = oldname, + newname = newname, + } ) + end + + -- recolor + + programs.recolor = { + command = "gm", + argument = [[convert -recolor "%color%" "%oldname%" "%newname%"]], + } + + pngconverters["recolor.png"] = function(oldname,newname,resolution,arguments) + runprogram ( + programs.recolor.command, + programs.recolor.argument, + { + oldname = oldname, + newname = newname, + color = arguments or ".5 0 0 .7 0 0 .9 0 0", + } + ) + end + +end diff --git a/tex/context/base/mkiv/grph-inc.lua b/tex/context/base/mkiv/grph-inc.lua index 7125edc2e..d4bb4755b 100644 --- a/tex/context/base/mkiv/grph-inc.lua +++ b/tex/context/base/mkiv/grph-inc.lua @@ -40,13 +40,13 @@ run TeX code from within Lua. Some more functionality will move to Lua. -- todo: store loaded pages per pdf file someplace -local format, lower, find, match, gsub, gmatch = string.format, string.lower, string.find, string.match, string.gsub, string.gmatch +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 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, R, S, Cc, C, Cs, Ct, lpegmatch = lpeg.P, lpeg.R, lpeg.S, lpeg.Cc, lpeg.C, lpeg.Cs, lpeg.Ct, lpeg.match @@ -91,19 +91,19 @@ local report_inclusion = logs.reporter("graphics","inclusion") local report_figures = logs.reporter("system","graphics") local report_figure = logs.reporter("used graphic") -local f_hash_part = formatters["%s->%s->%s"] -local f_hash_full = formatters["%s->%s->%s->%s->%s->%s->%s"] +local f_hash_part = formatters["%s->%s->%s->%s"] +local f_hash_full = formatters["%s->%s->%s->%s->%s->%s->%s->%s"] -local v_yes = variables.yes -local v_low = variables.low -local v_medium = variables.medium -local v_high = variables.high -local v_global = variables["global"] -local v_local = variables["local"] -local v_default = variables.default -local v_auto = variables.auto +local v_yes = variables.yes +local v_low = variables.low +local v_medium = variables.medium +local v_high = variables.high +local v_global = variables["global"] +local v_local = variables["local"] +local v_default = variables.default +local v_auto = variables.auto -local maxdimen = 2^30-1 +local maxdimen = 2^30-1 function images.check(figure) if figure then @@ -495,6 +495,8 @@ local function new() -- we could use metatables status -> used -> request but it mask = false, conversion = false, resolution = false, + color = false, + arguments = false, cache = false, prefix = false, size = false, @@ -642,6 +644,14 @@ local function rejected(specification) end end +local function wipe(str) + if str == "" or str == "default" or str == "unknown" then + return nil + else + return str + end +end + local function register(askedname,specification) if not specification then specification = { askedname = askedname, comment = "invalid specification" } @@ -656,24 +666,26 @@ local function register(askedname,specification) elseif not rejected(specification) then local format = specification.format if format then - local conversion = specification.conversion - local resolution = specification.resolution - if conversion == "" then - conversion = nil - end - if resolution == "" then - resolution = nil - end - local newformat = conversion + local conversion = wipe(specification.conversion) + local resolution = wipe(specification.resolution) + local arguments = wipe(specification.arguments) + local newformat = conversion if not newformat or newformat == "" then newformat = defaultformat end if trace_conversion then - report_inclusion("checking conversion of %a, fullname %a, old format %a, new format %a, conversion %a, resolution %a", - askedname,specification.fullname,format,newformat,conversion or "default",resolution or "default") + report_inclusion("checking conversion of %a, fullname %a, old format %a, new format %a, conversion %a, resolution %a, arguments %a", + askedname, + specification.fullname, + format, + newformat, + conversion or "default", + resolution or "default", + arguments or "" + ) end -- quick hack - local converter = (newformat ~= format or resolution) and converters[format] + local converter = (newformat ~= format or resolution or arguments) and converters[format] if converter then if converter[newformat] then converter = converter[newformat] @@ -729,8 +741,15 @@ local function register(askedname,specification) if prefix and prefix ~= "" then newbase = prefix .. newbase end - if resolution and resolution ~= "" then -- the order might change - newbase = newbase .. "_" .. resolution + local hash = "" + if resolution then + hash = hash .. "[r:" .. resolution .. "]" + end + if arguments then + hash = hash .. "[a:" .. arguments .. "]" + end + if hash ~= "" then + newbase = newbase .. "_" .. md5.hex(hash) end -- -- see *, we had: @@ -744,7 +763,6 @@ local function register(askedname,specification) -- sticking around) -- local newbase = newbase .. "." .. newformat - -- local newname = file.join(newpath,newbase) oldname = collapsepath(oldname) newname = collapsepath(newname) @@ -754,7 +772,7 @@ local function register(askedname,specification) if trace_conversion then report_inclusion("converting %a (%a) from %a to %a",askedname,oldname,format,newformat) end - converter(oldname,newname,resolution or "") + converter(oldname,newname,resolution or "", arguments or "") else if trace_conversion then report_inclusion("no need to convert %a (%a) from %a to %a",askedname,oldname,format,newformat) @@ -817,7 +835,12 @@ local function register(askedname,specification) specification.foundname = nil end specification.badname = figures.badname(askedname) - local askedhash = f_hash_part(askedname,specification.conversion or "default",specification.resolution or "default") + local askedhash = f_hash_part( + askedname, + specification.conversion or "default", + specification.resolution or "default", + specification.arguments or "" + ) figures_found[askedhash] = specification return specification end @@ -834,16 +857,22 @@ local internalschemes = { local function locate(request) -- name, format, cache -- not resolvers.cleanpath(request.name) as it fails on a!b.pdf and b~c.pdf -- todo: more restricted cleanpath - local askedname = request.name or "" - local askedhash = f_hash_part(askedname,request.conversion or "default",request.resolution or "default") - local foundname = figures_found[askedhash] + local askedname = request.name or "" + local askedcache = request.cache + local askedconversion = request.conversion + local askedresolution = request.resolution + local askedarguments = request.arguments + local askedhash = f_hash_part( + askedname, + askedconversion or "default", + askedresolution or "default", + askedarguments or "" + ) + local foundname = figures_found[askedhash] if foundname then return foundname end -- - local askedcache = request.cache - local askedconversion = request.conversion - local askedresolution = request.resolution -- local askedformat = request.format if not askedformat or askedformat == "" or askedformat == "unknown" then @@ -892,6 +921,7 @@ local function locate(request) -- name, format, cache cache = askedcache, conversion = askedconversion, resolution = askedresolution, + arguments = askedarguments, }) end end @@ -927,6 +957,7 @@ local function locate(request) -- name, format, cache -- foundname = foundname, -- no conversion = askedconversion, resolution = askedresolution, + arguments = askedarguments, internal = internal, }) elseif quitscanning then @@ -947,6 +978,7 @@ local function locate(request) -- name, format, cache cache = askedcache, conversion = askedconversion, resolution = askedresolution, + arguments = askedarguments, }) end else @@ -965,6 +997,7 @@ local function locate(request) -- name, format, cache cache = askedcache, conversion = askedconversion, resolution = askedresolution, + arguments = askedarguments, }) end end @@ -978,6 +1011,7 @@ local function locate(request) -- name, format, cache cache = askedcache, conversion = askedconversion, resolution = askedresolution, + arguments = askedarguments, }) end end @@ -1001,6 +1035,7 @@ local function locate(request) -- name, format, cache cache = askedcache, conversion = askedconversion, resolution = askedresolution, + arguments = askedarguments, }) end end @@ -1035,6 +1070,7 @@ local function locate(request) -- name, format, cache cache = askedcache, conversion = askedconversion, resolution = askedresolution, + arguments = askedarguments }) end end @@ -1062,6 +1098,7 @@ local function locate(request) -- name, format, cache cache = askedcache, conversion = askedconversion, resolution = askedresolution, + arguments = askedarguments, }) end end @@ -1086,6 +1123,7 @@ local function locate(request) -- name, format, cache cache = askedcache, conversion = askedconversion, resolution = askedresolution, + arguments = askedarguments, }) end end @@ -1095,6 +1133,7 @@ local function locate(request) -- name, format, cache return register(askedname, { -- these two are needed for hashing 'found' conversion = askedconversion, resolution = askedresolution, + arguments = askedarguments, }) end @@ -1246,20 +1285,33 @@ end function checkers.generic(data) local dr, du, ds = data.request, data.used, data.status - local name = du.fullname or "unknown generic" - local page = du.page or dr.page - local size = dr.size or "crop" - local color = dr.color or "natural" - local mask = dr.mask or "none" + local name = du.fullname or "unknown generic" + local page = du.page or dr.page + local size = dr.size or "crop" + local color = dr.color or "natural" + local mask = dr.mask or "none" local conversion = dr.conversion local resolution = dr.resolution + local arguments = dr.arguments if not conversion or conversion == "" then - conversion = "unknown" + conversion = "default" end if not resolution or resolution == "" then - resolution = "unknown" - end - local hash = f_hash_full(name,page,size,color,conversion,resolution,mask) + resolution = "default" + end + if not arguments or arguments == "" then + arguments = "default" + end + local hash = f_hash_full( + name, + page, + size, + color, + mask, + conversion, + resolution, + arguments + ) local figure = figures_loaded[hash] if figure == nil then figure = images.new { @@ -1508,14 +1560,14 @@ includers.cld = includers.nongeneric -- -- -- converters -- -- -- -local function makeoptions(options) +setmetatableindex(converters,"table") + +function programs.makeoptions(options) local to = type(options) return (to == "table" and concat(options," ")) or (to == "string" and options) or "" end --- programs.makeoptions = makeoptions - -local function runprogram(binary,argument,variables) +function programs.run(binary,argument,variables) -- move this check to the runner code local found = nil if type(binary) == "table" then @@ -1551,306 +1603,7 @@ local function runprogram(binary,argument,variables) end end -programs.run = runprogram - --- -- -- eps & pdf -- -- -- --- --- \externalfigure[cow.eps] --- \externalfigure[cow.pdf][conversion=stripped] - -local epsconverter = converters.eps or { } -converters.eps = epsconverter -converters.ps = epsconverter - --- todo: colorspace - -local epstopdf = { - resolutions = { - [v_low] = "screen", - [v_medium] = "ebook", - [v_high] = "prepress", - }, - command = os.type == "windows" and { "gswin64c", "gswin32c" } or "gs", - -- -dProcessDSCComments=false - argument = [[ - -q - -sDEVICE=pdfwrite - -dNOPAUSE - -dNOCACHE - -dBATCH - -dAutoRotatePages=/None - -dPDFSETTINGS=/%presets% - -dEPSCrop - -dCompatibilityLevel=%level% - -sOutputFile="%newname%" - %colorspace% - "%oldname%" - -c quit - ]], -} - -programs.epstopdf = epstopdf -programs.gs = epstopdf - -local cleanups = { } -local cleaners = { } - -local whitespace = lpeg.patterns.whitespace -local quadruple = Ct((whitespace^0 * lpeg.patterns.number/tonumber * whitespace^0)^4) -local betterbox = P("%%BoundingBox:") * quadruple - * P("%%HiResBoundingBox:") * quadruple - * P("%AI3_Cropmarks:") * quadruple - * P("%%CropBox:") * quadruple - / function(b,h,m,c) - return formatters["%%%%BoundingBox: %i %i %i %i\n%%%%HiResBoundingBox: %F %F %F %F\n%%%%CropBox: %F %F %F %F\n"]( - m[1],m[2],m[3],m[4], - m[1],m[2],m[3],m[4], - m[1],m[2],m[3],m[4] - ) - end -local nocrap = P("%") / "" * ( - (P("AI9_PrivateDataBegin") * P(1)^0) / "%%%%EOF" - + (P("%EOF") * whitespace^0 * P("%AI9_PrintingDataEnd") * P(1)^0) / "%%%%EOF" - + (P("AI7_Thumbnail") * (1-P("%%EndData"))^0 * P("%%EndData")) / "" - ) -local whatever = nocrap + P(1) -local pattern = Cs((betterbox * whatever^1 + whatever)^1) - -directives.register("graphics.conversion.eps.cleanup.ai",function(v) cleanups.ai = v end) - -cleaners.ai = function(name) - local tmpname = name .. ".tmp" - io.savedata(tmpname,lpegmatch(pattern,io.loaddata(name) or "")) - return tmpname -end - -function epsconverter.pdf(oldname,newname,resolution,colorspace) -- the resolution interface might change - local epstopdf = programs.epstopdf -- can be changed - local presets = epstopdf.resolutions[resolution or "high"] or epstopdf.resolutions.high - local level = codeinjections.getformatoption("pdf_level") or "1.3" - local tmpname = oldname - if not tmpname or tmpname == "" or not lfs.isfile(tmpname) then - return - end - if cleanups.ai then - tmpname = cleaners.ai(oldname) - end - if colorspace == "gray" then - colorspace = "-sColorConversionStrategy=Gray -sProcessColorModel=DeviceGray" - -- colorspace = "-sColorConversionStrategy=Gray" - else - colorspace = nil - end - runprogram(epstopdf.command, epstopdf.argument, { - newname = newname, - oldname = tmpname, - presets = presets, - level = tostring(level), - colorspace = colorspace, - } ) - if tmpname ~= oldname then - os.remove(tmpname) - end -end - -epsconverter["gray.pdf"] = function(oldname,newname,resolution) -- the resolution interface might change - epsconverter.pdf(oldname,newname,resolution,"gray") -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 level = codeinjections.getformatoption("pdf_level") or "1.3" --- local tmpname = newname .. ".tmp" --- runprogram(pdftoeps.command, pdftoeps.argument, { oldname = oldname, newname = tmpname, presets = presets, level = level }) --- runprogram(epstopdf.command, epstopdf.argument, { oldname = tmpname, newname = newname, presets = presets, level = level }) --- os.remove(tmpname) --- end --- --- figures.registersuffix("stripped","pdf") - --- -- -- svg -- -- -- - -local svgconverter = { } -converters.svg = svgconverter -converters.svgz = svgconverter - --- inkscape on windows only works with complete paths .. did the command line arguments change again? - -programs.inkscape = { - command = "inkscape", - pdfargument = [[ - "%oldname%" - --export-dpi=600 - -A - --export-pdf="%newname%" - ]], - pngargument = [[ - "%oldname%" - --export-dpi=600 - --export-png="%newname%" - ]], -} - -function svgconverter.pdf(oldname,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(inkscape.command, inkscape.pngargument, { - newname = expandfilename(newname), - oldname = expandfilename(oldname), - } ) -end - -svgconverter.default = svgconverter.pdf - --- -- -- gif -- -- -- --- -- -- tif -- -- -- - -local gifconverter = converters.gif or { } -local tifconverter = converters.tif or { } -local bmpconverter = converters.bmp or { } - -converters.gif = gifconverter -converters.tif = tifconverter -converters.bmp = bmpconverter - -programs.convert = { - command = "gm", -- graphicmagick - argument = [[convert "%oldname%" "%newname%"]], -} - -local function converter(oldname,newname) - local convert = programs.convert - runprogram(convert.command, convert.argument, { - newname = newname, - oldname = oldname, - } ) -end - -tifconverter.pdf = converter -gifconverter.pdf = converter -bmpconverter.pdf = converter - -gifconverter.default = converter -tifconverter.default = converter -bmpconverter.default = converter - --- todo: lowres - --- cmyk conversion - --- ecirgb_v2.icc --- ecirgb_v2_iccv4.icc --- isocoated_v2_300_eci.icc --- isocoated_v2_eci.icc --- srgb.icc --- srgb_v4_icc_preference.icc - --- [[convert %?colorspace: -colorspace "%colorspace%" ?%]] - -local rgbprofile = "srgb_v4_icc_preference.icc" -- srgb.icc -local cmykprofile = "isocoated_v2_300_eci.icc" -- isocoated_v2_eci.icc - -directives.register("graphics.conversion.rgbprofile", function(v) rgbprofile = type(v) == "string" and v or rgbprofile end) -directives.register("graphics.conversion.cmykprofile",function(v) cmykprofile = type(v) == "string" and v or cmykprofile end) - -local function profiles() - if not lfs.isfile(rgbprofile) then - local found = resolvers.findfile(rgbprofile) - if found and found ~= "" then - rgbprofile = found - else - report_figures("unknown profile %a",rgbprofile) - end - end - if not lfs.isfile(cmykprofile) then - local found = resolvers.findfile(cmykprofile) - if found and found ~= "" then - cmykprofile = found - else - report_figures("unknown profile %a",cmykprofile) - end - end - return rgbprofile, cmykprofile -end - -programs.pngtocmykpdf = { - command = "gm", - argument = [[convert -compress Zip -strip +profile "*" -profile "%rgbprofile%" -profile "%cmykprofile%" -sampling-factor 1x1 "%oldname%" "%newname%"]], -} - -programs.jpgtocmykpdf = { - command = "gm", - argument = [[convert -compress JPEG -strip +profile "*" -profile "%rgbprofile%" -profile "%cmykprofile%" -sampling-factor 1x1 "%oldname%" "%newname%"]], -} - -programs.pngtograypdf = { - command = "gm", - argument = [[convert -colorspace gray -compress Zip -sampling-factor 1x1 "%oldname%" "%newname%"]], -} - -programs.jpgtograypdf = { - command = "gm", - argument = [[convert -colorspace gray -compress Zip -sampling-factor 1x1 "%oldname%" "%newname%"]], -} - -figures.converters.png = { - ["cmyk.pdf"] = function(oldname,newname,resolution) - local rgbprofile, cmykprofile = profiles() - runprogram(programs.pngtocmykpdf.command, programs.pngtocmykpdf.argument, { - -- runprogram(programs.pngtocmykpdf, { - rgbprofile = rgbprofile, - cmykprofile = cmykprofile, - oldname = oldname, - newname = newname, - } ) - end, - ["gray.pdf"] = function(oldname,newname,resolution) - runprogram(programs.pngtograypdf.command, programs.pngtograypdf.argument, { - -- runprogram(programs.pngtograypdf, { - oldname = oldname, - newname = newname, - } ) - end, -} - -figures.converters.jpg = { - ["cmyk.pdf"] = function(oldname,newname,resolution) - local rgbprofile, cmykprofile = profiles() - runprogram(programs.jpgtocmykpdf.command, programs.jpgtocmykpdf.argument, { - -- runprogram(programs.jpgtocmykpdf, { - rgbprofile = rgbprofile, - cmykprofile = cmykprofile, - oldname = oldname, - newname = newname, - } ) - end, - ["gray.pdf"] = function(oldname,newname,resolution) - runprogram(programs.jpgtograypdf.command, programs.jpgtograypdf.argument, { - -- runprogram(programs.jpgtograypdf, { - oldname = oldname, - newname = newname, - } ) - end, -} +-- the rest of the code has been moved to grph-con.lua -- -- -- bases -- -- -- @@ -2072,6 +1825,7 @@ implement { { "conversion" }, { "resolution" }, { "color" }, + { "arguments" }, { "repeat" }, { "width", "dimen" }, { "height", "dimen" }, diff --git a/tex/context/base/mkiv/grph-inc.mkiv b/tex/context/base/mkiv/grph-inc.mkiv index 8b581589e..94682b65f 100644 --- a/tex/context/base/mkiv/grph-inc.mkiv +++ b/tex/context/base/mkiv/grph-inc.mkiv @@ -21,6 +21,7 @@ \writestatus{loading}{ConTeXt Graphic Macros / Figure Inclusion} \registerctxluafile{grph-inc}{1.001} +\registerctxluafile{grph-con}{1.001} \registerctxluafile{grph-fil}{1.001} \registerctxluafile{grph-mem}{1.001} \registerctxluafile{grph-u3d}{1.001} % this will change @@ -60,6 +61,7 @@ \c!preset =\v!yes, \c!split =, \c!color =, + \c!arguments =, \c!symbol =\v!no, \c!controls =\v!no, \c!resources =, @@ -330,7 +332,8 @@ mask {\externalfigureparameter\c!mask}% conversion {\externalfigureparameter\c!conversion}% resolution {\externalfigureparameter\c!resolution}% - color {\internalspotcolorparent{\externalfigureparameter\c!color}}% hack is needed + color {\externalfigureparameter\c!color}% unprocessed raw key + arguments {\externalfigureparameter\c!arguments}% used for converters repeat {\externalfigureparameter\c!repeat}% \ifx\p_width\empty \else width \dimexpr\p_width\relax @@ -528,6 +531,9 @@ \def\figurefilepage {\clf_figurerequest{page}{1}} \def\figurefileoptions {\clf_figurerequest{options}{}} \def\figurefileconversion{\clf_figurerequest{conversion}{}} +\def\figurefileresolution{\clf_figurerequest{resolution}{}} +\def\figurefilecolor {\clf_figurerequest{color}{}} +\def\figurefilearguments {\clf_figurerequest{arguments}{}} \def\figurefilecache {\clf_figurerequest{cache}{}} \def\figurefileprefix {\clf_figurerequest{prefix}{}} diff --git a/tex/context/base/mkiv/lpdf-col.lua b/tex/context/base/mkiv/lpdf-col.lua index 5075ecd48..15d21cbf3 100644 --- a/tex/context/base/mkiv/lpdf-col.lua +++ b/tex/context/base/mkiv/lpdf-col.lua @@ -8,6 +8,7 @@ if not modules then modules = { } end modules ['lpdf-col'] = { local type, next, tostring, tonumber = type, next, tostring, tonumber local char, byte, format, gsub, rep, gmatch = string.char, string.byte, string.format, string.gsub, string.rep, string.gmatch +local settings_to_array, settings_to_numbers = utilities.parsers.settings_to_array, utilities.parsers.settings_to_numbers local concat = table.concat local round = math.round local formatters = string.formatters @@ -166,9 +167,9 @@ local pdf_device_cmyk = pdfconstant("DeviceCMYK") local pdf_device_gray = pdfconstant("DeviceGray") local pdf_extgstate = pdfconstant("ExtGState") -local pdf_rbg_range = pdfarray { 0, 1, 0, 1, 0, 1 } -local pdf_cmyk_range = pdfarray { 0, 1, 0, 1, 0, 1, 0, 1 } -local pdf_gray_range = pdfarray { 0, 1 } +local pdf_rgb_range = pdfarray { 0, 1, 0, 1, 0, 1 } +local pdf_cmyk_range = pdfarray { 0, 1, 0, 1, 0, 1, 0, 1 } +local pdf_gray_range = pdfarray { 0, 1 } local f_rgb_function = formatters["dup %s mul exch dup %s mul exch %s mul"] local f_cmyk_function = formatters["dup %s mul exch dup %s mul exch dup %s mul exch %s mul"] @@ -304,13 +305,15 @@ local function registersomeindexcolor(name,noffractions,names,p,colorspace,range noffractions = tonumber(noffractions) or 1 -- to be checked local cnames = pdfarray() local domain = pdfarray() - if names == "" then - names = name .. ",None" - else - names = names .. ",None" - end - for n in gmatch(names,"[^,]+") do - cnames[#cnames+1] = pdfconstant(spotcolornames[n] or n) + local names = settings_to_array(#names == 0 and name or names) + local values = settings_to_numbers(p) + names [#names +1] = "None" + values[#values+1] = 1 + -- check for #names == #values + for i=1,#names do + local name = names[i] + local spot = spotcolornames[name] + cnames[#cnames+1] = pdfconstant(spot ~= "" and spot or name) domain[#domain+1] = 0 domain[#domain+1] = 1 end @@ -326,19 +329,10 @@ local function registersomeindexcolor(name,noffractions,names,p,colorspace,range colorspace, pdfreference(n), } - if p == "" then - p = "1" - else - p = p .. ",1" - end - local pi = { } - for pp in gmatch(p,"[^,]+") do - pi[#pi+1] = tonumber(pp) - end - local vector, set, n = { }, { }, #pi + local vector, set, n = { }, { }, #values for i=255,0,-1 do for j=1,n do - set[j] = format("%02X",round(pi[j]*i)) + set[j] = format("%02X",round(values[j]*i)) end vector[#vector+1] = concat(set) end @@ -356,21 +350,24 @@ local function delayindexcolor(name,names,func) end local function indexcolorref(name) -- actually, names (parent) is the hash - if not indexcolorhash[name] then - local delayedindexcolor = delayedindexcolors[name] + local parent = colors.spotcolorparent(name) + local data = indexcolorhash[name] + if data == nil then + local delayedindexcolor = delayedindexcolors[parent] if type(delayedindexcolor) == "function" then - indexcolorhash[name] = delayedindexcolor() - delayedindexcolors[name] = true + data = delayedindexcolor() + delayedindexcolors[parent] = true end + indexcolorhash[parent] = data or false end - return indexcolorhash[name] + return data end function registrations.rgbspotcolor(name,noffractions,names,p,r,g,b) if noffractions == 1 then - registersomespotcolor(name,noffractions,names,p,pdf_device_rgb,pdf_rbg_range,f_rgb_function(r,g,b)) + registersomespotcolor(name,noffractions,names,p,pdf_device_rgb,pdf_rgb_range,f_rgb_function(r,g,b)) else - registersomespotcolor(name,noffractions,names,p,pdf_device_rgb,pdf_rbg_range,f_num_3(r,g,b)) + registersomespotcolor(name,noffractions,names,p,pdf_device_rgb,pdf_rgb_range,f_num_3(r,g,b)) end delayindexcolor(name,names,function() return registersomeindexcolor(name,noffractions,names,p,pdf_device_rgb,pdf_rgb_range,f_rgb_function(r,g,b)) @@ -413,7 +410,7 @@ end function codeinjections.setfigurecolorspace(data,figure) local color = data.request.color - if color then + if color then -- != v_default local ref = indexcolorref(color) if ref then figure.colorspace = ref diff --git a/tex/context/base/mkiv/lpdf-grp.lua b/tex/context/base/mkiv/lpdf-grp.lua index 3ec260ff5..e3826faeb 100644 --- a/tex/context/base/mkiv/lpdf-grp.lua +++ b/tex/context/base/mkiv/lpdf-grp.lua @@ -35,32 +35,15 @@ local pdfflushobject = lpdf.flushobject -- 22 : << /Bounds [ ] /Domain [ 0.0 1.0 ] /Encode [ 0.0 1.0 ] /FunctionType 3 /Functions [ 31 0 R ] >> -- 31 : << /C0 [ 1.0 0.0 ] /C1 [ 0.0 1.0 ] /Domain [ 0.0 1.0 ] /FunctionType 2 /N 1.0 >> -local function shade(stype,name,domain,color_a,color_b,n,colorspace,coordinates,separation,steps) - if steps then - color_a = color_a[1] - color_b = color_b[1] - end - local f = pdfdictionary { - FunctionType = 2, - Domain = pdfarray(domain), -- domain is actually a string - C0 = pdfarray(color_a), - C1 = pdfarray(color_b), - N = tonumber(n), - } - separation = separation and registrations.getspotcolorreference(separation) - local s = pdfdictionary { - ShadingType = stype, - ColorSpace = separation and pdfreference(separation) or pdfconstant(colorspace), - Function = pdfreference(pdfflushobject(f)), - Coords = pdfarray(coordinates), - Extend = pdfarray { true, true }, - AntiAlias = pdfboolean(true), - } - lpdf.adddocumentshade(name,pdfreference(pdfflushobject(s))) -end - local function shade(stype,name,domain,color_a,color_b,n,colorspace,coordinates,separation,steps,fractions) local func = nil + -- + -- domain has to be consistently added in all dictionaries here otherwise + -- acrobat fails with a drawing error + -- + domain = pdfarray(domain) + n = tonumber(n) + -- if steps then local list = pdfarray() local bounds = pdfarray() @@ -71,10 +54,10 @@ local function shade(stype,name,domain,color_a,color_b,n,colorspace,coordinates, encode[2*i] = 1 list [i] = pdfdictionary { FunctionType = 2, - Domain = pdfarray(domain), -- domain is actually a string + Domain = domain, C0 = pdfarray(color_a[i]), C1 = pdfarray(color_b[i]), - N = tonumber(n), + N = n, } end func = pdfdictionary { @@ -82,21 +65,22 @@ local function shade(stype,name,domain,color_a,color_b,n,colorspace,coordinates, Bounds = bounds, Encode = encode, Functions = list, - Domain = pdfarray(domain), -- domain is actually a string + Domain = domain, } else func = pdfdictionary { FunctionType = 2, - Domain = pdfarray(domain), -- domain is actually a string + Domain = domain, C0 = pdfarray(color_a), C1 = pdfarray(color_b), - N = tonumber(n), + N = n, } end separation = separation and registrations.getspotcolorreference(separation) local s = pdfdictionary { ShadingType = stype, ColorSpace = separation and pdfreference(separation) or pdfconstant(colorspace), + Domain = domain, Function = pdfreference(pdfflushobject(func)), Coords = pdfarray(coordinates), Extend = pdfarray { true, true }, diff --git a/tex/context/base/mkiv/mlib-pdf.lua b/tex/context/base/mkiv/mlib-pdf.lua index a2d4638a9..711b860b8 100644 --- a/tex/context/base/mkiv/mlib-pdf.lua +++ b/tex/context/base/mkiv/mlib-pdf.lua @@ -136,15 +136,13 @@ function pdfflusher.comment(message) message = formatters["%% mps graphic %s: %s"](metapost.n,message) if experiment then context(pdfliteral(message)) + elseif savedliterals then + local last = #savedliterals + 1 + savedliterals[last] = message + context.MPLIBtoPDF(last) else - if savedliterals then - local last = #savedliterals + 1 - savedliterals[last] = message - context.MPLIBtoPDF(last) - else - savedliterals = { message } - context.MPLIBtoPDF(1) - end + savedliterals = { message } + context.MPLIBtoPDF(1) end end end @@ -393,6 +391,8 @@ local function setvariables(figure) return variables end +function metapost.comment() end + function metapost.flush(result,flusher,askedfig) if result then local figures = result.fig @@ -408,6 +408,7 @@ function metapost.flush(result,flusher,askedfig) local textfigure = flusher.textfigure local processspecial = flusher.processspecial or metapost.processspecial local variables = setvariables(figure) -- also resets then in case of not found + metapost.comment = flusher.comment for index=1,#figures do local figure = figures[index] local properties = setproperties(figure) @@ -632,6 +633,7 @@ function metapost.flush(result,flusher,askedfig) end end end + function metapost.comment() end end end end diff --git a/tex/context/base/mkiv/mlib-pps.lua b/tex/context/base/mkiv/mlib-pps.lua index b2c6bc785..f72061372 100644 --- a/tex/context/base/mkiv/mlib-pps.lua +++ b/tex/context/base/mkiv/mlib-pps.lua @@ -182,7 +182,7 @@ local function checkandconvert(ca,cb,model) normalize(cb,ca) end if not model then - model = colors.model + model = colors.currentnamedmodel() end if model == "all" then model= (#ca == 4 and "cmyk") or (#ca == 3 and "rgb") or "gray" @@ -460,7 +460,7 @@ setmetatableindex(models, function(t,k) end) local function colorconverter(cs) - -- return models[colors.model](cs) + -- return models[colors.currentmodel()](cs) return models[outercolormodel](cs) end diff --git a/tex/context/base/mkiv/mult-def.lua b/tex/context/base/mkiv/mult-def.lua index da982d949..97b7a2cff 100644 --- a/tex/context/base/mkiv/mult-def.lua +++ b/tex/context/base/mkiv/mult-def.lua @@ -6591,6 +6591,10 @@ return { ["pe"]="apa", ["ro"]="apa", }, + ["arguments"]={ + ["en"]="arguments", + ["nl"]="argumenten", + }, ["arrow"]={ ["cs"]="sipka", ["de"]="pfeil", diff --git a/tex/context/base/mkiv/page-sel.mkvi b/tex/context/base/mkiv/page-sel.mkvi index b6bb3174d..335d01187 100644 --- a/tex/context/base/mkiv/page-sel.mkvi +++ b/tex/context/base/mkiv/page-sel.mkvi @@ -67,7 +67,11 @@ {\bgroup \dontcomplain \getfiguredimensions[#filename]% - \setupcurrentwithpages[\c!width=\zeropoint,\c!n=\noffigurepages,#settings]% + \setupcurrentwithpages + [\c!width=\zeropoint,% + \c!n=\noffigurepages,% + \c!category=,% + #settings]% \global\c_page_selectors_n\directwithpagesparameter\c!n\relax \scratchwidth\directwithpagesparameter\c!width\relax \doifinset0{#emptylist} @@ -85,7 +89,11 @@ {\bgroup \dontcomplain \getfiguredimensions[#filename]% - \setupcurrentwithpages[\c!width=\zeropoint,\c!n=\noffigurepages,#settings]% + \setupcurrentwithpages + [\c!width=\zeropoint,% + \c!n=\noffigurepages,% + \c!category=,% + #settings]% \global\c_page_selectors_n\directwithpagesparameter\c!n\relax \scratchwidth\directwithpagesparameter\c!width\relax \edef\p_selection{#selection}% @@ -134,7 +142,12 @@ \def\page_selectors_copy[#filename][#settings][#figuresettings]% {\bgroup \getfiguredimensions[#filename]% - \setupcurrentwithpages[\c!marking=\v!off,\c!offset=\zeropoint,\c!n=\noffigurepages,#settings]% + \setupcurrentwithpages + [\c!marking=\v!off,% + \c!offset=\zeropoint,% + \c!n=\noffigurepages,% + \c!category=,% + #settings]% \global\c_page_selectors_n\directwithpagesparameter\c!n\relax \scratchoffset\directwithpagesparameter\c!offset\relax \dorecurse\c_page_selectors_n @@ -196,6 +209,7 @@ \c!before=\page,\c!after=\page,\c!inbetween=\blank, \c!frame=,\c!background=,\c!backgroundcolor=, \c!name={#filename}, + \c!category=, #settings]% \global\c_page_selectors_n\directwithpagesparameter\c!n\relax \directwithpagesparameter\c!before @@ -331,8 +345,14 @@ \global\let\slicedpagenumber\!!zerocount \getfiguredimensions[#filename]% \setupcurrentwithpages - [\c!offset=\zeropoint,\c!hoffset=\zeropoint,\c!voffset=\zeropoint, - \c!width=\figurewidth,\c!height=\figureheight,\c!n=\noffigurepages,#oddsettings]% + [\c!offset=\zeropoint,% + \c!hoffset=\zeropoint,% + \c!voffset=\zeropoint, + \c!width=\figurewidth,% + \c!height=\figureheight,% + \c!n=\noffigurepages,% + \c!category=,% + #oddsettings]% \global\c_page_selectors_n\directwithpagesparameter\c!n\relax \ifnum\c_page_selectors_n>\zerocount \definepapersize diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf Binary files differindex 9db31798c..eba625374 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 67b67bce8..a07a2be00 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-mat.mkiv b/tex/context/base/mkiv/strc-mat.mkiv index dd747c6ea..54bf7d225 100644 --- a/tex/context/base/mkiv/strc-mat.mkiv +++ b/tex/context/base/mkiv/strc-mat.mkiv @@ -659,6 +659,9 @@ \directvspacing\p_spaceafter \fi\fi} +% \newtoks\everybeforedisplay +% \appendtoks\page_sides_check_floats_indeed\to\everybeforedisplay + \unexpanded\def\beforedisplayspace {\ifhmode \par @@ -669,7 +672,8 @@ \fi \ifhmode \par - \fi} + \fi + \page_sides_check_floats_indeed} % probably needs more \unexpanded\def\afterdisplayspace {\ifhmode diff --git a/tex/context/base/mkiv/util-prs.lua b/tex/context/base/mkiv/util-prs.lua index 82789ba3a..650a7ead6 100644 --- a/tex/context/base/mkiv/util-prs.lua +++ b/tex/context/base/mkiv/util-prs.lua @@ -193,6 +193,23 @@ function parsers.settings_to_array(str,strict) end end +function parsers.settings_to_numbers(str) + if not str or str == "" then + return { } + end + if type(str) == "table" then + -- fall through + elseif find(str,",",1,true) then + str = lpegmatch(pattern,str) + else + return { tonumber(str) } + end + for i=1,#str do + str[i] = tonumber(str[i]) + end + return str +end + local value = P(lbrace * C((nobrace + nestedbraces)^0) * rbrace) + C((nestedbraces + nestedbrackets + nestedparents + (1-comma))^0) local pattern = spaces * Ct(value*(separator*value)^0) diff --git a/tex/context/interface/mkii/keys-cs.xml b/tex/context/interface/mkii/keys-cs.xml index 473756022..b69905b97 100644 --- a/tex/context/interface/mkii/keys-cs.xml +++ b/tex/context/interface/mkii/keys-cs.xml @@ -628,6 +628,7 @@ <cd:constant name='anchor' value='anchor'/> <cd:constant name='andtext' value='andtext'/> <cd:constant name='apa' value='apa'/> + <cd:constant name='arguments' value='arguments'/> <cd:constant name='arrow' value='sipka'/> <cd:constant name='artauthor' value='artauthor'/> <cd:constant name='artauthoretaldisplay' value='artauthoretaldisplay'/> diff --git a/tex/context/interface/mkii/keys-de.xml b/tex/context/interface/mkii/keys-de.xml index bef6a9b73..32f8ded67 100644 --- a/tex/context/interface/mkii/keys-de.xml +++ b/tex/context/interface/mkii/keys-de.xml @@ -628,6 +628,7 @@ <cd:constant name='anchor' value='anchor'/> <cd:constant name='andtext' value='andtext'/> <cd:constant name='apa' value='apa'/> + <cd:constant name='arguments' value='arguments'/> <cd:constant name='arrow' value='pfeil'/> <cd:constant name='artauthor' value='artauthor'/> <cd:constant name='artauthoretaldisplay' value='artauthoretaldisplay'/> diff --git a/tex/context/interface/mkii/keys-en.xml b/tex/context/interface/mkii/keys-en.xml index 599609f29..94a77a6d4 100644 --- a/tex/context/interface/mkii/keys-en.xml +++ b/tex/context/interface/mkii/keys-en.xml @@ -628,6 +628,7 @@ <cd:constant name='anchor' value='anchor'/> <cd:constant name='andtext' value='andtext'/> <cd:constant name='apa' value='apa'/> + <cd:constant name='arguments' value='arguments'/> <cd:constant name='arrow' value='arrow'/> <cd:constant name='artauthor' value='artauthor'/> <cd:constant name='artauthoretaldisplay' value='artauthoretaldisplay'/> diff --git a/tex/context/interface/mkii/keys-fr.xml b/tex/context/interface/mkii/keys-fr.xml index 7f7f99094..5df08a40b 100644 --- a/tex/context/interface/mkii/keys-fr.xml +++ b/tex/context/interface/mkii/keys-fr.xml @@ -628,6 +628,7 @@ <cd:constant name='anchor' value='anchor'/> <cd:constant name='andtext' value='andtext'/> <cd:constant name='apa' value='apa'/> + <cd:constant name='arguments' value='arguments'/> <cd:constant name='arrow' value='fleche'/> <cd:constant name='artauthor' value='artauthor'/> <cd:constant name='artauthoretaldisplay' value='artauthoretaldisplay'/> diff --git a/tex/context/interface/mkii/keys-it.xml b/tex/context/interface/mkii/keys-it.xml index 7f917eb8e..ddeb35689 100644 --- a/tex/context/interface/mkii/keys-it.xml +++ b/tex/context/interface/mkii/keys-it.xml @@ -628,6 +628,7 @@ <cd:constant name='anchor' value='anchor'/> <cd:constant name='andtext' value='andtext'/> <cd:constant name='apa' value='apa'/> + <cd:constant name='arguments' value='arguments'/> <cd:constant name='arrow' value='freccia'/> <cd:constant name='artauthor' value='artauthor'/> <cd:constant name='artauthoretaldisplay' value='artauthoretaldisplay'/> diff --git a/tex/context/interface/mkii/keys-nl.xml b/tex/context/interface/mkii/keys-nl.xml index 33fe35c39..7e8bd0d4a 100644 --- a/tex/context/interface/mkii/keys-nl.xml +++ b/tex/context/interface/mkii/keys-nl.xml @@ -628,6 +628,7 @@ <cd:constant name='anchor' value='anker'/> <cd:constant name='andtext' value='andtext'/> <cd:constant name='apa' value='apa'/> + <cd:constant name='arguments' value='argumenten'/> <cd:constant name='arrow' value='pijl'/> <cd:constant name='artauthor' value='artauthor'/> <cd:constant name='artauthoretaldisplay' value='artauthoretaldisplay'/> diff --git a/tex/context/interface/mkii/keys-pe.xml b/tex/context/interface/mkii/keys-pe.xml index 522778150..ec216beae 100644 --- a/tex/context/interface/mkii/keys-pe.xml +++ b/tex/context/interface/mkii/keys-pe.xml @@ -628,6 +628,7 @@ <cd:constant name='anchor' value='anchor'/> <cd:constant name='andtext' value='andtext'/> <cd:constant name='apa' value='apa'/> + <cd:constant name='arguments' value='arguments'/> <cd:constant name='arrow' value='پیکان'/> <cd:constant name='artauthor' value='artauthor'/> <cd:constant name='artauthoretaldisplay' value='artauthoretaldisplay'/> diff --git a/tex/context/interface/mkii/keys-ro.xml b/tex/context/interface/mkii/keys-ro.xml index 9011c24d6..bad10a1a2 100644 --- a/tex/context/interface/mkii/keys-ro.xml +++ b/tex/context/interface/mkii/keys-ro.xml @@ -628,6 +628,7 @@ <cd:constant name='anchor' value='anchor'/> <cd:constant name='andtext' value='andtext'/> <cd:constant name='apa' value='apa'/> + <cd:constant name='arguments' value='arguments'/> <cd:constant name='arrow' value='sageata'/> <cd:constant name='artauthor' value='artauthor'/> <cd:constant name='artauthoretaldisplay' value='artauthoretaldisplay'/> diff --git a/tex/context/interface/mkiv/i-color.xml b/tex/context/interface/mkiv/i-color.xml index 3f98914e4..157f56ea2 100644 --- a/tex/context/interface/mkiv/i-color.xml +++ b/tex/context/interface/mkiv/i-color.xml @@ -385,7 +385,7 @@ </cd:arguments> </cd:command> - <cd:command name="setcolormodell" file="colo-ini.mkiv"> + <cd:command name="setcolormodel" file="colo-ini.mkiv"> <cd:arguments> <cd:keywords> <cd:constant type="black"/> @@ -594,4 +594,4 @@ </cd:arguments> </cd:command> -</cd:interface>
\ No newline at end of file +</cd:interface> diff --git a/tex/context/interface/mkiv/i-context.pdf b/tex/context/interface/mkiv/i-context.pdf Binary files differindex 0bf50a849..7b504b1e4 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-graphics.xml b/tex/context/interface/mkiv/i-graphics.xml index 4e90a0c81..c2b339eb0 100644 --- a/tex/context/interface/mkiv/i-graphics.xml +++ b/tex/context/interface/mkiv/i-graphics.xml @@ -85,6 +85,9 @@ <cd:parameter name="color"> <cd:constant type="cd:color"/> </cd:parameter> + <cd:parameter name="arguments"> + <cd:constant type="cd:string"/> + </cd:parameter> <cd:parameter name="repeat"> <cd:constant type="yes"/> <cd:constant type="no" default="yes"/> diff --git a/tex/context/interface/mkiv/i-readme.pdf b/tex/context/interface/mkiv/i-readme.pdf Binary files differindex 31661e08a..5e84ca3a2 100644 --- a/tex/context/interface/mkiv/i-readme.pdf +++ b/tex/context/interface/mkiv/i-readme.pdf diff --git a/tex/context/modules/mkiv/x-setups-basics.mkiv b/tex/context/modules/mkiv/x-setups-basics.mkiv index 9faf3f79c..b1555f039 100644 --- a/tex/context/modules/mkiv/x-setups-basics.mkiv +++ b/tex/context/modules/mkiv/x-setups-basics.mkiv @@ -297,6 +297,8 @@ \let \m_cmd_current_hash \empty \let \m_cmd_current_file \empty +% todo: use different names (and a backward compatible extra module then) + \unexpanded\def\basicsetup{\c_cmd_kind\zerocount\cmd_show_setup} \unexpanded\def\shortsetup{\c_cmd_kind\plusone \cmd_show_setup} \unexpanded\def\setup {\c_cmd_kind\plustwo \cmd_show_setup} diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 206d6251b..e6738ea9e 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 : 07/12/16 10:14:22 +-- merge date : 07/13/16 15:09:54 do -- begin closure to overcome local limits and interference |