From 4bfd1949398de94ab92544f2c4c49b9c41c1189f Mon Sep 17 00:00:00 2001
From: Hans Hagen <pragma@wxs.nl>
Date: Thu, 12 May 2011 15:19:00 +0200
Subject: beta 2011.05.12 15:19

---
 tex/context/base/cont-new.mkii              |   2 +-
 tex/context/base/cont-new.mkiv              |   2 +-
 tex/context/base/context.mkii               |   2 +-
 tex/context/base/context.mkiv               |   2 +-
 tex/context/base/font-con.lua               |  11 +++++++---
 tex/context/base/font-ctx.lua               |  33 ++++++++++++++++++++++------
 tex/context/base/font-ini.mkiv              |  33 +++++++++++++++-------------
 tex/context/base/node-inj.lua               |   3 +--
 tex/context/base/status-files.pdf           | Bin 23541 -> 23572 bytes
 tex/context/base/status-lua.pdf             | Bin 154319 -> 154274 bytes
 tex/context/base/type-otf.mkiv              |  27 ++++++++++++-----------
 tex/generic/context/luatex-fonts-merged.lua |  16 +++++++++-----
 12 files changed, 81 insertions(+), 50 deletions(-)

(limited to 'tex')

diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii
index dabf23b77..e73e00f0b 100644
--- a/tex/context/base/cont-new.mkii
+++ b/tex/context/base/cont-new.mkii
@@ -11,7 +11,7 @@
 %C therefore copyrighted by \PRAGMA. See mreadme.pdf for
 %C details.
 
-\newcontextversion{2011.05.10 19:20}
+\newcontextversion{2011.05.12 15:19}
 
 %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/cont-new.mkiv b/tex/context/base/cont-new.mkiv
index f18429a55..aefb7d43a 100644
--- a/tex/context/base/cont-new.mkiv
+++ b/tex/context/base/cont-new.mkiv
@@ -11,7 +11,7 @@
 %C therefore copyrighted by \PRAGMA. See mreadme.pdf for
 %C details.
 
-\newcontextversion{2011.05.10 19:20}
+\newcontextversion{2011.05.12 15:19}
 
 %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.mkii b/tex/context/base/context.mkii
index 5c71cd25b..4c33eba16 100644
--- a/tex/context/base/context.mkii
+++ b/tex/context/base/context.mkii
@@ -20,7 +20,7 @@
 %D your styles an modules.
 
 \edef\contextformat {\jobname}
-\edef\contextversion{2011.05.10 19:20}
+\edef\contextversion{2011.05.12 15:19}
 
 %D For those who want to use this:
 
diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv
index 4e616920d..17dde0702 100644
--- a/tex/context/base/context.mkiv
+++ b/tex/context/base/context.mkiv
@@ -20,7 +20,7 @@
 %D your styles an modules.
 
 \edef\contextformat {\jobname}
-\edef\contextversion{2011.05.10 19:20}
+\edef\contextversion{2011.05.12 15:19}
 
 %D For those who want to use this:
 
diff --git a/tex/context/base/font-con.lua b/tex/context/base/font-con.lua
index 0da0e8e46..5d30842ef 100644
--- a/tex/context/base/font-con.lua
+++ b/tex/context/base/font-con.lua
@@ -995,15 +995,17 @@ a helper function.</p>
 --ldx]]--
 
 function constructors.checkedfeatures(what,features)
+    local defaults = handlers[what].features.defaults
     if features and next(features) then
-        for key, value in next, handlers[what].features.defaults do
+        features = fastcopy(features) -- can be inherited
+        for key, value in next, defaults do
             if features[key] == nil then
                 features[key] = value
             end
         end
         return features
     else
-        return fastcopy(defaults)
+        return fastcopy(defaults) -- we can change features in place
     end
 end
 
@@ -1019,6 +1021,7 @@ function constructors.initializefeatures(what,tfmdata,features,trace,report)
         -- properties.mode can be enforces (for instance in font-otd)
         local mode             = properties.mode or (whatmodechecker and whatmodechecker(tfmdata,features,features.mode)) or features.mode or "base"
         properties.mode        = mode -- also status
+        features.mode          = mode -- both properties.mode or features.mode can be changed
         --
         local done             = { }
         while true do
@@ -1028,6 +1031,7 @@ function constructors.initializefeatures(what,tfmdata,features,trace,report)
                 for i=1,#initializers do
                     local step = initializers[i]
                     local feature = step.name
+-- we could intercept mode here .. needs a rewrite of this whole loop then btu it's cleaner that way
                     local value = features[feature]
                     if not value then
                         -- disabled
