From 24f6f7de245bdff10f21984a9a3c6af3d31fa1f1 Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Fri, 11 Oct 2019 16:46:49 +0200 Subject: 2019-10-11 15:56:00 --- tex/context/base/mkii/cont-new.mkii | 2 +- tex/context/base/mkii/context.mkii | 2 +- tex/context/base/mkiv/cont-new.mkiv | 2 +- tex/context/base/mkiv/context.mkiv | 2 +- tex/context/base/mkiv/context.mkxl | 5 +- tex/context/base/mkiv/font-ogr.lua | 22 +- tex/context/base/mkiv/font-otc.lua | 18 +- tex/context/base/mkiv/font-prv.lua | 4 + tex/context/base/mkiv/lpdf-ano.lua | 6 +- tex/context/base/mkiv/meta-imp-gamesymbols.mkxl | 349 +++++++++++++++++++++ tex/context/base/mkiv/mlib-cnt.lua | 85 +++-- tex/context/base/mkiv/mlib-lua.lua | 24 +- tex/context/base/mkiv/status-files.pdf | Bin 26669 -> 26676 bytes tex/context/base/mkiv/status-lua.pdf | Bin 268380 -> 268444 bytes tex/context/base/mkiv/strc-not.mkvi | 6 + tex/context/interface/mkiv/i-context.pdf | Bin 893663 -> 893281 bytes tex/context/interface/mkiv/i-readme.pdf | Bin 61165 -> 61165 bytes tex/generic/context/luatex/luatex-fonts-merged.lua | 19 +- 18 files changed, 496 insertions(+), 50 deletions(-) create mode 100644 tex/context/base/mkiv/meta-imp-gamesymbols.mkxl (limited to 'tex') diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii index 6d54caf5b..adfd46772 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.10 14:20} +\newcontextversion{2019.10.11 15:47} %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 cef416033..71b70dd56 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.10 14:20} +\edef\contextversion{2019.10.11 15:47} %D For those who want to use this: diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index 9ad762de2..4b584e787 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.10 14:20} +\newcontextversion{2019.10.11 15:47} %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 5a9fd38fc..58334d47a 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.10 14:20} +\edef\contextversion{2019.10.11 15:47} \edef\contextkind {beta} %D Kind of special: diff --git a/tex/context/base/mkiv/context.mkxl b/tex/context/base/mkiv/context.mkxl index a17398ce2..1e235689a 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.10 14:20} +\edef\contextversion{2019.10.11 15:47} \edef\contextkind {beta} %D Kind of special: @@ -54,9 +54,6 @@ \def\loadmkxlfile#1{\normalinput{#1.mkxl}} \def\loadmklxfile#1{\normalinput{#1.mklx}} -% \def\loadmkxlfile#1{\normalinput{#1.mkiv}} -% \def\loadmklxfile#1{\normalinput{#1.mkvi}} - %D First we load the system modules. These implement a lot of manipulation macros. %D We start with setting up some basic \TEX\ machinery. diff --git a/tex/context/base/mkiv/font-ogr.lua b/tex/context/base/mkiv/font-ogr.lua index 2845cf0ba..b408fc5d6 100644 --- a/tex/context/base/mkiv/font-ogr.lua +++ b/tex/context/base/mkiv/font-ogr.lua @@ -165,7 +165,7 @@ do end -do +do -- this will move to its own module local dropins = fonts.dropins @@ -193,8 +193,11 @@ do function dropins.registerglyph(parameters) local category = parameters.category local unicode = parameters.unicode + local private = parameters.private local unichar = parameters.unichar - if type(unichar) == "string" then + if private then + unicode = fonts.helpers.newprivateslot(private) + elseif type(unichar) == "string" then unicode = utfbyte(unichar) else local unitype = type(unicode) @@ -209,9 +212,13 @@ do unicode = round(unicode) end end - parameters.unicode = unicode - -- print(category,unicode) - shapes[category].glyphs[unicode] = parameters + if unicode then + parameters.unicode = unicode + -- print(category,unicode) + shapes[category].glyphs[unicode] = parameters + else + -- error + end end -- local function hascolorspec(t) @@ -243,7 +250,7 @@ do if not specification or not next(specification) then specification = { category = value } end - -- todo: multiple categories but then mayb also different + -- todo: multiple categories but then maybe also different -- clones because of the units .. for now we assume the same -- units local category = specification.category @@ -317,6 +324,9 @@ do end end + -- This kicks in quite late, after features have been checked. So if needed + -- substitutions need to be defined with force. + otfregister { name = "metapost", description = "metapost glyphs", diff --git a/tex/context/base/mkiv/font-otc.lua b/tex/context/base/mkiv/font-otc.lua index a774a81c2..2643d022a 100644 --- a/tex/context/base/mkiv/font-otc.lua +++ b/tex/context/base/mkiv/font-otc.lua @@ -22,9 +22,10 @@ local otf = fonts.handlers.otf local registerotffeature = otf.features.register local setmetatableindex = table.setmetatableindex -local checkmerge = fonts.helpers.checkmerge -local checkflags = fonts.helpers.checkflags -local checksteps = fonts.helpers.checksteps +local fonthelpers = fonts.helpers +local checkmerge = fonthelpers.checkmerge +local checkflags = fonthelpers.checkflags +local checksteps = fonthelpers.checksteps local normalized = { substitution = "substitution", @@ -167,6 +168,7 @@ local function addfeature(data,feature,specifications) local done = 0 local skip = 0 local aglunicodes = false + local privateslot = fonthelpers.privateslot local specifications = validspecification(specifications,feature) if not specifications then @@ -196,6 +198,13 @@ local function addfeature(data,feature,specifications) return u end end + if privateslot then + u = privateslot(code) -- no creation ! + if u then + -- unicodes[code] = u + return u + end + end local u = lpegmatch(p,code) if u then -- unicodes[code] = u @@ -229,7 +238,7 @@ local function addfeature(data,feature,specifications) replacement = replacement[1] end replacement = tounicode(replacement) - if replacement and descriptions[replacement] then + if replacement and (nocheck or descriptions[replacement]) then cover(coverage,unicode,replacement) done = done + 1 else @@ -620,7 +629,6 @@ local function addfeature(data,feature,specifications) local featuretype = normalized[specification.type or "substitution"] or "substitution" local featureflags = specification.flags or noflags local nocheck = specification.nocheck - local futuresteps = specification.futuresteps local featureorder = specification.order or { feature } local featurechain = (featuretype == "chainsubstitution" or featuretype == "chainposition") and 1 or 0 local nofsteps = 0 diff --git a/tex/context/base/mkiv/font-prv.lua b/tex/context/base/mkiv/font-prv.lua index 20c06d2e5..57c93fd27 100644 --- a/tex/context/base/mkiv/font-prv.lua +++ b/tex/context/base/mkiv/font-prv.lua @@ -76,3 +76,7 @@ end function helpers.privateslot(name) return rawget(sharedprivates,name) end + +function helpers.newprivateslot(name) + return sharedprivates[name] +end diff --git a/tex/context/base/mkiv/lpdf-ano.lua b/tex/context/base/mkiv/lpdf-ano.lua index 2a77732eb..05f18f512 100644 --- a/tex/context/base/mkiv/lpdf-ano.lua +++ b/tex/context/base/mkiv/lpdf-ano.lua @@ -634,9 +634,9 @@ local function pdffilelink(filename,destination,page,actions) destination = pdfarray { (page or 1) - 1, pdf_fit } end return pdfdictionary { - S = pdf_gotor, -- can also be pdf_launch - F = filename, - D = destination or defaultdestination, + S = pdf_gotor, -- can also be pdf_launch + F = filename, + D = destination or defaultdestination, NewWindow = actions.newwindow and true or nil, } end diff --git a/tex/context/base/mkiv/meta-imp-gamesymbols.mkxl b/tex/context/base/mkiv/meta-imp-gamesymbols.mkxl new file mode 100644 index 000000000..d79e59f69 --- /dev/null +++ b/tex/context/base/mkiv/meta-imp-gamesymbols.mkxl @@ -0,0 +1,349 @@ +%D \module +%D [ file=meta-imp-gamesymbols, +%D version=2019.10.10, +%D title=\METAPOST\ Graphics, +%D subtitle=Game Symbols, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +%D The \METAFUN\ code here is not optimal and efficient but as it serves as an +%D example I decided to keep it simple. Also, performance is not really an issue +%D here anyway. Inspired by the classic \quote {Concrete Mathematics} by Don Knuth +%D we define dice and dominos, which happen to be \UNICODE\ characters now. We +%D use this opportunity to demonstrate slightly different approached. + +%D Each dice gets it's own macro at the \METAPOST\ end. Watch how we use the \type +%D {simplefun} instance in combination with a calculation wrapper. This will just +%D execute the code and leave no traces in the text flow. The code itself is not +%D that spectacular: + +\startMPcalculation{simplefun} + + def DiceFrame = + pickup pencircle scaled 1/2 ; + draw unitsquare scaled 8 ; + pickup pencircle scaled 3/2 ; + enddef ; + + vardef DiceOne = + DiceFrame ; + draw (4,4) ; + enddef ; + vardef DiceTwoA = + DiceFrame ; + draw (2,6) ; draw (6,2) ; + enddef ; + vardef DiceTwoB = + DiceFrame ; + draw (6,6) ; draw (2,2) ; + enddef ; + vardef DiceTwo = + if hasoption "mpsfont" "option" "reverse" : + DiceTwoB + else : + DiceTwoA + fi ; + enddef ; + vardef DiceThreeA = + DiceFrame ; + draw (2,6) ; draw (4,4) ; draw (6,2) ; + enddef ; + vardef DiceThreeB = + DiceFrame ; + draw (6,6) ; draw (4,4) ; draw (2,2) ; + enddef ; + vardef DiceThree = + if hasoption "mpsfont" "option" "reverse" : + DiceThreeB + else : + DiceThreeA + fi ; + enddef ; + vardef DiceFour = + DiceFrame ; + draw (2,6) ; draw (6,6) ; draw (2,2) ; draw (6,2) ; + enddef ; + vardef DiceFive = + DiceFrame ; + draw (2,6) ; draw (6,6) ; draw (4,4) ; draw (2,2) ; draw (6,2) ; + enddef ; + vardef DiceSix = + DiceFrame ; + draw (2,6) ; draw (6,6) ; draw (2,4) ; draw (6,4) ; draw (2,2) ; draw (6,2) ; + enddef ; + + vardef DiceBad = + pickup pencircle scaled 1/2 ; + draw unitsquare scaled 8 ; + draw (1,7) -- (7,1) ; draw (1,1) -- (7,7) ; + enddef ; + + lmt_registerglyphs [ + name = "dice", + units = 12, + width = 8, + height = 8, + depth = 0, + usecolor = true, + ] ; + + lmt_registerglyph [ category = "dice", unicode = "0x2680", code = "DiceOne;" ] ; + lmt_registerglyph [ category = "dice", unicode = "0x2681", code = "DiceTwo;" ] ; + lmt_registerglyph [ category = "dice", unicode = "0x2682", code = "DiceThree;" ] ; + lmt_registerglyph [ category = "dice", unicode = "0x2683", code = "DiceFour;" ] ; + lmt_registerglyph [ category = "dice", unicode = "0x2684", code = "DiceFive;" ] ; + lmt_registerglyph [ category = "dice", unicode = "0x2685", code = "DiceSix;" ] ; + + lmt_registerglyph [ category = "dice", private = "invaliddice", code = "DiceBad;" ] ; + +\stopMPcalculation + +%D At the \TEX\ end we define three features. The reverse is just there for fun. The +%D digits features will map digits onto dice. + +\definefontfeature + [dice:normal] + [default] + [metapost={category=dice}] + +\definefontfeature + [dice:reverse] + [default] + [metapost={category=dice,option=reverse}] + +\definefontfeature + [dice:digits] + [dice:digits=yes] + +%D The mapping to dice happens here: + +\startluacode + + -- local invalid = fonts.helpers.privateslot("invaliddice") + + fonts.handlers.otf.addfeature("dice:digits", { + type = "substitution", + order = { "dice:digits" }, + nocheck = true, + data = { + [0x30] = "invaliddice", + [0x31] = 0x2680, + [0x32] = 0x2681, + [0x33] = 0x2682, + [0x34] = 0x2683, + [0x35] = 0x2684, + [0x36] = 0x2685, + [0x37] = "invaliddice", + [0x38] = "invaliddice", + [0x39] = "invaliddice", + }, + } ) + +\stopluacode + +%D An example is given at the the end of this file so we now move forward with +%D the dominos. + +\startMPcalculation{simplefun} + + %D Because there are so many dominos we predefine the shapes and then register + %D the lot in a loop. + + picture Dominos[] ; + + Dominos[0] := image() ; + Dominos[1] := image(draw(4,4);) ; + Dominos[2] := image(draw(2,6);draw(6,2);); + Dominos[3] := image(draw(2,6);draw(4,4);draw(6,2);); + Dominos[4] := image(draw(2,6);draw(6,6);draw(2,2);draw(6,2);); + Dominos[5] := image(draw(2,6);draw(6,6);draw(4,4);draw(2,2);draw(6,2);); + Dominos[6] := image(draw(2,6);draw(4,6);draw(6,6);draw(2,2);draw(4,2);draw(6,2);); + % Dominos[7] := Dominos[0] ; + % Dominos[8] := Dominos[0] ; + % Dominos[9] := Dominos[0] ; + + %D Defining the font properties is straightforward: + + lmt_registerglyphs [ + name = "dominos", + units = 12, + width = 16, + height = 8, + depth = 0, + usecolor = true, + ] ; + + %D We have horizontal dominos: + + def DrawDominoH(expr a, b) = + draw image ( + pickup pencircle scaled 1/2 ; + if (getparameterdefault "mpsfont" "color" "") = "black" : + fillup unitsquare xyscaled (16,8) ; + draw (8,.5) -- (8,7.5) withcolor white ; + pickup pencircle scaled 3/2 ; + draw Dominos[a] + withpen currentpen + withcolor white ; + draw Dominos[b] shifted (8,0) + withpen currentpen + withcolor white ; + else : + draw unitsquare xyscaled (16,8) ; + draw (8,0) -- (8,8) ; + pickup pencircle scaled 3/2 ; + draw Dominos[a] + withpen currentpen ; + draw Dominos[b] shifted (8,0) + withpen currentpen ; + fi ; + ) ; + enddef ; + + %D and vertical ones. We could use the above macro and rotate and shift and reflect + %D but why bother with it: + + def DrawDominoV(expr a, b) = % is H rotated and shifted + draw image ( + pickup pencircle scaled 1/2 ; + if (getparameterdefault "mpsfont" "color" "") = "black" : + fillup unitsquare xyscaled (8,16) ; + draw (.5,8) -- (7.5,8) withcolor white ; + pickup pencircle scaled 3/2 ; + draw Dominos[a] rotatedaround(center Dominos[a],90) + withpen currentpen + withcolor white ; + draw Dominos[b] rotatedaround(center Dominos[b],90) shifted (0,8) + withpen currentpen + withcolor white ; + else : + draw unitsquare xyscaled (8,16) ; + draw (0,8) -- (8,8) ; + pickup pencircle scaled 3/2 ; + draw Dominos[a] rotatedaround(center Dominos[a],90) + withpen currentpen ; + draw Dominos[b] rotatedaround(center Dominos[b],90) shifted (0,8) + withpen currentpen ; + fi ; + ) ; + enddef ; + + %D We have two simple loops that define the horizontal range: + + save unicode ; numeric unicode ; unicode := 127025 ; % 1F031 + + for i=0 upto 6 : + for j=0 upto 6 : + lmt_registerglyph [ + category = "dominos", + unicode = unicode, + code = "DrawDominoH(" & decimal i & "," & decimal j & ");", + width = 16, + height = 8, + ] ; + unicode := unicode + 1 ; + endfor ; + endfor ; + + %D and the vertical range: + + save unicode ; numeric unicode ; unicode := 127075 ; + + for i=0 upto 6 : + for j=0 upto 6 : + lmt_registerglyph [ + category = "dominos", + unicode = unicode, + code = "DrawDominoV(" & decimal i & "," & decimal j & ");", + width = 8, + height = 16, + ] ; + unicode := unicode + 1 ; + endfor ; + endfor ; + + %D Now we're done at the \METAFUN\ end. + +\stopMPcalculation + +%D We predefine two features: + +\definefontfeature + [dominos:white] + [default] + [metapost={category=dominos}] + +\definefontfeature + [dominos:black] + [default] + [metapost={category=dominos,color=black}] + +\definefontfeature + [dominos:digits] + [dominos:digits=yes] + +%D This last feature is yet to be defined. We could deal with the invalid +%D dominos with some substitution trickery but let's keep it simple. + +\startluacode + + local ligatures = { } + local unicode = 127025 + + for i=0x30,0x36 do + for j=0x30,0x36 do + ligatures[unicode] = { i, j } + unicode = unicode + 1 ; + end + end + + fonts.handlers.otf.addfeature("dominos:digits", { + type = "ligature", + order = { "dominos:digits" }, + nocheck = true, + data = ligatures, + } ) + +\stopluacode + +\continueifinputfile{meta-imp-gamesymbols.mkxl} + +\starttext + + \definefont[DominoW][Serif*dominos:white] + \definefont[DominoB][Serif*dominos:black] + \definefont[DominoD][Serif*dominos:white,dominos:digits] + + \startTEXpage[offset=3pt] + \DominoW + \char"1F043\quad 🀱\quad + \char"1F052\quad 🀲\quad + \char"1F038\quad 🀳\quad + \darkgreen\char"1F049\quad \char"1F07B\quad + \DominoB + \char"1F087\quad + \char"1F088\quad + \char"1F089\quad + \DominoD + \darkred 12\quad56\quad64% + \stopTEXpage + + \definefont[DiceN][Serif*dice:normal] + \definefont[DiceR][Serif*dice:reverse] + \definefont[DiceD][Serif*dice:normal,dice:digits] + + \startTEXpage[offset=3pt] + \DiceN + \dostepwiserecurse{"2680}{"2685}{1}{\char#1\quad}% + \DiceN + \dostepwiserecurse{"2680}{"2685}{1}{\char#1\quad}% + \DiceD + \darkblue 2\quad5\quad3\quad0 + \stopTEXpage + +\stoptext diff --git a/tex/context/base/mkiv/mlib-cnt.lua b/tex/context/base/mkiv/mlib-cnt.lua index f257c0a6e..16625befb 100644 --- a/tex/context/base/mkiv/mlib-cnt.lua +++ b/tex/context/base/mkiv/mlib-cnt.lua @@ -65,7 +65,7 @@ local mp = mp or { } local getparameterset = metapost.getparameterset local mpflush = mp.flush -local mptriplet = mp.triplet +local mpcolor = mp.color local mpstring = mp.string local mpdraw = mp.draw local mpfill = mp.fill @@ -307,12 +307,18 @@ function mp.lmt_contours_start() if not fcolor then local color_step = mp.lmt_color_functions.step fcolor = function(l) - return color_step(l,levels,0.25, 0.50, 0.75) + return color_step(l,levels,0.25,0.50,0.75) end end for i=1,nofvalues do colors[i] = { fcolor(i) } end +if attributes.colors.model == "cmyk" then + for i=1,#colors do + local c = colors[i] + colors[i] = { 1 - c[1], 1 - c[2], 1 - c[3], 0 } + end +end return colors, fcolor end end @@ -563,22 +569,28 @@ function mp.lmt_contours_bitmap_set() -- i need to figure out this offset of + 1 - local bitmap = graphics.bitmaps.new(nx,ny,depth == 3 and "rgb" or "gray",1,false,true) + local bitmap = graphics.bitmaps.new( + nx, ny, + (depth == 3 and "rgb") or (depth == 4 and "cmyk") or "gray", + 1, false, true + ) local palette = bitmap.index or { } -- has to start at 0 local data = bitmap.data local p = 0 - if depth == 3 then + if depth == 3 or depth == 4 then for i=1,nofvalues do local c = colors[i] local r = round((c[1] or 0) * 255) local g = round((c[2] or 0) * 255) local b = round((c[3] or 0) * 255) + local k = depth == 4 and round((c[4] or 0) * 255) or nil palette[p] = { (r > 255 and 255) or (r < 0 and 0) or r, (g > 255 and 255) or (g < 0 and 0) or g, (b > 255 and 255) or (b < 0 and 0) or b, + k } p = p + 1 end @@ -1406,10 +1418,8 @@ end function mp.lmt_contours_color(value) local p = getparameterset() local color = p.result.colors[value] - if #color == 3 then - mptriplet(color) - else - return color[1] + if color then + mpcolor(color) end end @@ -1783,9 +1793,13 @@ end local sqrt, sin, cos = math.sqrt, math.sin, math.cos -local f_fill = string.formatters["F (%.6N,%.6N)--(%.6N,%.6N)--(%.6N,%.6N)--(%.6N,%.6N)--C withcolor (%.3N,%.3N,%.3N) ;"] -local f_draw = string.formatters["D (%.6N,%.6N)--(%.6N,%.6N)--(%.6N,%.6N)--(%.6N,%.6N)--C withcolor %.3F ;"] -local f_mesh = string.formatters["U (%.6N,%.6N)--(%.6N,%.6N)--(%.6N,%.6N)--(%.6N,%.6N)--C withcolor (%.3N,%.3N,%.3N) ;"] +local f_fill_rgb = formatters["F (%.6N,%.6N)--(%.6N,%.6N)--(%.6N,%.6N)--(%.6N,%.6N)--C withcolor (%.3N,%.3N,%.3N) ;"] +local f_draw_rgb = formatters["D (%.6N,%.6N)--(%.6N,%.6N)--(%.6N,%.6N)--(%.6N,%.6N)--C withcolor %.3F ;"] +local f_mesh_rgb = formatters["U (%.6N,%.6N)--(%.6N,%.6N)--(%.6N,%.6N)--(%.6N,%.6N)--C withcolor (%.3N,%.3N,%.3N) ;"] + +local f_fill_cmy = formatters["F (%.6N,%.6N)--(%.6N,%.6N)--(%.6N,%.6N)--(%.6N,%.6N)--C withcolor (%.3N,%.3N,%.3N,0) ;"] +local f_draw_cmy = formatters["D (%.6N,%.6N)--(%.6N,%.6N)--(%.6N,%.6N)--(%.6N,%.6N)--C withcolor %.3F ;"] +local f_mesh_cmy = formatters["U (%.6N,%.6N)--(%.6N,%.6N)--(%.6N,%.6N)--(%.6N,%.6N)--C withcolor (%.3N,%.3N,%.3N,0) ;"] local f_function_n = formatters [ [[ local math = math @@ -1940,10 +1954,11 @@ function mp.lmt_surface_do(specification) end xt = xt + dx end - local result = { } - local r = 0 - local range = maxf - minf - local cl = linecolor + local result = { } + local r = 0 + local range = maxf - minf + local cl = linecolor or 1 + local enforce = attributes.colors.model == "cmyk" for i=0,nx-1 do for j=0,ny-1 do -- points @@ -1964,14 +1979,42 @@ function mp.lmt_surface_do(specification) -- or remap when we want to cf = (z1[3] - minf) / range end + local z11 = z1[1] + local z12 = z1[2] + local z21 = z2[1] + local z22 = z2[2] + local z31 = z3[1] + local z32 = z3[2] + local z41 = z4[1] + local z42 = z4[2] + -- if lines then + -- -- fill first and draw then, previous shapes can be covered + -- else + -- -- fill and draw in one go to prevent artifacts + -- end local cr, cg, cb = color(cf) - if lines then - -- fill first and draw then, previous shapes can be covered - r = r + 1 ; result[r] = f_fill(z1[1],z1[2],z2[1],z2[2],z3[1],z3[2],z4[1],z4[2],cr or 0,cg or 0,cb or 0) - r = r + 1 ; result[r] = f_draw(z1[1],z1[2],z2[1],z2[2],z3[1],z3[2],z4[1],z4[2],cl or 1) + if not cr then cr = 0 end + if not cg then cg = 0 end + if not cb then cb = 0 end + if enforce then + cr, cg, cb = 1 - cr, 1 - cg, 1 - cb + r = r + 1 + if lines then + result[r] = f_fill_cmy(z11,z12,z21,z22,z31,z32,z41,z42,cr,cg,cb) + r = r + 1 + result[r] = f_draw_cmy(z11,z12,z21,z22,z31,z32,z41,z42,cl) + else + result[r] = f_mesh_cmy(z11,z12,z21,z22,z31,z32,z41,z42,cr,cg,cb) + end else - -- fill and draw in one go to prevent artifacts - r = r + 1 ; result[r] = f_mesh(z1[1],z1[2],z2[1],z2[2],z3[1],z3[2],z4[1],z4[2],cr or 0,cg or 0,cb or 0) + r = r + 1 + if lines then + result[r] = f_fill_rgb(z11,z12,z21,z22,z31,z32,z41,z42,cr,cg,cb) + r = r + 1 + result[r] = f_draw_rgb(z11,z12,z21,z22,z31,z32,z41,z42,cl) + else + result[r] = f_mesh_rgb(z11,z12,z21,z22,z31,z32,z41,z42,cr,cg,cb) + end end end end diff --git a/tex/context/base/mkiv/mlib-lua.lua b/tex/context/base/mkiv/mlib-lua.lua index 5af1ccb68..666025154 100644 --- a/tex/context/base/mkiv/mlib-lua.lua +++ b/tex/context/base/mkiv/mlib-lua.lua @@ -502,7 +502,6 @@ do local function mptransform(x,y,xx,xy,yx,yy) n = n + 1 - inspect(x) if type(x) == "table" then buffer[n] = f_transform(x[1],x[2],x[3],x[4],x[5],x[6]) else @@ -510,6 +509,28 @@ do end end + local function mpcolor(c,m,y,k) + n = n + 1 + if type(c) == "table" then + local l = #c + if l == 4 then + buffer[n] = f_quadruple(c[1],c[2],c[3],c[4]) + elseif l == 3 then + buffer[n] = f_triplet(c[1],c[2],c[3]) + else + buffer[n] = f_numeric(c[1]) + end + else + if k then + buffer[n] = f_quadruple(c,m,y,k) + elseif y then + buffer[n] = f_triplet(c,m,y) + else + buffer[n] = f_numeric(c) + end + end + end + -- we have three kind of connectors: -- -- .. ... -- (true) @@ -658,6 +679,7 @@ do aux.fprint = mpfprint aux.quoted = mpquoted aux.transform = mptransform + aux.color = mpcolor -- for the moment diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf index 478ce531a..b209ac2ab 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 7e0a6a2f9..2b57a46fb 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/strc-not.mkvi b/tex/context/base/mkiv/strc-not.mkvi index 7d8062eef..f11c831dd 100644 --- a/tex/context/base/mkiv/strc-not.mkvi +++ b/tex/context/base/mkiv/strc-not.mkvi @@ -1388,6 +1388,12 @@ \pickupattributes \to \everyinsidenoteinsert +%D Nasty, the might be more: + +\appendtoks + \c_strc_itemgroups_nesting\zerocount +\to \everyinsidenoteinsert + % maybe but better use [scope=local] here % % \appendtoks diff --git a/tex/context/interface/mkiv/i-context.pdf b/tex/context/interface/mkiv/i-context.pdf index 6bb755770..df76d474e 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 8a6e7aaa8..99f21c336 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 dcd61026f..c43682b9d 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/10/19 14:20:37 +-- merge date : 10/11/19 15:47:37 do -- begin closure to overcome local limits and interference @@ -32599,9 +32599,10 @@ local fonts=fonts local otf=fonts.handlers.otf local registerotffeature=otf.features.register local setmetatableindex=table.setmetatableindex -local checkmerge=fonts.helpers.checkmerge -local checkflags=fonts.helpers.checkflags -local checksteps=fonts.helpers.checksteps +local fonthelpers=fonts.helpers +local checkmerge=fonthelpers.checkmerge +local checkflags=fonthelpers.checkflags +local checksteps=fonthelpers.checksteps local normalized={ substitution="substitution", single="substitution", @@ -32723,6 +32724,7 @@ local function addfeature(data,feature,specifications) local done=0 local skip=0 local aglunicodes=false + local privateslot=fonthelpers.privateslot local specifications=validspecification(specifications,feature) if not specifications then return @@ -32745,6 +32747,12 @@ local function addfeature(data,feature,specifications) return u end end + if privateslot then + u=privateslot(code) + if u then + return u + end + end local u=lpegmatch(p,code) if u then return u @@ -32774,7 +32782,7 @@ local function addfeature(data,feature,specifications) replacement=replacement[1] end replacement=tounicode(replacement) - if replacement and descriptions[replacement] then + if replacement and (nocheck or descriptions[replacement]) then cover(coverage,unicode,replacement) done=done+1 else @@ -33144,7 +33152,6 @@ local function addfeature(data,feature,specifications) local featuretype=normalized[specification.type or "substitution"] or "substitution" local featureflags=specification.flags or noflags local nocheck=specification.nocheck - local futuresteps=specification.futuresteps local featureorder=specification.order or { feature } local featurechain=(featuretype=="chainsubstitution" or featuretype=="chainposition") and 1 or 0 local nofsteps=0 -- cgit v1.2.3