From f2b2b467de8e4c58a19859a713694ae50afb00be Mon Sep 17 00:00:00 2001
From: Khaled Hosny <khaledhosny@eglug.org>
Date: Wed, 19 Oct 2011 03:28:47 +0200
Subject: Sync with ConTeXt beta 2011.10.19 00:02

---
 otfl-basics-gen.lua |  2 ++
 otfl-font-con.lua   |  6 ++++--
 otfl-font-def.lua   | 32 ++++++++++++++++----------------
 otfl-font-otf.lua   |  5 +++++
 4 files changed, 27 insertions(+), 18 deletions(-)

diff --git a/otfl-basics-gen.lua b/otfl-basics-gen.lua
index c0fc396..bdbc3cf 100644
--- a/otfl-basics-gen.lua
+++ b/otfl-basics-gen.lua
@@ -80,6 +80,8 @@ local remapper = {
     dfont = "truetype fonts", -- "truetype dictionary",
     cid   = "cid maps",
     fea   = "font feature files",
+    pfa   = "type1 fonts", -- this is for Khaled, in ConTeXt we don't use this!
+    pfb   = "type1 fonts", -- this is for Khaled, in ConTeXt we don't use this!
 }
 
 function resolvers.findfile(name,fileformat)
diff --git a/otfl-font-con.lua b/otfl-font-con.lua
index 5352977..75d90f1 100644
--- a/otfl-font-con.lua
+++ b/otfl-font-con.lua
@@ -426,7 +426,9 @@ function constructors.scale(tfmdata,specification)
         end
     end
     --
-    local sharedkerns   = { }
+    local sharedkerns = { }
+    --
+    -- we can have a dumb mode (basemode without math etc) that skips most
     --
     for unicode, character in next, characters do
         local chr, description, index, touni
@@ -528,7 +530,7 @@ function constructors.scale(tfmdata,specification)
                 chr[italickey] = vi*hdelta
             end
         elseif hasitalic then
-            local vi = description.italic or character.italic -- why character
+            local vi = description.italic -- or character.italic hm, already scaled !
             if vi and vi ~= 0 then
                 chr[italickey] = vi*hdelta
             end
diff --git a/otfl-font-def.lua b/otfl-font-def.lua
index 63d3e2c..5f79170 100644
--- a/otfl-font-def.lua
+++ b/otfl-font-def.lua
@@ -248,27 +248,27 @@ features (esp in virtual fonts) so let's not do that now.</p>
 specification yet.</p>
 --ldx]]--
 
--- not in context, at least not now:
---
--- function definers.applypostprocessors(tfmdata)
---     local postprocessors = tfmdata.postprocessors
---     if postprocessors then
---         for i=1,#postprocessors do
---             local extrahash = postprocessors[i](tfmdata) -- after scaling etc
---             if type(extrahash) == "string" and extrahash ~= "" then
---                 -- e.g. a reencoding needs this
---                 extrahash = gsub(lower(extrahash),"[^a-z]","-")
---                 tfmdata.properties.fullname = format("%s-%s",tfmdata.properties.fullname,extrahash)
---             end
---         end
---     end
---     return tfmdata
--- end
+-- very experimental:
 
 function definers.applypostprocessors(tfmdata)
+    local postprocessors = tfmdata.postprocessors
+    if postprocessors then
+        for i=1,#postprocessors do
+            local extrahash = postprocessors[i](tfmdata) -- after scaling etc
+            if type(extrahash) == "string" and extrahash ~= "" then
+                -- e.g. a reencoding needs this
+                extrahash = gsub(lower(extrahash),"[^a-z]","-")
+                tfmdata.properties.fullname = format("%s-%s",tfmdata.properties.fullname,extrahash)
+            end
+        end
+    end
     return tfmdata
 end
 
+-- function definers.applypostprocessors(tfmdata)
+--     return tfmdata
+-- end
+
 function definers.loadfont(specification)
     local hash = constructors.hashinstance(specification)
     local tfmdata = loadedfonts[hash] -- hashes by size !
diff --git a/otfl-font-otf.lua b/otfl-font-otf.lua
index 6a75a0c..cab6fae 100644
--- a/otfl-font-otf.lua
+++ b/otfl-font-otf.lua
@@ -1838,6 +1838,11 @@ local function copytotfm(data,cache_id)
         local fullname = metadata.fullname or fontname
         local units    = metadata.units_per_em or 1000
         --
+        if units == 0 then -- catch bugs in fonts
+            units = 1000
+            metadata.units_per_em = 1000
+        end
+        --
         parameters.slant         = 0
         parameters.space         = spaceunits          -- 3.333 (cmr10)
         parameters.space_stretch = units/2   --  500   -- 1.666 (cmr10)
-- 
cgit v1.2.3