@@ -1040,9 +1044,10 @@ function constructors.initializefeatures(what,tfmdata,features,trace,report)
                                 tostring(value),mode or 'unknown', tfmdata.properties.fullname or 'unknown')
                         end
                         action(tfmdata,value,features) -- can set mode (e.g. goodies) so it can trigger a restart
-                        if mode ~= properties.mode then
+                        if mode ~= properties.mode or mode ~= features.mode then
                             if whatmodechecker then
                                 properties.mode = whatmodechecker(tfmdata,features,properties.mode) -- force checking
+                                features.mode   = properties.mode
                             end
                             if mode ~= properties.mode then
                                 mode = properties.mode
diff --git a/tex/context/base/font-ctx.lua b/tex/context/base/font-ctx.lua
index 7d7b1253b..1bc3f3db9 100644
--- a/tex/context/base/font-ctx.lua
+++ b/tex/context/base/font-ctx.lua
@@ -48,6 +48,8 @@ local texattribute        = tex.attribute
 
 local otffeatures         = fonts.constructors.newfeatures("otf")
 local registerotffeature  = otffeatures.register
+local baseprocessors      = otffeatures.processors.base
+local baseinitializers    = otffeatures.initializers.base
 
 specifiers.contextsetups  = specifiers.contextsetups  or { }
 specifiers.contextnumbers = specifiers.contextnumbers or { }
@@ -137,32 +139,49 @@ setmetatableindex(xheightdata, function(t,k)
 end)
 
 -- this cannot be a feature initializer as there is no auto namespace
--- so we never enter the loop then
+-- so we never enter the loop then; we can store the defaults in the tma
+-- file (features.gpos.mkmk = 1 etc)
+
+local needsnodemode = {
+    gpos_mark2mark     = true,
+    gpos_mark2base     = true,
+    gpos_mark2ligature = true,
+}
 
 local function modechecker(tfmdata,features,mode) -- we cannot adapt features as they are shared!
     if mode == "auto" then
-        local script    = features.script
-        local language  = features.language
         local rawdata   = tfmdata.shared.rawdata
-        local sequences = rawdata and rawdata.resources.sequences
-        if script and language and sequences and #sequences > 0 then
+        local resources = rawdata and rawdata.resources
+        local sequences = resources.sequences
+        if sequences and #sequences > 0 then
+            local script    = features.script   or "dflt"
+            local language  = features.language or "dflt"
             for feature, value in next, features do
                 if value then
                     local found = false
                     for i=1,#sequences do
-                        local features = sequences[i].features
+                        local sequence = sequences[i]
+                        local features = sequence.features
                         if features then
                             local scripts = features[feature]
                             if scripts then
                                 local languages = scripts[script]
                                 if languages and languages[language] then
                                     if found then
+                                        -- more than one lookup
+                                        if trace_automode then
+                                            report_defining("forcing node mode in font %s for feature %s, script %s, language %s (multiple lookups)",file.basename(tfmdata.properties.name),feature,script,language)
+                                        end
                                         features.mode = "node"
+                                        return "node"
+                                    elseif needsnodemode[sequence.type] then
                                         if trace_automode then
-                                            report_defining("forcing node mode due to features %s, script %s, language %s",feature,script,language)
+                                            report_defining("forcing node mode in font %s for feature %s, script %s, language %s (no base support)",file.basename(tfmdata.properties.name),feature,script,language)
                                         end
+                                        features.mode = "node"
                                         return "node"
                                     else
+                                        -- at least one lookup
                                         found = true
                                     end
                                 end
diff --git a/tex/context/base/font-ini.mkiv b/tex/context/base/font-ini.mkiv
index 8eb10e3ae..1c9cdcd32 100644
--- a/tex/context/base/font-ini.mkiv
+++ b/tex/context/base/font-ini.mkiv
@@ -2871,45 +2871,48 @@
   {\global\expandafter\chardef\csname\??fq=#1\endcsname % beware () needed as we get two values returned
      \ctxsprint{((fonts.specifiers.presetcontext("#1","#2","#3")))}\relax}
 
+\definefontfeature % experiment, this might move to the lua code
+  [always]
+  [mode=auto,
+   kern=yes,
+   mark=yes,
+   mkmk=yes,
+   curs=yes]
+
 \definefontfeature
   [default]
