From 64f50a1d7fe79d365b350c1bae688b9bf1b44d34 Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Thu, 10 Oct 2019 15:29:49 +0200 Subject: 2019-10-10 14:28:00 --- doc/context/documents/general/qrcs/setup-cs.pdf | Bin 887686 -> 887577 bytes doc/context/documents/general/qrcs/setup-de.pdf | Bin 889119 -> 889283 bytes doc/context/documents/general/qrcs/setup-en.pdf | Bin 893159 -> 893663 bytes doc/context/documents/general/qrcs/setup-fr.pdf | Bin 885478 -> 885333 bytes doc/context/documents/general/qrcs/setup-it.pdf | Bin 891076 -> 891084 bytes .../documents/general/qrcs/setup-mapping-cs.pdf | Bin 383599 -> 383439 bytes .../documents/general/qrcs/setup-mapping-de.pdf | Bin 383769 -> 383705 bytes .../documents/general/qrcs/setup-mapping-en.pdf | Bin 380224 -> 380582 bytes .../documents/general/qrcs/setup-mapping-fr.pdf | Bin 383743 -> 383911 bytes .../documents/general/qrcs/setup-mapping-it.pdf | Bin 383213 -> 383097 bytes .../documents/general/qrcs/setup-mapping-nl.pdf | Bin 381888 -> 382013 bytes .../documents/general/qrcs/setup-mapping-ro.pdf | Bin 620177 -> 620242 bytes doc/context/documents/general/qrcs/setup-nl.pdf | Bin 880835 -> 880864 bytes doc/context/documents/general/qrcs/setup-ro.pdf | Bin 885408 -> 885482 bytes .../manuals/luatex/luatex-modifications.tex | 9 ++ metapost/context/base/mpiv/mp-lmtx.mpxl | 10 +++ scripts/context/lua/mtx-fonts.lua | 24 ++++- tex/context/base/mkii/cont-new.mkii | 2 +- tex/context/base/mkii/context.mkii | 2 +- tex/context/base/mkiv/cldf-ini.lua | 45 +++++++--- tex/context/base/mkiv/cont-new.mkiv | 2 +- tex/context/base/mkiv/context.mkiv | 2 +- tex/context/base/mkiv/context.mkxl | 2 +- tex/context/base/mkiv/font-mis.lua | 55 ++++++------ tex/context/base/mkiv/font-ocl.lua | 83 ++++++++++++----- tex/context/base/mkiv/font-ogr.lua | 98 ++++++++++++++++----- tex/context/base/mkiv/font-pre.mkiv | 8 +- tex/context/base/mkiv/grph-inc.lua | 6 ++ tex/context/base/mkiv/grph-inc.mkiv | 2 + tex/context/base/mkiv/lpdf-emb.lua | 44 ++++++--- tex/context/base/mkiv/lpdf-img.lua | 68 ++++++++++++-- tex/context/base/mkiv/mlib-svg.lua | 11 ++- tex/context/base/mkiv/status-files.pdf | Bin 26651 -> 26669 bytes tex/context/base/mkiv/status-lua.pdf | Bin 267548 -> 268380 bytes tex/context/base/mkiv/syst-ini.mkiv | 6 ++ tex/context/interface/mkiv/i-context.pdf | Bin 893159 -> 893663 bytes tex/context/interface/mkiv/i-readme.pdf | Bin 61165 -> 61165 bytes tex/generic/context/luatex/luatex-fonts-merged.lua | 55 +++++++----- 38 files changed, 395 insertions(+), 139 deletions(-) diff --git a/doc/context/documents/general/qrcs/setup-cs.pdf b/doc/context/documents/general/qrcs/setup-cs.pdf index ea56afc81..d42be54c1 100644 Binary files a/doc/context/documents/general/qrcs/setup-cs.pdf and b/doc/context/documents/general/qrcs/setup-cs.pdf differ diff --git a/doc/context/documents/general/qrcs/setup-de.pdf b/doc/context/documents/general/qrcs/setup-de.pdf index 3290856a1..22699768e 100644 Binary files a/doc/context/documents/general/qrcs/setup-de.pdf and b/doc/context/documents/general/qrcs/setup-de.pdf differ diff --git a/doc/context/documents/general/qrcs/setup-en.pdf b/doc/context/documents/general/qrcs/setup-en.pdf index 344bcbcc1..6bb755770 100644 Binary files a/doc/context/documents/general/qrcs/setup-en.pdf and b/doc/context/documents/general/qrcs/setup-en.pdf differ diff --git a/doc/context/documents/general/qrcs/setup-fr.pdf b/doc/context/documents/general/qrcs/setup-fr.pdf index be66092a9..fe06cd4a4 100644 Binary files a/doc/context/documents/general/qrcs/setup-fr.pdf and b/doc/context/documents/general/qrcs/setup-fr.pdf differ diff --git a/doc/context/documents/general/qrcs/setup-it.pdf b/doc/context/documents/general/qrcs/setup-it.pdf index 110f4b6d6..664ae4688 100644 Binary files a/doc/context/documents/general/qrcs/setup-it.pdf and b/doc/context/documents/general/qrcs/setup-it.pdf differ diff --git a/doc/context/documents/general/qrcs/setup-mapping-cs.pdf b/doc/context/documents/general/qrcs/setup-mapping-cs.pdf index c0533f38f..951fe6e7f 100644 Binary files a/doc/context/documents/general/qrcs/setup-mapping-cs.pdf and b/doc/context/documents/general/qrcs/setup-mapping-cs.pdf differ diff --git a/doc/context/documents/general/qrcs/setup-mapping-de.pdf b/doc/context/documents/general/qrcs/setup-mapping-de.pdf index 537866653..c4101e667 100644 Binary files a/doc/context/documents/general/qrcs/setup-mapping-de.pdf and b/doc/context/documents/general/qrcs/setup-mapping-de.pdf differ diff --git a/doc/context/documents/general/qrcs/setup-mapping-en.pdf b/doc/context/documents/general/qrcs/setup-mapping-en.pdf index c6f0572cc..8570b9366 100644 Binary files a/doc/context/documents/general/qrcs/setup-mapping-en.pdf and b/doc/context/documents/general/qrcs/setup-mapping-en.pdf differ diff --git a/doc/context/documents/general/qrcs/setup-mapping-fr.pdf b/doc/context/documents/general/qrcs/setup-mapping-fr.pdf index a544f624c..b956246ec 100644 Binary files a/doc/context/documents/general/qrcs/setup-mapping-fr.pdf and b/doc/context/documents/general/qrcs/setup-mapping-fr.pdf differ diff --git a/doc/context/documents/general/qrcs/setup-mapping-it.pdf b/doc/context/documents/general/qrcs/setup-mapping-it.pdf index f630c517a..be2e96fb0 100644 Binary files a/doc/context/documents/general/qrcs/setup-mapping-it.pdf and b/doc/context/documents/general/qrcs/setup-mapping-it.pdf differ diff --git a/doc/context/documents/general/qrcs/setup-mapping-nl.pdf b/doc/context/documents/general/qrcs/setup-mapping-nl.pdf index 235f59bb8..7d0b99cbe 100644 Binary files a/doc/context/documents/general/qrcs/setup-mapping-nl.pdf and b/doc/context/documents/general/qrcs/setup-mapping-nl.pdf differ diff --git a/doc/context/documents/general/qrcs/setup-mapping-ro.pdf b/doc/context/documents/general/qrcs/setup-mapping-ro.pdf index 8b40e9d66..072836908 100644 Binary files a/doc/context/documents/general/qrcs/setup-mapping-ro.pdf and b/doc/context/documents/general/qrcs/setup-mapping-ro.pdf differ diff --git a/doc/context/documents/general/qrcs/setup-nl.pdf b/doc/context/documents/general/qrcs/setup-nl.pdf index fcb207a26..028390a8b 100644 Binary files a/doc/context/documents/general/qrcs/setup-nl.pdf and b/doc/context/documents/general/qrcs/setup-nl.pdf differ diff --git a/doc/context/documents/general/qrcs/setup-ro.pdf b/doc/context/documents/general/qrcs/setup-ro.pdf index a9228f210..faca57f72 100644 Binary files a/doc/context/documents/general/qrcs/setup-ro.pdf and b/doc/context/documents/general/qrcs/setup-ro.pdf differ diff --git a/doc/context/sources/general/manuals/luatex/luatex-modifications.tex b/doc/context/sources/general/manuals/luatex/luatex-modifications.tex index 50d23fb1b..b7ce6ca2b 100644 --- a/doc/context/sources/general/manuals/luatex/luatex-modifications.tex +++ b/doc/context/sources/general/manuals/luatex/luatex-modifications.tex @@ -128,6 +128,15 @@ functionality, but with a few small adaptations. (\LUATEX\ uses the variable \type {OVFFONTS} instead of \type {VFFONTS}). \stopitem +\startitem + The primitives that report a stretch or shrink order report a value in a + convenient range zero upto four. Because some macro packages can break on + that we also provide \type {\eTeXgluestretchorder} and \type + {\eTeXglueshrinkorder} which report values compatible with \ETEX. The (new) + \type {fi} value is reported as \type {-1} (so when used in an \type + {\ifcase} test that value makes one end up in the \type {\else}). +\stopitem + \stopitemize \stopsubsection diff --git a/metapost/context/base/mpiv/mp-lmtx.mpxl b/metapost/context/base/mpiv/mp-lmtx.mpxl index bc658a7b2..b618ea4b5 100644 --- a/metapost/context/base/mpiv/mp-lmtx.mpxl +++ b/metapost/context/base/mpiv/mp-lmtx.mpxl @@ -2010,6 +2010,16 @@ vardef lmt_do_contour = ) enddef ; +newinternal svgforcecmyk ; svgforcecmyk := 0 ; + +vardef svgcolor(expr r,g,b) = + if svgforcecmyk > 0 : + (1-r,1-g,1-b,0) % simple: no black component, kind of ok for emoji + else : + (r,g,b) + fi +enddef ; + presetparameters "svg" [ filename = "", fontname = "", diff --git a/scripts/context/lua/mtx-fonts.lua b/scripts/context/lua/mtx-fonts.lua index 64b04d780..c617524f4 100644 --- a/scripts/context/lua/mtx-fonts.lua +++ b/scripts/context/lua/mtx-fonts.lua @@ -268,7 +268,7 @@ local function showfeatures(tag,specification) report() indeed("instances : % t",instancenames) end - local features = fonts.helpers.getfeatures(specification.filename,not getargument("nosave")) + local features, tables = fonts.helpers.getfeatures(specification.filename,not getargument("nosave")) if features then for what, v in table.sortedhash(features) do local data = features[what] @@ -276,7 +276,7 @@ local function showfeatures(tag,specification) report() report("%s features:",what) report() - report("feature script languages") + report(" feature script languages") report() for f,ff in table.sortedhash(data) do local done = false @@ -288,7 +288,7 @@ local function showfeatures(tag,specification) else done = true end - report("% -8s % -8s % -8s",f,s,concat(table.sortedkeys(ss), " ")) -- todo: padd 4 + report(" % -8s % -8s % -8s",f,s,concat(table.sortedkeys(ss), " ")) -- todo: padd 4 end end end @@ -296,6 +296,24 @@ local function showfeatures(tag,specification) else report("no features") end + if tables then + tables = table.tohash(tables) + local methods = { + overlay = (tables.colr or tables.cpal) and { format = "cff/ttf", feature = "color:overlay" } or nil, + bitmap = (tables.cblc or tables.cbdt) and { format = "png", feature = "color:bitmap" } or nil, + outline = (tables.svg ) and { format = "svg", feature = "color:svg" } or nil, + } + if next(methods) then + report() + report("color features:") + report() + report(" method feature formats") + report() + for k, v in table.sortedhash(methods) do + report(" % -8s % -14s %s",k,v.feature,v.format) + end + end + end report() collectgarbage("collect") end diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii index bcfd567ac..6d54caf5b 100644 --- a/tex/context/base/mkii/cont-new.mkii +++ b/tex/context/base/mkii/cont-new.mkii @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2019.10.08 19:15} +\newcontextversion{2019.10.10 14:20} %D This file is loaded at runtime, thereby providing an %D excellent place for hacks, patches, extensions and new diff --git a/tex/context/base/mkii/context.mkii b/tex/context/base/mkii/context.mkii index cf799ddf2..cef416033 100644 --- a/tex/context/base/mkii/context.mkii +++ b/tex/context/base/mkii/context.mkii @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2019.10.08 19:15} +\edef\contextversion{2019.10.10 14:20} %D For those who want to use this: diff --git a/tex/context/base/mkiv/cldf-ini.lua b/tex/context/base/mkiv/cldf-ini.lua index 026d78c0d..e22de5a5b 100644 --- a/tex/context/base/mkiv/cldf-ini.lua +++ b/tex/context/base/mkiv/cldf-ini.lua @@ -749,6 +749,12 @@ local s_cldl_argument_e = "}" local t_cldl_luafunction = newtoken("luafunctioncall",0) local lua_expandable_call_token_code = token.command_id and token.command_id("lua_expandable_call") +local sortedhashindeed = false + +directives.register("context.sorthash",function(v) + sortedhashindeed = v and table.sortedhash or nil +end) + local function writer(parent,command,...) -- already optimized before call if type(command) == "string" then -- for now @@ -799,20 +805,39 @@ local function writer(parent,command,...) -- already optimized before call local tn = #ti if tn == 0 then local done = false - for k, v in next, ti do - if done then - if v == "" then - flush(currentcatcodes,",",k,'=') + if sortedhashindeed then + for k, v in sortedhashindeed(ti) do + if done then + if v == "" then + flush(currentcatcodes,",",k,'=') + else + flush(currentcatcodes,",",k,"={",v,"}") + end else - flush(currentcatcodes,",",k,"={",v,"}") + if v == "" then + flush(currentcatcodes,"[",k,"=") + else + flush(currentcatcodes,"[",k,"={",v,"}") + end + done = true end - else - if v == "" then - flush(currentcatcodes,"[",k,"=") + end + else + for k, v in next, ti do + if done then + if v == "" then + flush(currentcatcodes,",",k,'=') + else + flush(currentcatcodes,",",k,"={",v,"}") + end else - flush(currentcatcodes,"[",k,"={",v,"}") + if v == "" then + flush(currentcatcodes,"[",k,"=") + else + flush(currentcatcodes,"[",k,"={",v,"}") + end + done = true end - done = true end end if done then diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index eab60bbf9..9ad762de2 100644 --- a/tex/context/base/mkiv/cont-new.mkiv +++ b/tex/context/base/mkiv/cont-new.mkiv @@ -13,7 +13,7 @@ % \normalend % uncomment this to get the real base runtime -\newcontextversion{2019.10.08 19:15} +\newcontextversion{2019.10.10 14:20} %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 035353db2..5a9fd38fc 100644 --- a/tex/context/base/mkiv/context.mkiv +++ b/tex/context/base/mkiv/context.mkiv @@ -45,7 +45,7 @@ %D {YYYY.MM.DD HH:MM} format. \edef\contextformat {\jobname} -\edef\contextversion{2019.10.08 19:15} +\edef\contextversion{2019.10.10 14:20} \edef\contextkind {beta} %D Kind of special: diff --git a/tex/context/base/mkiv/context.mkxl b/tex/context/base/mkiv/context.mkxl index 1867e3df4..a17398ce2 100644 --- a/tex/context/base/mkiv/context.mkxl +++ b/tex/context/base/mkiv/context.mkxl @@ -29,7 +29,7 @@ %D {YYYY.MM.DD HH:MM} format. \edef\contextformat {\jobname} -\edef\contextversion{2019.10.08 19:15} +\edef\contextversion{2019.10.10 14:20} \edef\contextkind {beta} %D Kind of special: diff --git a/tex/context/base/mkiv/font-mis.lua b/tex/context/base/mkiv/font-mis.lua index 68165c9b8..c3fb58580 100644 --- a/tex/context/base/mkiv/font-mis.lua +++ b/tex/context/base/mkiv/font-mis.lua @@ -27,32 +27,35 @@ if readers then function fonts.helpers.getfeatures(name,save) local filename = resolvers.findfile(name) or "" if filename ~= "" then --- local name = file.removesuffix(file.basename(filename)) --- local cleanname = containers.cleanname(name) --- local data = containers.read(otf.cache,cleanname) --- if data then --- readers.unpack(data) --- else --- data = readers.loadfont(filename) -- we can do a more minimal load --- -- if data and save then --- -- -- keep this in sync with font-otl --- -- readers.compact(data) --- -- readers.rehash(data,"unicodes") --- -- readers.addunicodetable(data) --- -- readers.extend(data) --- -- readers.pack(data) --- -- -- till here --- -- containers.write(otf.cache,cleanname,data) --- -- end --- end --- if not data then --- data = readers.loadfont(filename) -- we can do a more minimal load --- end --- if data then --- readers.unpack(data) --- end -local data = otf.load(filename) - return data and data.resources and data.resources.features + -- local name = file.removesuffix(file.basename(filename)) + -- local cleanname = containers.cleanname(name) + -- local data = containers.read(otf.cache,cleanname) + -- if data then + -- readers.unpack(data) + -- else + -- data = readers.loadfont(filename) -- we can do a more minimal load + -- -- if data and save then + -- -- -- keep this in sync with font-otl + -- -- readers.compact(data) + -- -- readers.rehash(data,"unicodes") + -- -- readers.addunicodetable(data) + -- -- readers.extend(data) + -- -- readers.pack(data) + -- -- -- till here + -- -- containers.write(otf.cache,cleanname,data) + -- -- end + -- end + -- if not data then + -- data = readers.loadfont(filename) -- we can do a more minimal load + -- end + -- if data then + -- readers.unpack(data) + -- end + local data = otf.load(filename) + local resources = data and data.resources + if resources then + return data.resources.features, data.resources.foundtables, data + end end end diff --git a/tex/context/base/mkiv/font-ocl.lua b/tex/context/base/mkiv/font-ocl.lua index 9ce6982a8..3752203fa 100644 --- a/tex/context/base/mkiv/font-ocl.lua +++ b/tex/context/base/mkiv/font-ocl.lua @@ -29,6 +29,7 @@ local leftcommand = helpers.commands.left local downcommand = helpers.commands.down local otf = fonts.handlers.otf +local otfregister = otf.features.register local f_color = formatters["%.3f %.3f %.3f rg"] local f_gray = formatters["%.3f g"] @@ -155,7 +156,7 @@ local pop = { "pdf", "page", "Q" } -- -- only shows the first glyph in acrobat and nothing more. No problem with other -- -- renderers. -- --- local function initialize(tfmdata,kind,value) -- hm, always value +-- local function initializeoverlay(tfmdata,kind,value) -- hm, always value -- if value then -- local resources = tfmdata.resources -- local palettes = resources.colorpalettes @@ -226,7 +227,7 @@ local pop = { "pdf", "page", "Q" } -- end -- end -local function initialize(tfmdata,kind,value) +local function initializeoverlay(tfmdata,kind,value) if value then local resources = tfmdata.resources local palettes = resources.colorpalettes @@ -296,16 +297,17 @@ local function initialize(tfmdata,kind,value) end end end + return true end end end -fonts.handlers.otf.features.register { +otfregister { name = "colr", description = "color glyphs", manipulators = { - base = initialize, - node = initialize, + base = initializeoverlay, + node = initializeoverlay, } } @@ -532,21 +534,21 @@ do remove(svgfile) remove(pdffile) end -local characters = tfmdata.characters -for k, v in next, characters do - local d = descriptions[k] - local i = d.index - if i then - local p = pdfshapes[i] - if p then - local w = d.width - local l = d.boundingbox[1] - local r = d.boundingbox[3] - p.scale = (r - l) / w - p.x = l - end - end -end + local characters = tfmdata.characters + for k, v in next, characters do + local d = descriptions[k] + local i = d.index + if i then + local p = pdfshapes[i] + if p then + local w = d.width + local l = d.boundingbox[1] + local r = d.boundingbox[3] + p.scale = (r - l) / w + p.x = l + end + end + end if not next(pdfshapes) then report_svg("there are no converted shapes, fix your setup") end @@ -582,10 +584,11 @@ local function initializesvg(tfmdata,kind,value) -- hm, always value }) end pdftovirtual(tfmdata,pdfshapes,"svg") + return true end end -fonts.handlers.otf.features.register { +otfregister { name = "svg", description = "svg glyphs", manipulators = { @@ -693,10 +696,11 @@ local function initializepng(tfmdata,kind,value) -- hm, always value end -- pdftovirtual(tfmdata,pdfshapes,"png") + return true end end -fonts.handlers.otf.features.register { +otfregister { name = "sbix", description = "sbix glyphs", manipulators = { @@ -705,7 +709,7 @@ fonts.handlers.otf.features.register { } } -fonts.handlers.otf.features.register { +otfregister { name = "cblc", description = "cblc glyphs", manipulators = { @@ -713,3 +717,36 @@ fonts.handlers.otf.features.register { node = initializepng, } } + +if context then + + -- untested in generic and might clash with other color trickery + -- anyway so let's stick to context only + + local function initializecolor(tfmdata,kind,value) + if value == "auto" then + return + initializeoverlay(tfmdata,kind,value) or + initializesvg(tfmdata,kind,value) or + initializepng(tfmdata,kind,value) + elseif value == "overlay" then + return initializeoverlay(tfmdata,kind,value) + elseif value == "svg" then + return initializesvg(tfmdata,kind,value) + elseif value == "png" or value == "bitmap" then + return initializepng(tfmdata,kind,value) + else + -- forget about it + end + end + + otfregister { + name = "color", + description = "color glyphs", + manipulators = { + base = initializecolor, + node = initializecolor, + } + } + +end diff --git a/tex/context/base/mkiv/font-ogr.lua b/tex/context/base/mkiv/font-ogr.lua index 5fc946f42..2845cf0ba 100644 --- a/tex/context/base/mkiv/font-ogr.lua +++ b/tex/context/base/mkiv/font-ogr.lua @@ -385,33 +385,37 @@ local sharedpalettes do end -do +local initializeoverlay do - local f_color = formatters["%.3f %.3f %.3f rg"] - local f_gray = formatters["%.3f g"] + -- we should use the proper interface instead but for now: - local hash = setmetatableindex(function(t,k) - local v = k - t[k] = v - return v - end) + local colors = attributes.colors + local rgbtocmyk = colors.rgbtocmyk + + local f_cmyk = formatters["%.3N %.3f %.3N %.3N k"] + local f_rgb = formatters["%.3N %.3f %.3N rg"] + local f_gray = formatters["%.3N g"] local function convert(t,k) local v = { } + local m = colors.model for i=1,#k do local p = k[i] - local r, g, b = p[1], p[2], p[3] + local r, g, b = p[1]/255, p[2]/255, p[3]/255 if r == g and g == b then - v[i] = hash[f_gray(r/255)] + p = f_gray(r) + elseif m == "cmyk" then + p = f_cmyk(rgbtocmyk(r,g,b)) else - v[i] = hash[f_color(r/255,g/255,b/255)] + p = f_rgb(r,g,b) end + v[i] = p end t[k] = v return v end - local function initialize(tfmdata,kind,value) -- we really need the id ... todo + initializeoverlay = function(tfmdata,kind,value) -- we really need the id ... todo if value then local resources = tfmdata.resources local palettes = resources.colorpalettes @@ -475,6 +479,7 @@ do end end end + return true end end end @@ -483,20 +488,22 @@ do name = "colr", description = "color glyphs", manipulators = { - base = initialize, - node = initialize, + base = initializeoverlay, + node = initializeoverlay, } } end -do +local initializesvg do local report_svg = logs.reporter("fonts","svg") - local cached = true directives.register("fonts.svg.cached", function(v) cached = v end) + local cached = true -- maybe always false (after i've optimized the lot) - local function initializesvg(tfmdata,kind,value) -- hm, always value + directives.register("fonts.svg.cached", function(v) cached = v end) + + initializesvg = function(tfmdata,kind,value) -- hm, always value if value then local properties = tfmdata.properties local svg = properties.svg @@ -505,10 +512,11 @@ do if not hash then return end - local shapes = nil - local method = nil - if cached then - -- we need a different hash than for mkiv, so we append: + local shapes = nil + local method = nil + local enforce = attributes.colors.model == "cmyk" + if cached and not enforce then + -- we need a different hash than for mkiv, so we append: local pdfhash = hash .. "-svg" local pdffile = containers.read(otf.pdfcache,pdfhash) local pdfshapes = pdffile and pdffile.pdfshapes @@ -532,6 +540,10 @@ do local svgshapes = svgfile and svgfile.svgshapes -- still suboptimal mpsshapes = svgshapes and metapost.svgshapestomp(svgshapes,report_svg,tfmdata.parameters.units) or { } + if enforce then + -- cheap conversion, no black component generation + mpsshapes.preamble = "interim svgforcecmyk := 1;" + end containers.write(otf.mpscache, hash, { mpsshapes = mpsshapes, timestamp = timestamp, @@ -544,6 +556,7 @@ do shapes.fixdepth = value == "fixdepth" fonts.dropins.clone(method,tfmdata,shapes) end + return true end end @@ -558,14 +571,16 @@ do end -do +local initializepng do -- If this is really critical we can also use a pdf file as cache but I don't expect -- png fonts to remain used. + local colors = attributes.colors + local report_png = logs.reporter("fonts","png conversion") - local function initializepng(tfmdata,kind,value) -- hm, always value + initializepng = function(tfmdata,kind,value) -- hm, always value if value then local properties = tfmdata.properties local png = properties.png @@ -577,8 +592,12 @@ do local pngfile = containers.read(otf.pngcache,hash) local pngshapes = pngfile and pngfile.pngshapes if pngshapes then + if colors.model == "cmyk" then + pngshapes.enforcecmyk = true + end fonts.dropins.clone("png",tfmdata,pngshapes) end + return true end end @@ -601,3 +620,36 @@ do } end + +do + + -- I need to check jpeg and such but will do that when I run into + -- it. + + local function initializecolor(tfmdata,kind,value) + if value == "auto" then + return + initializeoverlay(tfmdata,kind,value) or + initializesvg(tfmdata,kind,value) or + initializepng(tfmdata,kind,value) + elseif value == "overlay" then + return initializeoverlay(tfmdata,kind,value) + elseif value == "svg" then + return initializesvg(tfmdata,kind,value) + elseif value == "png" or value == "bitmap" then + return initializepng(tfmdata,kind,value) + else + -- forget about it + end + end + + otfregister { + name = "color", + description = "color glyphs", + manipulators = { + base = initializecolor, + node = initializecolor, + } + } + +end diff --git a/tex/context/base/mkiv/font-pre.mkiv b/tex/context/base/mkiv/font-pre.mkiv index d17f57167..721c4c6eb 100644 --- a/tex/context/base/mkiv/font-pre.mkiv +++ b/tex/context/base/mkiv/font-pre.mkiv @@ -497,14 +497,18 @@ [boldened] [boldened-30] -%D Emoji: +%D Emoji etc: \definefontfeature[bandw:overlay][ccmp=yes,dist=yes] \definefontfeature[color:overlay][ccmp=yes,dist=yes,colr=yes] %definefontfeature[bandw:svg] [ccmp=yes,dist=yes] \definefontfeature[color:svg] [ccmp=yes,dist=yes,svg=yes] %definefontfeature[bandw:bitmap] [ccmp=yes,dist=yes,sbix=yes] -\definefontfeature[color:bitmap] [ccmp=yes,dist=yes,sbix=yes] +\definefontfeature[color:bitmap] [ccmp=yes,dist=yes,sbix=yes] % also cblc + +% Plus an automatic one: + +\definefontfeature[color] [ccmp=yes,dist=yes,color=auto] %D We define some colors that are used in tracing (for instance \OPENTYPE\ %D features). We cannot yet inherit because no colors are predefined. diff --git a/tex/context/base/mkiv/grph-inc.lua b/tex/context/base/mkiv/grph-inc.lua index fdac5f1a9..bfe67094e 100644 --- a/tex/context/base/mkiv/grph-inc.lua +++ b/tex/context/base/mkiv/grph-inc.lua @@ -1509,6 +1509,11 @@ function checkers.generic(data) -- tricky as img doesn't allow it f.attr = figure.attr end + if dr.cmyk == v_yes then + f.enforcecmyk = true + elseif dr.cmyk == v_auto and attributes.colors.model == "cmyk" then + f.enforcecmyk = true + end figure = f end local f, d = codeinjections.setfigurealternative(data,figure) @@ -2059,6 +2064,7 @@ implement { { "conversion" }, { "resolution" }, { "color" }, + { "cmyk" }, { "arguments" }, { "repeat" }, { "transform" }, diff --git a/tex/context/base/mkiv/grph-inc.mkiv b/tex/context/base/mkiv/grph-inc.mkiv index 30846c90f..31c9cbce9 100644 --- a/tex/context/base/mkiv/grph-inc.mkiv +++ b/tex/context/base/mkiv/grph-inc.mkiv @@ -115,6 +115,7 @@ \c!userpassword =, \c!ownerpassword =, \c!compact =, + \c!cmyk =, ] %D Defining figures. @@ -367,6 +368,7 @@ conversion {\externalfigureparameter\c!conversion}% resolution {\externalfigureparameter\c!resolution}% color {\externalfigureparameter\c!color}% unprocessed raw key + cmyk {\externalfigureparameter\c!cmyk}% kind of special arguments {\externalfigureparameter\c!arguments}% used for converters repeat {\externalfigureparameter\c!repeat}% transform {\externalfigureparameter\c!transform}% diff --git a/tex/context/base/mkiv/lpdf-emb.lua b/tex/context/base/mkiv/lpdf-emb.lua index bb6a421f2..1cb858571 100644 --- a/tex/context/base/mkiv/lpdf-emb.lua +++ b/tex/context/base/mkiv/lpdf-emb.lua @@ -6,7 +6,8 @@ if not modules then modules = { } end modules ['lpdf-ini'] = { license = "see context related readme files" } --- vkgoeswild: Pink Floyd - Shine on You Crazy Diamond - piano cover +-- vkgoeswild: Pink Floyd - Shine on You Crazy Diamond - piano cover (around that +-- time I redid the code, a reminder so to say) -- At some point I wanted to have access to the shapes so that we could use them in -- metapost. So, after looking at the cff and ttf specifications, I decided to write @@ -16,6 +17,15 @@ if not modules then modules = { } end modules ['lpdf-ini'] = { -- was only then that I found out that some of the juggling also happens in the the -- backend, but spread over places, so I could have saved myself some time -- deciphering the specifications. Anyway, here we go. +-- +-- Color fonts are a bit messy. Catching issues with older fonts will break new ones +-- so I don't think that it's wise to build in too many catches (like for fonts with +-- zero boundingboxes, weird dimensions, transformations that in a next version are +-- fixed, etc.). Better is then to wait till something gets fixed. If a spec doesn't +-- tell me how to deal with it ... I'll happily wait till it does. After all we're +-- not in a hurry as these fonts are mostly meant for the web or special purposes +-- with manual tweaking in desk top publishing applications. Keep in mind that Emoji +-- can have funny dimensions (e.g. to be consistent within a font, so no tight ones). local next, type, unpack = next, type, unpack local char, byte, gsub, sub, match, rep, gmatch = string.char, string.byte, string.gsub, string.sub, string.match, string.rep, string.gmatch @@ -762,7 +772,7 @@ do streamoffset = streamoffset + #blob lastoffset = tocardinal4(streamoffset) else - print("missing .notdef") + report_fonts("missing .notdef in font %a",basefontname) end -- todo: use a rep for h/v for index=1,minindex-1 do @@ -793,7 +803,7 @@ do if vertical then v = v + 1 ; verticals[v] = zero4 end - print("missing blob for index",index) + report_fonts("missing blob for index %i in font %a",index,basefontname) end else h = h + 1 ; horizontals[h] = zero4 @@ -1534,6 +1544,7 @@ do local f_width = formatters["%.6N 0 d0"] local f_index = formatters["I%d"] local f_image = formatters["%.6N 0 d0 /%s Do"] + local f_image_xy = formatters["%.6N 0 d0 1 0 0 1 %.3N %.3N cm /%s Do"] local f_image_d = formatters["%.6N 0 d0 1 0 0 1 0 %.3N cm /%s Do"] local f_stream = formatters["%.6N 0 d0 %s"] local f_stream_c = formatters["%.6N 0 0 0 0 0 d1 %s"] @@ -1624,10 +1635,11 @@ do function methods.mps(filename,details) local properties = details.properties + local parameters = details.parameters local mpshapes = properties.indexdata[1] -- indexdata will change if mpshapes then - local scale = 10 * details.parameters.size/details.parameters.designsize - local units = mpshapes.units or details.parameters.units + local scale = 10 * parameters.size/parameters.designsize + local units = mpshapes.units or parameters.units local factor = units * bpfactor / scale local fixdepth = mpshapes.fixdepth local usecolor = mpshapes.usecolor @@ -1688,22 +1700,28 @@ do function methods.png(filename,details) local properties = details.properties + local parameters = details.parameters local png = properties.png local hash = png.hash local pngshapes = properties.indexdata[1] local xforms = pdfdictionary() local nofglyphs = 0 + local scale = 10 * parameters.size/parameters.designsize + local factor = bpfactor / scale if pngshapes then local function pngtopdf(glyph,data) - local width = data.width - local info = graphics.identifiers.png(glyph.data,"string") - local image = lpdf.injectors.png(info,"string") + -- local width = data.width + local info = graphics.identifiers.png(glyph.data,"string") + info.enforcecmyk = pngshapes.enforcecmyk + local image = lpdf.injectors.png(info,"string") embedimage(image) - width = width * bpfactor / 10 - nofglyphs = nofglyphs + 1 - local name = f_glyph(nofglyphs) - xforms[name] = pdfreference(image.objnum) - local pdf = f_image(width,name) + nofglyphs = nofglyphs + 1 + local width = (data.width or 0) * factor + local xoffset = (glyph.x or 0) / 1000 -- or units ? + local yoffset = (glyph.y or 0) / 1000 -- or units ? + local name = f_glyph(nofglyphs) + xforms[name] = pdfreference(image.objnum) + local pdf = f_image_xy(width,xoffset,yoffset,name) return pdf, width end local function closepng() diff --git a/tex/context/base/mkiv/lpdf-img.lua b/tex/context/base/mkiv/lpdf-img.lua index 6b19f0cfd..4e54989cd 100644 --- a/tex/context/base/mkiv/lpdf-img.lua +++ b/tex/context/base/mkiv/lpdf-img.lua @@ -19,8 +19,8 @@ if not modules then modules = { } end modules ['lpdf-img'] = { local type = type local concat, move = table.concat, table.move -local ceil = math.ceil -local char, find = string.char, string.find +local ceil, min = math.ceil, math.min +local char, byte, find, gmatch = string.char, string.byte, string.find, string.gmatch local idiv = number.idiv local band, rshift = bit32.band, bit32.rshift @@ -177,8 +177,9 @@ do local pngsplitmask = pngdecode.splitmask local pnginterlace = pngdecode.interlace local pngexpand = pngdecode.expand + local pngtocmyk = pngdecode.tocmyk - local filtermask, decodemask, decodestrip, transpose, expand + local filtermask, decodemask, decodestrip, transpose, expand, tocmyk local newindex = lua.newindex local newtable = lua.newtable @@ -834,6 +835,37 @@ do end end + local function tocmyk_l(content,colordepth) + local l = #content + local t = { } + local n = 0 + if colordepth == 8 then + for i=1,l,3 do + local r, g, b = byte(content,i,i+2) + n = n + 1 ; t[n] = char(255-r,255-g,255-b,0) -- a tad faster than chars[...] + end + else + for i=1,l,6 do + local r1, r2, g1, g2, b1, b2 = byte(content,i,i+5) + n = n + 1 ; t[n] = char(255-r1,255-r2,255-g1,255-g2,255-b1,255-b2,0,0) + end + end + return concat(t) + end + + local tocmyk_c = pngtocmyk or tocmyk_l + + local function converttocmyk(content,colorspace,colordepth) + if colorspace == "DeviceRGB" and colordepth == 8 or colordepth == 16 then + local done = tocmyk(content,colordepth) + if done then + content = done + colorspace = "DeviceCMYK" + end + end + return content, colorspace + end + local function switch(v) if v then filtermask = filtermask_l @@ -842,6 +874,7 @@ do transpose = transpose_l expand = expand_l createmask = createmask_l + tocmyk = tocmyk_l else filtermask = filtermask_c decodemask = decodemask_c @@ -849,6 +882,7 @@ do transpose = transpose_c expand = expand_c createmask = createmask_c + tocmyk = tocmyk_c end end @@ -859,7 +893,7 @@ do switch(true) end - local alwaysdecode = false + local alwaysdecode = false -- trucky with palettes local compresslevel = 3 directives.register("graphics.png.recompress", function(v) @@ -874,7 +908,6 @@ do end) function injectors.png(specification,method) -- todo: method in specification --- inspect(specification) if specification.error then return end @@ -920,6 +953,7 @@ do local mask = false local transparent = false local palette = false + local enforcecmyk = specification.enforcecmyk local colors = 1 if colorspace == 0 then -- gray | image b colorspace = "DeviceGray" @@ -957,7 +991,7 @@ do end end -- - local decode = alwaysdecode + local decode = alwaysdecode -- tricky, might go away local filter = pdfconstant("FlateDecode") local major = pdfmajorversion() local minor = pdfminorversion() @@ -1007,6 +1041,9 @@ do else content = convert(r) -- can be in deinterlace if needed end + if enforcecmyk then + content, colorspace = converttocmyk(content,colorspace,colordepth) + end if compresslevel > 0 then content = zlibcompress(content,compresslevel) else @@ -1020,6 +1057,9 @@ do end content = zlibdecompress(content) content, mask = decodemask(content,xsize,ysize,colordepth,colorspace) + if enforcecmyk and not palette then + content, colorspace = converttocmyk(content,colorspace,colordepth) + end if compresslevel > 0 then content = zlibcompress(content,compresslevel) else @@ -1040,6 +1080,9 @@ do if bytes then content = zlibdecompress(content) content = decodestrip(openstring(content),xsize,ysize,bytes) + if enforcecmyk and not palette then + content, colorspace = converttocmyk(content,colorspace,colordepth) + end if compresslevel > 0 then content = zlibcompress(content,compresslevel) else @@ -1052,10 +1095,17 @@ do -- print("PASS ON") end if palette then + local colorspace = "DeviceRGB" + local nofbytes = 3 + if enforcecmyk then + palette = converttocmyk(palette,colorspace,8) + colorspace = "DeviceCMYK" + nofbytes = 4 + end palette = pdfarray { pdfconstant("Indexed"), - pdfconstant("DeviceRGB"), - idiv(#palette,3), + pdfconstant(colorspace), + idiv(#palette,nofbytes), pdfreference(pdfflushstreamobject(palette)), } end @@ -1145,6 +1195,7 @@ do n = n + 1 ; t[n] = chars[c[1]] n = n + 1 ; t[n] = chars[c[2]] n = n + 1 ; t[n] = chars[c[3]] + -- n = n + 1 ; t[n] = char(c[1],c[2],c[3]) -- test this end end elseif s == 3 then @@ -1156,6 +1207,7 @@ do n = n + 1 ; t[n] = chars[c[2]] n = n + 1 ; t[n] = chars[c[3]] n = n + 1 ; t[n] = chars[c[4]] + -- n = n + 1 ; t[n] = char(c[1],c[2],c[3],c[4]) -- test this end end end diff --git a/tex/context/base/mkiv/mlib-svg.lua b/tex/context/base/mkiv/mlib-svg.lua index d9156d2e8..d201ec20e 100644 --- a/tex/context/base/mkiv/mlib-svg.lua +++ b/tex/context/base/mkiv/mlib-svg.lua @@ -103,10 +103,15 @@ local f_nodraw = formatters['nodraw %s(%s)%s ;'] -- local f_nodraw = formatters['d %s(%s)%s ;'] local f_color = formatters[' withcolor "%s"'] -local f_rgb = formatters[' withcolor (%.3N,%.3N,%.3N)'] -local f_rgba = formatters[' withcolor (%.3N,%.3N,%.3N) withtransparency (1,%3N)'] -local f_triplet = formatters['(%.3N,%.3N,%.3N)'] +----- f_color_rgb = formatters[' withcolor "0x%02X%02X%02X"'] +----- f_color_rgba = formatters[' withcolor "0x%02X%02X%02X" withtransparency (1,%3N)'] +----- f_color_triplet = formatters['"0x%02X%02X%02X"'] + +local f_rgb = formatters[' withcolor svgcolor(%.3N,%.3N,%.3N)'] +local f_rgba = formatters[' withcolor svgcolor(%.3N,%.3N,%.3N) withtransparency (1,%3N)'] +local f_triplet = formatters['svgvolor(%.3N,%.3N,%.3N)'] local f_gray = formatters[' withcolor %.3N'] + local f_opacity = formatters[' withtransparency (1,%.3N)'] local f_pen = formatters[' withpen pencircle scaled %.3N'] diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf index ef92c2d37..478ce531a 100644 Binary files a/tex/context/base/mkiv/status-files.pdf and b/tex/context/base/mkiv/status-files.pdf differ diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf index 236879972..7e0a6a2f9 100644 Binary files a/tex/context/base/mkiv/status-lua.pdf and b/tex/context/base/mkiv/status-lua.pdf differ diff --git a/tex/context/base/mkiv/syst-ini.mkiv b/tex/context/base/mkiv/syst-ini.mkiv index 63e1cebab..c8de22b28 100644 --- a/tex/context/base/mkiv/syst-ini.mkiv +++ b/tex/context/base/mkiv/syst-ini.mkiv @@ -1169,4 +1169,10 @@ \def\wildcardsymbol{*} +%D Get rid of this, we don't need it. If we ever need to check the order we will +%D use proper symbolic constants. + +\let\eTeXglueshrinkorder \undefined +\let\eTeXgluestretchorder\undefined + \protect \endinput diff --git a/tex/context/interface/mkiv/i-context.pdf b/tex/context/interface/mkiv/i-context.pdf index 344bcbcc1..6bb755770 100644 Binary files a/tex/context/interface/mkiv/i-context.pdf and b/tex/context/interface/mkiv/i-context.pdf differ diff --git a/tex/context/interface/mkiv/i-readme.pdf b/tex/context/interface/mkiv/i-readme.pdf index a5cd19671..8a6e7aaa8 100644 Binary files a/tex/context/interface/mkiv/i-readme.pdf and b/tex/context/interface/mkiv/i-readme.pdf differ diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index c388eaca1..dcd61026f 100644 --- a/tex/generic/context/luatex/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : c:/data/develop/context/sources/luatex-fonts-merged.lua -- parent file : c:/data/develop/context/sources/luatex-fonts.lua --- merge date : 10/08/19 19:15:39 +-- merge date : 10/10/19 14:20:37 do -- begin closure to overcome local limits and interference @@ -32121,6 +32121,7 @@ local rightcommand=helpers.commands.right local leftcommand=helpers.commands.left local downcommand=helpers.commands.down local otf=fonts.handlers.otf +local otfregister=otf.features.register local f_color=formatters["%.3f %.3f %.3f rg"] local f_gray=formatters["%.3f g"] if context then @@ -32177,7 +32178,7 @@ end local start={ "pdf","mode","font" } local push={ "pdf","page","q" } local pop={ "pdf","page","Q" } -local function initialize(tfmdata,kind,value) +local function initializeoverlay(tfmdata,kind,value) if value then local resources=tfmdata.resources local palettes=resources.colorpalettes @@ -32242,15 +32243,16 @@ local function initialize(tfmdata,kind,value) end end end + return true end end end -fonts.handlers.otf.features.register { +otfregister { name="colr", description="color glyphs", manipulators={ - base=initialize, - node=initialize, + base=initializeoverlay, + node=initializeoverlay, } } do @@ -32418,21 +32420,21 @@ do remove(svgfile) remove(pdffile) end -local characters=tfmdata.characters -for k,v in next,characters do - local d=descriptions[k] - local i=d.index - if i then - local p=pdfshapes[i] - if p then - local w=d.width - local l=d.boundingbox[1] - local r=d.boundingbox[3] - p.scale=(r-l)/w - p.x=l - end - end -end + local characters=tfmdata.characters + for k,v in next,characters do + local d=descriptions[k] + local i=d.index + if i then + local p=pdfshapes[i] + if p then + local w=d.width + local l=d.boundingbox[1] + local r=d.boundingbox[3] + p.scale=(r-l)/w + p.x=l + end + end + end if not next(pdfshapes) then report_svg("there are no converted shapes, fix your setup") end @@ -32464,9 +32466,10 @@ local function initializesvg(tfmdata,kind,value) }) end pdftovirtual(tfmdata,pdfshapes,"svg") + return true end end -fonts.handlers.otf.features.register { +otfregister { name="svg", description="svg glyphs", manipulators={ @@ -32549,9 +32552,10 @@ local function initializepng(tfmdata,kind,value) }) end pdftovirtual(tfmdata,pdfshapes,"png") + return true end end -fonts.handlers.otf.features.register { +otfregister { name="sbix", description="sbix glyphs", manipulators={ @@ -32559,7 +32563,7 @@ fonts.handlers.otf.features.register { node=initializepng, } } -fonts.handlers.otf.features.register { +otfregister { name="cblc", description="cblc glyphs", manipulators={ @@ -32567,6 +32571,11 @@ fonts.handlers.otf.features.register { node=initializepng, } } +if context then + +--removed + +end end -- closure -- cgit v1.2.3