summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorContext Git Mirror Bot <phg42.2a@gmail.com>2016-06-09 20:47:50 +0200
committerContext Git Mirror Bot <phg42.2a@gmail.com>2016-06-09 20:47:50 +0200
commitbe735a865e2bdc6b7ac57161a24e4911741024f1 (patch)
tree583ffc0d91324da3b4f1239449bbcdf8e28a8ec3
parent4e4dcdd6d58631f6b260dbc16007152ac14d9677 (diff)
downloadcontext-be735a865e2bdc6b7ac57161a24e4911741024f1.tar.gz
2016-06-09 19:28:00
-rw-r--r--tex/context/base/context-version.pdfbin4246 -> 4251 bytes
-rw-r--r--tex/context/base/mkiv/cont-new.mkiv2
-rw-r--r--tex/context/base/mkiv/context.mkiv2
-rw-r--r--tex/context/base/mkiv/file-res.lua6
-rw-r--r--tex/context/base/mkiv/font-enh.lua25
-rw-r--r--tex/context/base/mkiv/font-ocl.lua234
-rw-r--r--tex/context/base/mkiv/font-otl.lua2
-rw-r--r--tex/context/base/mkiv/grph-mem.lua51
-rw-r--r--tex/context/base/mkiv/luat-run.lua5
-rw-r--r--tex/context/base/mkiv/status-files.pdfbin9209 -> 9196 bytes
-rw-r--r--tex/context/base/mkiv/status-lua.pdfbin268935 -> 269009 bytes
-rw-r--r--tex/context/interface/mkiv/i-context.pdfbin821069 -> 821199 bytes
-rw-r--r--tex/context/interface/mkiv/i-readme.pdfbin60788 -> 60788 bytes
-rw-r--r--tex/generic/context/luatex/luatex-fonts-merged.lua247
-rw-r--r--tex/generic/context/luatex/luatex-fonts.lua1
15 files changed, 457 insertions, 118 deletions
diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf
index 7cad31a63..f67cd8bff 100644
--- a/tex/context/base/context-version.pdf
+++ b/tex/context/base/context-version.pdf
Binary files differ
diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv
index ea0e2182c..aab85b119 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.06.08 16:32}
+\newcontextversion{2016.06.09 19:23}
%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 f6bf3244d..a90fecab0 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.06.08 16:32}
+\edef\contextversion{2016.06.09 19:23}
\edef\contextkind {beta}
%D For those who want to use this:
diff --git a/tex/context/base/mkiv/file-res.lua b/tex/context/base/mkiv/file-res.lua
index 08a3e22af..44117ed46 100644
--- a/tex/context/base/mkiv/file-res.lua
+++ b/tex/context/base/mkiv/file-res.lua
@@ -118,7 +118,11 @@ local function readfilename(specification,backtrack,treetoo)
return fnd or ""
end
---~ resolvers.readfilename = readfilename -- bonus use getreadfilename instead
+-- resolvers.readfilename = readfilename -- bonus use getreadfilename instead
+
+function resolvers.finders.original(specification) -- handy, see memstreams
+ return specification.path
+end
function finders.job(specification) return readfilename(specification,false, false) end -- current path, no backtracking
function finders.loc(specification) return readfilename(specification,resolvers.maxreadlevel,false) end -- current path, backtracking
diff --git a/tex/context/base/mkiv/font-enh.lua b/tex/context/base/mkiv/font-enh.lua
index 99b5c597b..b1fcd9be8 100644
--- a/tex/context/base/mkiv/font-enh.lua
+++ b/tex/context/base/mkiv/font-enh.lua
@@ -118,19 +118,16 @@ local registerotffeature = otffeatures.register
local function initializeunicoding(tfmdata)
local goodies = tfmdata.goodies
local newcoding = nil
- -- local tounicode = false
for i=1,#goodies do
local remapping = goodies[i].remapping
if remapping and remapping.unicodes then
newcoding = remapping.unicodes -- names to unicodes
- -- tounicode = remapping.tounicode -- not used
end
end
if newcoding then
local characters = tfmdata.characters
local descriptions = tfmdata.descriptions
local oldcoding = tfmdata.resources.unicodes
- -- local tounicodes = tfmdata.resources.tounicode -- index to unicode
local originals = { }
for name, newcode in next, newcoding do
local oldcode = oldcoding[name]
@@ -142,25 +139,21 @@ local function initializeunicoding(tfmdata)
end
if oldcode then
local original = originals[oldcode]
+ local character, description
if original then
- characters [newcode] = original.character
- descriptions[newcode] = original.description
+ character = original.character
+ description = original.description
else
- characters [newcode] = characters [oldcode]
- descriptions[newcode] = descriptions[oldcode]
+ character = characters [oldcode]
+ description = descriptions[oldcode]
end
+ characters [newcode] = character
+ descriptions[newcode] = description
+ character .unicode = newcode
+ description.unicode = newcode
else
oldcoding[name] = newcode
end
- -- if tounicode then
- -- local description = descriptions[newcode]
- -- if description then
- -- local index = description.index
- -- if not tounicodes[index] then
- -- tounicodes[index] = tosixteen(newcode) -- shared (we could have a metatable)
- -- end
- -- end
- -- end
if trace_unicoding then
if oldcode then
report_unicoding("aliasing glyph %a from %U to %U",name,oldcode,newcode)
diff --git a/tex/context/base/mkiv/font-ocl.lua b/tex/context/base/mkiv/font-ocl.lua
index fd9dcf2e8..9661083bf 100644
--- a/tex/context/base/mkiv/font-ocl.lua
+++ b/tex/context/base/mkiv/font-ocl.lua
@@ -15,27 +15,27 @@ local otf = fonts.handlers.otf
local f_color_start = formatters["pdf:direct: %f %f %f rg"]
local s_color_stop = "pdf:direct:"
-local function actualtexthandlers()
+if context then
+
local startactualtext = nil
local stopactualtext = nil
- if context then
- local codeinjections = backends.codeinjections
- if codeinjections then
- startactualtext = codeinjections.startunicodetoactualtext
- stopactualtext = codeinjections.stopunicodetoactualtext
+
+ function otf.getactualtext(n)
+ if not startactualtext then
+ startactualtext = backends.codeinjections.startunicodetoactualtext
+ stopactualtext = backends.codeinjections.stopunicodetoactualtext
end
+ return startactualtext(n), stopactualtext()
end
- if not startactualtext then
- -- let's be nice for generic
- local tounicode = fonts.mappings.tounicode16
- startactualtext = function(n)
- return "/Span << /ActualText <feff" .. tounicode(n) .. "> >> BDC"
- end
- stopactualtext = function(n)
- return "EMC"
- end
+
+else
+
+ local tounicode = fonts.mappings.tounicode16
+
+ function otf.getactualtext(n)
+ return "/Span << /ActualText <feff" .. tounicode(n) .. "> >> BDC", "EMC"
end
- return startactualtext, stopactualtext
+
end
local function initializecolr(tfmdata,kind,value) -- hm, always value
@@ -59,25 +59,24 @@ local function initializecolr(tfmdata,kind,value) -- hm, always value
{ id = 0 }
}
--
- local startactualtext, stopactualtext = actualtexthandlers()
- --
for i=1,classes do
local p = palette[i]
colorvalues[i] = { "special", f_color_start(p[1]/255,p[2]/255,p[3]/255) }
end
--
- local stop = { "special", "pdf:direct:" .. stopactualtext() .. " Q" }
+ local getactualtext = otf.getactualtext
--
for unicode, character in next, characters do
local description = descriptions[unicode]
if description then
local colorlist = description.colors
if colorlist then
+ local b, e = getactualtext(unicode)
local w = character.width or 0
local s = #colorlist
local n = 1
local t = {
- { "special", "pdf:direct: q " .. startactualtext(unicode) }
+ { "special", "pdf:direct: q " .. b }
}
for i=1,s do
local entry = colorlist[i]
@@ -87,7 +86,7 @@ local function initializecolr(tfmdata,kind,value) -- hm, always value
n = n + 1 t[n] = { "right", -w }
end
end
- n = n + 1 t[n] = stop
+ n = n + 1 t[n] = { "special", "pdf:direct:" .. e .. " Q" }
character.commands = t
end
end
@@ -105,62 +104,122 @@ fonts.handlers.otf.features.register {
}
}
-otf.svgenabled = true -- for now, this might change
-
-local report_svg = logs.reporter("fonts","svg conversion")
-
-local nofpdfstreams = 0
-local f_name = formatters["svg-glyph-%05i"]
-local f_stream = formatters["memstream:///svg-glyph-%05i"]
-
--- todo: make a plugin
-
-local function svgtopdf(svgshapes)
- local svgfile = "temp-otf-svg-shape.svg"
- local pdffile = "temp-otf-svg-shape.pdf"
- local command = "inkscape " .. svgfile .. " --export-pdf=" .. pdffile
- -- local command = [[python "c:\Users\Hans Hagen\AppData\Roaming\Python\Scripts\cairosvg" -f pdf ]] .. svgfile .. " -o " .. pdffile
- local testrun = false
-
- local pdfshapes = { }
- local nofshapes = #svgshapes
- report_svg("processing %i svg containers",nofshapes)
- for i=1,nofshapes do
- local entry = svgshapes[i]
- for j=entry.first,entry.last do
- local svg = xml.convert(entry.data)
- local data = xml.first(svg,"/svg[@id='glyph"..j.."']")
- io.savedata(svgfile,tostring(data))
- report_svg("processing svg shape of glyph %i in container %i",j,i)
- os.execute(command)
- pdfshapes[j] = io.loaddata(pdffile)
- end
- if testrun and i > testrun then
- report_svg("quiting test run")
- break
+local otfsvg = otf.svg or { }
+otf.svg = otfsvg
+otf.svgenabled = true
+
+do
+
+ local nofstreams = 0
+
+ -- local f_setstream = formatters[ [[io.savedata("svg-glyph-%05i",%q)]] ]
+ -- local f_getstream = formatters[ [[svg-glyph-%05i]] ]
+
+ -- function otfsvg.storepdfdata(pdf)
+ -- nofstreams = nofstreams + 1
+ -- storepdfdata = function(pdf)
+ -- nofstreams = nofstreams + 1
+ -- return f_setstream(nofstreams,pdf), f_getstream(nofstreams)
+ -- end
+ -- end
+
+ local f_name = formatters[ [[svg-glyph-%05i]] ]
+ local f_used = context and formatters[ [[original:///%s]] ] or formatters[ [[%s]] ]
+
+ local cache = { }
+
+ function otfsvg.storepdfdata(pdf)
+ nofstreams = nofstreams + 1
+ local o, n = epdf.openMemStream(pdf,#pdf,f_name(nofstreams))
+ cache[n] = o -- we need to keep in mem
+ return nil, f_used(n), nil
+ end
+
+ if context then
+
+ local storepdfdata = otfsvg.storepdfdata
+ local initialized = false
+
+ function otfsvg.storepdfdata(pdf)
+ if not initialized then
+ if resolvers.setmemstream then
+ local f_setstream = formatters[ [[resolvers.setmemstream("svg-glyph-%05i",%q,true)]] ]
+ local f_getstream = formatters[ [[memstream:///svg-glyph-%05i]] ]
+ local f_nilstream = formatters[ [[resolvers.resetmemstream("svg-glyph-%05i",true)]] ]
+ storepdfdata = function(pdf)
+ nofstreams = nofstreams + 1
+ return
+ f_setstream(nofstreams,pdf),
+ f_getstream(nofstreams),
+ f_nilstream(nofstreams)
+ end
+ otfsvg.storepdfdata = storepdfdata
+ end
+ initialized = true
+ end
+ return storepdfdata(pdf)
end
+
end
- os.remove(svgfile)
- return pdfshapes
+
end
-local function savepdfhandler()
- if context then
- local setmemstream = resolvers.setmemstream
- if setmemstream then
- return function(pdf)
- nofpdfstreams = nofpdfstreams + 1
- setmemstream(f_name(nofpdfstreams),pdf)
- return f_stream(nofpdfstreams)
+if context and xml.convert then
+
+ local report_svg = logs.reporter("fonts","svg conversion")
+
+ function otfsvg.topdf(svgshapes)
+ local svgfile = "temp-otf-svg-shape.svg"
+ local pdffile = "temp-otf-svg-shape.pdf"
+ local command = "inkscape " .. svgfile .. " --export-pdf=" .. pdffile
+ -- local command = [[python "c:\Users\Hans Hagen\AppData\Roaming\Python\Scripts\cairosvg" -f pdf ]] .. svgfile .. " -o " .. pdffile
+ local testrun = false
+ local pdfshapes = { }
+ local nofshapes = #svgshapes
+ report_svg("processing %i svg containers",nofshapes)
+ for i=1,nofshapes do
+ local entry = svgshapes[i]
+ for j=entry.first,entry.last do
+ local svg = xml.convert(entry.data)
+ local data = xml.first(svg,"/svg[@id='glyph"..j.."']")
+ io.savedata(svgfile,tostring(data))
+ report_svg("processing svg shape of glyph %i in container %i",j,i)
+ os.execute(command)
+ pdfshapes[j] = io.loaddata(pdffile)
+ end
+ if testrun and i > testrun then
+ report_svg("quiting test run")
+ break
end
end
+ os.remove(svgfile)
+ return pdfshapes
end
- return function(pdf)
- nofpdfstreams = nofpdfstreams + 1
- local name = f_name(nofpdfstreams)
- io.savedata(name,pdf)
- return name
+
+else
+
+ function otfsvg.topdf(svgshapes)
+ local svgfile = "temp-otf-svg-shape.svg"
+ local pdffile = "temp-otf-svg-shape.pdf"
+ local command = "inkscape " .. svgfile .. " --export-pdf=" .. pdffile
+ local pdfshapes = { }
+ local nofshapes = #svgshapes
+ texio.write(formatters["[converting %i svg glyphs to pdf using command %q : "](nofshapes,command))
+ for i=1,nofshapes do
+ local entry = svgshapes[i]
+ for j=entry.first,entry.last do
+ -- cross our fingers .. some, day i will filter
+ texio.write(formatters["%i "](j))
+ io.savedata(svgfile,tostring(entry.data))
+ os.execute(command)
+ pdfshapes[j] = io.loaddata(pdffile)
+ end
+ end
+ os.remove(svgfile)
+ texio.write("done]")
+ return pdfshapes
end
+
end
local function initializesvg(tfmdata,kind,value) -- hm, always value
@@ -181,7 +240,7 @@ local function initializesvg(tfmdata,kind,value) -- hm, always value
if not pdfshapes or pdffile.timestamp ~= timestamp then
local svgfile = containers.read(otf.svgcache,hash)
local svgshapes = svgfile and svgfile.svgshapes
- pdfshapes = svgshapes and svgtopdf(svgshapes) or { }
+ pdfshapes = svgshapes and otfsvg.topdf(svgshapes) or { }
containers.write(otf.pdfcache, hash, {
pdfshapes = pdfshapes,
timestamp = timestamp,
@@ -196,29 +255,32 @@ local function initializesvg(tfmdata,kind,value) -- hm, always value
{ id = 0 }
}
--
- local startactualtext, stopactualtext = actualtexthandlers()
- local savepdf = savepdfhandler()
+ local getactualtext = otf.getactualtext
+ local storepdfdata = otfsvg.storepdfdata
--
- local stop = { "special", "pdf:direct:" .. stopactualtext() }
+ local nop = { "nop" }
--
for unicode, character in next, characters do
local index = character.index
if index then
local pdf = pdfshapes[index]
if pdf then
- local filename = savepdf(pdf)
- character.commands = {
- { "special", "pdf:direct:" .. startactualtext(unicode) },
- { "down", character.depth or 0 },
- { "image", img.new {
- filename = filename,
- width = character.width,
- height = character.height or 0,
- depth = character.depth or 0,
- } },
- stop
- }
- character.svg = true
+ local setcode, name, nilcode = storepdfdata(pdf)
+ if name then
+ local bt, et = getactualtext(unicode)
+ local wd = character.width or 0
+ local ht = character.height or 0
+ local dp = character.depth or 0
+ character.commands = {
+ { "special", "pdf:direct:" .. bt },
+ { "down", dp },
+ setcode and { "lua", setcode } or nop,
+ { "image", { filename = name, width = wd, height = ht, depth = dp } },
+ nilcode and { "lua", nilcode } or nop,
+ { "special", "pdf:direct:" .. et },
+ }
+ character.svg = true
+ end
end
end
end
diff --git a/tex/context/base/mkiv/font-otl.lua b/tex/context/base/mkiv/font-otl.lua
index dd44a165e..c7c278a71 100644
--- a/tex/context/base/mkiv/font-otl.lua
+++ b/tex/context/base/mkiv/font-otl.lua
@@ -58,6 +58,8 @@ otf.cache = containers.define("fonts", "otl", otf.version, true)
otf.svgcache = containers.define("fonts", "svg", otf.version, true)
otf.pdfcache = containers.define("fonts", "pdf", otf.version, true)
+otf.svgenabled = false
+
local otfreaders = otf.readers
local hashes = fonts.hashes
diff --git a/tex/context/base/mkiv/grph-mem.lua b/tex/context/base/mkiv/grph-mem.lua
index 80a6bfdbf..b1ca1a15d 100644
--- a/tex/context/base/mkiv/grph-mem.lua
+++ b/tex/context/base/mkiv/grph-mem.lua
@@ -19,44 +19,71 @@ local report = logs.reporter("memstream")
local data = { }
local trace = false
+local opened = { }
+
function resolvers.finders.memstream(specification)
- local original = specification.original
- local identifier = data[original]
+ local name = specification.path
+ local identifier = data[name]
if identifier then
if trace then
report("reusing %a",identifier)
end
return identifier
end
- local stream = io.loaddata(specification.path)
+ local stream = io.loaddata(name)
if not stream or stream == "" then
return resolvers.finders.notfound()
end
- local memstream = { epdf.openMemStream(stream,#stream,original) }
- local identifier = memstream[2]
+ local memstream, identifier = epdf.openMemStream(stream,#stream,original)
if not identifier then
report("invalid %a",name)
identifier = "invalid-memstream"
elseif trace then
report("using %a",identifier)
end
- data[original] = identifier
+ data [name] = identifier
+ opened[name] = memstream
return identifier
end
-function resolvers.setmemstream(name,stream)
- local original = "memstream:///" .. name
- local memstream = { epdf.openMemStream(stream,#stream,original) }
- local identifier = memstream[2]
+function resolvers.setmemstream(name,stream,once)
+ if once and data[name] then
+ if trace then
+ report("not overloading %a",name) --
+ end
+ return
+ end
+ local memstream, identifier = epdf.openMemStream(stream,#stream,name)
if not identifier then
report("invalid %a",name)
identifier = "invalid-memstream"
elseif trace then
- report("setting %a",identifier)
+ report("setting %a as %a",name,identifier)
+ end
+ data [name] = identifier
+ opened[name] = memstream
+end
+
+local flush = { }
+
+function resolvers.resetmemstream(name,afterpage)
+ if afterpage then
+ flush[#flush+1] = name
+ else
+ opened[name] = nil
end
- data[original] = identifier
end
+luatex.registerpageactions(function()
+ if #flush > 0 then
+ for i=1,#flush do
+ opened[flush[i]] = nil -- we keep of course data[name] because of reuse
+ end
+ flush = { }
+ end
+end)
+
+
figures.identifiers.list[#figures.identifiers.list+1] = function(specification)
local name = specification.request.name
if name and data[name] then
diff --git a/tex/context/base/mkiv/luat-run.lua b/tex/context/base/mkiv/luat-run.lua
index 7e81350f0..8b498eda7 100644
--- a/tex/context/base/mkiv/luat-run.lua
+++ b/tex/context/base/mkiv/luat-run.lua
@@ -26,10 +26,12 @@ local luatex = luatex
local startactions = { }
local stopactions = { }
local dumpactions = { }
+local pageactions = { }
function luatex.registerstartactions(...) insert(startactions, ...) end
function luatex.registerstopactions (...) insert(stopactions, ...) end
function luatex.registerdumpactions (...) insert(dumpactions, ...) end
+function luatex.registerpageactions (...) insert(pageactions, ...) end
local function start_run()
if logs.start_run then
@@ -63,6 +65,9 @@ end
local function stop_shipout_page()
logs.stop_page_number()
+ for i=1,#pageactions do
+ pageactions[i]()
+ end
end
local function report_output_pages()
diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf
index 1d8e59b01..d2ea65d65 100644
--- a/tex/context/base/mkiv/status-files.pdf
+++ b/tex/context/base/mkiv/status-files.pdf
Binary files differ
diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf
index 8899da21f..820752067 100644
--- a/tex/context/base/mkiv/status-lua.pdf
+++ b/tex/context/base/mkiv/status-lua.pdf
Binary files differ
diff --git a/tex/context/interface/mkiv/i-context.pdf b/tex/context/interface/mkiv/i-context.pdf
index dcdcf7e46..c58d9af06 100644
--- a/tex/context/interface/mkiv/i-context.pdf
+++ b/tex/context/interface/mkiv/i-context.pdf
Binary files differ
diff --git a/tex/context/interface/mkiv/i-readme.pdf b/tex/context/interface/mkiv/i-readme.pdf
index 303ccaf36..5942fddbc 100644
--- a/tex/context/interface/mkiv/i-readme.pdf
+++ b/tex/context/interface/mkiv/i-readme.pdf
Binary files differ
diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua
index dbbe11f6b..89dcbbc86 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 : 06/08/16 16:32:52
+-- merge date : 06/09/16 19:23:43
do -- begin closure to overcome local limits and interference
@@ -15349,6 +15349,7 @@ otf.version=3.022
otf.cache=containers.define("fonts","otl",otf.version,true)
otf.svgcache=containers.define("fonts","svg",otf.version,true)
otf.pdfcache=containers.define("fonts","pdf",otf.version,true)
+otf.svgenabled=false
local otfreaders=otf.readers
local hashes=fonts.hashes
local definers=fonts.definers
@@ -23097,6 +23098,250 @@ end -- closure
do -- begin closure to overcome local limits and interference
+if not modules then modules={} end modules ['font-ocl']={
+ version=1.001,
+ comment="companion to font-otf.lua (context)",
+ author="Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright="PRAGMA ADE / ConTeXt Development Team",
+ license="see context related readme files"
+}
+local formatters=string.formatters
+local otf=fonts.handlers.otf
+local f_color_start=formatters["pdf:direct: %f %f %f rg"]
+local s_color_stop="pdf:direct:"
+if context then
+ local startactualtext=nil
+ local stopactualtext=nil
+ function otf.getactualtext(n)
+ if not startactualtext then
+ startactualtext=backends.codeinjections.startunicodetoactualtext
+ stopactualtext=backends.codeinjections.stopunicodetoactualtext
+ end
+ return startactualtext(n),stopactualtext()
+ end
+else
+ local tounicode=fonts.mappings.tounicode16
+ function otf.getactualtext(n)
+ return "/Span << /ActualText <feff"..tounicode(n).."> >> BDC","EMC"
+ end
+end
+local function initializecolr(tfmdata,kind,value)
+ if value then
+ local palettes=tfmdata.resources.colorpalettes
+ if palettes then
+ local palette=palettes[tonumber(value) or 1] or palettes[1] or {}
+ local classes=#palette
+ if classes==0 then
+ return
+ end
+ local characters=tfmdata.characters
+ local descriptions=tfmdata.descriptions
+ local properties=tfmdata.properties
+ local colorvalues={}
+ properties.virtualized=true
+ tfmdata.fonts={
+ { id=0 }
+ }
+ for i=1,classes do
+ local p=palette[i]
+ colorvalues[i]={ "special",f_color_start(p[1]/255,p[2]/255,p[3]/255) }
+ end
+ local getactualtext=otf.getactualtext
+ for unicode,character in next,characters do
+ local description=descriptions[unicode]
+ if description then
+ local colorlist=description.colors
+ if colorlist then
+ local b,e=getactualtext(unicode)
+ local w=character.width or 0
+ local s=#colorlist
+ local n=1
+ local t={
+ { "special","pdf:direct: q "..b }
+ }
+ for i=1,s do
+ local entry=colorlist[i]
+ n=n+1 t[n]=colorvalues[entry.class]
+ n=n+1 t[n]={ "char",entry.slot }
+ if s>1 and i<s and w~=0 then
+ n=n+1 t[n]={ "right",-w }
+ end
+ end
+ n=n+1 t[n]={ "special","pdf:direct:"..e.." Q" }
+ character.commands=t
+ end
+ end
+ end
+ end
+ end
+end
+fonts.handlers.otf.features.register {
+ name="colr",
+ description="color glyphs",
+ manipulators={
+ base=initializecolr,
+ node=initializecolr,
+ }
+}
+local otfsvg=otf.svg or {}
+otf.svg=otfsvg
+otf.svgenabled=true
+do
+ local nofstreams=0
+ local f_name=formatters[ [[svg-glyph-%05i]] ]
+ local f_used=context and formatters[ [[original:///%s]] ] or formatters[ [[%s]] ]
+ local cache={}
+ function otfsvg.storepdfdata(pdf)
+ nofstreams=nofstreams+1
+ local o,n=epdf.openMemStream(pdf,#pdf,f_name(nofstreams))
+ cache[n]=o
+ return nil,f_used(n),nil
+ end
+ if context then
+ local storepdfdata=otfsvg.storepdfdata
+ local initialized=false
+ function otfsvg.storepdfdata(pdf)
+ if not initialized then
+ if resolvers.setmemstream then
+ local f_setstream=formatters[ [[resolvers.setmemstream("svg-glyph-%05i",%q,true)]] ]
+ local f_getstream=formatters[ [[memstream:///svg-glyph-%05i]] ]
+ local f_nilstream=formatters[ [[resolvers.resetmemstream("svg-glyph-%05i",true)]] ]
+ storepdfdata=function(pdf)
+ nofstreams=nofstreams+1
+ return
+ f_setstream(nofstreams,pdf),
+ f_getstream(nofstreams),
+ f_nilstream(nofstreams)
+ end
+ otfsvg.storepdfdata=storepdfdata
+ end
+ initialized=true
+ end
+ return storepdfdata(pdf)
+ end
+ end
+end
+if context and xml.convert then
+ local report_svg=logs.reporter("fonts","svg conversion")
+ function otfsvg.topdf(svgshapes)
+ local svgfile="temp-otf-svg-shape.svg"
+ local pdffile="temp-otf-svg-shape.pdf"
+ local command="inkscape "..svgfile.." --export-pdf="..pdffile
+ local testrun=false
+ local pdfshapes={}
+ local nofshapes=#svgshapes
+ report_svg("processing %i svg containers",nofshapes)
+ for i=1,nofshapes do
+ local entry=svgshapes[i]
+ for j=entry.first,entry.last do
+ local svg=xml.convert(entry.data)
+ local data=xml.first(svg,"/svg[@id='glyph"..j.."']")
+ io.savedata(svgfile,tostring(data))
+ report_svg("processing svg shape of glyph %i in container %i",j,i)
+ os.execute(command)
+ pdfshapes[j]=io.loaddata(pdffile)
+ end
+ if testrun and i>testrun then
+ report_svg("quiting test run")
+ break
+ end
+ end
+ os.remove(svgfile)
+ return pdfshapes
+ end
+else
+ function otfsvg.topdf(svgshapes)
+ local svgfile="temp-otf-svg-shape.svg"
+ local pdffile="temp-otf-svg-shape.pdf"
+ local command="inkscape "..svgfile.." --export-pdf="..pdffile
+ local pdfshapes={}
+ local nofshapes=#svgshapes
+ texio.write(formatters["[converting %i svg glyphs to pdf using command %q : "](nofshapes,command))
+ for i=1,nofshapes do
+ local entry=svgshapes[i]
+ for j=entry.first,entry.last do
+ texio.write(formatters["%i "](j))
+ io.savedata(svgfile,tostring(entry.data))
+ os.execute(command)
+ pdfshapes[j]=io.loaddata(pdffile)
+ end
+ end
+ os.remove(svgfile)
+ texio.write("done]")
+ return pdfshapes
+ end
+end
+local function initializesvg(tfmdata,kind,value)
+ if value and otf.svgenabled then
+ local characters=tfmdata.characters
+ local descriptions=tfmdata.descriptions
+ local properties=tfmdata.properties
+ local svg=properties.svg
+ local hash=svg and svg.hash
+ local timestamp=svg and svg.timestamp
+ if not hash then
+ return
+ end
+ local pdffile=containers.read(otf.pdfcache,hash)
+ local pdfshapes=pdffile and pdffile.pdfshapes
+ if not pdfshapes or pdffile.timestamp~=timestamp then
+ local svgfile=containers.read(otf.svgcache,hash)
+ local svgshapes=svgfile and svgfile.svgshapes
+ pdfshapes=svgshapes and otfsvg.topdf(svgshapes) or {}
+ containers.write(otf.pdfcache,hash,{
+ pdfshapes=pdfshapes,
+ timestamp=timestamp,
+ })
+ end
+ if not pdfshapes or not next(pdfshapes) then
+ return
+ end
+ properties.virtualized=true
+ tfmdata.fonts={
+ { id=0 }
+ }
+ local getactualtext=otf.getactualtext
+ local storepdfdata=otfsvg.storepdfdata
+ local nop={ "nop" }
+ for unicode,character in next,characters do
+ local index=character.index
+ if index then
+ local pdf=pdfshapes[index]
+ if pdf then
+ local setcode,name,nilcode=storepdfdata(pdf)
+ if name then
+ local bt,et=getactualtext(unicode)
+ local wd=character.width or 0
+ local ht=character.height or 0
+ local dp=character.depth or 0
+ character.commands={
+ { "special","pdf:direct:"..bt },
+ { "down",dp },
+ setcode and { "lua",setcode } or nop,
+ { "image",{ filename=name,width=wd,height=ht,depth=dp } },
+ nilcode and { "lua",nilcode } or nop,
+ { "special","pdf:direct:"..et },
+ }
+ character.svg=true
+ end
+ end
+ end
+ end
+ end
+end
+fonts.handlers.otf.features.register {
+ name="svg",
+ description="svg glyphs",
+ manipulators={
+ base=initializesvg,
+ node=initializesvg,
+ }
+}
+
+end -- closure
+
+do -- begin closure to overcome local limits and interference
+
if not modules then modules={} end modules ['font-onr']={
version=1.001,
comment="companion to font-ini.mkiv",
diff --git a/tex/generic/context/luatex/luatex-fonts.lua b/tex/generic/context/luatex/luatex-fonts.lua
index 07d9343a7..83d52d9a5 100644
--- a/tex/generic/context/luatex/luatex-fonts.lua
+++ b/tex/generic/context/luatex/luatex-fonts.lua
@@ -258,6 +258,7 @@ if non_generic_context.luatex_fonts.skip_loading ~= true then
loadmodule('font-ota.lua')
loadmodule('font-ots.lua')
loadmodule('font-osd.lua')
+ loadmodule('font-ocl.lua') -- svg needs 0.97 (for fix in memstreams)
-- type one code