summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Gesang <phg42.2a@gmail.com>2013-12-28 04:29:58 -0800
committerPhilipp Gesang <phg42.2a@gmail.com>2013-12-28 04:29:58 -0800
commitc8a6d4cfba7a0d5d53917f709a973292931e0d3e (patch)
tree598057b804a40e469cf286551de03a98cb6ab1d0
parentdc441726bcac289118b6601e1410bc8ea37b03be (diff)
parent715057ab3798e45c31c12673c06299dfbd8f8c2b (diff)
downloadluaotfload-c8a6d4cfba7a0d5d53917f709a973292931e0d3e.tar.gz
Merge pull request #158 from phi-gamma/master
Xetex compatibility for letterspacing
-rw-r--r--NEWS2
-rw-r--r--luaotfload-extralibs.lua35
2 files changed, 35 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index 3825605..526d32d 100644
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,8 @@ Change History
this
* rename ``luaotfload-merged.lua`` (the fontloader package from Context)
to ``luaotfload-fontloader.lua``
+ * Treat arguments of the ``letterspace`` option as percentages; add
+ ``kernfactor`` option that behaves as before.
2013/07/10, luaotfload v2.3a
* Detect LuaJIT interpreter (LuaJITTeX)
diff --git a/luaotfload-extralibs.lua b/luaotfload-extralibs.lua
index 6d486b2..21f738c 100644
--- a/luaotfload-extralibs.lua
+++ b/luaotfload-extralibs.lua
@@ -411,14 +411,45 @@ end
--- feature mechanism
otffeatures.register {
- name = "letterspace", --"kerncharacters",
- description = "letterspace", --"kerncharacters",
+ name = "kernfactor",
+ description = "kernfactor",
initializers = {
base = initializefontkerning,
node = initializefontkerning,
}
}
+--[[doc--
+
+ The “letterspace” feature is essentially identical with the above
+ “kernfactor” method, but scales the factor to percentages to match
+ Xetex’s behavior. (See the Xetex reference, page 5, section 1.2.2.)
+
+ Since Xetex doesn’t appear to have a (documented) “max” keyword, we
+ assume all input values are numeric.
+
+--doc]]--
+
+local initializecompatfontkerning = function (tfmdata, percentage)
+ local factor = tonumber (percentage)
+ if not factor then
+ logs.names_report ("both", 0, "letterspace",
+ "Invalid argument to letterspace: %s (type %q), was expecting percentage as Lua number instead.",
+ percentage, type (percentage))
+ return
+ end
+ return initializefontkerning (tfmdata, factor * 0.01)
+end
+
+otffeatures.register {
+ name = "letterspace",
+ description = "letterspace",
+ initializers = {
+ base = initializecompatfontkerning,
+ node = initializecompatfontkerning,
+ }
+}
+
kerns.set = nil
local characterkerning_enabled = false