summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/font-ogr.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/mkiv/font-ogr.lua')
-rw-r--r--tex/context/base/mkiv/font-ogr.lua104
1 files changed, 61 insertions, 43 deletions
diff --git a/tex/context/base/mkiv/font-ogr.lua b/tex/context/base/mkiv/font-ogr.lua
index c441ddbf7..a2e5d2e82 100644
--- a/tex/context/base/mkiv/font-ogr.lua
+++ b/tex/context/base/mkiv/font-ogr.lua
@@ -51,7 +51,7 @@ do
return droppedin
end
- function dropins.provide(method,clone,t_tfmdata,indexdata,...)
+ function dropins.provide(method,t_tfmdata,indexdata,...)
droppedin = dropins.nextid()
local t_characters = t_tfmdata.characters
local t_descriptions = t_tfmdata.descriptions
@@ -59,12 +59,10 @@ do
local d_tfmdata = setmetatableindex({ },t_tfmdata)
local d_properties = setmetatableindex({ },t_properties)
d_tfmdata.properties = d_properties
- if clone then
- local d_characters = setmetatableindex({ },t_characters)
- local d_descriptions = setmetatableindex({ },t_descriptions)
- d_tfmdata.characters = d_characters
- d_tfmdata.descriptions = d_descriptions
- end
+ local d_characters = setmetatableindex({ },t_characters)
+ local d_descriptions = setmetatableindex({ },t_descriptions)
+ d_tfmdata.characters = d_characters
+ d_tfmdata.descriptions = d_descriptions
d_properties.instance = - droppedin -- will become an extra element in the hash
t_properties.virtualized = true
identifiers[droppedin] = d_tfmdata
@@ -75,19 +73,53 @@ do
d_properties.indexdata = { indexdata, ... } -- can take quite some memory
local slot = #fonts + 1
fonts[slot] = { id = droppedin }
- if not clone then
- for k, v in next, t_characters do
+ return slot, droppedin, d_tfmdata, d_properties
+ end
+
+ function dropins.clone(method,tfmdata,shapes,...)
+ 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
+ --
+ for k, v in next, characters do
local index = v.index
- if index and indexdata[index] then
- -- todo: use extender
- v.commands = { { "slot", slot, k } }
+ if index then
+ local description = descriptions[k]
+ if description then
+ local shape = shapes[index]
+ if shape then
+ if idx >= 255 then
+ idx = 1
+ colrshapes = { filename = shapes.filename, fixdepth = shapes.fixdepth } -- not needed
+ 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
+ --
+-- local helpers = fonts.helpers
+-- local prependcommands = helpers.prependcommands
+-- print(v.commands)
+ v.commands = { { "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 = tfmdata }
+ setmetatableindex(c,v)
+ setmetatableindex(d,description)
+ dropchars[idx] = c
+ dropdescs[idx] = d
+ end
+ end
end
end
else
- -- make sure that the drop characters should get a copy with no commands
- -- (false will do)
+ -- error
end
- return slot, droppedin, d_tfmdata, d_properties
end
end
@@ -198,15 +230,9 @@ do
return
end
--
- -- todo: delay with lua function or plugin in vf handler, saves a lot of
- -- overhead
- --
local characters = tfmdata.characters
local descriptions = tfmdata.descriptions
local droppedin, tfmdrop, dropchars, dropdescs, colrshapes
- -- alternative 1:
- -- local slots = { }
- -- alternative 2:
local idx = 255
local slot = 0
--
@@ -217,25 +243,10 @@ do
if description then
local colorlist = description.colors
if colorlist then
- -- alternative 1:
- -- local fnt = div(index,256)
- -- local idx = mod(index,256)
- -- local slt = slots[fnt]
- -- if not slt then
- -- colrshapes = { }
- -- slot, droppedin, tfmdrop = fonts.dropins.provide("color",true,tfmdata,colrshapes,colorvalues)
- -- slt = { slot, colrshapes, tfmdrop.characters, tfmdrop.descriptions }
- -- slots[fnt] = slt
- -- end
- -- slot = slt[1]
- -- colrshapes = slt[2]
- -- dropchars = slt[3]
- -- dropdescs = slt[4]
- -- alternative 2:
if idx >= 255 then
idx = 1
colrshapes = { }
- slot, droppedin, tfmdrop = fonts.dropins.provide("color",true,tfmdata,colrshapes,colorvalues)
+ slot, droppedin, tfmdrop = fonts.dropins.provide("color",tfmdata,colrshapes,colorvalues)
dropchars = tfmdrop.characters
dropdescs = tfmdrop.descriptions
else
@@ -290,6 +301,8 @@ 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 pdfhash = hash .. "-svg"
@@ -299,14 +312,14 @@ do
if not pdfshapes or pdffile.timestamp ~= timestamp or not next(pdfshapes) or not lfs.isfile(pdftarget) then
local svgfile = containers.read(otf.svgcache,hash)
local svgshapes = svgfile and svgfile.svgshapes
- pdfshapes = svgshapes and metapost.svgshapestopdf(svgshapes,pdftarget,report_svg) or { }
+ pdfshapes = svgshapes and metapost.svgshapestopdf(svgshapes,pdftarget,report_svg,tfmdata.parameters.units) or { }
containers.write(otf.pdfcache, pdfhash, {
pdfshapes = pdfshapes,
timestamp = timestamp,
})
end
- -- this can be delayed, no need to keep this in mem
- fonts.dropins.provide("pdf",false,tfmdata,pdfshapes)
+ shapes = pdfshapes
+ method = "pdf"
else
local mpsfile = containers.read(otf.mpscache,hash)
local mpsshapes = mpsfile and mpsfile.mpsshapes
@@ -314,13 +327,18 @@ do
local svgfile = containers.read(otf.svgcache,hash)
local svgshapes = svgfile and svgfile.svgshapes
-- still suboptimal
- mpsshapes = svgshapes and metapost.svgshapestomp(svgshapes,report_svg) or { }
+ mpsshapes = svgshapes and metapost.svgshapestomp(svgshapes,report_svg,tfmdata.parameters.units) or { }
containers.write(otf.mpscache, hash, {
mpsshapes = mpsshapes,
timestamp = timestamp,
})
end
- fonts.dropins.provide("mps",false,tfmdata,mpsshapes)
+ shapes = mpsshapes
+ method = "mps"
+ end
+ if shapes then
+ shapes.fixdepth = value == "fixdepth"
+ fonts.dropins.clone(method,tfmdata,shapes)
end
end
end
@@ -355,7 +373,7 @@ do
local pngfile = containers.read(otf.pngcache,hash)
local pngshapes = pngfile and pngfile.pngshapes
if pngshapes then
- fonts.dropins.provide("png",false,tfmdata,pngshapes)
+ fonts.dropins.clone("png",tfmdata,pngshapes)
end
end
end