-  [mode=auto, % was nothing
-   liga=yes,
-   kern=yes,
+  [always]
+  [liga=yes,
    tlig=yes,
    trep=yes] % texligatures=yes,texquotes=yes
 
 \definefontfeature
   [smallcaps]
-  [mode=auto, % was nothing
-   smcp=yes,
-   kern=yes,
+  [always]
+  [smcp=yes,
    tlig=yes,
    trep=yes] % texligatures=yes,texquotes=yes
 
 \definefontfeature
   [oldstyle]
-  [mode=auto, % was nothing
-   onum=yes,
+  [always]
+  [onum=yes,
    liga=yes,
-   kern=yes,
    tlig=yes,
    trep=yes] % texligatures=yes,texquotes=yes
 
 \definefontfeature % == default unless redefined
   [ligatures]
-  [mode=auto, % was nothing
-   liga=yes,
-   kern=yes,
+  [always]
+  [liga=yes,
    tlig=yes,
    trep=yes]
 
 \definefontfeature % can be used for type1 fonts
   [complete]
-  [mode=auto, % was nothing
+  [always]
+  [compose=yes,
    liga=yes,
-   kern=yes,
-   compose=yes,
    tlig=yes,
    trep=yes]
 
diff --git a/tex/context/base/node-inj.lua b/tex/context/base/node-inj.lua
index aee2d1575..b9ef9188f 100644
--- a/tex/context/base/node-inj.lua
+++ b/tex/context/base/node-inj.lua
@@ -321,8 +321,7 @@ function injections.handler(head,where,keep)
                                 local d = mrks[index]
                                 if d then
                                     local rlmode = d[3]
-                                    -- maybe better swap and "rlmode and rlmode < 0" as lr (1) is default
-                                    if rlmode and rlmode > 0 then
+                                    if rlmode and rlmode >= 0 then
                                         -- new per 2010-10-06, width adapted per 2010-02-03
                                         -- we used to negate the width of marks because in tfm
                                         -- that makes sense but we no longer do that so as a
diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf
index 196f218e7..ad9e92d69 100644
Binary files a/tex/context/base/status-files.pdf and b/tex/context/base/status-files.pdf differ
diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf
index 229ab2c5f..234a294af 100644
Binary files a/tex/context/base/status-lua.pdf and b/tex/context/base/status-lua.pdf differ
diff --git a/tex/context/base/type-otf.mkiv b/tex/context/base/type-otf.mkiv
index 224e6d980..9bb2d3e47 100644
--- a/tex/context/base/type-otf.mkiv
+++ b/tex/context/base/type-otf.mkiv
@@ -20,10 +20,10 @@
 %
 %     \starttypescript [serif] [myserif] [name]
 %         \setups[font:fallback:serif]
-%         \definefontsynonym [Serif]           [file:myserif.ttf]           [features=default]
-%         \definefontsynonym [SerifBold]       [file:myserifbold.ttf]       [features=default]
-%         \definefontsynonym [SerifItalic]     [file:myserifitalic.ttf]     [features=default]
-%         \definefontsynonym [SerifBoldItalic] [file:myserifbolditalic.ttf] [features=default]
+%         \definefontsynonym [Serif]           [\s!file:myserif.ttf]           [features=default]
+%         \definefontsynonym [SerifBold]       [\s!file:myserifbold.ttf]       [features=default]
+%         \definefontsynonym [SerifItalic]     [\s!file:myserifitalic.ttf]     [features=default]
+%         \definefontsynonym [SerifBoldItalic] [\s!file:myserifbolditalic.ttf] [features=default]
 %     \stoptypescript
 %
 %     \starttypescript[myfont]
@@ -223,6 +223,7 @@
 
     \starttypescript [math] [modern,latin-modern,computer-modern,default] [name]
         \definefontsynonym [MathRoman]        [LMMathRoman-Regular]
+        \definefontsynonym [MathRomanBold]    [LMMathRoman-Bold]
         %definefontsynonym [MathExtension]    [LMMathExtension-Regular]
         %definefontsynonym [MathItalic]       [LMMathItalic-Italic]
         %definefontsynonym [MathSymbol]       [LMMathSymbols-Italic]
@@ -373,14 +374,14 @@
     \stoptypescript
 
     \starttypescript [math] [modern,latin-modern,default]
-        % isn't this obsolete now?
-        \definefontsynonym [LMMathRoman-Regular]       [LMMathRoman10-Regular]
-        \definefontsynonym [LMMathRoman-Bold]          [LMMathRoman10-Bold]
-        %definefontsynonym [LMMathSymbols-BoldItalic]  [LMMathSymbols10-BoldItalic]
-        %definefontsynonym [LMMathSymbols-Italic]      [LMMathSymbols10-Italic]
-        %definefontsynonym [LMMathExtension-Regular]   [LMMathExtension10-Regular]
-        %definefontsynonym [LMMathItalic-Italic]       [LMMathItalic10-Italic]
-        %definefontsynonym [LMMathItalic-BoldItalic]   [LMMathItalic10-BoldItalic]
+        \definefontsynonym [LMMathRoman-Regular] [LMMathRoman10-Regular]
+        \definefontsynonym [LMMathRoman-Bold]    [LMMathRoman10-Bold]
+    \stoptypescript
+
+    \starttypescript [math] [modern,latin-modern,default]
+      % \loadfontgoodies[lm-math]
+        \definefontsynonym [LMMathRoman-Regular] [\v!file:lmmath.otf]     [\s!features=\s!math]
+      % \definefontsynonym [LMMathRoman-Bold]    [\v!file:lmmathbold.otf] [\s!features=\s!math]
     \stoptypescript
 
     \starttypescript [modern,default]
@@ -1847,7 +1848,7 @@
     % use with LaTeX, will follow in 2011. So, we are on our own anyway.
 
     \starttypescript [math] [xits] [name]
-        \definefontsynonym[MathRoman][file:xits-math.otf][\s!features=\s!math\mathsizesuffix,\s!goodies=xits-math]
+        \definefontsynonym[MathRoman][\s!file:xits-math.otf][\s!features=\s!math\mathsizesuffix,\s!goodies=xits-math]
     \stoptypescript
 
     \starttypescript [serif] [xits] [name]
diff --git a/tex/generic/context/luatex-fonts-merged.lua b/tex/generic/context/luatex-fonts-merged.lua
index 224ca24c7..61f19becf 100644
--- a/tex/generic/context/luatex-fonts-merged.lua
+++ b/tex/generic/context/luatex-fonts-merged.lua
@@ -1,6 +1,6 @@
 -- merged file : luatex-fonts-merged.lua
 -- parent file : luatex-fonts.lua
--- merge date  : 05/10/11 19:20:23
+-- merge date  : 05/12/11 15:19:18
 
 do -- begin closure to overcome local limits and interference
 
@@ -3905,15 +3905,17 @@ a helper function.</p>
 --ldx]]--
 
 function constructors.checkedfeatures(what,features)
+    local defaults = handlers[what].features.defaults
     if features and next(features) then
-        for key, value in next, handlers[what].features.defaults do
+        features = fastcopy(features) -- can be inherited
+        for key, value in next, defaults do
             if features[key] == nil then
                 features[key] = value
             end
         end
         return features
     else
-        return fastcopy(defaults)
+        return fastcopy(defaults) -- we can change features in place
     end
 end
 
@@ -3929,6 +3931,7 @@ function constructors.initializefeatures(what,tfmdata,features,trace,report)
         -- properties.mode can be enforces (for instance in font-otd)
         local mode             = properties.mode or (whatmodechecker and whatmodechecker(tfmdata,features,features.mode)) or features.mode or "base"
         properties.mode        = mode -- also status
+        features.mode          = mode -- both properties.mode or features.mode can be changed
         --
         local done             = { }
         while true do
@@ -3938,6 +3941,7 @@ function constructors.initializefeatures(what,tfmdata,features,trace,report)
                 for i=1,#initializers do
                     local step = initializers[i]
                     local feature = step.name
+-- we could intercept mode here .. needs a rewrite of this whole loop then btu it's cleaner that way
                     local value = features[feature]
                     if not value then
                         -- disabled
@@ -3950,9 +3954,10 @@ function constructors.initializefeatures(what,tfmdata,features,trace,report)
                                 tostring(value),mode or 'unknown', tfmdata.properties.fullname or 'unknown')
                         end
                         action(tfmdata,value,features) -- can set mode (e.g. goodies) so it can trigger a restart
-                        if mode ~= properties.mode then
+                        if mode ~= properties.mode or mode ~= features.mode then
                             if whatmodechecker then
                                 properties.mode = whatmodechecker(tfmdata,features,properties.mode) -- force checking
+                                features.mode   = properties.mode
                             end
                             if mode ~= properties.mode then
                                 mode = properties.mode
@@ -7692,8 +7697,7 @@ function injections.handler(head,where,keep)
                                 local d = mrks[index]
                                 if d then
                                     local rlmode = d[3]
-                                    -- maybe better swap and "rlmode and rlmode < 0" as lr (1) is default
-                                    if rlmode and rlmode > 0 then
+                                    if rlmode and rlmode >= 0 then
                                         -- new per 2010-10-06, width adapted per 2010-02-03
                                         -- we used to negate the width of marks because in tfm
                                         -- that makes sense but we no longer do that so as a
-- 
cgit v1.2.3