summaryrefslogtreecommitdiff
path: root/tex/context/base/font-vf.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/font-vf.lua')
-rw-r--r--tex/context/base/font-vf.lua214
1 files changed, 91 insertions, 123 deletions
diff --git a/tex/context/base/font-vf.lua b/tex/context/base/font-vf.lua
index 455646a22..8eab88b40 100644
--- a/tex/context/base/font-vf.lua
+++ b/tex/context/base/font-vf.lua
@@ -14,27 +14,79 @@ changes. This will change.</p>
local next = next
local fastcopy = table.fastcopy
-local allocate = utilities.storage.allocate
+local allocate = utilities.storage.allocate
+
+local fonts = fonts
+local constructors = fonts.constructors
+local vf = { }
+fonts.handlers.vf = vf
+
+-- general code
+
+function vf.find(name)
+ name = file.removesuffix(file.basename(name))
+ if constructors.resolvevirtualtoo then
+ local format = fonts.loggers.format(name)
+ if format == 'tfm' or format == 'ofm' then
+ if trace_defining then
+ report_defining("locating vf for %s",name)
+ end
+ return findbinfile(name,"ovf")
+ else
+ if trace_defining then
+ report_defining("vf for %s is already taken care of",name)
+ end
+ return nil -- ""
+ end
+ else
+ if trace_defining then
+ report_defining("locating vf for %s",name)
+ end
+ return findbinfile(name,"ovf")
+ end
+end
-local fonts = fonts
-local vf = fonts.vf
-local tfm = fonts.tfm
+--[[ldx--
+<p>We overload the <l n='vf'/> reader.</p>
+--ldx]]--
+
+callbacks.register('find_vf_file', vf.find, "locating virtual fonts, insofar needed") -- not that relevant any more
-fonts.definers = fonts.definers or { }
-local definers = fonts.definers
+-- specific code (will move to other module)
-definers.methods = definers.methods or { }
-local methods = definers.methods
+local definers = fonts.definers
+local methods = definers.methods
-methods.variants = allocate()
-local variants = methods.variants
+local variants = allocate()
+local combinations = { }
+local combiner = { }
+local whatever = allocate() -- can be used to store data
+local predefined = allocate() -- can be used to store data
+local helpers = allocate() -- can be used to store data
-vf.combinations = vf.combinations or { }
-vf.aux = vf.aux or { }
-vf.aux.combine = vf.aux.combine or { }
-local combine = vf.aux.combine
+methods.variants = variants -- todo .. wrong namespace
+vf.combinations = combinations
+vf.combiner = combiner
+vf.whatever = whatever
+vf.helpers = helpers
+vf.predefined = predefined
-local chardata = characters.data
+setmetatable(whatever, { __index = function(t,k) local v = { } t[k] = v return v end })
+
+predefined.dummy = { "comment" }
+predefined.push = { "push" }
+predefined.pop = { "pop" }
+
+local function checkparameters(g,f)
+ if f and g and not g.parameters and #g.fonts > 0 then
+ local p = { }
+ for k,v in next, f.parameters do
+ p[k] = v
+ end
+ g.parameters = p
+ setmetatable(p, getmetatable(f.parameters))
+ end
+end
function methods.install(tag, rules)
vf.combinations[tag] = rules
@@ -44,7 +96,7 @@ function methods.install(tag, rules)
end
local function combine_load(g,name)
- return tfm.readanddefine(name or g.specification.name,g.specification.size)
+ return constructors.readanddefine(name or g.specification.name,g.specification.size)
end
local function combine_assign(g, name, from, to, start, force)
@@ -66,26 +118,20 @@ local function combine_assign(g, name, from, to, start, force)
end
start = start + 1
end
- if not g.parameters and #g.fonts > 0 then -- share this code !
- g.parameters = fastcopy(f.parameters)
- g.italicangle = f.italicangle
- g.ascender = f.ascender
- g.descender = f.descender
- g.factor = f.factor -- brrr
- end
+ checkparameters(g,f)
end
end
local function combine_process(g,list)
if list then
for _,v in next, list do
- (combine.commands[v[1]] or nop)(g,v)
+ (combiner.commands[v[1]] or nop)(g,v)
end
end
end
local function combine_names(g,name,force)
- local f, id = tfm.readanddefine(name,g.specification.size)
+ local f, id = constructors.readanddefine(name,g.specification.size)
if f and id then
local fc, gc = f.characters, g.characters
local fd, gd = f.descriptions, g.descriptions
@@ -98,13 +144,7 @@ local function combine_names(g,name,force)
gd[i] = fd[i]
end
end
- if not g.parameters and #g.fonts > 0 then -- share this code !
- g.parameters = fastcopy(f.parameters)
- g.italicangle = f.italicangle
- g.ascender = f.ascender
- g.descender = f.descender
- g.factor = f.factor -- brrr
- end
+ checkparameters(g,f)
end
end
@@ -124,111 +164,39 @@ local combine_feature = function(g,v)
end
end
---~ combine.load = combine_load
---~ combine.assign = combine_assign
---~ combine.process = combine_process
---~ combine.names = combine_names
---~ combine.feature = combine_feature
+--~ combiner.load = combine_load
+--~ combiner.assign = combine_assign
+--~ combiner.process = combine_process
+--~ combiner.names = combine_names
+--~ combiner.feature = combine_feature
-combine.commands = allocate {
- ["initialize"] = function(g,v) combine_assign (g,g.name) end,
- ["include-method"] = function(g,v) combine_process (g,vf.combinations[v[2]]) end, -- name
+combiner.commands = allocate {
+ ["initialize"] = function(g,v) combine_assign (g,g.properties.name) end,
+ ["include-method"] = function(g,v) combine_process (g,combinations[v[2]]) end, -- name
-- ["copy-parameters"] = function(g,v) combine_parameters(g,v[2]) end, -- name
["copy-range"] = function(g,v) combine_assign (g,v[2],v[3],v[4],v[5],true) end, -- name, from-start, from-end, to-start
["copy-char"] = function(g,v) combine_assign (g,v[2],v[3],v[3],v[4],true) end, -- name, from, to
["fallback-range"] = function(g,v) combine_assign (g,v[2],v[3],v[4],v[5],false) end, -- name, from-start, from-end, to-start
["fallback-char"] = function(g,v) combine_assign (g,v[2],v[3],v[3],v[4],false) end, -- name, from, to
["copy-names"] = function(g,v) combine_names (g,v[2],true) end,
- ["fallback_names"] = function(g,v) combine_names (g,v[2],false) end,
+ ["fallback-names"] = function(g,v) combine_names (g,v[2],false) end,
["feature"] = combine_feature,
}
function vf.combine(specification,tag)
local g = {
name = specification.name,
- -- type = 'virtual',
- virtualized = true,
- fonts = { },
- characters = { },
- descriptions = { },
+ properties = {
+ virtualized = true,
+ },
+ fonts = {
+ },
+ characters = {
+ },
+ descriptions = {
+ },
specification = fastcopy(specification),
}
- combine_process(g,vf.combinations[tag])
+ combine_process(g,combinations[tag])
return g
end
-
--- simple example with features
-
-methods.install(
- "ligatures", {
- { "feature", "liga" } ,
- { "feature", "dlig" } ,
- { "initialize" } ,
- }
-)
-
---~ methods.install (
---~ "ligatures-x", {
---~ { "feature", "liga" } ,
---~ { "feature", "dlig" } ,
---~ { "initialize" } ,
---~ { "lineheight" }
---~ }
---~ )
-
---~ methods.install(
---~ "lmsymbol10", {
---~ { "fallback_names", "lmsy10.afm" } ,
---~ { "fallback_names", "msam10.afm" } ,
---~ { "fallback_names", "msbm10.afm" }
---~ }
---~ )
---~ \font\TestFont=dummy@lmsymbol10 at 24pt
-
--- docu case
-
---~ methods.install(
---~ "weird", {
---~ { "copy-range", "lmroman10-regular" } ,
---~ { "copy-char", "lmroman10-regular", 65, 66 } ,
---~ { "copy-range", "lmsans10-regular", 0x0100, 0x01FF } ,
---~ { "copy-range", "lmtypewriter10-regular", 0x0200, 0xFF00 } ,
---~ { "fallback-range", "lmtypewriter10-regular", 0x0000, 0x0200 }
---~ }
---~ )
-
--- demo case -> move to module
-
--- todo: interface tables in back-ini
-
-variants["demo-1"] = function(specification)
- local name = specification.name -- symbolic name
- local size = specification.size -- given size
- local f, id = tfm.readanddefine('lmroman10-regular',size)
- if f and id then
- local capscale, digscale = 0.85, 0.75
- -- f.name, f.type = name, 'virtual'
- f.name, f.virtualized = name, true
- f.fonts = {
- { id = id },
- { name = 'lmsans10-regular' , size = size*capscale }, -- forced extra name
- { name = 'lmtypewriter10-regular', size = size*digscale } -- forced extra name
- }
- local characters, descriptions = f.characters, f.descriptions
- local vfspecials = backends.tables.vfspecials
- local red, green, blue, black = vfspecials.red, vfspecials.green, vfspecials.blue, vfspecials.black
- for u,v in next, characters do
- local category = chardata[u].category
- if category == 'lu' then
- v.width = capscale*v.width
- v.commands = { red, { 'slot', 2, u }, black }
- elseif category == 'nd' then
- v.width = digscale*v.width
- v.commands = { blue, { 'slot', 3, u }, black }
- else
- v.commands = { green, { 'slot', 1, u }, black }
- end
- end
- end
- return f
-end