From efa8114de758153a8773ca906ef7eaf2ba40c4ae Mon Sep 17 00:00:00 2001
From: Khaled Hosny <khaledhosny@eglug.org>
Date: Sun, 13 May 2012 00:35:10 +0200
Subject: Make anum work again

---
 luaotfload.dtx | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 62 insertions(+)

(limited to 'luaotfload.dtx')

diff --git a/luaotfload.dtx b/luaotfload.dtx
index 47b2595..9bf0ac9 100644
--- a/luaotfload.dtx
+++ b/luaotfload.dtx
@@ -650,6 +650,68 @@ fonts.handlers.otf.addfeature("tlig", tlig_specification)
 fonts.handlers.otf.addfeature("trep", { })
 %    \end{macrocode}
 %
+%    And overriding the \context's definition of |anum|.
+%
+%    \begin{macrocode}
+local anum_arabic = {
+    [0x0030] = 0x0660,
+    [0x0031] = 0x0661,
+    [0x0032] = 0x0662,
+    [0x0033] = 0x0663,
+    [0x0034] = 0x0664,
+    [0x0035] = 0x0665,
+    [0x0036] = 0x0666,
+    [0x0037] = 0x0667,
+    [0x0038] = 0x0668,
+    [0x0039] = 0x0669,
+}
+
+local anum_persian = {
+    [0x0030] = 0x06F0,
+    [0x0031] = 0x06F1,
+    [0x0032] = 0x06F2,
+    [0x0033] = 0x06F3,
+    [0x0034] = 0x06F4,
+    [0x0035] = 0x06F5,
+    [0x0036] = 0x06F6,
+    [0x0037] = 0x06F7,
+    [0x0038] = 0x06F8,
+    [0x0039] = 0x06F9,
+}
+
+local function valid(data)
+    local features = data.resources.features
+    if features then
+        for k, v in next, features do
+            for k, v in next, v do
+                if v.arab then
+                    return true
+                end
+            end
+        end
+    end
+end
+
+local anum_specification = {
+    {
+        type     = "substitution",
+        features = { arab = { far = true, urd = true, snd = true } },
+        data     = anum_persian,
+        flags    = { },
+        valid    = valid,
+    },
+    {
+        type     = "substitution",
+	features = { arab = { ["*"] = true } },
+        data     = anum_arabic,
+        flags    = { },
+        valid    = valid,
+    },
+}
+
+fonts.handlers.otf.addfeature("anum",anum_specification)
+%    \end{macrocode}
+%
 %    we provide a callback for patching fonts on the fly, to be used by other
 %    packages.
 %
-- 
cgit v1.2.3

