summaryrefslogtreecommitdiff
path: root/tex
diff options
context:
space:
mode:
Diffstat (limited to 'tex')
-rw-r--r--tex/context/base/context-version.pdfbin4249 -> 4253 bytes
-rw-r--r--tex/context/base/mkii/mult-de.mkii1
-rw-r--r--tex/context/base/mkii/mult-en.mkii1
-rw-r--r--tex/context/base/mkii/mult-fr.mkii1
-rw-r--r--tex/context/base/mkii/mult-it.mkii1
-rw-r--r--tex/context/base/mkii/mult-nl.mkii1
-rw-r--r--tex/context/base/mkii/mult-pe.mkii1
-rw-r--r--tex/context/base/mkii/mult-ro.mkii1
-rw-r--r--tex/context/base/mkiv/anch-pos.lua64
-rw-r--r--tex/context/base/mkiv/cont-new.mkiv2
-rw-r--r--tex/context/base/mkiv/context-todo.tex3
-rw-r--r--tex/context/base/mkiv/context.mkiv2
-rw-r--r--tex/context/base/mkiv/font-one.lua407
-rw-r--r--tex/context/base/mkiv/grph-inc.lua31
-rw-r--r--tex/context/base/mkiv/grph-inc.mkiv81
-rw-r--r--tex/context/base/mkiv/mult-def.lua3
-rw-r--r--tex/context/base/mkiv/pack-rul.mkiv18
-rw-r--r--tex/context/base/mkiv/spac-ver.mkiv2
-rw-r--r--tex/context/base/mkiv/status-files.pdfbin9125 -> 9126 bytes
-rw-r--r--tex/context/base/mkiv/status-lua.pdfbin266625 -> 268187 bytes
-rw-r--r--tex/context/interface/mkii/keys-cs.xml1
-rw-r--r--tex/context/interface/mkii/keys-de.xml1
-rw-r--r--tex/context/interface/mkii/keys-en.xml1
-rw-r--r--tex/context/interface/mkii/keys-fr.xml1
-rw-r--r--tex/context/interface/mkii/keys-it.xml1
-rw-r--r--tex/context/interface/mkii/keys-nl.xml1
-rw-r--r--tex/context/interface/mkii/keys-pe.xml1
-rw-r--r--tex/context/interface/mkii/keys-ro.xml1
-rw-r--r--tex/context/interface/mkiv/i-context.pdfbin820451 -> 820456 bytes
-rw-r--r--tex/context/interface/mkiv/i-readme.pdfbin60792 -> 60793 bytes
-rw-r--r--tex/generic/context/luatex/luatex-fonts-merged.lua304
31 files changed, 556 insertions, 376 deletions
diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf
index 50805410f..f0938c902 100644
--- a/tex/context/base/context-version.pdf
+++ b/tex/context/base/context-version.pdf
Binary files differ
diff --git a/tex/context/base/mkii/mult-de.mkii b/tex/context/base/mkii/mult-de.mkii
index f3bdc0740..0762fadfc 100644
--- a/tex/context/base/mkii/mult-de.mkii
+++ b/tex/context/base/mkii/mult-de.mkii
@@ -726,6 +726,7 @@
\setinterfaceconstant{couplingway}{verkopplungsart}
\setinterfaceconstant{criterium}{kriterium}
\setinterfaceconstant{cropoffset}{cropoffset}
+\setinterfaceconstant{crossreference}{crossreference}
\setinterfaceconstant{cssfile}{cssfile}
\setinterfaceconstant{current}{aktuell}
\setinterfaceconstant{cutspace}{cutspace}
diff --git a/tex/context/base/mkii/mult-en.mkii b/tex/context/base/mkii/mult-en.mkii
index 262b4fde5..a16b87a48 100644
--- a/tex/context/base/mkii/mult-en.mkii
+++ b/tex/context/base/mkii/mult-en.mkii
@@ -726,6 +726,7 @@
\setinterfaceconstant{couplingway}{couplingway}
\setinterfaceconstant{criterium}{criterium}
\setinterfaceconstant{cropoffset}{cropoffset}
+\setinterfaceconstant{crossreference}{crossreference}
\setinterfaceconstant{cssfile}{cssfile}
\setinterfaceconstant{current}{current}
\setinterfaceconstant{cutspace}{cutspace}
diff --git a/tex/context/base/mkii/mult-fr.mkii b/tex/context/base/mkii/mult-fr.mkii
index 6d9bf8982..6c71d4aad 100644
--- a/tex/context/base/mkii/mult-fr.mkii
+++ b/tex/context/base/mkii/mult-fr.mkii
@@ -726,6 +726,7 @@
\setinterfaceconstant{couplingway}{modecouplage}
\setinterfaceconstant{criterium}{critere}
\setinterfaceconstant{cropoffset}{cropoffset}
+\setinterfaceconstant{crossreference}{crossreference}
\setinterfaceconstant{cssfile}{cssfile}
\setinterfaceconstant{current}{courant}
\setinterfaceconstant{cutspace}{cutspace}
diff --git a/tex/context/base/mkii/mult-it.mkii b/tex/context/base/mkii/mult-it.mkii
index a5367dfbb..a875555bd 100644
--- a/tex/context/base/mkii/mult-it.mkii
+++ b/tex/context/base/mkii/mult-it.mkii
@@ -726,6 +726,7 @@
\setinterfaceconstant{couplingway}{modoaccoppiamento}
\setinterfaceconstant{criterium}{criterio}
\setinterfaceconstant{cropoffset}{cropoffset}
+\setinterfaceconstant{crossreference}{crossreference}
\setinterfaceconstant{cssfile}{cssfile}
\setinterfaceconstant{current}{corrente}
\setinterfaceconstant{cutspace}{cutspace}
diff --git a/tex/context/base/mkii/mult-nl.mkii b/tex/context/base/mkii/mult-nl.mkii
index 6cd6a7b5d..efc0d2be3 100644
--- a/tex/context/base/mkii/mult-nl.mkii
+++ b/tex/context/base/mkii/mult-nl.mkii
@@ -726,6 +726,7 @@
\setinterfaceconstant{couplingway}{koppelwijze}
\setinterfaceconstant{criterium}{criterium}
\setinterfaceconstant{cropoffset}{cropoffset}
+\setinterfaceconstant{crossreference}{crossreference}
\setinterfaceconstant{cssfile}{cssfile}
\setinterfaceconstant{current}{huidige}
\setinterfaceconstant{cutspace}{snijwit}
diff --git a/tex/context/base/mkii/mult-pe.mkii b/tex/context/base/mkii/mult-pe.mkii
index 371b64074..7e5c53791 100644
--- a/tex/context/base/mkii/mult-pe.mkii
+++ b/tex/context/base/mkii/mult-pe.mkii
@@ -726,6 +726,7 @@
\setinterfaceconstant{couplingway}{روش‌تزویج}
\setinterfaceconstant{criterium}{criterium}
\setinterfaceconstant{cropoffset}{cropoffset}
+\setinterfaceconstant{crossreference}{crossreference}
\setinterfaceconstant{cssfile}{cssfile}
\setinterfaceconstant{current}{جاری}
\setinterfaceconstant{cutspace}{فضای‌برش}
diff --git a/tex/context/base/mkii/mult-ro.mkii b/tex/context/base/mkii/mult-ro.mkii
index 00e2f30cc..f7121f703 100644
--- a/tex/context/base/mkii/mult-ro.mkii
+++ b/tex/context/base/mkii/mult-ro.mkii
@@ -726,6 +726,7 @@
\setinterfaceconstant{couplingway}{modcuplare}
\setinterfaceconstant{criterium}{criteriu}
\setinterfaceconstant{cropoffset}{cropoffset}
+\setinterfaceconstant{crossreference}{crossreference}
\setinterfaceconstant{cssfile}{cssfile}
\setinterfaceconstant{current}{curent}
\setinterfaceconstant{cutspace}{cutspace}
diff --git a/tex/context/base/mkiv/anch-pos.lua b/tex/context/base/mkiv/anch-pos.lua
index c01e90179..fef1a8474 100644
--- a/tex/context/base/mkiv/anch-pos.lua
+++ b/tex/context/base/mkiv/anch-pos.lua
@@ -110,18 +110,19 @@ local f_e_tag = formatters["e:%s"]
local f_p_tag = formatters["p:%s"]
local f_w_tag = formatters["w:%s"]
-local f_b_column = formatters["_plib_.b_col(%q)"]
-local f_e_column = formatters["_plib_.e_col()"]
-
-local f_enhance = formatters["_plib_.enhance(%q)"]
local f_region = formatters["region:%s"]
-local f_b_region = formatters["_plib_.b_region(%q)"]
-local f_e_region = formatters["_plib_.e_region(%s)"]
-
local f_tag_three = formatters["%s:%s:%s"]
local f_tag_two = formatters["%s:%s"]
+----- f_enhance = formatters["_plib_.enhance(%q)"]
+
+----- f_b_column = formatters["_plib_.b_column(%q)"]
+----- f_e_column = formatters["_plib_.e_column()"]
+
+----- f_b_region = formatters["_plib_.b_region(%q)"]
+----- f_e_region = formatters["_plib_.e_region(%s)"]
+
local function sorter(a,b)
return a.y > b.y
end
@@ -272,7 +273,7 @@ local function enhance(data)
data.y = getvpos()
end
if data.p == true then
- data.p = texgetcount("realpageno")
+ data.p = texgetcount("realpageno") -- we should use a variable set in otr
end
if data.c == true then
data.c = column
@@ -351,7 +352,7 @@ scanners.dosavepositionplus = compilescanner {
-- not much gain in keeping stack (inc/dec instead of insert/remove)
-function jobpositions.b_col(tag)
+local function b_column(tag)
tobesaved[tag] = {
r = true,
x = gethpos(),
@@ -361,7 +362,7 @@ function jobpositions.b_col(tag)
column = tag
end
-function jobpositions.e_col(tag)
+local function e_column(tag)
local t = tobesaved[column]
if not t then
-- something's wrong
@@ -373,6 +374,9 @@ function jobpositions.e_col(tag)
column = columns[#columns]
end
+jobpositions.b_column = b_column
+jobpositions.e_column = e_column
+
scanners.bposcolumn = function() -- tag
local tag = scanstring()
insert(columns,tag)
@@ -383,7 +387,8 @@ scanners.bposcolumnregistered = function() -- tag
local tag = scanstring()
insert(columns,tag)
column = tag
- context(new_latelua_node(f_b_column(tag)))
+ -- context(new_latelua_node(f_b_column(tag)))
+ context(new_latelua_node(function() b_column(tag) end))
end
scanners.eposcolumn = function()
@@ -392,14 +397,15 @@ scanners.eposcolumn = function()
end
scanners.eposcolumnregistered = function()
- context(new_latelua_node(f_e_column()))
+ -- context(new_latelua_node(f_e_column()))
+ context(new_latelua_node(e_column))
remove(columns)
column = columns[#columns]
end
-- regions
-function jobpositions.b_region(tag)
+local function b_region(tag)
local last = tobesaved[tag]
last.x, last.y = getpos()
last.p = texgetcount("realpageno")
@@ -407,7 +413,7 @@ function jobpositions.b_region(tag)
region = tag
end
-function jobpositions.e_region(correct)
+local function e_region(correct)
local last = tobesaved[region]
local v = getvpos()
if correct then
@@ -418,6 +424,9 @@ function jobpositions.e_region(correct)
region = regions[#regions]
end
+jobpositions.b_region = b_region
+jobpositions.e_region = e_region
+
local function setregionbox(n,tag)
if not tag or tag == "" then
nofregions = nofregions + 1
@@ -438,10 +447,13 @@ local function setregionbox(n,tag)
return tag, box
end
-local function markregionbox(n,tag,correct)
+local function markregionbox(n,tag,correct) -- correct needs checking
local tag, box = setregionbox(n,tag)
- local push = new_latelua(f_b_region(tag))
- local pop = new_latelua(f_e_region(tostring(correct))) -- todo: check if tostring is needed with formatter
+ -- todo: check if tostring is needed with formatter
+ -- local push = new_latelua(f_b_region(tag))
+ -- local pop = new_latelua(f_e_region(tostring(correct)))
+ local push = new_latelua(function() b_region(tag) end)
+ local pop = new_latelua(function() e_region(tostring(correct)) end)
-- maybe we should construct a hbox first (needs experimenting) so that we can avoid some at the tex end
local head = getlist(box)
if head then
@@ -509,7 +521,8 @@ scanners.parpos = function() -- todo: relate to localpar (so this is an intermed
end
local tag = f_p_tag(nofparagraphs)
tobesaved[tag] = t
- context(new_latelua_node(f_enhance(tag)))
+ -- context(new_latelua_node(f_enhance(tag)))
+ context(new_latelua_node(function() enhance(tobesaved[tag]) end))
end
scanners.dosetposition = function() -- name
@@ -522,7 +535,8 @@ scanners.dosetposition = function() -- name
y = true,
n = nofparagraphs > 0 and nofparagraphs or nil,
}
- context(new_latelua_node(f_enhance(name)))
+ -- context(new_latelua_node(f_enhance(name)))
+ context(new_latelua_node(function() enhance(tobesaved[name]) end))
end
scanners.dosetpositionwhd = function() -- name w h d extra
@@ -538,7 +552,8 @@ scanners.dosetpositionwhd = function() -- name w h d extra
d = scandimen(),
n = nofparagraphs > 0 and nofparagraphs or nil,
}
- context(new_latelua_node(f_enhance(name)))
+ -- context(new_latelua_node(f_enhance(name)))
+ context(new_latelua_node(function() enhance(tobesaved[name]) end))
end
scanners.dosetpositionbox = function() -- name box
@@ -555,7 +570,8 @@ scanners.dosetpositionbox = function() -- name box
d = getfield(box,"depth"),
n = nofparagraphs > 0 and nofparagraphs or nil,
}
- context(new_latelua_node(f_enhance(name)))
+ -- context(new_latelua_node(f_enhance(name)))
+ context(new_latelua_node(function() enhance(tobesaved[name]) end))
end
scanners.dosetpositionplus = function() -- name w h d extra
@@ -572,7 +588,8 @@ scanners.dosetpositionplus = function() -- name w h d extra
n = nofparagraphs > 0 and nofparagraphs or nil,
e = scanstring(),
}
- context(new_latelua_node(f_enhance(name)))
+ -- context(new_latelua_node(f_enhance(name)))
+ context(new_latelua_node(function() enhance(tobesaved[name]) end))
end
scanners.dosetpositionstrut = function() -- name
@@ -588,7 +605,8 @@ scanners.dosetpositionstrut = function() -- name
d = getfield(strutbox,"depth"),
n = nofparagraphs > 0 and nofparagraphs or nil,
}
- context(new_latelua_node(f_enhance(name)))
+ -- context(new_latelua_node(f_enhance(name)))
+ context(new_latelua_node(function() enhance(tobesaved[name]) end))
end
function jobpositions.getreserved(tag,n)
diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv
index 7925f8797..79aa939d4 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.05.10 23:43}
+\newcontextversion{2016.05.12 23:49}
%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-todo.tex b/tex/context/base/mkiv/context-todo.tex
index 66889c4d3..bf7d198c9 100644
--- a/tex/context/base/mkiv/context-todo.tex
+++ b/tex/context/base/mkiv/context-todo.tex
@@ -47,6 +47,9 @@
redo some of the spacing (adapt to improvements in engine)
\stopitem
\startitem
+ reorganize position data (more subtables)
+ \stopitem
+ \startitem
use \type {\matheqnogapstep}, \type {\Ustack}, \type {\mathscriptsmode}, \
\type {\mathdisplayskipmode} and other new math primitives
\stopitem
diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv
index 228e3f0cd..b670c40c1 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.05.10 23:43}
+\edef\contextversion{2016.05.12 23:49}
\edef\contextkind {beta}
%D For those who want to use this:
diff --git a/tex/context/base/mkiv/font-one.lua b/tex/context/base/mkiv/font-one.lua
index af3246342..5d54150c5 100644
--- a/tex/context/base/mkiv/font-one.lua
+++ b/tex/context/base/mkiv/font-one.lua
@@ -55,7 +55,7 @@ local otfenhancers = otf.enhancers
local afmfeatures = constructors.newfeatures("afm")
local registerafmfeature = afmfeatures.register
-afm.version = 1.507 -- incrementing this number one up will force a re-cache
+afm.version = 1.510 -- incrementing this number one up will force a re-cache
afm.cache = containers.define("fonts", "afm", afm.version, true)
afm.autoprefixed = true -- this will become false some day (catches texnansi-blabla.*)
@@ -87,143 +87,6 @@ and <l n='otf'/> reader.</p>
-- Comment DELIM 2390 1010
-- Comment AXISHEIGHT 250
-local comment = P("Comment")
-local spacing = patterns.spacer -- S(" \t")^1
-local lineend = patterns.newline -- S("\n\r")
-local words = spacing * C((1 - lineend)^1)
-local number = spacing * C((R("09") + S("."))^1) / tonumber * spacing^0
-local data = Carg(1)
-local plus = P("plus") * number
-local minus = P("minus") * number
-
-local pattern = ( -- needs testing ... not used anyway as we no longer need math afm's
- comment * spacing * (
- data * (
- ("CODINGSCHEME" * words ) / function(t,a) end +
- ("DESIGNSIZE" * number * words ) / function(t,a) t[ 1] = a end +
- ("CHECKSUM" * number * words ) / function(t,a) t[ 2] = a end +
- ("SPACE" * number * plus * minus ) / function(t,a,b,c) t[ 3], t[ 4], t[ 5] = a, b, c end +
- ("QUAD" * number ) / function(t,a) t[ 6] = a end +
- ("EXTRASPACE" * number ) / function(t,a) t[ 7] = a end +
- ("NUM" * number * number * number ) / function(t,a,b,c) t[ 8], t[ 9], t[10] = a, b, c end +
- ("DENOM" * number * number ) / function(t,a,b) t[11], t[12] = a, b end +
- ("SUP" * number * number * number ) / function(t,a,b,c) t[13], t[14], t[15] = a, b, c end +
- ("SUB" * number * number ) / function(t,a,b) t[16], t[17] = a, b end +
- ("SUPDROP" * number ) / function(t,a) t[18] = a end +
- ("SUBDROP" * number ) / function(t,a) t[19] = a end +
- ("DELIM" * number * number ) / function(t,a,b) t[20], t[21] = a, b end +
- ("AXISHEIGHT" * number ) / function(t,a) t[22] = a end
- )
- + (1-lineend)^0
- )
- + (1-comment)^1
-)^0
-
-local function scan_comment(str)
- local fd = { }
- lpegmatch(pattern,str,1,fd)
- return fd
-end
-
--- Comment DesignSize 12 (pts)
--- Comment TFM designsize: 12 (in points)
-
-local keys = {
-
- FontName = function(data,line)
- data.metadata.fontname = strip(line) -- get rid of spaces
- data.metadata.fullname = strip(line)
- end,
-
- ItalicAngle = function(data,line)
- data.metadata.italicangle = tonumber(line)
- end,
-
- IsFixedPitch = function(data,line)
- data.metadata.monospaced = toboolean(line,true)
- end,
-
- CharWidth = function(data,line)
- data.metadata.charwidth = tonumber(line)
- end,
-
- XHeight = function(data,line)
- data.metadata.xheight = tonumber(line)
- end,
-
- Descender = function(data,line)
- data.metadata.descender = tonumber (line)
- end,
-
- Ascender = function(data,line)
- data.metadata.ascender = tonumber (line)
- end,
-
- Comment = function(data,line)
- line = lower(line)
- local designsize = match(line,"designsize[^%d]*(%d+)")
- if designsize then data.metadata.designsize = tonumber(designsize) end
- end,
-
-}
-
-local function get_charmetrics(data,charmetrics,vector)
- local characters = data.characters
- local chr, ind = { }, 0
- for k, v in gmatch(charmetrics,"([%a]+) +(.-) *;") do
- if k == 'C' then
- v = tonumber(v)
- if v < 0 then
- ind = ind + 1 -- ?
- else
- ind = v
- end
- chr = {
- index = ind
- }
- elseif k == 'WX' then
- chr.width = tonumber(v)
- elseif k == 'N' then
- characters[v] = chr
- elseif k == 'B' then
- local llx, lly, urx, ury = match(v,"^ *(.-) +(.-) +(.-) +(.-)$")
- chr.boundingbox = { tonumber(llx), tonumber(lly), tonumber(urx), tonumber(ury) }
- elseif k == 'L' then
- local plus, becomes = match(v,"^(.-) +(.-)$")
- local ligatures = chr.ligatures
- if ligatures then
- ligatures[plus] = becomes
- else
- chr.ligatures = { [plus] = becomes }
- end
- end
- end
-end
-
-local function get_kernpairs(data,kernpairs)
- local characters = data.characters
- for one, two, value in gmatch(kernpairs,"KPX +(.-) +(.-) +(.-)\n") do
- local chr = characters[one]
- if chr then
- local kerns = chr.kerns
- if kerns then
- kerns[two] = tonumber(value)
- else
- chr.kerns = { [two] = tonumber(value) }
- end
- end
- end
-end
-
-local function get_variables(data,fontmetrics)
- for key, rest in gmatch(fontmetrics,"(%a+) *(.-)[\n\r]") do
- local keyhandler = keys[key]
- if keyhandler then
- keyhandler(data,rest)
- end
- end
-end
-
--[[ldx--
<p>We now use a new (unfinished) pfb loader but I see no differences between the old
and new vectors (we actually had one bad vector with the old loader).</p>
@@ -353,61 +216,205 @@ do
end
-local function readafm(filename)
- local ok, afmblob, size = resolvers.loadbinfile(filename) -- has logging
- if ok and afmblob then
- local data = {
- resources = {
- filename = resolvers.unresolve(filename),
- version = afm.version,
- creator = "context mkiv",
- },
- properties = {
- hasitalics = false,
- },
- goodies = {
- },
- metadata = {
- filename = file.removesuffix(file.basename(filename))
- },
- characters = {
- -- a temporary store
- },
- descriptions = {
- -- the final store
- },
- }
--- afmblob = gsub(afmblob,"StartCharMetrics(.-)EndCharMetrics", function(charmetrics)
- for charmetrics in gmatch(afmblob,"StartCharMetrics(.-)EndCharMetrics") do
- if trace_loading then
- report_afm("loading char metrics")
+--[[ldx--
+<p>We start with the basic reader which we give a name similar to the built in <l n='tfm'/>
+and <l n='otf'/> reader.</p>
+--ldx]]--
+
+-- Comment FONTIDENTIFIER LMMATHSYMBOLS10
+-- Comment CODINGSCHEME TEX MATH SYMBOLS
+-- Comment DESIGNSIZE 10.0 pt
+-- Comment CHECKSUM O 4261307036
+-- Comment SPACE 0 plus 0 minus 0
+-- Comment QUAD 1000
+-- Comment EXTRASPACE 0
+-- Comment NUM 676.508 393.732 443.731
+-- Comment DENOM 685.951 344.841
+-- Comment SUP 412.892 362.892 288.889
+-- Comment SUB 150 247.217
+-- Comment SUPDROP 386.108
+-- Comment SUBDROP 50
+-- Comment DELIM 2390 1010
+-- Comment AXISHEIGHT 250
+-- Comment DesignSize 12 (pts)
+-- Comment TFM designsize: 12 (in points)
+
+local readafm
+
+do -- no need for a further speedup with locals
+
+ local spacing = patterns.spacer
+ local lineend = patterns.newline
+ local number = spacing * (R("09") + S("."))^1 / tonumber
+ local name = spacing * C((1-spacing)^1)
+ local words = spacing * (1 - lineend)^1 / strip
+ local rest = (1 - lineend)^0
+ local fontdata = Carg(1)
+ local semicolon = spacing * P(";")
+ local plus = P("plus") * number
+ local minus = P("minus") * number
+
+ -- kern pairs
+
+ local function addkernpair(data,one,two,value)
+ local chr = data.characters[one]
+ if chr then
+ local kerns = chr.kerns
+ if kerns then
+ kerns[two] = tonumber(value)
+ else
+ chr.kerns = { [two] = tonumber(value) }
end
- get_charmetrics(data,charmetrics,vector)
- break
end
- for kernpairs in gmatch(afmblob,"StartKernPairs(.-)EndKernPairs") do
+ end
+
+ local p_kernpair = (fontdata * P("KPX") * name * name * number) / addkernpair
+
+ -- char metrics
+
+ local chr = false
+ local ind = 0
+
+ local function start()
+ ind = 0
+ chr = { }
+ end
+
+ local function stop()
+ ind = 0
+ chr = false
+ end
+
+ local function setindex(i)
+ if i < 0 then
+ ind = ind + 1 -- ?
+ else
+ ind = i
+ end
+ chr = {
+ index = ind
+ }
+ end
+
+ local function setwidth(width)
+ chr.width = width
+ end
+
+ local function setname(data,name)
+ data.characters[name] = chr
+ end
+
+ local function setboundingbox(boundingbox)
+ chr.boundingbox = boundingbox
+ end
+
+ local function setligature(plus,becomes)
+ local ligatures = chr.ligatures
+ if ligatures then
+ ligatures[plus] = becomes
+ else
+ chr.ligatures = { [plus] = becomes }
+ end
+ end
+
+ local p_charmetric = ( (
+ P("C") * number / setindex
+ + P("WX") * number / setwidth
+ + P("N") * fontdata * name / setname
+ + P("B") * Ct((number)^4) / setboundingbox
+ + P("L") * (name)^2 / setligature
+ ) * semicolon )^1
+
+ local p_charmetrics = P("StartCharMetrics") * number * (p_charmetric + (1-P("EndCharMetrics")))^0 * P("EndCharMetrics")
+ local p_kernpairs = P("StartKernPairs") * number * (p_kernpair + (1-P("EndKernPairs")) )^0 * P("EndKernPairs")
+
+ local function set_1(data,key,a) data.metadata[lower(key)] = a end
+ local function set_2(data,key,a,b) data.metadata[lower(key)] = { a, b } end
+ local function set_3(data,key,a,b,c) data.metadata[lower(key)] = { a, b, c } end
+
+ local p_parameters = P(false)
+ + P("FontName") * fontdata * words / function(data,line)
+ data.metadata.fontname = line
+ data.metadata.fullname = line
+ end
+ + P("ItalicAngle") * fontdata * number / function(data,angle)
+ data.metadata.italicangle = angle
+ end
+ + P("IsFixedPitch") * fontdata * name / function(data,pitch)
+ data.metadata.monospaced = toboolean(pitch,true)
+ end
+ + P("CharWidth") * fontdata * number / function(data,width)
+ data.metadata.charwidth = width
+ end
+ + P("XHeight") * fontdata * number / function(data,xheight)
+ data.metadata.xheight = xheight
+ end
+ + P("Descender") * fontdata * number / function(data,descender)
+ data.metadata.descender = descender
+ end
+ + P("Ascender") * fontdata * number / function(data,ascender)
+ data.metadata.ascender = ascender
+ end
+ + P("Comment") * spacing * ( P(false)
+ + (fontdata * C("DESIGNSIZE") * number * rest) / set_1 -- 1
+ + (fontdata * C("TFM designsize") * number * rest) / set_1
+ + (fontdata * C("DesignSize") * number * rest) / set_1
+ + (fontdata * C("CODINGSCHEME") * words * rest) / set_1 --
+ + (fontdata * C("CHECKSUM") * number * words * rest) / set_1 -- 2
+ + (fontdata * C("SPACE") * number * plus * minus * rest) / set_3 -- 3 4 5
+ + (fontdata * C("QUAD") * number * rest) / set_1 -- 6
+ + (fontdata * C("EXTRASPACE") * number * rest) / set_1 -- 7
+ + (fontdata * C("NUM") * number * number * number * rest) / set_3 -- 8 9 10
+ + (fontdata * C("DENOM") * number * number * rest) / set_2 -- 11 12
+ + (fontdata * C("SUP") * number * number * number * rest) / set_3 -- 13 14 15
+ + (fontdata * C("SUB") * number * number * rest) / set_2 -- 16 17
+ + (fontdata * C("SUPDROP") * number * rest) / set_1 -- 18
+ + (fontdata * C("SUBDROP") * number * rest) / set_1 -- 19
+ + (fontdata * C("DELIM") * number * number * rest) / set_2 -- 20 21
+ + (fontdata * C("AXISHEIGHT") * number * rest) / set_1 -- 22
+ )
+
+ local parser = ( P("StartFontMetrics") / start )
+ * ( p_charmetrics + p_kernpairs + p_parameters + (1-P("EndFontMetrics")) )^0
+ * ( P("EndFontMetrics") / stop )
+
+ readafm = function(filename)
+ local ok, afmblob, size = resolvers.loadbinfile(filename) -- has logging
+ if ok and afmblob then
+ local data = {
+ resources = {
+ filename = resolvers.unresolve(filename),
+ version = afm.version,
+ creator = "context mkiv",
+ },
+ properties = {
+ hasitalics = false,
+ },
+ goodies = {
+ },
+ metadata = {
+ filename = file.removesuffix(file.basename(filename))
+ },
+ characters = {
+ -- a temporary store
+ },
+ descriptions = {
+ -- the final store
+ },
+ }
if trace_loading then
- report_afm("loading kern pairs")
+ report_afm("parsing afm file %a",filename)
end
- get_kernpairs(data,kernpairs)
- break
- end
- for version, fontmetrics in gmatch(afmblob,"StartFontMetrics%s+([%d%.]+)(.-)EndFontMetrics") do
+ lpegmatch(parser,afmblob,1,data)
+ return data
+ else
if trace_loading then
- report_afm("loading variables")
+ report_afm("no valid afm file %a",filename)
end
- data.afmversion = version
- get_variables(data,fontmetrics)
- data.fontdimens = scan_comment(fontmetrics) -- todo: all lpeg, no time now
- break
- end
- return data
- else
- if trace_loading then
- report_afm("no valid afm file %a",filename)
+ return nil
end
- return nil
end
+
end
--[[ldx--
@@ -929,11 +936,31 @@ local function copytotfm(data)
end
--
end
- local fd = data.fontdimens
- if fd and fd[8] and fd[9] and fd[10] then -- math
- for k,v in next, fd do
- parameters[k] = v
- end
+ --
+ if metadata.sup then
+ local dummy = { 0, 0, 0 }
+ parameters[ 1] = metadata.designsize or 0
+ parameters[ 2] = metadata.checksum or 0
+ parameters[ 3],
+ parameters[ 4],
+ parameters[ 5] = unpack(metadata.space or dummy)
+ parameters[ 6] = metadata.quad or 0
+ parameters[ 7] = metadata.extraspace or 0
+ parameters[ 8],
+ parameters[ 9],
+ parameters[10] = unpack(metadata.num or dummy)
+ parameters[11],
+ parameters[12] = unpack(metadata.denom or dummy)
+ parameters[13],
+ parameters[14],
+ parameters[15] = unpack(metadata.sup or dummy)
+ parameters[16],
+ parameters[17] = unpack(metadata.sub or dummy)
+ parameters[18] = metadata.supdrop or 0
+ parameters[19] = metadata.subdrop or 0
+ parameters[20],
+ parameters[21] = unpack(metadata.delim or dummy)
+ parameters[22] = metadata.axisheight or 0
end
--
parameters.designsize = (metadata.designsize or 10)*65536
diff --git a/tex/context/base/mkiv/grph-inc.lua b/tex/context/base/mkiv/grph-inc.lua
index cf4a70269..d13d45a29 100644
--- a/tex/context/base/mkiv/grph-inc.lua
+++ b/tex/context/base/mkiv/grph-inc.lua
@@ -2117,3 +2117,34 @@ implement {
-- end
--
-- \externalfigure[t:/sources/hakker1b.tiff]
+
+-- something relatively new:
+
+local registered = { }
+
+interfaces.implement {
+ name = "figure_register_page",
+ arguments = { "string", "string", "string" },
+ actions = function(a,b,c)
+ registered[#registered+1] = { a, b, c }
+ context(#registered)
+ end
+}
+
+interfaces.implement {
+ name = "figure_nof_registered_pages",
+ actions = function()
+ context(#registered)
+ end
+}
+
+interfaces.implement {
+ name = "figure_flush_registered_pages",
+ arguments = "string",
+ actions = function(n)
+ local f = registered[tonumber(n)]
+ if f then
+ context.doexternalfigurerepeat(f[1],f[2],f[3],n)
+ end
+ end
+}
diff --git a/tex/context/base/mkiv/grph-inc.mkiv b/tex/context/base/mkiv/grph-inc.mkiv
index deba82c58..de5a2227a 100644
--- a/tex/context/base/mkiv/grph-inc.mkiv
+++ b/tex/context/base/mkiv/grph-inc.mkiv
@@ -99,6 +99,7 @@
\c!ymax =24,
\c!xmax =,
\c!align =\v!none, % New, for Tacos extremely large graphics.
+ \c!crossreference =\v!no,
]
%D Defining figures.
@@ -305,9 +306,10 @@
%
\the\t_grph_include_local_settings
%
- \edef\p_width {\externalfigureparameter\c!width}%
- \edef\p_height{\externalfigureparameter\c!height}%
- \edef\p_label {\externalfigureparameter\c!label}%
+ \edef\p_width {\externalfigureparameter\c!width}%
+ \edef\p_height {\externalfigureparameter\c!height}%
+ \edef\p_label {\externalfigureparameter\c!label}%
+ \edef\p_reference{\externalfigureparameter\c!reference}%
%
\dostarttagged\t!image\empty
\clf_figure_push
@@ -361,10 +363,81 @@
\fi
\clf_figure_pop
\dotagfigure
- \naturalvbox attr \imageattribute 2 {\box\foundexternalfigure}%
+ %
+ \scratchcounter\zerocount
+ \edef\p_crossreference{\externalfigureparameter\c!crossreference}%
+ \iflocation\iftrialtypesetting\else
+ \ifx\p_crossreference\empty
+ % nothing
+ \else\ifx\p_crossreference\v!no
+ % nothing
+ \else\ifx\p_crossreference\v!yes
+ \ifassignment
+ \scratchcounter\clf_figure_register_page{#1}{}{#2}\relax
+ \else
+ \scratchcounter\clf_figure_register_page{#1}{#2}{#3}\relax
+ \fi
+ \else
+ \scratchcounter-\p_crossreference % passed by repeater
+ \fi\fi\fi
+ \fi\fi
+ \naturalvpack
+ attr \imageattribute \plustwo
+ \ifnum\scratchcounter>\zerocount
+ {\strc_references_cross_forward {ex:\number \scratchcounter}{\box\foundexternalfigure}}%
+ \else\ifnum\scratchcounter<\zerocount
+ {\strc_references_cross_backward{ex:\number-\scratchcounter}{\box\foundexternalfigure}}%
+ \else
+ {\box\foundexternalfigure}%
+ \fi\fi
+ %
\dostoptagged
\egroup}
+%D Next we provide a cross referenced scale-up mechanism:
+
+\def\strc_references_cross_forward#1#2%
+ {\begingroup
+ \strc_references_set_simple_internal_reference{cross:b:#1}%
+ \naturalhpack
+ attr \destinationattribute\number\lastdestinationattribute
+ {\naturalhpack{\strc_references_flush_destination_nodes\directgotodumbbox{#2}[cross:f:#1]}}%
+ \endgroup}
+
+\def\strc_references_cross_backward#1#2%
+ {\begingroup
+ \strc_references_set_simple_internal_reference{cross:f:#1}%
+ \naturalhpack
+ attr \destinationattribute\number\lastdestinationattribute
+ {\naturalhpack{\strc_references_flush_destination_nodes\directgotodumbbox{#2}[cross:b:#1]}}%
+ \endgroup}
+
+\let\doexternalfigurerepeat\gobblefourarguments % called from lua end
+
+\unexpanded\def\placeregisteredexternalfigures
+ {\dosingleempty\grph_include_place_registered}
+
+\unexpanded\def\grph_include_place_registered[#1]%
+ {\page
+ \begingroup
+ \unexpanded\def\doexternalfigurerepeat{\grph_include_place_registered_indeed{#1}}%
+ \dorecurse\clf_figure_nof_registered_pages
+ {\page
+ \clf_figure_flush_registered_pages\recurselevel
+ \page}%
+ \endgroup
+ \page}
+
+\unexpanded\def\grph_include_place_registered_indeed#1#2#3#4#5% called from lua end
+ {\grph_include_place[#2][#3][#4,%
+ \c!hfactor=,\c!wfactor=,\c!factor=,%
+ \c!maxwidth=,\c!maxheight=,%
+ \c!xscale=,\c!yscale=,\c!scale=,%
+ \c!sx=,\c!sy=,\c!s=,%
+ \c!width=,\c!height=,%
+ \c!crossreference=#5,%
+ #1]}
+
%D Scaling:
\let\dowithfigure\relax % name might change (into a proper hook)
diff --git a/tex/context/base/mkiv/mult-def.lua b/tex/context/base/mkiv/mult-def.lua
index 99e0eb604..681144816 100644
--- a/tex/context/base/mkiv/mult-def.lua
+++ b/tex/context/base/mkiv/mult-def.lua
@@ -7362,6 +7362,9 @@ return {
["pe"]="criterium",
["ro"]="criteriu",
},
+ ["crossreference"]={
+ ["en"]="crossreference",
+ },
["cropoffset"]={
["en"]="cropoffset",
},
diff --git a/tex/context/base/mkiv/pack-rul.mkiv b/tex/context/base/mkiv/pack-rul.mkiv
index c8288586f..635863302 100644
--- a/tex/context/base/mkiv/pack-rul.mkiv
+++ b/tex/context/base/mkiv/pack-rul.mkiv
@@ -2727,6 +2727,8 @@
{\pack_framed_text_start_continue\empty{#1}}
{\pack_framed_text_start_continue{#1}{#2}}}
+% todo: sort out first/lastline ht/dp
+
\def\pack_framed_text_start_continue#1#2%
{\setupframedtexts[\currentframedtext][#2]%
\doifsomething{#1}{\setframedtextparameter\c!location{#1}}% does not listen to #3
@@ -2739,10 +2741,10 @@
\hsize\localhsize
% \insidefloattrue % ? better
\usebodyfontparameter\framedtextparameter
+ % \edef\p_framed_text_strut{\letframedtextparameter\c!strut}% to be used
\letframedtextparameter\c!strut\v!no
\inheritedframedtextframed\bgroup
\let\\=\endgraf
- \framedtextparameter\c!inner % oud spul
\edef\p_framed_text_depthcorrection{\framedtextparameter\c!depthcorrection}%
\ifx\p_framed_text_depthcorrection\v!on
\pack_framed_text_start_depth_correction
@@ -2753,6 +2755,7 @@
\doinhibitblank
\useindentingparameter\framedtextparameter
\useframedtextstyleandcolor\c!style\c!color
+ \framedtextparameter\c!inner
\ignorespaces}
% testcase 1:
@@ -2855,17 +2858,26 @@
\def\pack_framed_text_start_direct[#1]%
{\usebodyfontparameter\framedtextparameter
- \letframedtextparameter\c!strut\v!no
\iffirstargument
\setupcurrentframedtext[#1]%
\fi
+ \edef\p_framed_text_strut{\letframedtextparameter\c!strut}%
+ \letframedtextparameter\c!strut\v!no
\inheritedframedtextframed\bgroup
\blank[\v!disable]%
\let\\=\endgraf
- \framedtextparameter\c!inner
\useframedtextstyleandcolor\c!style\c!color
+ \vskip-\strutdp % brrr why is this needed ... needs to be sorted out, see testcase 1
+ \framedtextparameter\c!inner
+ \ifx\p_framed_text_strut\v!no
+ \let\pack_framed_strut\relax
+ \else
+ \let\pack_framed_strut\strut
+ \fi
\bgroup
\aftergroup\pack_framed_text_stop_direct
+ \afterassignment\ignorespaces
+ \afterassignment\pack_framed_strut
\let\next=}
\def\pack_framed_text_stop_direct
diff --git a/tex/context/base/mkiv/spac-ver.mkiv b/tex/context/base/mkiv/spac-ver.mkiv
index bbe53fb2a..e591d85f6 100644
--- a/tex/context/base/mkiv/spac-ver.mkiv
+++ b/tex/context/base/mkiv/spac-ver.mkiv
@@ -1139,7 +1139,7 @@
% when enabled, sigstruts will remove themselves if nothing
% goes inbetween
-%D For poractical reasons we define some boundary characters here.
+%D For practical reasons we define some boundary characters here.
\unexpanded\def\leftboundary {\protrusionboundary\plusone}
\unexpanded\def\rightboundary {\protrusionboundary\plustwo}
diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf
index bc8c201e7..ce4ce0520 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 5260d86f0..c3f475e42 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/mkii/keys-cs.xml b/tex/context/interface/mkii/keys-cs.xml
index e8df8ee30..ce8e41016 100644
--- a/tex/context/interface/mkii/keys-cs.xml
+++ b/tex/context/interface/mkii/keys-cs.xml
@@ -732,6 +732,7 @@
<cd:constant name='couplingway' value='zpusobpropojeni'/>
<cd:constant name='criterium' value='kriterium'/>
<cd:constant name='cropoffset' value='cropoffset'/>
+ <cd:constant name='crossreference' value='crossreference'/>
<cd:constant name='cssfile' value='cssfile'/>
<cd:constant name='current' value='aktualni'/>
<cd:constant name='cutspace' value='cutspace'/>
diff --git a/tex/context/interface/mkii/keys-de.xml b/tex/context/interface/mkii/keys-de.xml
index 94314bf61..5c7ecc651 100644
--- a/tex/context/interface/mkii/keys-de.xml
+++ b/tex/context/interface/mkii/keys-de.xml
@@ -732,6 +732,7 @@
<cd:constant name='couplingway' value='verkopplungsart'/>
<cd:constant name='criterium' value='kriterium'/>
<cd:constant name='cropoffset' value='cropoffset'/>
+ <cd:constant name='crossreference' value='crossreference'/>
<cd:constant name='cssfile' value='cssfile'/>
<cd:constant name='current' value='aktuell'/>
<cd:constant name='cutspace' value='cutspace'/>
diff --git a/tex/context/interface/mkii/keys-en.xml b/tex/context/interface/mkii/keys-en.xml
index b0cb6fa2c..621cbd763 100644
--- a/tex/context/interface/mkii/keys-en.xml
+++ b/tex/context/interface/mkii/keys-en.xml
@@ -732,6 +732,7 @@
<cd:constant name='couplingway' value='couplingway'/>
<cd:constant name='criterium' value='criterium'/>
<cd:constant name='cropoffset' value='cropoffset'/>
+ <cd:constant name='crossreference' value='crossreference'/>
<cd:constant name='cssfile' value='cssfile'/>
<cd:constant name='current' value='current'/>
<cd:constant name='cutspace' value='cutspace'/>
diff --git a/tex/context/interface/mkii/keys-fr.xml b/tex/context/interface/mkii/keys-fr.xml
index dae2ecfe0..301f94628 100644
--- a/tex/context/interface/mkii/keys-fr.xml
+++ b/tex/context/interface/mkii/keys-fr.xml
@@ -732,6 +732,7 @@
<cd:constant name='couplingway' value='modecouplage'/>
<cd:constant name='criterium' value='critere'/>
<cd:constant name='cropoffset' value='cropoffset'/>
+ <cd:constant name='crossreference' value='crossreference'/>
<cd:constant name='cssfile' value='cssfile'/>
<cd:constant name='current' value='courant'/>
<cd:constant name='cutspace' value='cutspace'/>
diff --git a/tex/context/interface/mkii/keys-it.xml b/tex/context/interface/mkii/keys-it.xml
index 0d661c5e1..458acd5c1 100644
--- a/tex/context/interface/mkii/keys-it.xml
+++ b/tex/context/interface/mkii/keys-it.xml
@@ -732,6 +732,7 @@
<cd:constant name='couplingway' value='modoaccoppiamento'/>
<cd:constant name='criterium' value='criterio'/>
<cd:constant name='cropoffset' value='cropoffset'/>
+ <cd:constant name='crossreference' value='crossreference'/>
<cd:constant name='cssfile' value='cssfile'/>
<cd:constant name='current' value='corrente'/>
<cd:constant name='cutspace' value='cutspace'/>
diff --git a/tex/context/interface/mkii/keys-nl.xml b/tex/context/interface/mkii/keys-nl.xml
index d9f192ec5..5e214c8bb 100644
--- a/tex/context/interface/mkii/keys-nl.xml
+++ b/tex/context/interface/mkii/keys-nl.xml
@@ -732,6 +732,7 @@
<cd:constant name='couplingway' value='koppelwijze'/>
<cd:constant name='criterium' value='criterium'/>
<cd:constant name='cropoffset' value='cropoffset'/>
+ <cd:constant name='crossreference' value='crossreference'/>
<cd:constant name='cssfile' value='cssfile'/>
<cd:constant name='current' value='huidige'/>
<cd:constant name='cutspace' value='snijwit'/>
diff --git a/tex/context/interface/mkii/keys-pe.xml b/tex/context/interface/mkii/keys-pe.xml
index ec120ee06..1afb96c9a 100644
--- a/tex/context/interface/mkii/keys-pe.xml
+++ b/tex/context/interface/mkii/keys-pe.xml
@@ -732,6 +732,7 @@
<cd:constant name='couplingway' value='روش‌تزویج'/>
<cd:constant name='criterium' value='criterium'/>
<cd:constant name='cropoffset' value='cropoffset'/>
+ <cd:constant name='crossreference' value='crossreference'/>
<cd:constant name='cssfile' value='cssfile'/>
<cd:constant name='current' value='جاری'/>
<cd:constant name='cutspace' value='فضای‌برش'/>
diff --git a/tex/context/interface/mkii/keys-ro.xml b/tex/context/interface/mkii/keys-ro.xml
index 71fa22e92..8a7707a2d 100644
--- a/tex/context/interface/mkii/keys-ro.xml
+++ b/tex/context/interface/mkii/keys-ro.xml
@@ -732,6 +732,7 @@
<cd:constant name='couplingway' value='modcuplare'/>
<cd:constant name='criterium' value='criteriu'/>
<cd:constant name='cropoffset' value='cropoffset'/>
+ <cd:constant name='crossreference' value='crossreference'/>
<cd:constant name='cssfile' value='cssfile'/>
<cd:constant name='current' value='curent'/>
<cd:constant name='cutspace' value='cutspace'/>
diff --git a/tex/context/interface/mkiv/i-context.pdf b/tex/context/interface/mkiv/i-context.pdf
index 525127f6f..99c3cce1f 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 cc920a21b..5dc85d2f5 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 b84893719..183135443 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 : 05/10/16 23:43:55
+-- merge date : 05/12/16 23:49:15
do -- begin closure to overcome local limits and interference
@@ -22287,116 +22287,13 @@ local otfreaders=otf.readers
local otfenhancers=otf.enhancers
local afmfeatures=constructors.newfeatures("afm")
local registerafmfeature=afmfeatures.register
-afm.version=1.507
+afm.version=1.510
afm.cache=containers.define("fonts","afm",afm.version,true)
afm.autoprefixed=true
afm.helpdata={}
afm.syncspace=true
local overloads=fonts.mappings.overloads
local applyruntimefixes=fonts.treatments and fonts.treatments.applyfixes
-local comment=P("Comment")
-local spacing=patterns.spacer
-local lineend=patterns.newline
-local words=spacing*C((1-lineend)^1)
-local number=spacing*C((R("09")+S("."))^1)/tonumber*spacing^0
-local data=Carg(1)
-local plus=P("plus")*number
-local minus=P("minus")*number
-local pattern=(
- comment*spacing*(
- data*(
- ("CODINGSCHEME"*words )/function(t,a) end+("DESIGNSIZE"*number*words )/function(t,a) t[ 1]=a end+("CHECKSUM"*number*words )/function(t,a) t[ 2]=a end+("SPACE"*number*plus*minus )/function(t,a,b,c) t[ 3],t[ 4],t[ 5]=a,b,c end+("QUAD"*number )/function(t,a) t[ 6]=a end+("EXTRASPACE"*number )/function(t,a) t[ 7]=a end+("NUM"*number*number*number )/function(t,a,b,c) t[ 8],t[ 9],t[10]=a,b,c end+("DENOM"*number*number )/function(t,a,b) t[11],t[12]=a,b end+("SUP"*number*number*number )/function(t,a,b,c) t[13],t[14],t[15]=a,b,c end+("SUB"*number*number )/function(t,a,b) t[16],t[17]=a,b end+("SUPDROP"*number )/function(t,a) t[18]=a end+("SUBDROP"*number )/function(t,a) t[19]=a end+("DELIM"*number*number )/function(t,a,b) t[20],t[21]=a,b end+("AXISHEIGHT"*number )/function(t,a) t[22]=a end
- )+(1-lineend)^0
- )+(1-comment)^1
-)^0
-local function scan_comment(str)
- local fd={}
- lpegmatch(pattern,str,1,fd)
- return fd
-end
-local keys={
- FontName=function(data,line)
- data.metadata.fontname=strip(line)
- data.metadata.fullname=strip(line)
- end,
- ItalicAngle=function(data,line)
- data.metadata.italicangle=tonumber(line)
- end,
- IsFixedPitch=function(data,line)
- data.metadata.monospaced=toboolean(line,true)
- end,
- CharWidth=function(data,line)
- data.metadata.charwidth=tonumber(line)
- end,
- XHeight=function(data,line)
- data.metadata.xheight=tonumber(line)
- end,
- Descender=function(data,line)
- data.metadata.descender=tonumber (line)
- end,
- Ascender=function(data,line)
- data.metadata.ascender=tonumber (line)
- end,
- Comment=function(data,line)
- line=lower(line)
- local designsize=match(line,"designsize[^%d]*(%d+)")
- if designsize then data.metadata.designsize=tonumber(designsize) end
- end,
-}
-local function get_charmetrics(data,charmetrics,vector)
- local characters=data.characters
- local chr,ind={},0
- for k,v in gmatch(charmetrics,"([%a]+) +(.-) *;") do
- if k=='C' then
- v=tonumber(v)
- if v<0 then
- ind=ind+1
- else
- ind=v
- end
- chr={
- index=ind
- }
- elseif k=='WX' then
- chr.width=tonumber(v)
- elseif k=='N' then
- characters[v]=chr
- elseif k=='B' then
- local llx,lly,urx,ury=match(v,"^ *(.-) +(.-) +(.-) +(.-)$")
- chr.boundingbox={ tonumber(llx),tonumber(lly),tonumber(urx),tonumber(ury) }
- elseif k=='L' then
- local plus,becomes=match(v,"^(.-) +(.-)$")
- local ligatures=chr.ligatures
- if ligatures then
- ligatures[plus]=becomes
- else
- chr.ligatures={ [plus]=becomes }
- end
- end
- end
-end
-local function get_kernpairs(data,kernpairs)
- local characters=data.characters
- for one,two,value in gmatch(kernpairs,"KPX +(.-) +(.-) +(.-)\n") do
- local chr=characters[one]
- if chr then
- local kerns=chr.kerns
- if kerns then
- kerns[two]=tonumber(value)
- else
- chr.kerns={ [two]=tonumber(value) }
- end
- end
- end
-end
-local function get_variables(data,fontmetrics)
- for key,rest in gmatch(fontmetrics,"(%a+) *(.-)[\n\r]") do
- local keyhandler=keys[key]
- if keyhandler then
- keyhandler(data,rest)
- end
- end
-end
local get_indexes
do
local n,m
@@ -22482,56 +22379,138 @@ do
end
end
end
-local function readafm(filename)
- local ok,afmblob,size=resolvers.loadbinfile(filename)
- if ok and afmblob then
- local data={
- resources={
- filename=resolvers.unresolve(filename),
- version=afm.version,
- creator="context mkiv",
- },
- properties={
- hasitalics=false,
- },
- goodies={},
- metadata={
- filename=file.removesuffix(file.basename(filename))
- },
- characters={
- },
- descriptions={
- },
- }
- for charmetrics in gmatch(afmblob,"StartCharMetrics(.-)EndCharMetrics") do
- if trace_loading then
- report_afm("loading char metrics")
+local readafm
+do
+ local spacing=patterns.spacer
+ local lineend=patterns.newline
+ local number=spacing*(R("09")+S("."))^1/tonumber
+ local name=spacing*C((1-spacing)^1)
+ local words=spacing*(1-lineend)^1/strip
+ local rest=(1-lineend)^0
+ local fontdata=Carg(1)
+ local semicolon=spacing*P(";")
+ local plus=P("plus")*number
+ local minus=P("minus")*number
+ local function addkernpair(data,one,two,value)
+ local chr=data.characters[one]
+ if chr then
+ local kerns=chr.kerns
+ if kerns then
+ kerns[two]=tonumber(value)
+ else
+ chr.kerns={ [two]=tonumber(value) }
end
- get_charmetrics(data,charmetrics,vector)
- break
end
- for kernpairs in gmatch(afmblob,"StartKernPairs(.-)EndKernPairs") do
+ end
+ local p_kernpair=(fontdata*P("KPX")*name*name*number)/addkernpair
+ local chr=false
+ local ind=0
+ local function start()
+ ind=0
+ chr={}
+ end
+ local function stop()
+ ind=0
+ chr=false
+ end
+ local function setindex(i)
+ if i<0 then
+ ind=ind+1
+ else
+ ind=i
+ end
+ chr={
+ index=ind
+ }
+ end
+ local function setwidth(width)
+ chr.width=width
+ end
+ local function setname(data,name)
+ data.characters[name]=chr
+ end
+ local function setboundingbox(boundingbox)
+ chr.boundingbox=boundingbox
+ end
+ local function setligature(plus,becomes)
+ local ligatures=chr.ligatures
+ if ligatures then
+ ligatures[plus]=becomes
+ else
+ chr.ligatures={ [plus]=becomes }
+ end
+ end
+ local p_charmetric=((
+ P("C")*number/setindex+P("WX")*number/setwidth+P("N")*fontdata*name/setname+P("B")*Ct((number)^4)/setboundingbox+P("L")*(name)^2/setligature
+ )*semicolon )^1
+ local p_charmetrics=P("StartCharMetrics")*number*(p_charmetric+(1-P("EndCharMetrics")))^0*P("EndCharMetrics")
+ local p_kernpairs=P("StartKernPairs")*number*(p_kernpair+(1-P("EndKernPairs")) )^0*P("EndKernPairs")
+ local function set_1(data,key,a) data.metadata[lower(key)]=a end
+ local function set_2(data,key,a,b) data.metadata[lower(key)]={ a,b } end
+ local function set_3(data,key,a,b,c) data.metadata[lower(key)]={ a,b,c } end
+ local p_parameters=P(false)+P("FontName")*fontdata*words/function(data,line)
+ data.metadata.fontname=line
+ data.metadata.fullname=line
+ end+P("ItalicAngle")*fontdata*number/function(data,angle)
+ data.metadata.italicangle=angle
+ end+P("IsFixedPitch")*fontdata*name/function(data,pitch)
+ data.metadata.monospaced=toboolean(pitch,true)
+ end+P("CharWidth")*fontdata*number/function(data,width)
+ data.metadata.charwidth=width
+ end+P("XHeight")*fontdata*number/function(data,xheight)
+ data.metadata.xheight=xheight
+ end+P("Descender")*fontdata*number/function(data,descender)
+ data.metadata.descender=descender
+ end+P("Ascender")*fontdata*number/function(data,ascender)
+ data.metadata.ascender=ascender
+ end+P("Comment")*spacing*(P(false)+(fontdata*C("DESIGNSIZE")*number*rest)/set_1
++(fontdata*C("TFM designsize")*number*rest)/set_1+(fontdata*C("DesignSize")*number*rest)/set_1+(fontdata*C("CODINGSCHEME")*words*rest)/set_1
++(fontdata*C("CHECKSUM")*number*words*rest)/set_1
++(fontdata*C("SPACE")*number*plus*minus*rest)/set_3
++(fontdata*C("QUAD")*number*rest)/set_1
++(fontdata*C("EXTRASPACE")*number*rest)/set_1
++(fontdata*C("NUM")*number*number*number*rest)/set_3
++(fontdata*C("DENOM")*number*number*rest)/set_2
++(fontdata*C("SUP")*number*number*number*rest)/set_3
++(fontdata*C("SUB")*number*number*rest)/set_2
++(fontdata*C("SUPDROP")*number*rest)/set_1
++(fontdata*C("SUBDROP")*number*rest)/set_1
++(fontdata*C("DELIM")*number*number*rest)/set_2
++(fontdata*C("AXISHEIGHT")*number*rest)/set_1
+ )
+ local parser=(P("StartFontMetrics")/start )*(p_charmetrics+p_kernpairs+p_parameters+(1-P("EndFontMetrics")) )^0*(P("EndFontMetrics")/stop )
+ readafm=function(filename)
+ local ok,afmblob,size=resolvers.loadbinfile(filename)
+ if ok and afmblob then
+ local data={
+ resources={
+ filename=resolvers.unresolve(filename),
+ version=afm.version,
+ creator="context mkiv",
+ },
+ properties={
+ hasitalics=false,
+ },
+ goodies={},
+ metadata={
+ filename=file.removesuffix(file.basename(filename))
+ },
+ characters={
+ },
+ descriptions={
+ },
+ }
if trace_loading then
- report_afm("loading kern pairs")
+ report_afm("parsing afm file %a",filename)
end
- get_kernpairs(data,kernpairs)
- break
- end
- for version,fontmetrics in gmatch(afmblob,"StartFontMetrics%s+([%d%.]+)(.-)EndFontMetrics") do
+ lpegmatch(parser,afmblob,1,data)
+ return data
+ else
if trace_loading then
- report_afm("loading variables")
+ report_afm("no valid afm file %a",filename)
end
- data.afmversion=version
- get_variables(data,fontmetrics)
- data.fontdimens=scan_comment(fontmetrics)
- break
+ return nil
end
- return data
- else
- if trace_loading then
- report_afm("no valid afm file %a",filename)
- end
- return nil
end
end
local enhancers={
@@ -22975,11 +22954,30 @@ local function copytotfm(data)
end
end
end
- local fd=data.fontdimens
- if fd and fd[8] and fd[9] and fd[10] then
- for k,v in next,fd do
- parameters[k]=v
- end
+ if metadata.sup then
+ local dummy={ 0,0,0 }
+ parameters[ 1]=metadata.designsize or 0
+ parameters[ 2]=metadata.checksum or 0
+ parameters[ 3],
+ parameters[ 4],
+ parameters[ 5]=unpack(metadata.space or dummy)
+ parameters[ 6]=metadata.quad or 0
+ parameters[ 7]=metadata.extraspace or 0
+ parameters[ 8],
+ parameters[ 9],
+ parameters[10]=unpack(metadata.num or dummy)
+ parameters[11],
+ parameters[12]=unpack(metadata.denom or dummy)
+ parameters[13],
+ parameters[14],
+ parameters[15]=unpack(metadata.sup or dummy)
+ parameters[16],
+ parameters[17]=unpack(metadata.sub or dummy)
+ parameters[18]=metadata.supdrop or 0
+ parameters[19]=metadata.subdrop or 0
+ parameters[20],
+ parameters[21]=unpack(metadata.delim or dummy)
+ parameters[22]=metadata.axisheight or 0
end
parameters.designsize=(metadata.designsize or 10)*65536
parameters.ascender=abs(metadata.ascender or 0)