From 26d8a2c8fa6c870cc1bd617e94827771344f9e83 Mon Sep 17 00:00:00 2001
From: Context Git Mirror Bot <phg42.2a@gmail.com>
Date: Tue, 4 Aug 2015 23:15:06 +0200
Subject: 2015-08-04 23:03:00

---
 tex/context/base/cont-new.mkiv                     |   2 +-
 tex/context/base/context-version.pdf               | Bin 4198 -> 4199 bytes
 tex/context/base/context.mkiv                      |   2 +-
 tex/context/base/pack-rul.mkiv                     |  24 ++---
 tex/context/base/status-files.pdf                  | Bin 24463 -> 24448 bytes
 tex/context/base/status-lua.pdf                    | Bin 255437 -> 255438 bytes
 tex/context/base/typo-dha.lua                      | 104 ++++++++++++++-------
 tex/generic/context/luatex/luatex-fonts-merged.lua |   2 +-
 8 files changed, 86 insertions(+), 48 deletions(-)

diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv
index 8a835e568..32ee270dc 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{2015.08.04 01:25}
+\newcontextversion{2015.08.04 23:01}
 
 %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/context-version.pdf b/tex/context/base/context-version.pdf
index ba07df476..006bd2078 100644
Binary files a/tex/context/base/context-version.pdf and b/tex/context/base/context-version.pdf differ
diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv
index 2e5b71d87..522b3240d 100644
--- a/tex/context/base/context.mkiv
+++ b/tex/context/base/context.mkiv
@@ -39,7 +39,7 @@
 %D up and the dependencies are more consistent.
 
 \edef\contextformat {\jobname}
-\edef\contextversion{2015.08.04 01:25}
+\edef\contextversion{2015.08.04 23:01}
 \edef\contextkind   {beta}
 
 %D For those who want to use this:
