[latex3-commits] [git/LaTeX3-latex3-luaotfload] harf-dev: Some cleanup (d9d88f6)

Marcel Fabian Krüger tex at 2krueger.de
Tue Sep 17 15:00:18 CEST 2019


Repository : https://github.com/latex3/luaotfload
On branch  : harf-dev
Link       : https://github.com/latex3/luaotfload/commit/d9d88f68bd430a2b23502dff1ec2ac5523c28320

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

commit d9d88f68bd430a2b23502dff1ec2ac5523c28320
Author: Marcel Fabian Krüger <tex at 2krueger.de>
Date:   Mon Sep 16 21:48:41 2019 +0200

    Some cleanup


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

d9d88f68bd430a2b23502dff1ec2ac5523c28320
 build.lua               |  2 +
 src/harf/harf-load.lua  | 97 ++-----------------------------------------------
 src/harf/harf-plain.lua |  5 ---
 src/harf/harfload.sty   |  9 -----
 4 files changed, 5 insertions(+), 108 deletions(-)

diff --git a/build.lua b/build.lua
index 111b9ef..64dd88e 100644
--- a/build.lua
+++ b/build.lua
@@ -167,6 +167,7 @@ else
     "**/luaotfload-*.lua",
     "**/fontloader-*.lua",
     "**/fontloader-*.tex",
+    "**/harf*.lua",
     "luaotfload-blacklist.cnf",
     "./doc/filegraph.tex",
     "./doc/luaotfload-main.tex",
@@ -177,6 +178,7 @@ else
      "**/luaotfload-*.lua",
      "**/fontloader-*.lua",
      "**/fontloader-*.tex",
+     "**/harf*.lua",
                 }
 end
 tdslocations=
diff --git a/src/harf/harf-load.lua b/src/harf/harf-load.lua
index 0543c94..a4b799f 100644
--- a/src/harf/harf-load.lua
+++ b/src/harf/harf-load.lua
@@ -9,60 +9,6 @@ local os2tag  = hb.Tag.new("OS/2")
 local posttag = hb.Tag.new("post")
 local glyftag = hb.Tag.new("glyf")
 
-local function trim(str)
-  return str:gsub("^%s*(.-)%s*$", "%1")
-end
-
-local function split(str, sep)
-  if str then
-    local result = string.explode(str, sep.."+")
-    for i, s in next, result do
-      result[i] = trim(result[i])
-    end
-    return result
-  end
-end
-
-local function parse(str, size)
-  local name, options = str:match("%s*(.*)%s*:%s*(.*)%s*")
-  local spec = {
-    specification = str,
-    size = size,
-    variants = {}, features = {}, options = {},
-  }
-
-  name = trim(name or str)
-
-  local filename = name:match("%[(.*)%]")
-  if filename then
-    -- [file]
-    -- [file:index]
-    filename = string.explode(filename, ":+")
-    spec.file = filename[1]
-    spec.index = tonumber(filename[2]) or 0
-  else
-    -- name
-    -- name/variants
-    local fontname, variants = name:match("(.-)%s*/%s*(.*)")
-    spec.name = fontname or name
-    spec.variants = split(variants, "/")
-  end
-  if options then
-    options = split(options, ";+")
-    for _, opt in next, options do
-      if opt:find("[+-]") == 1 then
-        local feature = hb.Feature.new(opt)
-        spec.features[#spec.features + 1] = feature
-      elseif opt ~= "" then
-        local key, val = opt:match("(.*)%s*=%s*(.*)")
-        if key == "language" then val = hb.Language.new(val) end
-        spec.options[key or opt] = val or true
-      end
-    end
-  end
-  return spec
-end
-
 local function loadfont(spec)
   local path, index = spec.path, spec.index
   if not path then
@@ -212,25 +158,7 @@ end
 -- Drop illegal characters from PS Name, per the spec
 -- https://docs.microsoft.com/en-us/typography/opentype/spec/name#nid6
 local function sanitize(psname)
-  local new = psname:gsub(".", function(c)
-    local b = c:byte()
-    if (b < 33 or b > 126)
-    or c == "["
-    or c == "]"
-    or c == "("
-    or c == ")"
-    or c == "{"
-    or c == "}"
-    or c == "<"
-    or c == ">"
-    or c == "/"
-    or c == "%"
-    then
-      return "-"
-    end
-    return c
-  end)
-  return new
+  return psname:gsub('[][\0-\32\127-\255(){}<>/%%]', '-')
 end
 
 local tlig = hb.texlig
@@ -371,25 +299,6 @@ local function scalefont(data, spec)
   }
 end
 
-local function define_font(name, size)
-  local spec = type(name) == "string" and parse(name, size) or name
-  if spec.file then
-    spec.path = kpse.find_file(spec.file, "truetype fonts") or
-                kpse.find_file(spec.file, "opentype fonts")
-  else
-    -- XXX support font names
-  end
-
-  if spec.specification == "" then return nil end
-
-  local tfmdata = nil
-  local hbdata = loadfont(spec)
-  if hbdata then
-    tfmdata = scalefont(hbdata, spec)
-  else
-    tfmdata = font.read_tfm(spec.specification, spec.size)
-  end
-  return tfmdata
+return function(spec)
+  return scalefont(loadfont(spec), spec)
 end
-
-return define_font
diff --git a/src/harf/harf-plain.lua b/src/harf/harf-plain.lua
deleted file mode 100644
index a79a174..0000000
--- a/src/harf/harf-plain.lua
+++ /dev/null
@@ -1,5 +0,0 @@
-local harf = require("harf")
-
-for name, func in next, harf.callbacks do
-  callback.register(name, func)
-end
diff --git a/src/harf/harfload.sty b/src/harf/harfload.sty
deleted file mode 100644
index 9675b10..0000000
--- a/src/harf/harfload.sty
+++ /dev/null
@@ -1,9 +0,0 @@
-\csname ifharfloadloaded\endcsname
-\let\ifharfloadloaded\endinput
-\ifdefined\ProvidesPackage
-  \RequirePackage{luaotfload}
-  \ProvidesPackage{harfload}[2019/06/30 v0.3.1  Unicode text layout system]
-\else
-  \input luaotfload.sty
-\fi
-\directlua{require('harf-luaotfload')}





More information about the latex3-commits mailing list