summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/mkxl/font-ogr.lmt
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkxl/font-ogr.lmt')
-rw-r--r--Master/texmf-dist/tex/context/base/mkxl/font-ogr.lmt221
1 files changed, 82 insertions, 139 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkxl/font-ogr.lmt b/Master/texmf-dist/tex/context/base/mkxl/font-ogr.lmt
index 698593ac7e0..3b4f9f86784 100644
--- a/Master/texmf-dist/tex/context/base/mkxl/font-ogr.lmt
+++ b/Master/texmf-dist/tex/context/base/mkxl/font-ogr.lmt
@@ -36,9 +36,14 @@ otf.pngenabled = true
-- what here and what in backend ...
+local report_fonts = logs.reporter("backend","fonts")
+local trace_fonts trackers.register("backend.fonts",function(v) trace_fonts = v end)
+
+local slotcommand = fonts.helpers.commands.slot
+
do
- -- This is a prelude to something better but I'm still experimenting.
+ -- This is a prelude to something better but I'm still experimenting. We should delay more.
local dropins = { }
fonts.dropins = dropins
@@ -59,7 +64,8 @@ do
local t_properties = t_tfmdata.properties
local d_tfmdata = setmetatableindex({ },t_tfmdata)
local d_properties = setmetatableindex({ },t_properties)
- d_properties.basefontname = "ContextRuntimeFont" .. droppedin
+ local d_basefontname = "ContextRuntimeFont" .. droppedin
+ d_properties.basefontname = d_basefontname
d_tfmdata.properties = d_properties
local d_characters = { } -- setmetatableindex({ },t_characters) -- hm, index vs unicode
local d_descriptions = { } -- setmetatableindex({ },t_descriptions) -- hm, index vs unicode
@@ -75,6 +81,9 @@ do
d_properties.indexdata = { indexdata, ... } -- can take quite some memory
local slot = #fonts + 1
fonts[slot] = { id = droppedin }
+ if trace_fonts then
+ report_fonts("registering dropin %a using method %a",d_basefontname,method)
+ end
return slot, droppedin, d_tfmdata, d_properties
end
@@ -84,9 +93,10 @@ do
if method and shapes then
local characters = tfmdata.characters
local descriptions = tfmdata.descriptions
- local droppedin, tfmdrop, dropchars, dropdescs, colrshapes
+ local droppedin, tfmdrop, dropchars, dropdescs, colrshapes, props
local idx = 255
local slot = 0
+ -- sorted ?
for k, v in next, characters do
local index = v.index
if index then
@@ -97,7 +107,7 @@ do
if idx >= 255 then
idx = 1
colrshapes = setmetatableindex({ },shapes)
- slot, droppedin, tfmdrop = dropins.provide(method,tfmdata,colrshapes)
+ slot, droppedin, tfmdrop, props = dropins.provide(method,tfmdata,colrshapes)
dropchars = tfmdrop.characters
dropdescs = tfmdrop.descriptions
else
@@ -105,7 +115,7 @@ do
end
colrshapes[idx] = shape -- so not: description
-- todo: prepend
- v.commands = { { "slot", slot, idx } }
+ v.commands = { slotcommand[slot][idx] }
-- hack to prevent that type 3 also gets 'use' flags .. todo
local c = { commands = false, index = idx, dropin = tfmdrop }
local d = { } -- { index = idx, dropin = tfmdrop }
@@ -122,46 +132,6 @@ do
end
end
--- function dropins.swap(method,tfmdata,shapes,...) -- by unicode
--- if method and shapes then
--- local characters = tfmdata.characters
--- local descriptions = tfmdata.descriptions
--- local droppedin, tfmdrop, dropchars, dropdescs, colrshapes
--- local idx = 255
--- local slot = 0
--- -- we can have a variant where shaped are by unicode and not by index
--- for k, v in next, characters do
--- local description = descriptions[k]
--- if description then
--- local shape = shapes[k]
--- if shape then
--- if idx >= 255 then
--- idx = 1
--- colrshapes = setmetatableindex({ },shapes)
--- slot, droppedin, tfmdrop = dropins.provide(method,tfmdata,colrshapes)
--- dropchars = tfmdrop.characters
--- dropdescs = tfmdrop.descriptions
--- else
--- idx = idx + 1
--- end
--- colrshapes[idx] = shape -- so not: description
--- -- todo: prepend
--- v.commands = { { "slot", slot, idx } }
--- -- hack to prevent that type 3 also gets 'use' flags .. todo
--- local c = { commands = false, index = idx, dropin = tfmdrop }
--- local d = { } -- index = idx, dropin = tfmdrop }
--- setmetatableindex(c,v)
--- setmetatableindex(d,description)
--- dropchars[idx] = c
--- dropdescs[idx] = d -- not needed
--- end
--- end
--- end
--- else
--- -- error
--- end
--- end
-
function dropins.swap(method,tfmdata,shapes) -- by unicode
if method and shapes then
local characters = tfmdata.characters
@@ -190,7 +160,7 @@ do
end
colrshapes[idx] = shape -- so not: description
-- todo: prepend
- v.commands = { { "slot", slot, idx } }
+ v.commands = { slotcommand[slot][idx] }
-- hack to prevent that type 3 also gets 'use' flags .. todo
local c = { commands = false, index = idx, dropin = tfmdrop }
local d = { } -- index = idx, dropin = tfmdrop }
@@ -238,7 +208,7 @@ do
end
colrshapes[idx] = shape.code -- so not: description
-- todo: prepend
- character.commands = { { "slot", slot, idx } }
+ character.commands = { slotcommand[slot][idx] }
-- hack to prevent that type 3 also gets 'use' flags .. todo
local c = { commands = false, index = idx, dropin = tfmdrop }
-- local d = { } -- index = idx, dropin = tfmdrop }
@@ -474,7 +444,7 @@ do -- this will move to its own module
end
--- This sits here for historcal reasons so for now we keep it here.
+-- This sits here for historical reasons so for now we keep it here.
local startactualtext = nil
local stopactualtext = nil
@@ -487,20 +457,8 @@ function otf.getactualtext(s)
return startactualtext(s), stopactualtext()
end
--- This is also somewhat specific.
-
-local color_direct = function() return false end
-local color_indirect = color_direct
-
-updaters.register("backend.update",function()
- color_direct = lpdf.fonts.color_direct
- color_indirect = lpdf.fonts.color_indirect
-end)
-
local sharedpalettes = { } do
- local register = attributes.colors.register
-
local colors = attributes.list[attributes.private('color')] or { }
local transparencies = attributes.list[attributes.private('transparency')] or { }
@@ -510,20 +468,10 @@ local sharedpalettes = { } do
local v = values[i]
if v == "textcolor" then
values[i] = false
- else
- local c = nil
- local t = nil
- if type(v) == "table" then
- c = register(name,"rgb",
- max(round((v.r or 0)*255),255)/255,
- max(round((v.g or 0)*255),255)/255,
- max(round((v.b or 0)*255),255)/255
- )
- else
- c = colors[v]
- t = transparencies[v]
- end
- values[i] = color_indirect(c,t)
+ elseif type(v) == "table" then
+ values[i] = { kind = "values", data = v }
+ else -- freezing
+ values[i] = { kind = "attributes", color = colors[v], transparency = transparencies[v] }
end
end
end
@@ -532,83 +480,73 @@ end
local initializeoverlay do
- local function autoconvert(t,k)
- local v = { }
- for i=1,#k do
- local p = k[i]
- v[i] = color_direct(p[1]/255, p[2]/255, p[3]/255)
- end
- t[k] = v
- return v
- end
-
initializeoverlay = function(tfmdata,kind,value) -- we really need the id ... todo
if value then
local resources = tfmdata.resources
local palettes = resources.colorpalettes
if palettes then
- --
- local converted = resources.converted
- if not converted then
- converted = setmetatableindex(autoconvert)
- resources.converted = converted
- end
- local colorvalues = sharedpalettes[value]
- local default = false -- so the text color (bad for icon overloads)
- if colorvalues then
- default = colorvalues[#colorvalues]
+ local colorvalues = false
+ local colordata = sharedpalettes[value]
+ if colordata and #colordata > 0 then
+ colorvalues = {
+ kind = "user",
+ data = colordata,
+ }
else
- colorvalues = converted[palettes[tonumber(value) or 1] or palettes[1]] or { }
- end
- local classes = #colorvalues
- if classes == 0 then
- return
+ colordata = palettes[tonumber(value) or 1] or palettes[1]
+ if colordata and #colordata > 0 then
+ colorvalues = {
+ kind = "font",
+ data = colordata,
+ }
+ end
end
- --
- local characters = tfmdata.characters
- local descriptions = tfmdata.descriptions
- local droppedin, tfmdrop, dropchars, dropdescs, colrshapes
- local idx = 255
- local slot = 0
- --
- -- maybe delay in which case we have less fonts as we can be sparse
- --
- for k, v in next, characters do
- local index = v.index
- if index then
- local description = descriptions[k]
- if description then
- local colorlist = description.colors
- if colorlist then
- if idx >= 255 then
- idx = 1
- colrshapes = { }
- slot, droppedin, tfmdrop = fonts.dropins.provide("color",tfmdata,colrshapes,colorvalues)
- dropchars = tfmdrop.characters
- dropdescs = tfmdrop.descriptions
- else
- idx = idx + 1
- end
- --
- colrshapes[idx] = description
- -- todo: use extender
- local u = { "use", 0 }
- for i=1,#colorlist do
- u[i+2] = colorlist[i].slot
+ if colorvalues then
+ local characters = tfmdata.characters
+ local descriptions = tfmdata.descriptions
+ local droppedin, tfmdrop, dropchars, dropdescs, colrshapes
+ local idx = 255
+ local slot = 0
+ --
+ -- maybe delay in which case we have less fonts as we can be sparse
+ --
+ for k, v in next, characters do
+ local index = v.index
+ if index then
+ local description = descriptions[k]
+ if description then
+ local colorlist = description.colors
+ if colorlist then
+ if idx >= 255 then
+ idx = 1
+ colrshapes = { }
+ slot, droppedin, tfmdrop = fonts.dropins.provide("color",tfmdata,colrshapes,colorvalues)
+ dropchars = tfmdrop.characters
+ dropdescs = tfmdrop.descriptions
+ else
+ idx = idx + 1
+ end
+ --
+ colrshapes[idx] = description
+ -- todo: use extender
+ local u = { "use", 0 }
+ for i=1,#colorlist do
+ u[i+2] = colorlist[i].slot
+ end
+ v.commands = { u, slotcommand[slot][idx] }
+ -- hack to prevent that type 3 also gets 'use' flags .. todo
+ local c = { commands = false, index = idx, dropin = tfmdata }
+ local d = { } -- index = idx, dropin = tfmdrop
+ setmetatableindex(c,v)
+ setmetatableindex(d,description)
+ dropchars[idx] = c
+ dropdescs[idx] = d -- not needed
end
- v.commands = { u, { "slot", slot, idx } }
- -- hack to prevent that type 3 also gets 'use' flags .. todo
- local c = { commands = false, index = idx, dropin = tfmdata }
- local d = { } -- index = idx, dropin = tfmdrop
- setmetatableindex(c,v)
- setmetatableindex(d,description)
- dropchars[idx] = c
- dropdescs[idx] = d -- not needed
end
end
end
+ return true
end
- return true
end
end
end
@@ -619,6 +557,7 @@ local initializeoverlay do
manipulators = {
base = initializeoverlay,
node = initializeoverlay,
+ plug = initializeoverlay,
}
}
@@ -696,6 +635,7 @@ local initializesvg do
manipulators = {
base = initializesvg,
node = initializesvg,
+ plug = initializesvg,
}
}
@@ -737,6 +677,7 @@ local initializepng do
manipulators = {
base = initializepng,
node = initializepng,
+ plug = initializepng,
}
}
@@ -746,6 +687,7 @@ local initializepng do
manipulators = {
base = initializepng,
node = initializepng,
+ plug = initializepng,
}
}
@@ -779,6 +721,7 @@ do
manipulators = {
base = initializecolor,
node = initializecolor,
+ plug = initializecolor,
}
}