diff --git a/tex/context/base/pack-rul.mkiv b/tex/context/base/pack-rul.mkiv
index 2a7cca92a..af6841288 100644
--- a/tex/context/base/pack-rul.mkiv
+++ b/tex/context/base/pack-rul.mkiv
@@ -1506,12 +1506,12 @@
   {%\pack_framed_stop_orientation % hm, wrong place ! should rotate the result (after reshape) .. moved down
    \pack_framed_locator_before\p_framed_location
    \ifconditional\c_framed_has_format
-%      \ifconditional\c_framed_has_height \else
-%        \edef\p_profile{\framedparameter\c!profile}%
-%        \ifx\p_profile\empty\else
-%          \pack_framed_profile_box
-%        \fi
-%      \fi
+    %\ifconditional\c_framed_has_height \else
+    %  \edef\p_profile{\framedparameter\c!profile}%
+    %  \ifx\p_profile\empty\else
+    %    \pack_framed_profile_box
+    %  \fi
+    %\fi
      \ifx\p_framed_autowidth\v!force
        \pack_framed_finish_a
      \else\ifx\localwidth\v!fit
@@ -1525,12 +1525,12 @@
      \else
        \pack_framed_finish_c
      \fi\fi\fi
- \ifconditional\c_framed_has_height \else
-   \edef\p_profile{\framedparameter\c!profile}%
-   \ifx\p_profile\empty\else
-     \pack_framed_profile_box
-   \fi
- \fi
+     \ifconditional\c_framed_has_height \else
+       \edef\p_profile{\framedparameter\c!profile}%
+       \ifx\p_profile\empty\else
+         \pack_framed_profile_box
+       \fi
+     \fi
      \ifconditional\page_postprocessors_needed_box
        % quite late
        \page_postprocessors_linenumbers_box\b_framed_normal
diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf
index dd044e140..fb4fc1ba0 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 7b199667f..5eeef5490 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/typo-dha.lua b/tex/context/base/typo-dha.lua
index 5ea18f001..6ab1f91c0 100644
--- a/tex/context/base/typo-dha.lua
+++ b/tex/context/base/typo-dha.lua
@@ -116,11 +116,15 @@ local strip              = false
 local s_isol             = fonts.analyzers.states.isol
 
 local function stopdir(finish)
-    return new_textdir(finish == "TRT" and "-TRT" or "-TLT")
+    local n = new_textdir(finish == "TRT" and "-TRT" or "-TLT")
+    setprop(n,"direction",true)
+    return n
 end
 
 local function startdir(finish)
-    return new_textdir(finish == "TRT" and "+TRT" or "+TLT")
+    local n = new_textdir(finish == "TRT" and "+TRT" or "+TLT")
+    setprop(n,"direction",true)
+    return n
 end
 
 local function nextisright(current)
@@ -297,11 +301,16 @@ local function process(start)
                             obsolete[#obsolete+1] = current
                         elseif trace_directions then
                             setcolor(current)
+                            setprop(current,"direction",true)
                         end
                     end
                 else
                     setprop(current,"direction",true)
                 end
+            elseif id == glue_code then
+                setprop(current,"direction",'g')
+            elseif id == kern_code then
+                setprop(current,"direction",'k')
             elseif id == whatsit_code then
                 local subtype = getsubtype(current)
                 if subtype == localpar_code then
@@ -339,52 +348,81 @@ local function process(start)
     end
 
     -- todo: track if really needed
+    -- todo: maybe we need to set the property (as it can be a copied list)
 
-    local pp = nil
+    if done and strip then
+        local n = #obsolete
+        if n > 0 then
+            for i=1,n do
+                remove_node(head,obsolete[i],true)
+            end
+            if trace_directions then
+                report_directions("%s character nodes removed",n)
+            end
+        end
+    end
+
+    local state    = false
+    local last     = false
+    local collapse = true
+    current        = head
+
+    -- spaces are an issue: todo
 
     while current do
         local id = getid(current)
         if id == math_code then
+            -- todo: this might be tricky nesting
             current = getnext(end_of_math(getnext(current)))
         else
             local cp = getprop(current,"direction")
-            if cp == pp then
-            elseif cp == true then
-                if pp == "r" then
-                    head = insert_node_before(head,current,stopdir("TRT"))
-                elseif pp == "l" then
-                    head = insert_node_before(head,current,stopdir("TLT"))
-                end
-                pp   = cp
-                done = true
-            elseif cp == "l" then
-                if pp == "r" then
-                    head = insert_node_before(head,current,stopdir("TRT"))
+            if cp == "l" then
+                if state ~= "l" then
+                    if state == "r" then
+                        head = insert_node_before(head,last or current,stopdir("TRT"))
+                    end
+                    head  = insert_node_before(head,current,startdir("TLT"))
+                    state = "l"
+                    done  = true
                 end
-                head = insert_node_before(head,current,startdir("TLT"))
-                pp   = cp
-                done = true
+                last  = false
             elseif cp == "r" then
-                if pp == "l" then
+                if state ~= "r" then
+                    if state == "l" then
+                        head = insert_node_before(head,last or current,stopdir("TLT"))
+                    end
+                    head  = insert_node_before(head,current,startdir("TRT"))
+                    state = "r"
+                    done  = true
+                end
+                last  = false
+            elseif collapse then
+                if cp == "k" or cp == "g" then
+                    last = last or current
+                else
+                    last = false
+                end
+            else
+                if state == "r" then
+                    head = insert_node_before(head,current,stopdir("TRT"))
+                elseif state == "l" then
                     head = insert_node_before(head,current,stopdir("TLT"))
                 end
-                head = insert_node_before(head,current,startdir("TRT"))
-                pp   = cp
-                done = true
+                state = false
+                last  = false
             end
+            setprop(current,"direction",true)
         end
-        current = getnext(current)
-    end
-
-    if done and strip then
-        local n = #obsolete
-        if n > 0 then
-            for i=1,n do
-                remove_node(head,obsolete[i],true)
-            end
-            if trace_directions then
-                report_directions("%s character nodes removed",n)
+        local next = getnext(current)
+        if next then
+            current = next
+        else
+            if state == "r" then
+                head = insert_node_after(head,current,stopdir("TRT"))
+            elseif state == "l" then
+                head = insert_node_after(head,current,stopdir("TLT"))
             end
+            break
         end
     end
 
diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua
index 680952a7a..86af13339 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 : luatex-fonts-merged.lua
 -- parent file : luatex-fonts.lua
--- merge date  : 08/04/15 01:25:05
+-- merge date  : 08/04/15 23:01:26
 
 do -- begin closure to overcome local limits and interference
 
-- 
cgit v1.2.3