summaryrefslogtreecommitdiff
path: root/tex
diff options
context:
space:
mode:
Diffstat (limited to 'tex')
-rw-r--r--tex/context/base/buff-ini.lua2
-rw-r--r--tex/context/base/buff-ver.mkiv12
-rw-r--r--tex/context/base/catc-ini.mkiv34
-rw-r--r--tex/context/base/char-act.mkiv13
-rw-r--r--tex/context/base/cont-new.tex2
-rw-r--r--tex/context/base/context.tex2
-rw-r--r--tex/context/base/enco-ini.mkiv23
-rw-r--r--tex/context/base/font-ctx.lua19
-rw-r--r--tex/context/base/font-enc.lua2
-rw-r--r--tex/context/base/font-enh.lua201
-rw-r--r--tex/context/base/font-ext.lua183
-rw-r--r--tex/context/base/font-ini.mkiv43
-rw-r--r--tex/context/base/font-otb.lua76
-rw-r--r--tex/context/base/font-otf.lua33
-rw-r--r--tex/context/base/font-otn.lua2
-rw-r--r--tex/context/base/font-tfm.lua172
-rw-r--r--tex/context/base/grph-inc.lua2
-rw-r--r--tex/context/base/grph-inc.mkiv2
-rw-r--r--tex/context/base/hand-ini.mkiv18
-rw-r--r--tex/context/base/math-ini.mkii5
-rw-r--r--tex/context/base/math-lbr.mkii10
-rw-r--r--tex/context/base/math-vfu.lua240
-rw-r--r--tex/context/base/node-inj.lua3
-rw-r--r--tex/context/base/s-fnt-25.tex31
-rw-r--r--tex/context/base/spac-ali.mkiv2
-rw-r--r--tex/context/base/spac-ver.mkiv50
-rw-r--r--tex/context/base/strc-ref.lua2
-rw-r--r--tex/context/base/syst-aux.mkiv4
-rw-r--r--tex/context/base/syst-ext.mkii4
-rw-r--r--tex/generic/context/luatex-fonts-merged.lua288
30 files changed, 857 insertions, 623 deletions
diff --git a/tex/context/base/buff-ini.lua b/tex/context/base/buff-ini.lua
index 1a76791ad..129182741 100644
--- a/tex/context/base/buff-ini.lua
+++ b/tex/context/base/buff-ini.lua
@@ -513,7 +513,7 @@ function default.flush_line(str)
if visualizers.obeyspace then
for c in utfcharacters(str) do
if c == " " then
- texsprint(ctxcatcodes,"\\obs ")
+ texsprint(ctxcatcodes,"\\obs")
else
texwrite(c)
end
diff --git a/tex/context/base/buff-ver.mkiv b/tex/context/base/buff-ver.mkiv
index 1ade44c7c..f1d733d76 100644
--- a/tex/context/base/buff-ver.mkiv
+++ b/tex/context/base/buff-ver.mkiv
@@ -115,18 +115,10 @@
\def\setupcommonverbatim
{\let\prettyidentifier\s!default
%
-% \doifelse{\typingparameter\c!text}\v!yes
-% \naturaltextexttrue
-% \naturaltextextfalse
\def\prettyidentifierfont{\typingparameter\c!icommand}%
\def\prettyvariablefont {\typingparameter\c!vcommand}%
\def\prettynaturalfont {\typingparameter\c!ccommand}%
%
- \doif{\typingparameter\c!space}\v!on
- {\def\obeyspaces{\setcontrolspaces}}%
- \doif{\typingparameter\c!page }\v!no
- {\def\obeypages {\ignorepages}}%
- %
\ignorehyphens % default
\getvalue{\??tp:\c!lines:\typingparameter\c!lines}%
\getvalue{\??tp:\c!empty:\typingparameter\c!empty}%
@@ -151,7 +143,9 @@
\def\doinitializeverbatim
{\ctxlua{buffers.visualizers.reset()}%
- \def\obs{\obeyedspace}%
+ \doifelse{\typingparameter\c!space}\v!on
+ {\let\obs\fastcontrolspace}%
+ {\let\obs\specialobeyedspace}%
\ctxlua{buffers.doifelsevisualizer("\prettyidentifier")}
{\ctxlua{buffers.setvisualizer("\prettyidentifier")}%
\let\bop\doverbatimbop
diff --git a/tex/context/base/catc-ini.mkiv b/tex/context/base/catc-ini.mkiv
index 311f0526e..d7ddfdc3d 100644
--- a/tex/context/base/catc-ini.mkiv
+++ b/tex/context/base/catc-ini.mkiv
@@ -279,5 +279,39 @@
% \tracecatcodetables
+%D Only in \MKIV\ (to be used when crossing pages with changed catcodes
+%D in the current vector):
+%D
+%D \starttyping
+%D \def\startcrap
+%D {\bgroup
+%D \pushcatcodes
+%D \whitespace
+%D \obeylines
+%D \activatespacehandler\v!yes
+%D \strut}
+%D
+%D \def\stopcrap
+%D {\popcatcodes
+%D \egroup}
+%D \stoptyping
+
+\newcount\catcodetablelevel
+
+\def\pushcatcodes
+ {\bgroup
+ \global\advance\catcodetablelevel\plusone
+ \ifcsname @@ccf:\number\catcodetablelevel\endcsname \else
+ \global\advance\cctdefcounter\plusone
+ \expandafter\global\expandafter\chardef\csname @@ccf:\number\catcodetablelevel\endcsname\cctdefcounter
+ \fi
+ \catcodetable\ctxcatcodes
+ \expandafter\savecatcodetable\csname @@ccf:\number\catcodetablelevel\endcsname
+ \egroup
+ \expandafter\catcodetable\csname @@ccf:\number\catcodetablelevel\endcsname}
+
+\def\popcatcodes
+ {\global\advance\catcodetablelevel\minusone}
+
\endinput
diff --git a/tex/context/base/char-act.mkiv b/tex/context/base/char-act.mkiv
index 34358784a..2dc7823f0 100644
--- a/tex/context/base/char-act.mkiv
+++ b/tex/context/base/char-act.mkiv
@@ -102,6 +102,19 @@
\prettynaturalfont{\scantextokens\expandafter{\ascii}\ifhmode\unskip\fi}%
\egroup}
+%D What-a-mess:
+
+% \def\normalspacecodes
+% {\catcode`\^^I = 10
+% \catcode`\^^M = 5
+% \catcode`\^^L = 5
+% \catcode`\ = 10
+% \catcode`\^^Z = 9 }
+
+% \appendtoks
+% \normalspacecodes
+% \to \everybeforeoutput
+
\endinput \protect
% obsolete (old hack for idris)
diff --git a/tex/context/base/cont-new.tex b/tex/context/base/cont-new.tex
index 45e1675b7..1c4d68b39 100644
--- a/tex/context/base/cont-new.tex
+++ b/tex/context/base/cont-new.tex
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2010.02.23 14:10}
+\newcontextversion{2010.02.24 22:28}
%D This file is loaded at runtime, thereby providing an
%D excellent place for hacks, patches, extensions and new
diff --git a/tex/context/base/context.tex b/tex/context/base/context.tex
index bbc70ee28..f030aa5e1 100644
--- a/tex/context/base/context.tex
+++ b/tex/context/base/context.tex
@@ -20,7 +20,7 @@
%D your styles an modules.
\edef\contextformat {\jobname}
-\edef\contextversion{2010.02.23 14:10}
+\edef\contextversion{2010.02.24 22:28}
%D For those who want to use this:
diff --git a/tex/context/base/enco-ini.mkiv b/tex/context/base/enco-ini.mkiv
index 7740c8b30..af4ddabaa 100644
--- a/tex/context/base/enco-ini.mkiv
+++ b/tex/context/base/enco-ini.mkiv
@@ -322,9 +322,26 @@
\unexpanded\def\schwa {\hbox{\rotate[\c!rotation=180,\c!location=\v!high]{\hbox{e}}}}
\unexpanded\def\schwagrave {\buildtextgrave\schwa}
-\unexpanded\def\normalcontrolspace{\getglyph{ComputerModernMono}{\char32}}
-\unexpanded\def\textvisiblespace {\fakecontrolspace}
-\unexpanded\def\fakecontrolspace {\let\normalcontrolspace\fakedcontrolspace}
+\chardef\textcontrolspace"2423
+
+\unexpanded\def\fallbackcontrolspace
+ %{\getglyph{ComputerModernMono}\textcontrolspace}
+ {\getglyph{LMTypewriter10-Regular}\textcontrolspace}
+
+\unexpanded\def\normalcontrolspace
+ {\iffontchar\font\textcontrolspace
+ \textcontrolspace
+ \else
+ \fallbackcontrolspace
+ \fi}
+
+\unexpanded\def\fastcontrolspace
+ {\iffontchar\font\textcontrolspace
+ \textcontrolspace
+ \else
+ \fallbackcontrolspace
+ \let\normalcontrolspace\fallbackcontrolspace
+ \fi}
% helpers
diff --git a/tex/context/base/font-ctx.lua b/tex/context/base/font-ctx.lua
index 48f99efba..6ee2ca0d9 100644
--- a/tex/context/base/font-ctx.lua
+++ b/tex/context/base/font-ctx.lua
@@ -277,12 +277,13 @@ local spaces = space^0
local leftparent = (P"(")
local rightparent = (P")")
local value = C((leftparent * (1-rightparent)^0 * rightparent + (1-space))^1)
+local dimension = C((space/"" + P(1))^1)
local rest = C(P(1)^0)
local scale_none = Cc(0)
-local scale_at = P("at") * Cc(1) * spaces * value
-local scale_sa = P("sa") * Cc(2) * spaces * value
-local scale_mo = P("mo") * Cc(3) * spaces * value
-local scale_scaled = P("scaled") * Cc(4) * spaces * value
+local scale_at = P("at") * Cc(1) * spaces * dimension -- value
+local scale_sa = P("sa") * Cc(2) * spaces * dimension -- value
+local scale_mo = P("mo") * Cc(3) * spaces * dimension -- value
+local scale_scaled = P("scaled") * Cc(4) * spaces * dimension -- value
local sizepattern = spaces * (scale_at + scale_sa + scale_mo + scale_scaled + scale_none)
local splitpattern = spaces * value * spaces * rest
@@ -449,3 +450,13 @@ end
function fonts.cleanname(name)
texsprint(ctxcatcodes,fonts.names.cleanname(name))
end
+
+local p, f = 1, "%0.01fpt" -- normally this value is changed only once
+
+function fonts.nbfs(amount,precision)
+ if precision ~= p then
+ p = precision
+ f = "%0.0" .. p .. "fpt"
+ end
+ texsprint(ctxcatcodes,format(f,amount/65536))
+end
diff --git a/tex/context/base/font-enc.lua b/tex/context/base/font-enc.lua
index f43a212c4..874f7c3f4 100644
--- a/tex/context/base/font-enc.lua
+++ b/tex/context/base/font-enc.lua
@@ -17,7 +17,7 @@ fonts.enc = fonts.enc or { }
fonts.enc.version = 1.03
fonts.enc.cache = containers.define("fonts", "enc", fonts.enc.version, true)
-fonts.enc.known = {
+fonts.enc.known = { -- sort of obsolete
texnansi = true,
ec = true,
qx = true,
diff --git a/tex/context/base/font-enh.lua b/tex/context/base/font-enh.lua
new file mode 100644
index 000000000..0f86b6930
--- /dev/null
+++ b/tex/context/base/font-enh.lua
@@ -0,0 +1,201 @@
+if not modules then modules = { } end modules ['font-enh'] = {
+ version = 1.001,
+ comment = "companion to font-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local next, match = next, string.match
+
+local trace_defining = false trackers.register("fonts.defining", function(v) trace_defining = v end)
+
+-- tfmdata has also fast access to indices and unicodes
+-- to be checked: otf -> tfm -> tfmscaled
+--
+-- watch out: no negative depths and negative eights permitted in regular fonts
+
+--[[ldx--
+<p>Here we only implement a few helper functions.</p>
+--ldx]]--
+
+local tfm = fonts.tfm
+
+--[[ldx--
+<p>The next function encapsulates the standard <l n='tfm'/> loader as
+supplied by <l n='luatex'/>.</p>
+--ldx]]--
+
+-- auto complete font with missing composed characters
+
+table.insert(fonts.manipulators,"compose")
+
+function fonts.initializers.common.compose(tfmdata,value)
+ if value then
+ fonts.vf.aux.compose_characters(tfmdata)
+ end
+end
+
+-- tfm features, experimental
+
+tfm.features = tfm.features or { }
+tfm.features.list = tfm.features.list or { }
+tfm.features.default = tfm.features.default or { }
+
+function tfm.enhance(tfmdata,specification)
+ -- we don't really share tfm data because we always reload
+ -- but this is more in sycn with afm and such
+ local features = (specification.features and specification.features.normal ) or { }
+ tfmdata.shared = tfmdata.shared or { }
+ tfmdata.shared.features = features
+ -- tfmdata.shared.tfmdata = tfmdata -- circular
+ tfmdata.filename = specification.name
+ if not features.encoding then
+ local name, size = specification.name, specification.size
+ local encoding, filename = match(name,"^(.-)%-(.*)$") -- context: encoding-name.*
+ if filename and encoding and fonts.enc.known[encoding] then
+ features.encoding = encoding
+ end
+ end
+ tfm.set_features(tfmdata)
+end
+
+function tfm.set_features(tfmdata)
+ -- todo: no local functions
+ local shared = tfmdata.shared
+-- local tfmdata = shared.tfmdata
+ local features = shared.features
+ if not table.is_empty(features) then
+ local mode = tfmdata.mode or fonts.mode
+ local fi = fonts.initializers[mode]
+ if fi and fi.tfm then
+ local function initialize(list) -- using tex lig and kerning
+ if list then
+ for i=1,#list do
+ local f = list[i]
+ local value = features[f]
+ if value and fi.tfm[f] then -- brr
+ if tfm.trace_features then
+ logs.report("define font","initializing feature %s to %s for mode %s for font %s",f,tostring(value),mode or 'unknown',tfmdata.name or 'unknown')
+ end
+ fi.tfm[f](tfmdata,value)
+ mode = tfmdata.mode or fonts.mode
+ fi = fonts.initializers[mode]
+ end
+ end
+ end
+ end
+ initialize(fonts.triggers)
+ initialize(tfm.features.list)
+ initialize(fonts.manipulators)
+ end
+ local fm = fonts.methods[mode]
+ if fm and fm.tfm then
+ local function register(list) -- node manipulations
+ if list then
+ for i=1,#list do
+ local f = list[i]
+ if features[f] and fm.tfm[f] then -- brr
+ if not shared.processors then -- maybe also predefine
+ shared.processors = { fm.tfm[f] }
+ else
+ shared.processors[#shared.processors+1] = fm.tfm[f]
+ end
+ end
+ end
+ end
+ end
+ register(tfm.features.list)
+ end
+ end
+end
+
+function tfm.features.register(name,default)
+ tfm.features.list[#tfm.features.list+1] = name
+ tfm.features.default[name] = default
+end
+
+function tfm.reencode(tfmdata,encoding)
+ if encoding and fonts.enc.known[encoding] then
+ local data = fonts.enc.load(encoding)
+ if data then
+ local characters, original, vector = tfmdata.characters, { }, data.vector
+ tfmdata.encoding = encoding -- not needed
+ for k, v in next, characters do
+ v.name, v.index, original[k] = vector[k], k, v
+ end
+ for k,v in next, data.unicodes do
+ if k ~= v then
+ if trace_defining then
+ logs.report("define font","reencoding U+%04X to U+%04X",k,v)
+ end
+ characters[k] = original[v]
+ end
+ end
+ end
+ end
+end
+
+tfm.features.register('reencode')
+
+fonts.initializers.base.tfm.reencode = tfm.reencode
+fonts.initializers.node.tfm.reencode = tfm.reencode
+
+fonts.enc = fonts.enc or { }
+fonts.enc.remappings = fonts.enc.remappings or { }
+
+function tfm.remap(tfmdata,remapping)
+ local vector = remapping and fonts.enc.remappings[remapping]
+ if vector then
+ local characters, original = tfmdata.characters, { }
+ for k, v in next, characters do
+ original[k], characters[k] = v, nil
+ end
+ for k,v in next, vector do
+ if k ~= v then
+ if trace_defining then
+ logs.report("define font","remapping U+%04X to U+%04X",k,v)
+ end
+ local c = original[k]
+ characters[v] = c
+ c.index = k
+ end
+ end
+ tfmdata.encodingbytes = 2
+ tfmdata.format = 'type1'
+ end
+end
+
+tfm.features.register('remap')
+
+fonts.initializers.base.tfm.remap = tfm.remap
+fonts.initializers.node.tfm.remap = tfm.remap
+
+--~ obsolete
+--~
+--~ function tfm.enhance(tfmdata,specification)
+--~ local name, size = specification.name, specification.size
+--~ local encoding, filename = match(name,"^(.-)%-(.*)$") -- context: encoding-name.*
+--~ if filename and encoding and fonts.enc.known[encoding] then
+--~ local data = fonts.enc.load(encoding)
+--~ if data then
+--~ local characters = tfmdata.characters
+--~ tfmdata.encoding = encoding
+--~ local vector = data.vector
+--~ local original = { }
+--~ for k, v in next, characters do
+--~ v.name = vector[k]
+--~ v.index = k
+--~ original[k] = v
+--~ end
+--~ for k,v in next, data.unicodes do
+--~ if k ~= v then
+--~ if trace_defining then
+--~ logs.report("define font","mapping %s onto %s",k,v)
+--~ end
+--~ characters[k] = original[v]
+--~ end
+--~ end
+--~ end
+--~ end
+--~ end
diff --git a/tex/context/base/font-ext.lua b/tex/context/base/font-ext.lua
index ade80fa9e..f32f1b77c 100644
--- a/tex/context/base/font-ext.lua
+++ b/tex/context/base/font-ext.lua
@@ -6,8 +6,10 @@ if not modules then modules = { } end modules ['font-ext'] = {
license = "see context related readme files"
}
+local utf = unicode.utf8
local next, type, byte = next, type, string.byte
-local gmatch = string.gmatch
+local gmatch, concat = string.gmatch, table.concat
+local utfchar = utf.char
local trace_protrusion = false trackers.register("fonts.protrusion", function(v) trace_protrusion = v end)
local trace_expansion = false trackers.register("fonts.expansion" , function(v) trace_expansion = v end)
@@ -293,51 +295,158 @@ vectors['quality'] = table.merge( {},
vectors['alpha']
)
+-- As this is experimental code, users should not depend on it. The
+-- implications are still discussed on the ConTeXt Dev List and we're
+-- not sure yet what exactly the spec is (the next code is tested with
+-- a gyre font patched by / fea file made by Khaled Hosny). The double
+-- trick should not be needed it proper hanging punctuation is used in
+-- which case values < 1 can be used.
+--
+-- preferred (in context, usine vectors):
+--
+-- \definefontfeature[whatever][default][mode=node,protrusion=quality]
+--
+-- using lfbd and rtbd, with possibibility to enable only one side :
+--
+-- \definefontfeature[whocares][default][mode=node,protrusion=yes, opbd=yes,script=latn]
+-- \definefontfeature[whocares][default][mode=node,protrusion=right,opbd=yes,script=latn]
+--
+-- idem, using multiplier
+--
+-- \definefontfeature[whocares][default][mode=node,protrusion=2,opbd=yes,script=latn]
+-- \definefontfeature[whocares][default][mode=node,protrusion=double,opbd=yes,script=latn]
+--
+-- idem, using named feature file (less frozen):
+--
+-- \definefontfeature[whocares][default][mode=node,protrusion=2,opbd=yes,script=latn,featurefile=texgyrepagella-regularxx.fea]
+
+classes['double'] = { -- for testing opbd
+ factor = 2, left = 1, right = 1,
+}
+
+local function map_opbd_onto_protrusion(tfmdata,value,opbd)
+ local characters, descriptions = tfmdata.characters, tfmdata.descriptions
+ local otfdata = tfmdata.shared.otfdata
+ local singles = otfdata.shared.featuredata.gpos_single
+ local script, language = tfmdata.script, tfmdata.language
+ local done, factor, left, right = false, 1, 1, 1
+ local class = classes[value]
+ if class then
+ factor = class.factor or 1
+ left = class.left or 1
+ right = class.right or 1
+ else
+ factor = tonumber(value) or 1
+ end
+ if opbd ~= "right" then
+ local validlookups, lookuplist = fonts.otf.collect_lookups(otfdata,"lfbd",script,language)
+ if validlookups then
+ for i=1,#lookuplist do
+ local lookup = lookuplist[i]
+ local data = singles[lookup]
+ if data then
+ if trace_protrusion then
+ logs.report("fonts","set left protrusion using lfbd lookup '%s'",lookup)
+ end
+ for k, v in next, data do
+ -- local p = - v[3] / descriptions[k].width-- or 1 ~= 0 too but the same
+ local p = - (v[1] / 1000) * factor * left
+ characters[k].left_protruding = p
+ if trace_protrusion then
+ logs.report("opbd","lfbd -> %s -> 0x%05X (%s) -> %0.03f (%s)",lookup,k,utfchar(k),p,concat(v," "))
+ end
+ end
+ done = true
+ end
+ end
+ end
+ end
+ if opbd ~= "left" then
+ local validlookups, lookuplist = fonts.otf.collect_lookups(otfdata,"rtbd",script,language)
+ if validlookups then
+ for i=1,#lookuplist do
+ local lookup = lookuplist[i]
+ local data = singles[lookup]
+ if data then
+ if trace_protrusion then
+ logs.report("fonts","set right protrusion using rtbd lookup '%s'",lookup)
+ end
+ for k, v in next, data do
+ -- local p = v[3] / descriptions[k].width -- or 3
+ local p = (v[1] / 1000) * factor * right
+ characters[k].right_protruding = p
+ if trace_protrusion then
+ logs.report("opbd","rtbd -> %s -> 0x%05X (%s) -> %0.03f (%s)",lookup,k,utfchar(k),p,concat(v," "))
+ end
+ end
+ end
+ done = true
+ end
+ end
+ end
+ tfmdata.auto_protrude = done
+end
+
+-- The opbd test is just there because it was discussed on the
+-- context development list. However, the mentioned fxlbi.otf font
+-- only has some kerns for digits. So, consider this feature not
+-- supported till we have a proper test font.
+
function initializers.common.protrusion(tfmdata,value)
if value then
- local class = classes[value]
- if class then
- local vector = vectors[class.vector]
- if vector then
- local factor = class.factor or 1
- local left = class.left or 1
- local right = class.right or 1
- if trace_protrusion then
- logs.report("fonts","set protrusion class %s, vector: %s, factor: %s, left: %s, right: %s",value,class.vector,factor.left,right)
- end
- local data = characters.data
- local emwidth = tfmdata.parameters.quad
- tfmdata.auto_protrude = true
- for i, chr in next, tfmdata.characters do
- local v, pl, pr = vector[i], nil, nil
- if v then
- pl, pr = v[1], v[2]
- else
- local d = data[i]
- if d then
- local s = d.shcode
- if not s then
- -- sorry
- elseif type(s) == "table" then
- local vl, vr = vector[s[1]], vector[s[#s]]
- if vl then pl = vl[1] end
- if vr then pr = vr[2] end
- else
- v = vector[s]
- if v then
- pl, pr = v[1], v[2]
+ local opbd = tfmdata.shared.features.opbd
+ if opbd then
+ -- possible values: left right both yes no (experimental)
+ map_opbd_onto_protrusion(tfmdata,value,opbd)
+ else
+ local class = classes[value]
+ if class then
+ local vector = vectors[class.vector]
+ if vector then
+ local factor = class.factor or 1
+ local left = class.left or 1
+ local right = class.right or 1
+ if trace_protrusion then
+ logs.report("fonts","set protrusion class %s, vector: %s, factor: %s, left: %s, right: %s",value,class.vector,factor,left,right)
+ end
+ local data = characters.data
+ local emwidth = tfmdata.parameters.quad
+ tfmdata.auto_protrude = true
+ for i, chr in next, tfmdata.characters do
+ local v, pl, pr = vector[i], nil, nil
+ if v then
+ pl, pr = v[1], v[2]
+ else
+ local d = data[i]
+ if d then
+ local s = d.shcode
+ if not s then
+ -- sorry
+ elseif type(s) == "table" then
+ local vl, vr = vector[s[1]], vector[s[#s]]
+ if vl then pl = vl[1] end
+ if vr then pr = vr[2] end
+ else
+ v = vector[s]
+ if v then
+ pl, pr = v[1], v[2]
+ end
end
end
end
+ if pl and pl ~= 0 then
+ chr.left_protruding = left *pl*factor
+ end
+ if pr and pr ~= 0 then
+ chr.right_protruding = right*pr*factor
+ end
end
- if pl and pl ~= 0 then chr.left_protruding = left *pl*factor end
- if pr and pr ~= 0 then chr.right_protruding = right*pr*factor end
+ elseif trace_protrusion then
+ logs.report("fonts","unknown protrusion vector '%s' in class '%s",class.vector,value)
end
elseif trace_protrusion then
- logs.report("fonts","unknown protrusion vector '%s' in class '%s",class.vector,value)
+ logs.report("fonts","unknown protrusion class '%s'",value)
end
- elseif trace_protrusion then
- logs.report("fonts","unknown protrusion class '%s'",value)
end
end
end
diff --git a/tex/context/base/font-ini.mkiv b/tex/context/base/font-ini.mkiv
index 94d14de8c..2d1953663 100644
--- a/tex/context/base/font-ini.mkiv
+++ b/tex/context/base/font-ini.mkiv
@@ -61,6 +61,7 @@
\registerctxluafile{font-syn}{1.001}
\registerctxluafile{font-log}{1.001}
\registerctxluafile{font-tfm}{1.001}
+\registerctxluafile{font-enh}{1.001}
\registerctxluafile{font-afm}{1.001}
\registerctxluafile{font-cid}{1.001} % cid maps
\registerctxluafile{font-ott}{1.001} % otf tables
@@ -1816,34 +1817,24 @@
\chardef\fontdigits=2 % was 1
-\def\normalizebodyfontsize#1\to#2%
- {\@EA\@EA\@EA\donormalizedbodyfontsize\@EA\WITHOUTPT\the\dimexpr#1+\ifcase\fontdigits.5\or.05\or.005\fi\points\relax000\to#2}
-
-\def\donormalizedbodyfontsize#1.#2#3#4#5\to#6% \points ?
- {\edef#6% not \ifcase#2\else due to \relax adding
- {#1%
- \ifcase\fontdigits
- \or \ifcase#2 \else .#2\fi % 1
- \or \ifcase#2#3 \else .#2\ifcase#3 \else #3\fi\fi % 2
- \else \ifcase#2#3#4 \else .#2\ifcase#4 \ifcase#3 \else#3\fi \else#3#4\fi\fi % 3
- \fi
- \s!pt}}
-
-% not faster, just less tracing
-%
-% \def\setfontdigits#1%
-% {\chardef\fontdigits\ifnum#1>\plusthree\plusthree\else#1\fi\relax
-% \@EA\let\@EA\normalizedbfs\csname normalizedbfs\number\fontdigits\endcsname}
-%
% \def\normalizebodyfontsize#1\to#2%
-% {\@EA\@EA\@EA\normalizedbfs\@EA\WITHOUTPT\the\dimexpr#1+\ifcase\fontdigits.5\or.05\or.005\fi\points\relax000\to#2}
-%
-% \setvalue{normalizedbfs0}#1.#2\to #3{\edef#3{#1\s!pt}}
-% \setvalue{normalizedbfs1}#1.#2#3\to #4{\edef#4{#1\ifcase#2 \else.#2\fi\s!pt}}
-% \setvalue{normalizedbfs2}#1.#2#3#4\to #5{\edef#5{#1\ifcase#2#3 \else.#2\ifcase#3 \else#3\fi\fi\s!pt}}
-% \setvalue{normalizedbfs3}#1.#2#3#4#5\to#6{\edef#6{#1\ifcase#2#3#4 \else.#2\ifcase#4 \ifcase#3 \else#3\fi\else#3#4\fi\fi\s!pt}}
+% {\@EA\@EA\@EA\donormalizedbodyfontsize\@EA\WITHOUTPT\the\dimexpr#1+\ifcase\fontdigits.5\or.05\or.005\fi\points\relax000\to#2}
%
-% \setfontdigits2
+% \def\donormalizedbodyfontsize#1.#2#3#4#5\to#6% \points ?
+% {\edef#6% not \ifcase#2\else due to \relax adding
+% {#1%
+% \ifcase\fontdigits
+% \or \ifcase#2 \else .#2\fi % 1
+% \or \ifcase#2#3 \else .#2\ifcase#3 \else #3\fi\fi % 2
+% \else \ifcase#2#3#4 \else .#2\ifcase#4 \ifcase#3 \else#3\fi \else#3#4\fi\fi % 3
+% \fi
+% \s!pt}}
+
+\def\normalizebodyfontsize#1\to#2%
+ {\edef#2{\ctxlua{fonts.nbfs(\number\dimexpr#1\relax,\number\fontdigits)}}}
+
+\def\thenormalizedbodyfontsize#1%
+ {\ctxlua{fonts.nbfs(\number\dimexpr#1\relax,\number\fontdigits)}}
\normalizebodyfontsize\bodyfontsize\to\normalizedglobalbodyfontsize
\normalizebodyfontsize\bodyfontsize\to\normalizedlocalbodyfontsize
diff --git a/tex/context/base/font-otb.lua b/tex/context/base/font-otb.lua
index a4cd5be02..020b107a5 100644
--- a/tex/context/base/font-otb.lua
+++ b/tex/context/base/font-otb.lua
@@ -134,43 +134,12 @@ local function resolve_ligatures(tfmdata,ligatures,kind)
end
end
-local function collect_lookups(otfdata,kind,script,language)
- -- maybe store this in the font
- local sequences = otfdata.luatex.sequences
- if sequences then
- local featuremap, featurelist = { }, { }
- for s=1,#sequences do
- local sequence = sequences[s]
- local features = sequence.features
- features = features and features[kind]
- features = features and (features[script] or features[default] or features[wildcard])
- features = features and (features[language] or features[default] or features[wildcard])
- if features then
- local subtables = sequence.subtables
- if subtables then
- for s=1,#subtables do
- local ss = subtables[s]
- if not featuremap[s] then
- featuremap[ss] = true
- featurelist[#featurelist+1] = ss
- end
- end
- end
- end
- end
- if #featurelist > 0 then
- return featuremap, featurelist
- end
- end
- return nil, nil
-end
-
local splitter = lpeg.splitat(" ")
function prepare_base_substitutions(tfmdata,kind,value) -- we can share some code with the node features
if value then
local otfdata = tfmdata.shared.otfdata
- local validlookups, lookuplist = collect_lookups(otfdata,kind,tfmdata.script,tfmdata.language)
+ local validlookups, lookuplist = otf.collect_lookups(otfdata,kind,tfmdata.script,tfmdata.language)
if validlookups then
local ligatures = { }
local unicodes = tfmdata.unicodes -- names to unicodes
@@ -279,51 +248,10 @@ function prepare_base_substitutions(tfmdata,kind,value) -- we can share some cod
end
end
---~ local function prepare_base_kerns(tfmdata,kind,value) -- todo what kind of kerns, currently all
---~ if value then
---~ local otfdata = tfmdata.shared.otfdata
---~ local validlookups, lookuplist = collect_lookups(otfdata,kind,tfmdata.script,tfmdata.language)
---~ if validlookups then
---~ local unicodes = tfmdata.unicodes -- names to unicodes
---~ local indices = tfmdata.indices
---~ local characters = tfmdata.characters
---~ local descriptions = tfmdata.descriptions
---~ for u, chr in next, characters do
---~ local d = descriptions[u]
---~ if d then
---~ local dk = d.mykerns
---~ if dk then
---~ local t, done = chr.kerns or { }, false
---~ for l=1,#lookuplist do
---~ local lookup = lookuplist[l]
---~ local kerns = dk[lookup]
---~ if kerns then
---~ for k, v in next, kerns do
---~ if v ~= 0 and not t[k] then -- maybe no 0 test here
---~ t[k], done = v, true
---~ if trace_baseinit and trace_kerns then
---~ logs.report("define otf","%s: base kern %s + %s => %s",cref(kind,lookup),gref(descriptions,u),gref(descriptions,k),v)
---~ end
---~ end
---~ end
---~ end
---~ end
---~ if done then
---~ chr.kerns = t -- no empty assignments
---~ end
---~ -- elseif d.kerns then
---~ -- logs.report("define otf","%s: invalid mykerns for %s",cref(kind),gref(descriptions,u))
---~ end
---~ end
---~ end
---~ end
---~ end
---~ end
-
local function prepare_base_kerns(tfmdata,kind,value) -- todo what kind of kerns, currently all
if value then
local otfdata = tfmdata.shared.otfdata
- local validlookups, lookuplist = collect_lookups(otfdata,kind,tfmdata.script,tfmdata.language)
+ local validlookups, lookuplist = otf.collect_lookups(otfdata,kind,tfmdata.script,tfmdata.language)
if validlookups then
local unicodes = tfmdata.unicodes -- names to unicodes
local indices = tfmdata.indices
diff --git a/tex/context/base/font-otf.lua b/tex/context/base/font-otf.lua
index 94f5dcf16..1465e138b 100644
--- a/tex/context/base/font-otf.lua
+++ b/tex/context/base/font-otf.lua
@@ -1711,3 +1711,36 @@ function tfm.read_from_open_type(specification)
--~ print(tfmtable.fullname)
return tfmtable
end
+
+-- helpers
+
+function otf.collect_lookups(otfdata,kind,script,language)
+ -- maybe store this in the font
+ local sequences = otfdata.luatex.sequences
+ if sequences then
+ local featuremap, featurelist = { }, { }
+ for s=1,#sequences do
+ local sequence = sequences[s]
+ local features = sequence.features
+ features = features and features[kind]
+ features = features and (features[script] or features[default] or features[wildcard])
+ features = features and (features[language] or features[default] or features[wildcard])
+ if features then
+ local subtables = sequence.subtables
+ if subtables then
+ for s=1,#subtables do
+ local ss = subtables[s]
+ if not featuremap[s] then
+ featuremap[ss] = true
+ featurelist[#featurelist+1] = ss
+ end
+ end
+ end
+ end
+ end
+ if #featurelist > 0 then
+ return featuremap, featurelist
+ end
+ end
+ return nil, nil
+end
diff --git a/tex/context/base/font-otn.lua b/tex/context/base/font-otn.lua
index efafa30c6..16ecc2d48 100644
--- a/tex/context/base/font-otn.lua
+++ b/tex/context/base/font-otn.lua
@@ -1988,6 +1988,7 @@ function fonts.methods.node.otf.features(head,font,attr)
if not lookupcache then
report_missing_cache(typ,lookupname)
else
+--~ print(typ,lookupname,lookupcache,table.serialize(lookupcache))
while start do
local id = start.id
if id == glyph then
@@ -1997,6 +1998,7 @@ function fonts.methods.node.otf.features(head,font,attr)
if lookupmatch then
-- sequence kan weg
local ok
+--~ print("!!!")
start, ok = handler(start,r[4],lookupname,lookupmatch,sequence,featuredata,1)
--~ texio.write_nl(tostring(lookupname),tostring(lookupmatch),tostring(ok))
if ok then
diff --git a/tex/context/base/font-tfm.lua b/tex/context/base/font-tfm.lua
index 1e39dc4e3..aa8739800 100644
--- a/tex/context/base/font-tfm.lua
+++ b/tex/context/base/font-tfm.lua
@@ -50,32 +50,7 @@ tfm.share_base_kerns = false -- true (.5 sec slower on mk but brings down mem fr
tfm.mathactions = { }
tfm.fontname_mode = "fullpath"
-function tfm.enhance(tfmdata,specification)
- local name, size = specification.name, specification.size
- local encoding, filename = match(name,"^(.-)%-(.*)$") -- context: encoding-name.*
- if filename and encoding and fonts.enc.known[encoding] then
- local data = fonts.enc.load(encoding)
- if data then
- local characters = tfmdata.characters
- tfmdata.encoding = encoding
- local vector = data.vector
- local original = { }
- for k, v in next, characters do
- v.name = vector[k]
- v.index = k
- original[k] = v
- end
- for k,v in next, data.unicodes do
- if k ~= v then
- if trace_defining then
- logs.report("define font","mapping %s onto %s",k,v)
- end
- characters[k] = original[v]
- end
- end
- end
- end
-end
+tfm.enhance = tfm.enhance or function() end
function tfm.read_from_tfm(specification)
local fname, tfmdata = specification.filename or "", nil
@@ -733,151 +708,6 @@ function tfm.replacements(tfm,value)
-- tfm.characters[0x0060] = tfm.characters[0x2018]
end
--- auto complete font with missing composed characters
-
-table.insert(fonts.manipulators,"compose")
-
-function fonts.initializers.common.compose(tfmdata,value)
- if value then
- fonts.vf.aux.compose_characters(tfmdata)
- end
-end
-
--- tfm features, experimental
-
-tfm.features = tfm.features or { }
-tfm.features.list = tfm.features.list or { }
-tfm.features.default = tfm.features.default or { }
-
-function tfm.enhance(tfmdata,specification)
- -- we don't really share tfm data because we always reload
- -- but this is more in sycn with afm and such
- local features = (specification.features and specification.features.normal ) or { }
- tfmdata.shared = tfmdata.shared or { }
- tfmdata.shared.features = features
- -- tfmdata.shared.tfmdata = tfmdata -- circular
- tfmdata.filename = specification.name
- if not features.encoding then
- local name, size = specification.name, specification.size
- local encoding, filename = match(name,"^(.-)%-(.*)$") -- context: encoding-name.*
- if filename and encoding and fonts.enc.known[encoding] then
- features.encoding = encoding
- end
- end
- tfm.set_features(tfmdata)
-end
-
-function tfm.set_features(tfmdata)
- -- todo: no local functions
- local shared = tfmdata.shared
--- local tfmdata = shared.tfmdata
- local features = shared.features
- if not table.is_empty(features) then
- local mode = tfmdata.mode or fonts.mode
- local fi = fonts.initializers[mode]
- if fi and fi.tfm then
- local function initialize(list) -- using tex lig and kerning
- if list then
- for i=1,#list do
- local f = list[i]
- local value = features[f]
- if value and fi.tfm[f] then -- brr
- if tfm.trace_features then
- logs.report("define font","initializing feature %s to %s for mode %s for font %s",f,tostring(value),mode or 'unknown',tfmdata.name or 'unknown')
- end
- fi.tfm[f](tfmdata,value)
- mode = tfmdata.mode or fonts.mode
- fi = fonts.initializers[mode]
- end
- end
- end
- end
- initialize(fonts.triggers)
- initialize(tfm.features.list)
- initialize(fonts.manipulators)
- end
- local fm = fonts.methods[mode]
- if fm and fm.tfm then
- local function register(list) -- node manipulations
- if list then
- for i=1,#list do
- local f = list[i]
- if features[f] and fm.tfm[f] then -- brr
- if not shared.processors then -- maybe also predefine
- shared.processors = { fm.tfm[f] }
- else
- shared.processors[#shared.processors+1] = fm.tfm[f]
- end
- end
- end
- end
- end
- register(tfm.features.list)
- end
- end
-end
-
-function tfm.features.register(name,default)
- tfm.features.list[#tfm.features.list+1] = name
- tfm.features.default[name] = default
-end
-
-function tfm.reencode(tfmdata,encoding)
- if encoding and fonts.enc.known[encoding] then
- local data = fonts.enc.load(encoding)
- if data then
- local characters, original, vector = tfmdata.characters, { }, data.vector
- tfmdata.encoding = encoding -- not needed
- for k, v in next, characters do
- v.name, v.index, original[k] = vector[k], k, v
- end
- for k,v in next, data.unicodes do
- if k ~= v then
- if trace_defining then
- logs.report("define font","reencoding U+%04X to U+%04X",k,v)
- end
- characters[k] = original[v]
- end
- end
- end
- end
-end
-
-tfm.features.register('reencode')
-
-fonts.initializers.base.tfm.reencode = tfm.reencode
-fonts.initializers.node.tfm.reencode = tfm.reencode
-
-fonts.enc = fonts.enc or { }
-fonts.enc.remappings = fonts.enc.remappings or { }
-
-function tfm.remap(tfmdata,remapping)
- local vector = remapping and fonts.enc.remappings[remapping]
- if vector then
- local characters, original = tfmdata.characters, { }
- for k, v in next, characters do
- original[k], characters[k] = v, nil
- end
- for k,v in next, vector do
- if k ~= v then
- if trace_defining then
- logs.report("define font","remapping U+%04X to U+%04X",k,v)
- end
- local c = original[k]
- characters[v] = c
- c.index = k
- end
- end
- tfmdata.encodingbytes = 2
- tfmdata.format = 'type1'
- end
-end
-
-tfm.features.register('remap')
-
-fonts.initializers.base.tfm.remap = tfm.remap
-fonts.initializers.node.tfm.remap = tfm.remap
-
-- status info
statistics.register("fonts load time", function()
diff --git a/tex/context/base/grph-inc.lua b/tex/context/base/grph-inc.lua
index b984f9877..7f786248e 100644
--- a/tex/context/base/grph-inc.lua
+++ b/tex/context/base/grph-inc.lua
@@ -672,7 +672,7 @@ function figures.done(data)
local dr, du, ds, nr = data.request, data.used, data.status, figures.boxnumber
ds.width = texwd[nr]
ds.height = texht[nr]
- ds.xscale = ds.width/(du.width or 1)
+ ds.xscale = ds.width /(du.width or 1)
ds.yscale = ds.height/(du.height or 1)
return data
end
diff --git a/tex/context/base/grph-inc.mkiv b/tex/context/base/grph-inc.mkiv
index e28a289ab..1fc9656a9 100644
--- a/tex/context/base/grph-inc.mkiv
+++ b/tex/context/base/grph-inc.mkiv
@@ -85,7 +85,7 @@
\def\figurefilecache {\ctxlua{figures.tprint("request","cache")}}
\def\figurefileprefix {\ctxlua{figures.tprint("request","prefix")}}
-\def\figurenaturalwidth {\ctxlua{figures.tprint("used","width",\number\dimexpr\defaultfigurewidth\relax)}sp}
+\def\figurenaturalwidth {\ctxlua{figures.tprint("used","width", \number\dimexpr\defaultfigurewidth \relax)}sp}
\def\figurenaturalheight {\ctxlua{figures.tprint("used","height",\number\dimexpr\defaultfigureheight\relax)}sp}
\def\figurefilepath {\ctxlua{tex.sprint(tex.ctxcatcodes,file.dirname (figures.get("used","fullname")))}}
diff --git a/tex/context/base/hand-ini.mkiv b/tex/context/base/hand-ini.mkiv
index 9b1bc41c7..9473fecc6 100644
--- a/tex/context/base/hand-ini.mkiv
+++ b/tex/context/base/hand-ini.mkiv
@@ -17,6 +17,24 @@
% \definefontfeature[demo][default][mode=node,expansion=quality]
% \definefontfeature[demo][default][mode=node,protrusion=pure]
+% experimental setup:
+%
+% \showframe \setupalign[hanging] \enabletrackers[fonts.protrusion]
+%
+% \definefontfeature[default] [default][mode=node,script=latn]
+% %definefontfeature[whatever][default][mode=node,lfbd=yes,rtbd=yes,script=latn]
+% \definefontfeature[whatever][default][mode=node,protrusion=quality]
+% \definefontfeature[whocares][default][mode=node,protrusion=yes,opbd=yes,script=latn] % left|right|yes
+%
+% \definedfont[fxlbi.otf*default] \input tufte 0123456789 \par \dorecurse{15}{1 2 3 4 5 6 7 8 9 0 } \par
+% \definedfont[fxlbi.otf*whatever] \input tufte 0123456789 \par \dorecurse{15}{1 2 3 4 5 6 7 8 9 0 } \par
+% \definedfont[fxlbi.otf*whocares] \input tufte 0123456789 \par \dorecurse{15}{1 2 3 4 5 6 7 8 9 0 } \par
+%
+% %definefontfeature[whocares][default][mode=node,protrusion=2,opbd=yes,script=latn,featurefile=texgyrepagella-regularxx.fea]
+% \definefontfeature[whocares][default][mode=node,protrusion=2,opbd=yes,script=latn]
+%
+% \definedfont[texgyrepagella-regularxx.otf*whocares] \input tufte
+
\unprotect
%D New stuff.
diff --git a/tex/context/base/math-ini.mkii b/tex/context/base/math-ini.mkii
index 6713987f7..f9dd859c4 100644
--- a/tex/context/base/math-ini.mkii
+++ b/tex/context/base/math-ini.mkii
@@ -451,7 +451,10 @@
\newtoks\everymathpunctuation
\def\enablemathpunctuation % can be called inside math, so after \everymathematics
- {\the\everymathpunctuation
+ {\relax
+ \ifmmode
+ \the\everymathpunctuation
+ \fi
\appendtoksonce
\the\everymathpunctuation
\to\everymathematics}
diff --git a/tex/context/base/math-lbr.mkii b/tex/context/base/math-lbr.mkii
index 7ac7c3aff..05a422cba 100644
--- a/tex/context/base/math-lbr.mkii
+++ b/tex/context/base/math-lbr.mkii
@@ -13,12 +13,12 @@
\unprotect
-\definefamilysynonym [lbr] [calligrapahy] [sy]
-\definefamilysynonym [lbr] [oldstyle] [mi]
+\definefamilysynonym [lbr] [calligraphy] [sy]
+\definefamilysynonym [lbr] [oldstyle] [mi]
-\definefamilysynonym [lbr] [blackboard] [ma]
-\definefamilysynonym [lbr] [ucgreek] [mb]
-\definefamilysynonym [lbr] [vargreek] [mi]
+\definefamilysynonym [lbr] [blackboard] [ma]
+\definefamilysynonym [lbr] [ucgreek] [mb]
+\definefamilysynonym [lbr] [vargreek] [mi]
\startmathcollection[lbr]
diff --git a/tex/context/base/math-vfu.lua b/tex/context/base/math-vfu.lua
index 2a9b3d3f1..6ed0a6abe 100644
--- a/tex/context/base/math-vfu.lua
+++ b/tex/context/base/math-vfu.lua
@@ -734,7 +734,7 @@ fonts.enc.math["tex-mi"] = {
[0x1D711] = 0x27, -- varphi (the other way around)
[0x021BC] = 0x28, -- leftharpoonup
[0x021BD] = 0x29, -- leftharpoondown
- [0x021C0] = 0x2A, -- righttharpoonup
+ [0x021C0] = 0x2A, -- rightharpoonup
[0x021C1] = 0x2B, -- rightharpoondown
[0xFE322] = 0x2C, -- lhook (hook for combining arrows)
[0xFE323] = 0x2D, -- rhook (hook for combining arrows)
@@ -1669,16 +1669,6 @@ mathematics.make_font ( "mathtimes-math", {
{ name = "msbm10.tfm", vector = "tex-mb" },
} )
-mathematics.make_font ( "lucida-math", {
- { name = "file:lbr.afm", features = "virtualmath", main = true },
- { name = "hlcrim.tfm", vector = "tex-mi", skewchar=0x7F },
- { name = "hlcrim.tfm", vector = "tex-it", skewchar=0x7F },
- { name = "hlcry.tfm", vector = "tex-sy", skewchar=0x30, parameters = true },
- { name = "hlcrv.tfm", vector = "tex-ex", extension = true },
- { name = "hlcra.tfm", vector = "tex-ma" },
- { name = "hlcrm.tfm", vector = "tex-mb" },
-} )
-
mathematics.make_font ( "charter-math", {
{ name = "file:bchr8a", features = "virtualmath", main = true },
-- { name = "md-chr7m.tfm", vector = "tex-mr" },
@@ -1722,3 +1712,231 @@ mathematics.make_font ( "hvmath-math", {
{ name = "hvam10.tfm", vector = "tex-ma" },
{ name = "hvbm10.tfm", vector = "tex-mb" },
} )
+
+-- the lucida mess
+
+fonts.enc.math["lbr-ma"] = {
+ [0x000A5] = 0x03, -- yen
+ [0x000B7] = 0xE1, -- centerdot
+ [0x000F0] = 0x03, -- eth
+ [0x00127] = 0x1B, -- hbar
+ [0x003DC] = 0x03, -- digamma
+ [0x003F6] = 0x03, -- backepsilon
+ [0x0219A] = 0x32, -- nleftarrow
+ [0x0219B] = 0x33, -- nrightarrow
+ [0x0219E] = 0x23, -- twoheadleftarrow
+ [0x021A0] = 0x25, -- twoheadrightarrow
+ [0x021A2] = 0x28, -- leftarrowtail
+ [0x021A3] = 0x29, -- rightarrowtail
+ [0x021A6] = 0x2C, -- mapsto
+ [0x021A9] = 0x3C, -- hookleftarrow
+ [0x021AA] = 0x3E, -- hookrightarrow
+ [0x021AB] = 0x3F, -- looparrowleft
+ [0x021AC] = 0x40, -- looparrowright
+ [0x021AD] = 0x91, -- leftrightsquigarrow
+ [0x021AE] = 0x34, -- nleftrightarrow
+ [0x021B0] = 0x7B, -- Lsh
+ [0x021B1] = 0x7D, -- Rsh
+ [0x021B6] = 0x87, -- curvearrowleft
+ [0x021B7] = 0x88, -- curvearrowright
+ [0x021BA] = 0x8C, -- circlearrowright
+ [0x021BB] = 0x8B, -- circlearrowleft
+ [0x021BF] = 0x76, -- upharpoonleft
+ [0x021C2] = 0x77, -- downharpoonright
+ [0x021C3] = 0x78, -- downharpoonleft
+ [0x021C4] = 0x6D, -- rightleftarrows
+ [0x021C6] = 0x6E, -- leftrightarrows
+ [0x021C7] = 0x71, -- leftleftarrows
+ [0x021C8] = 0x72, -- upuparrows
+ [0x021C9] = 0x73, -- rightrightarrows
+ [0x021CA] = 0x74, -- downdownarrows
+ [0x021CB] = 0x79, -- leftrightharpoons
+ [0x021CC] = 0x7A, -- rightleftharpoons
+ [0x021CD] = 0x66, -- nLeftarrow
+ [0x021CE] = 0x67, -- nLeftrightarrow
+ [0x021CF] = 0x68, -- nRightarrow
+ [0x021DA] = 0x6A, -- Lleftarrow
+ [0x021DB] = 0x6C, -- Rrightarrow
+ [0x021E0] = 0x38, -- dashleftarrow
+ [0x02204] = 0x20, -- nexists
+ [0x02226] = 0xF7, -- nparallel
+ [0x02241] = 0x96, -- nsim
+ [0x02268] = 0xDC, -- lneqq
+ [0x02269] = 0xDE, -- gneqq
+ [0x0226E] = 0x9A, -- nless
+ [0x0226F] = 0x9B, -- ngtr
+ [0x02270] = 0x9C, -- nleq
+ [0x02271] = 0x9D, -- ngeq
+ [0x02280] = 0xE5, -- nprec
+ [0x02281] = 0xE6, -- nsucc
+ [0x02288] = 0xC8, -- nsubseteq
+ [0x02289] = 0xC9, -- nsupseteq
+ [0x0228A] = 0xCC, -- subsetneq
+ [0x0228B] = 0xCD, -- supsetneq
+ [0x022AC] = 0xF8, -- nvdash
+ [0x022AD] = 0xFA, -- nvDash
+ [0x022AE] = 0xF9, -- nVdash
+ [0x022AF] = 0xFB, -- nVDash
+ [0x022BA] = 0x03, -- intercal
+ [0x022D4] = 0xF3, -- pitchfork
+ [0x022E6] = 0xE0, -- lnsim
+ [0x022E7] = 0xE2, -- gnsim
+ [0x022E8] = 0xEB, -- precnsim
+ [0x022E9] = 0xEC, -- succnsim
+ [0x022EA] = 0xF0, -- ntriangleright
+ [0x022EB] = 0xEF, -- ntriangleleft
+ [0x022EC] = 0xF1, -- ntrianglelefteq
+ [0x022ED] = 0xF2, -- ntrianglerighteq
+ [0x0231C] = 0x5B, -- ulcorner
+ [0x0231D] = 0x5C, -- urcorner
+ [0x0231E] = 0x5D, -- llcorner
+ [0x0231F] = 0x5E, -- lrcorner
+ [0x025A2] = 0x03, -- blacksquare
+ [0x02605] = 0xAB, -- bigstar
+ [0x02713] = 0xAC, -- checkmark
+ [0x029EB] = 0x09, -- blacklozenge
+ [0x02A87] = 0xDA, -- lneq
+ [0x02A89] = 0xE4, -- lnapprox
+ [0x02A8A] = 0xE3, -- gnapprox
+ [0x02AB5] = 0xE9, -- precneqq
+ [0x02AB6] = 0xEA, -- succneqq
+ [0x02AB9] = 0xED, -- precnapprox
+ [0x02ABA] = 0xEE, -- succnapprox
+ [0x02ACB] = 0xCE, -- subsetneqq
+ [0x02ACC] = 0xCF, -- supsetneqq
+}
+
+fonts.enc.math["lbr-mb"] = {
+ [0x00393] = 0x00, -- Gamma
+ [0x00394] = 0x01, -- Delta
+ [0x00398] = 0x02, -- Theta
+ [0x0039B] = 0x03, -- Lambda
+ [0x0039E] = 0x04, -- Xi
+ [0x003A0] = 0x05, -- Pi
+ [0x003A3] = 0x06, -- Sigma
+ [0x003A5] = 0x07, -- Upsilon
+ [0x003A6] = 0x08, -- Phi
+ [0x003A8] = 0x09, -- Psi
+ [0x003A9] = 0x0A, -- Omega
+ [0x0210F] = 0x9D, -- hslash
+ [0x02127] = 0x92, -- mho
+ [0x02132] = 0x90, -- Finv
+ [0x02136] = 0x95, -- beth
+ [0x02137] = 0x96, -- gimel
+ [0x02138] = 0x97, -- daleth
+ [0x02141] = 0x91, -- Game
+ [0x02201] = 0x94, -- complement
+ [0x0226C] = 0xF2, -- between
+ [0x0227C] = 0xE4, -- preccurlyeq
+ [0x0227D] = 0xE5, -- succcurlyeq
+ [0x0229D] = 0xCC, -- circleddash
+ [0x022A8] = 0xD6, -- vDash
+ [0x022AA] = 0xD3, -- Vvdash
+ [0x022B8] = 0xC7, -- multimap
+ [0x022BB] = 0xD2, -- veebar
+ [0x022C7] = 0xF7, -- divideontimes
+ [0x022C9] = 0xCF, -- ltimes
+ [0x022CA] = 0xCE, -- rtimes
+ [0x022CB] = 0xD0, -- leftthreetimes
+ [0x022CC] = 0xD1, -- rightthreetimes
+ [0x022D6] = 0xDC, -- lessdot
+ [0x022D7] = 0xDD, -- gtrdot
+ [0x022DA] = 0xE8, -- lesseqgtr
+ [0x022DB] = 0xE9, -- gtreqless
+ [0x022DE] = 0xE6, -- curlyeqprec
+ [0x022DF] = 0xE7, -- curlyeqsucc
+ [0x024C7] = 0xC9, -- circledR
+ [0x024C8] = 0xCA, -- circledS
+ [0x025B6] = 0xF1, -- blacktriangleright
+ [0x025B8] = 0xF0, -- blacktriangleleft
+ [0x02720] = 0xCB, -- maltese
+ [0x02A7D] = 0xE0, -- leqslant
+ [0x02A7E] = 0xE1, -- geqslant
+ [0x02A85] = 0xDA, -- lessapprox
+ [0x02A86] = 0xDB, -- gtrapprox
+ [0x02A8B] = 0xEA, -- lesseqqgtr
+ [0x02A8C] = 0xEB, -- gtreqqless
+ [0x02A95] = 0xE2, -- eqslantless
+ [0x02A96] = 0xE3, -- eqslantgtr
+ [0x02AB7] = 0xEC, -- precapprox
+ [0x02AB8] = 0xED, -- succapprox
+ [0x02AC5] = 0xEE, -- subseteqq
+ [0x02AC6] = 0xEF, -- supseteqq
+ [0x12035] = 0xC8, -- backprime
+ [0x1D718] = 0x9B, -- varkappa
+}
+
+--~ fonts.enc.math["lbr-mi"] = {
+--~ ["0x00127"] = 0x9D, -- hbar
+--~ ["0x003D1"] = 0x02, -- varTheta
+--~ ["0x020D7"] = 0x7E, -- vec
+--~ }
+
+fonts.enc.math["lbr-sy"] = {
+ [0x021CB] = 0x8D, -- leftrightharpoons
+ [0x021CC] = 0x8E, -- rightleftharpoons
+ [0x02214] = 0x89, -- dotplus
+ [0x02220] = 0x8B, -- angle
+ [0x02221] = 0x8C, -- measuredangle
+ [0x02222] = 0x8D, -- sphericalangle
+ [0x02234] = 0x90, -- therefore
+ [0x02235] = 0x91, -- because
+ [0x0223D] = 0x24, -- backsim
+ [0x02242] = 0x99, -- eqsim
+ [0x0224A] = 0x9D, -- approxeq
+ [0x0224E] = 0xC7, -- Bumpeq
+ [0x02252] = 0xCB, -- fallingdotseq
+ [0x02253] = 0xCC, -- risingdotseq
+ [0x02256] = 0xCF, -- eqcirc
+ [0x02257] = 0xD0, -- circeq
+ [0x0225C] = 0xD5, -- triangleq
+ [0x02266] = 0xDA, -- leqq
+ [0x02267] = 0xDB, -- geqq
+ [0x02272] = 0xDC, -- lesssim
+ [0x02273] = 0xDD, -- gtrsim
+ [0x02276] = 0xDE, -- lessgtr
+ [0x02277] = 0xDF, -- gtrless
+ [0x0227E] = 0xE0, -- precsim
+ [0x0227F] = 0xE1, -- succsim
+ [0x0228F] = 0xE4, -- sqsubset
+ [0x02290] = 0xE5, -- sqsupset
+ [0x0229A] = 0xE6, -- circledcirc
+ [0x0229B] = 0xE7, -- circledast
+ [0x0229E] = 0xEA, -- boxplus
+ [0x0229F] = 0xEB, -- boxminus
+ [0x022A0] = 0xEC, -- boxtimes
+ [0x022A1] = 0xED, -- boxdot
+ [0x022A7] = 0xEE, -- models
+ [0x022A9] = 0xF0, -- Vdash
+ [0x022BC] = 0xF6, -- barwedge
+ [0x022CE] = 0x85, -- curlyvee
+ [0x022CF] = 0x84, -- curlywedge
+ [0x022D0] = 0xF8, -- Subset
+ [0x022D1] = 0xF9, -- Supset
+ [0x02300] = 0x53, -- varnothing
+ [0x025CA] = 0x05, -- lozenge
+}
+
+fonts.enc.math["lbr-sy"] = table.merged(fonts.enc.math["tex-sy"],fonts.enc.math["lbr-sy"])
+
+--~ fonts.enc.math["lbr-rm"] = {
+--~ [0x00060] = 0x12, -- grave
+--~ [0x000A8] = 0x7F, -- ddot
+--~ [0x000AF] = 0x16, -- bar
+--~ [0x000B4] = 0x13, -- acute
+--~ [0x002C6] = 0x5E, -- hat
+--~ [0x002C7] = 0x14, -- check
+--~ [0x002D8] = 0x15, -- breve
+--~ [0x002D9] = 0x05, -- dot
+--~ [0x002DC] = 0x7E, -- tilde
+--~ }
+
+mathematics.make_font ( "lucida-math", {
+ { name = "file:lbr.afm", features = "virtualmath", main = true },
+ { name = "hlcrim.tfm", vector = "tex-mi", skewchar=0x7F },
+ { name = "hlcrim.tfm", vector = "tex-it", skewchar=0x7F },
+ { name = "hlcry.tfm", vector = "lbr-sy", skewchar=0x30, parameters = true },
+ { name = "hlcrv.tfm", vector = "tex-ex", extension = true },
+ { name = "hlcra.tfm", vector = "lbr-ma" },
+ { name = "hlcrm.tfm", vector = "lbr-mb" },
+} )
diff --git a/tex/context/base/node-inj.lua b/tex/context/base/node-inj.lua
index 4c5840978..9c4612a22 100644
--- a/tex/context/base/node-inj.lua
+++ b/tex/context/base/node-inj.lua
@@ -70,7 +70,8 @@ function nodes.set_pair(current,factor,rlmode,r2lflag,spec,tfmchr)
local bound = has_attribute(current,kernpair)
if bound then
local kb = kerns[bound]
- kb[2], kb[3], kb[4], kb[5] = kb[2] + x, kb[3] + y, kb[4] + w, kb[5] + h
+ -- inefficient but singles have less, but weird anyway, needs checking
+ kb[2], kb[3], kb[4], kb[5] = (kb[2] or 0) + x, (kb[3] or 0) + y, (kb[4] or 0)+ w, (kb[5] or 0) + h
else
bound = #kerns + 1
set_attribute(current,kernpair,bound)
diff --git a/tex/context/base/s-fnt-25.tex b/tex/context/base/s-fnt-25.tex
index abaaaa06e..a71aaa330 100644
--- a/tex/context/base/s-fnt-25.tex
+++ b/tex/context/base/s-fnt-25.tex
@@ -11,11 +11,15 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
+\def\enableshowmathfontvirtual
+ {\ctxlua{fonts.tfm.auto_cleanup=false}}
+
\def\showmathfontcharacters
{\dodoubleempty\doshowmathfontcharacters}
\def\doshowmathfontcharacters[#1][#2]%
{\begingroup
+ \dontcomplain
\doifelsenothing{#1}
{\definedfont[MathRoman*math-text]}
{\definedfont[#1]}%
@@ -46,6 +50,9 @@
\def\mathfontlistentrywdhtdpic#1#2#3#4%
{width: #1, height: #2, depth: #3, italic: #4\par}
+\def\mathfontlistentryresource#1%
+ {virtual: #1\par}
+
\def\mathfontlistentrynext#1#2%
{#1~\ruledhbox{\char#2}}
@@ -76,6 +83,14 @@ function document.showmathfont(id,slot)
local function report(...)
tex.sprint(tex.ctxcatcodes,string.format(...))
end
+ local virtual, names = tfmdata.type == "virtual", { }
+ if virtual then
+ for k, v in ipairs(tfmdata.fonts) do
+ local name = fonts.ids[v.id].name
+ names[k] = (name and file.basename(name)) or v.id
+ end
+ end
+ print(table.serialize(names))
for _, s in next, sorted do
local char = characters[s]
if char then
@@ -84,6 +99,22 @@ function document.showmathfont(id,slot)
report("\\startmathfontlistentry")
report("\\mathfontlistentryhexdectit{U+%05X}{%s}{%s}",s,s,string.lower(info.description or "no description, private to font"))
report("\\mathfontlistentrywdhtdpic{%s}{%s}{%s}{%s}",char.width or 0,char.height or 0,char.depth or 0,char.italic or 0)
+ if virtual then
+ local commands = char.commands
+ if commands then
+ local t = { }
+ for i=1,#commands do
+ local ci = commands[i]
+ if ci[1] == "slot" then
+ local fnt, idx = ci[2], ci[3]
+ t[#t+1] = string.format("%s/%0X",names[fnt] or fnt,idx)
+ end
+ end
+ if #t > 0 then
+ report("\\mathfontlistentryresource{%s}",table.concat(t,", "))
+ end
+ end
+ end
if info.mathclass then
report("\\mathfontlistentryclassname{%s}{%s}",info.mathclass,info.mathname or "no name")
end
diff --git a/tex/context/base/spac-ali.mkiv b/tex/context/base/spac-ali.mkiv
index 652180f6f..aab1d443d 100644
--- a/tex/context/base/spac-ali.mkiv
+++ b/tex/context/base/spac-ali.mkiv
@@ -648,7 +648,7 @@
\hbox}
{\doifelse{#1}\v!right{\kern-\rightskip}{\doifsomething{#1}{\kern-#1}}%
\parfillskip\zeropoint
- %\finalhyphendemerits\zerocount % yes or no
+ \finalhyphendemerits\zerocount % yes or no (see hyhenation/specialcases-001.tex)
\par}}
\def\wordright
diff --git a/tex/context/base/spac-ver.mkiv b/tex/context/base/spac-ver.mkiv
index 07b47b92d..58aec3caf 100644
--- a/tex/context/base/spac-ver.mkiv
+++ b/tex/context/base/spac-ver.mkiv
@@ -1378,26 +1378,15 @@
% \fi
\egroup}
-% no off
-
-% \def\docheckgridsnapping
-% {\doifelse\@@lygrid\v!yes\gridsnappingtrue\gridsnappingfalse
-% \ifgridsnapping
-% \setsnapvalue\v!normal
-% \setsystemmode\v!grid
-% \else
-% \resetsnapvalue
-% \resetsystemmode\v!grid
-% \fi}
-
\def\docheckgridsnapping
- {\doifelse\@@lygrid\v!no
+ {\edef\askedgridmode{\layoutparameter\c!grid}% needs checking by WS
+ \doifelse\askedgridmode\v!no
{\gridsnappingfalse
\resetsystemmode\v!grid
\resetsnapvalue}
{\gridsnappingtrue
\setsystemmode\v!grid
- \autosetsnapvalue\@@lygrid}}
+ \autosetsnapvalue\askedgridmode}}
%D Visualization:
@@ -1871,9 +1860,22 @@
%D Contrary to \MKII\ we can now define classes of lines (generalized by
%D Wolfgang). I will probably rewrite bits in \LUA.
-\def\linesparameter #1{\csname\dolinesparameter{\??rg\@@lines}#1\endcsname}
-\def\dolinesparameter #1#2{\ifcsname#1#2\endcsname#1#2\else\expandafter\dolinesparentparameter\csname#1\s!parent\endcsname#2\fi}
-\def\dolinesparentparameter#1#2{\ifx#1\relax\s!empty\else\dolinesparameter#1#2\fi}
+\let\currentlines\empty
+
+\def\linesparameter #1{\csname\dolinesparameter{\??rg\currentlines}#1\endcsname}
+\def\linesparameterhash#1{\dolinesparameterhash {\??rg\currentlines}#1}
+
+\def\dolinesparameter #1#2{\ifcsname#1#2\endcsname#1#2\else\expandafter\dolinesparentparameter \csname#1\s!parent\endcsname#2\fi}
+\def\dolinesparameterhash#1#2{\ifcsname#1#2\endcsname #1\else\expandafter\dolinesparentparameterhash\csname#1\s!parent\endcsname#2\fi}
+
+\def\dolinesparentparameter #1#2{\ifx#1\relax\s!empty\else\dolinesparameter #1#2\fi}
+\def\dolinesparentparameterhash#1#2{\ifx#1\relax \else\dolinesparameterhash#1#2\fi}
+
+\def\dosetlinesattributes#1#2% style color
+ {\edef\fontattributehash {\linesparameterhash#1}%
+ \edef\colorattributehash{\linesparameterhash#2}%
+ \ifx\fontattributehash \empty\else\dosetfontattribute \fontattributehash #1\fi
+ \ifx\colorattributehash\empty\else\dosetcolorattribute\colorattributehash#2\fi}
\getparameters
[\??rg]
@@ -1889,7 +1891,7 @@
\def\dodefinelines[#1][#2]%
{\getparameters[\??rg#1][\s!parent=\??rg,#2]%
- \setvalue{\e!start#1}{\dostartlines[#1]}%
+ \setvalue{\e!start#1}{\dodoubleempty\dostartlines[#1]}%
\setvalue{\e!stop #1}{\dostoplines}}
\def\setuplines
@@ -1901,13 +1903,17 @@
{\def\docommand##1{\getparameters[\??rg##1][#2]}%
\processcommacommand[#1]\docommand}}
-\def\dostartlines[#1]%
+\def\dostartlines[#1][#2]%
{\bgroup
- \edef\@@lines{#1}%
+ \edef\currentlines{#1}%
+ \ifsecondargument
+ \getparameters[\??rg\currentlines][#2]%
+ \fi
\linesparameter\c!before
\pushmacro\checkindentation
\whitespace
\begingroup
+ \dosetlinesattributes\c!style\c!color
\setupindenting[\linesparameter\c!indenting]%
\typesettinglinestrue
\setupwhitespace[\v!none]%
@@ -1931,8 +1937,8 @@
\def\dobetweenthelines
{\doifmeaningelse\next\obeyedline
- {\linesparameter\c!inbetween}
- {\afterfirstobeyedline}}
+ {\linesparameter\c!inbetween}
+ {\afterfirstobeyedline}}
\definelines[\v!lines]
diff --git a/tex/context/base/strc-ref.lua b/tex/context/base/strc-ref.lua
index 52bc2a51b..0cf06db02 100644
--- a/tex/context/base/strc-ref.lua
+++ b/tex/context/base/strc-ref.lua
@@ -883,7 +883,7 @@ end
function jobreferences.getinternalreference(n) -- n points into list
local l = structure.lists.collected[n]
- texsprint((l and l.references.internal) or n)
+ texsprint(ctxcatcodes,(l and l.references.internal) or n)
end
diff --git a/tex/context/base/syst-aux.mkiv b/tex/context/base/syst-aux.mkiv
index 7c1787705..b8551999e 100644
--- a/tex/context/base/syst-aux.mkiv
+++ b/tex/context/base/syst-aux.mkiv
@@ -3125,8 +3125,8 @@
%D We cannot use the simple scheme:
%D
%D \starttyping
-%D \def\settrue#1{\let#1=\iftrue}
-%D \def\settrue#1{\let#1=\iffalse}
+%D \def\settrue #1{\let#1=\iftrue}
+%D \def\setfalse#1{\let#1=\iffalse}
%D \stoptyping
%D
%D Such an implementation gives problems with nested
diff --git a/tex/context/base/syst-ext.mkii b/tex/context/base/syst-ext.mkii
index 7327ca0f8..73fb98b72 100644
--- a/tex/context/base/syst-ext.mkii
+++ b/tex/context/base/syst-ext.mkii
@@ -498,8 +498,8 @@
%D We cannot use the simple scheme:
%D
%D \starttyping
-%D \def\settrue#1{\let#1=\iftrue}
-%D \def\settrue#1{\let#1=\iffalse}
+%D \def\settrue #1{\let#1=\iftrue}
+%D \def\setfalse#1{\let#1=\iffalse}
%D \stoptyping
%D
%D Such an implementation gives problems with nested
diff --git a/tex/generic/context/luatex-fonts-merged.lua b/tex/generic/context/luatex-fonts-merged.lua
index e5ea88025..559220bc8 100644
--- a/tex/generic/context/luatex-fonts-merged.lua
+++ b/tex/generic/context/luatex-fonts-merged.lua
@@ -1,6 +1,6 @@
-- merged file : c:/data/develop/context/texmf/tex/generic/context/luatex-fonts-merged.lua
-- parent file : c:/data/develop/context/texmf/tex/generic/context/luatex-fonts.lua
--- merge date : 02/23/10 14:20:59
+-- merge date : 02/24/10 22:33:12
do -- begin closure to overcome local limits and interference
@@ -2618,7 +2618,8 @@ function nodes.set_pair(current,factor,rlmode,r2lflag,spec,tfmchr)
local bound = has_attribute(current,kernpair)
if bound then
local kb = kerns[bound]
- kb[2], kb[3], kb[4], kb[5] = kb[2] + x, kb[3] + y, kb[4] + w, kb[5] + h
+ -- inefficient but singles have less, but weird anyway, needs checking
+ kb[2], kb[3], kb[4], kb[5] = (kb[2] or 0) + x, (kb[3] or 0) + y, (kb[4] or 0)+ w, (kb[5] or 0) + h
else
bound = #kerns + 1
set_attribute(current,kernpair,bound)
@@ -3424,32 +3425,7 @@ tfm.share_base_kerns = false -- true (.5 sec slower on mk but brings down mem fr
tfm.mathactions = { }
tfm.fontname_mode = "fullpath"
-function tfm.enhance(tfmdata,specification)
- local name, size = specification.name, specification.size
- local encoding, filename = match(name,"^(.-)%-(.*)$") -- context: encoding-name.*
- if filename and encoding and fonts.enc.known[encoding] then
- local data = fonts.enc.load(encoding)
- if data then
- local characters = tfmdata.characters
- tfmdata.encoding = encoding
- local vector = data.vector
- local original = { }
- for k, v in next, characters do
- v.name = vector[k]
- v.index = k
- original[k] = v
- end
- for k,v in next, data.unicodes do
- if k ~= v then
- if trace_defining then
- logs.report("define font","mapping %s onto %s",k,v)
- end
- characters[k] = original[v]
- end
- end
- end
- end
-end
+tfm.enhance = tfm.enhance or function() end
function tfm.read_from_tfm(specification)
local fname, tfmdata = specification.filename or "", nil
@@ -4107,151 +4083,6 @@ function tfm.replacements(tfm,value)
-- tfm.characters[0x0060] = tfm.characters[0x2018]
end
--- auto complete font with missing composed characters
-
-table.insert(fonts.manipulators,"compose")
-
-function fonts.initializers.common.compose(tfmdata,value)
- if value then
- fonts.vf.aux.compose_characters(tfmdata)
- end
-end
-
--- tfm features, experimental
-
-tfm.features = tfm.features or { }
-tfm.features.list = tfm.features.list or { }
-tfm.features.default = tfm.features.default or { }
-
-function tfm.enhance(tfmdata,specification)
- -- we don't really share tfm data because we always reload
- -- but this is more in sycn with afm and such
- local features = (specification.features and specification.features.normal ) or { }
- tfmdata.shared = tfmdata.shared or { }
- tfmdata.shared.features = features
- -- tfmdata.shared.tfmdata = tfmdata -- circular
- tfmdata.filename = specification.name
- if not features.encoding then
- local name, size = specification.name, specification.size
- local encoding, filename = match(name,"^(.-)%-(.*)$") -- context: encoding-name.*
- if filename and encoding and fonts.enc.known[encoding] then
- features.encoding = encoding
- end
- end
- tfm.set_features(tfmdata)
-end
-
-function tfm.set_features(tfmdata)
- -- todo: no local functions
- local shared = tfmdata.shared
--- local tfmdata = shared.tfmdata
- local features = shared.features
- if not table.is_empty(features) then
- local mode = tfmdata.mode or fonts.mode
- local fi = fonts.initializers[mode]
- if fi and fi.tfm then
- local function initialize(list) -- using tex lig and kerning
- if list then
- for i=1,#list do
- local f = list[i]
- local value = features[f]
- if value and fi.tfm[f] then -- brr
- if tfm.trace_features then
- logs.report("define font","initializing feature %s to %s for mode %s for font %s",f,tostring(value),mode or 'unknown',tfmdata.name or 'unknown')
- end
- fi.tfm[f](tfmdata,value)
- mode = tfmdata.mode or fonts.mode
- fi = fonts.initializers[mode]
- end
- end
- end
- end
- initialize(fonts.triggers)
- initialize(tfm.features.list)
- initialize(fonts.manipulators)
- end
- local fm = fonts.methods[mode]
- if fm and fm.tfm then
- local function register(list) -- node manipulations
- if list then
- for i=1,#list do
- local f = list[i]
- if features[f] and fm.tfm[f] then -- brr
- if not shared.processors then -- maybe also predefine
- shared.processors = { fm.tfm[f] }
- else
- shared.processors[#shared.processors+1] = fm.tfm[f]
- end
- end
- end
- end
- end
- register(tfm.features.list)
- end
- end
-end
-
-function tfm.features.register(name,default)
- tfm.features.list[#tfm.features.list+1] = name
- tfm.features.default[name] = default
-end
-
-function tfm.reencode(tfmdata,encoding)
- if encoding and fonts.enc.known[encoding] then
- local data = fonts.enc.load(encoding)
- if data then
- local characters, original, vector = tfmdata.characters, { }, data.vector
- tfmdata.encoding = encoding -- not needed
- for k, v in next, characters do
- v.name, v.index, original[k] = vector[k], k, v
- end
- for k,v in next, data.unicodes do
- if k ~= v then
- if trace_defining then
- logs.report("define font","reencoding U+%04X to U+%04X",k,v)
- end
- characters[k] = original[v]
- end
- end
- end
- end
-end
-
-tfm.features.register('reencode')
-
-fonts.initializers.base.tfm.reencode = tfm.reencode
-fonts.initializers.node.tfm.reencode = tfm.reencode
-
-fonts.enc = fonts.enc or { }
-fonts.enc.remappings = fonts.enc.remappings or { }
-
-function tfm.remap(tfmdata,remapping)
- local vector = remapping and fonts.enc.remappings[remapping]
- if vector then
- local characters, original = tfmdata.characters, { }
- for k, v in next, characters do
- original[k], characters[k] = v, nil
- end
- for k,v in next, vector do
- if k ~= v then
- if trace_defining then
- logs.report("define font","remapping U+%04X to U+%04X",k,v)
- end
- local c = original[k]
- characters[v] = c
- c.index = k
- end
- end
- tfmdata.encodingbytes = 2
- tfmdata.format = 'type1'
- end
-end
-
-tfm.features.register('remap')
-
-fonts.initializers.base.tfm.remap = tfm.remap
-fonts.initializers.node.tfm.remap = tfm.remap
-
-- status info
statistics.register("fonts load time", function()
@@ -7457,6 +7288,39 @@ function tfm.read_from_open_type(specification)
return tfmtable
end
+-- helpers
+
+function otf.collect_lookups(otfdata,kind,script,language)
+ -- maybe store this in the font
+ local sequences = otfdata.luatex.sequences
+ if sequences then
+ local featuremap, featurelist = { }, { }
+ for s=1,#sequences do
+ local sequence = sequences[s]
+ local features = sequence.features
+ features = features and features[kind]
+ features = features and (features[script] or features[default] or features[wildcard])
+ features = features and (features[language] or features[default] or features[wildcard])
+ if features then
+ local subtables = sequence.subtables
+ if subtables then
+ for s=1,#subtables do
+ local ss = subtables[s]
+ if not featuremap[s] then
+ featuremap[ss] = true
+ featurelist[#featurelist+1] = ss
+ end
+ end
+ end
+ end
+ end
+ if #featurelist > 0 then
+ return featuremap, featurelist
+ end
+ end
+ return nil, nil
+end
+
end -- closure
do -- begin closure to overcome local limits and interference
@@ -7742,43 +7606,12 @@ local function resolve_ligatures(tfmdata,ligatures,kind)
end
end
-local function collect_lookups(otfdata,kind,script,language)
- -- maybe store this in the font
- local sequences = otfdata.luatex.sequences
- if sequences then
- local featuremap, featurelist = { }, { }
- for s=1,#sequences do
- local sequence = sequences[s]
- local features = sequence.features
- features = features and features[kind]
- features = features and (features[script] or features[default] or features[wildcard])
- features = features and (features[language] or features[default] or features[wildcard])
- if features then
- local subtables = sequence.subtables
- if subtables then
- for s=1,#subtables do
- local ss = subtables[s]
- if not featuremap[s] then
- featuremap[ss] = true
- featurelist[#featurelist+1] = ss
- end
- end
- end
- end
- end
- if #featurelist > 0 then
- return featuremap, featurelist
- end
- end
- return nil, nil
-end
-
local splitter = lpeg.splitat(" ")
function prepare_base_substitutions(tfmdata,kind,value) -- we can share some code with the node features
if value then
local otfdata = tfmdata.shared.otfdata
- local validlookups, lookuplist = collect_lookups(otfdata,kind,tfmdata.script,tfmdata.language)
+ local validlookups, lookuplist = otf.collect_lookups(otfdata,kind,tfmdata.script,tfmdata.language)
if validlookups then
local ligatures = { }
local unicodes = tfmdata.unicodes -- names to unicodes
@@ -7887,51 +7720,10 @@ function prepare_base_substitutions(tfmdata,kind,value) -- we can share some cod
end
end
---~ local function prepare_base_kerns(tfmdata,kind,value) -- todo what kind of kerns, currently all
---~ if value then
---~ local otfdata = tfmdata.shared.otfdata
---~ local validlookups, lookuplist = collect_lookups(otfdata,kind,tfmdata.script,tfmdata.language)
---~ if validlookups then
---~ local unicodes = tfmdata.unicodes -- names to unicodes
---~ local indices = tfmdata.indices
---~ local characters = tfmdata.characters
---~ local descriptions = tfmdata.descriptions
---~ for u, chr in next, characters do
---~ local d = descriptions[u]
---~ if d then
---~ local dk = d.mykerns
---~ if dk then
---~ local t, done = chr.kerns or { }, false
---~ for l=1,#lookuplist do
---~ local lookup = lookuplist[l]
---~ local kerns = dk[lookup]
---~ if kerns then
---~ for k, v in next, kerns do
---~ if v ~= 0 and not t[k] then -- maybe no 0 test here
---~ t[k], done = v, true
---~ if trace_baseinit and trace_kerns then
---~ logs.report("define otf","%s: base kern %s + %s => %s",cref(kind,lookup),gref(descriptions,u),gref(descriptions,k),v)
---~ end
---~ end
---~ end
---~ end
---~ end
---~ if done then
---~ chr.kerns = t -- no empty assignments
---~ end
---~ -- elseif d.kerns then
---~ -- logs.report("define otf","%s: invalid mykerns for %s",cref(kind),gref(descriptions,u))
---~ end
---~ end
---~ end
---~ end
---~ end
---~ end
-
local function prepare_base_kerns(tfmdata,kind,value) -- todo what kind of kerns, currently all
if value then
local otfdata = tfmdata.shared.otfdata
- local validlookups, lookuplist = collect_lookups(otfdata,kind,tfmdata.script,tfmdata.language)
+ local validlookups, lookuplist = otf.collect_lookups(otfdata,kind,tfmdata.script,tfmdata.language)
if validlookups then
local unicodes = tfmdata.unicodes -- names to unicodes
local indices = tfmdata.indices
@@ -10045,6 +9837,7 @@ function fonts.methods.node.otf.features(head,font,attr)
if not lookupcache then
report_missing_cache(typ,lookupname)
else
+--~ print(typ,lookupname,lookupcache,table.serialize(lookupcache))
while start do
local id = start.id
if id == glyph then
@@ -10054,6 +9847,7 @@ function fonts.methods.node.otf.features(head,font,attr)
if lookupmatch then
-- sequence kan weg
local ok
+--~ print("!!!")
start, ok = handler(start,r[4],lookupname,lookupmatch,sequence,featuredata,1)
--~ texio.write_nl(tostring(lookupname),tostring(lookupmatch),tostring(ok))
if ok then