[latex3-commits] [git/LaTeX3-latex3-luaotfload] dev: Casing, 2nd step (fc56c53)

Marcel Fabian Krüger tex at 2krueger.de
Fri Oct 23 16:45:41 CEST 2020


Repository : https://github.com/latex3/luaotfload
On branch  : dev
Link       : https://github.com/latex3/luaotfload/commit/fc56c531adaba9f4fbd3f5235c600ae767a8669b

>---------------------------------------------------------------

commit fc56c531adaba9f4fbd3f5235c600ae767a8669b
Author: Marcel Fabian Krüger <tex at 2krueger.de>
Date:   Fri Oct 23 16:43:24 2020 +0200

    Casing, 2nd step
    
    No context or language dependency, but "simple" entries in SpecialCasing
    covered


>---------------------------------------------------------------

fc56c531adaba9f4fbd3f5235c600ae767a8669b
 src/luaotfload-case.lua    | 17 ++++++++++++++++-
 src/luaotfload-unicode.lua | 44 +++++++++++++++++++++++++++++++++++++++-----
 2 files changed, 55 insertions(+), 6 deletions(-)

diff --git a/src/luaotfload-case.lua b/src/luaotfload-case.lua
index f3cb799..a005187 100644
--- a/src/luaotfload-case.lua
+++ b/src/luaotfload-case.lua
@@ -13,6 +13,9 @@ local getnext = direct.getnext
 local setchar = direct.setchar
 local setdisc = direct.setdisc
 local getdisc = direct.getdisc
+local remove = direct.remove
+local copy = direct.copy
+local insert_after = direct.insert_after
 
 local disc = node.id'disc'
 local glyph = node.id'disc'
@@ -26,13 +29,25 @@ local function process(table)
       if char then
         local mapping = table[char]
         if mapping then
-          setchar(n, mapping)
+          if tonumber(mapping) then
+            setchar(n, mapping)
+          elseif #mapping == 0 then
+            head, n = remove(head, n)
+            goto continue
+          else
+            setchar(n, mapping[1])
+            for i=2, #mapping do
+              head, n = insert_after(head, n, copy(n))
+              setchar(n, mapping[i])
+            end
+          end
         end
       elseif id == disc and uses_font(n, font) then
         local pre, post, rep = getdisc(n)
         setdisc(n, processor(pre, font), processor(post, font), processor(rep, font))
       end
       n = getnext(n)
+      ::continue::
     end
     return head
   end
diff --git a/src/luaotfload-unicode.lua b/src/luaotfload-unicode.lua
index aa5bee2..0cd196a 100644
--- a/src/luaotfload-unicode.lua
+++ b/src/luaotfload-unicode.lua
@@ -129,12 +129,12 @@ local uppercase, lowercase, titlecase = {}, {}, nil do
     * ignored_field -- Mirrored
     * ignored_field -- Obsolete
     * ignored_field -- Obsolete
-    * (codepoint + lpeg.Cc(false)) * ';' -- uppercase
-    * (codepoint + lpeg.Cc(false)) * ';' -- lowercase
-    * (codepoint + lpeg.Cc(false)) * '\n' -- titlecase
+    * (codepoint + lpeg.Cc(nil)) * ';' -- uppercase
+    * (codepoint + lpeg.Cc(nil)) * ';' -- lowercase
+    * (codepoint + lpeg.Cc(nil)) * '\n' -- titlecase
     / function(codepoint, upper, lower, title)
-      if upper then uppercase[codepoint] = upper end
-      if lower then lowercase[codepoint] = lower end
+      uppercase[codepoint] = upper
+      lowercase[codepoint] = lower
       -- if title then titlecase[codepoint] = title end -- Not implemented yet(?)
     end
   local file = entry^0 * -1
@@ -144,6 +144,40 @@ local uppercase, lowercase, titlecase = {}, {}, nil do
   f:close()
 end
 
+do
+  local ws = lpeg.P' '^0
+  local nl = ws * ('#' * (1-lpeg.P'\n')^0)^-1 * '\n'
+  local entry = codepoint * ";"
+              * lpeg.Ct((ws * codepoint)^1 + ws) * ";"
+              * lpeg.Ct((ws * codepoint)^1 + ws) * ";"
+              * lpeg.Ct((ws * codepoint)^1 + ws) * ";"
+              * (lpeg.Ct((ws * lpeg.C(lpeg.R('AZ', 'az', '__')^1))^1) * ";")^-1
+              * ws * nl / function(cp, lower, title, upper, condition)
+                if condition then return end
+                if #lower == 1 then
+                  lower = lower[1]
+                  if lower ~= lowercase[cp] then
+                    lowercase[cp] = lower
+                  end
+                else
+                  lowercase[cp] = lower
+                end
+                if #upper == 1 then
+                  upper = upper[1]
+                  if upper ~= uppercase[cp] then
+                    uppercase[cp] = upper
+                  end
+                else
+                  uppercase[cp] = upper
+                end
+              end
+  local file = (entry + nl)^0 * -1
+
+  local f = io.open(kpse.find_file"SpecialCasing.txt")
+  assert(file:match(f:read'*a'))
+  f:close()
+end
+
 return {
   casefold = casefold,
   alphnum_only = alphnum_only,





More information about the latex3-commits mailing list.