summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPhilipp Gesang <phg42.2a@gmail.com>2014-12-14 21:28:56 +0100
committerPhilipp Gesang <phg42.2a@gmail.com>2014-12-14 21:28:56 +0100
commit747e6fb2c41045add6a799498026ff0d2ddf115b (patch)
treee07b58121d10fe123fc2b31d9a75d47dd347a17d /src
parentc029158f450cd96f71db2f2a4da72a5c946089c0 (diff)
parentd2a1af0a62a2540c8b88345b8d1e84ba61a8a49f (diff)
downloadluaotfload-747e6fb2c41045add6a799498026ff0d2ddf115b.tar.gz
Merge pull request #261 from phi-gamma/master
[main, aux] add a callback that installs a .resources table in fonts tha...
Diffstat (limited to 'src')
-rw-r--r--src/luaotfload-auxiliary.lua29
-rw-r--r--src/luaotfload-main.lua25
2 files changed, 45 insertions, 9 deletions
diff --git a/src/luaotfload-auxiliary.lua b/src/luaotfload-auxiliary.lua
index 7ea747e..b3fa795 100644
--- a/src/luaotfload-auxiliary.lua
+++ b/src/luaotfload-auxiliary.lua
@@ -129,6 +129,35 @@ luatexbase.add_to_callback(
"luaotfload.patch_font",
patch_cambria_domh,
"luaotfload.aux.patch_cambria_domh")
+
+
+--[[doc--
+
+ Add missing field to fonts that lack it. Addresses issue
+ https://github.com/lualatex/luaotfload/issues/253
+
+ This is considered a hack, especially since importing the
+ unicode-math package fixes the problem quite nicely.
+
+--doc]]--
+
+--- fontobj -> unit
+local fixup_fontdata = function (data)
+
+ local t = type (data)
+ --- Some OT fonts like Libertine R lack the resources table, causing
+ --- the fontloader to nil-index.
+ if t == "table" then
+ if data and not data.resources then data.resources = { } end
+ end
+
+end
+
+luatexbase.add_to_callback(
+ "luaotfload.patch_font_unsafe",
+ fixup_fontdata,
+ "luaotfload.aux.fixup_fontdata")
+
--[[doc--
diff --git a/src/luaotfload-main.lua b/src/luaotfload-main.lua
index d3c4552..a090cce 100644
--- a/src/luaotfload-main.lua
+++ b/src/luaotfload-main.lua
@@ -354,7 +354,7 @@ else--- the loading sequence is known to change, so this might have to
load_fontloader_module "font-otf"
load_fontloader_module "font-otb"
load_fontloader_module "luatex-fonts-inj" --> since 2014-01-07, replaces node-inj.lua
- load_fontloader_module "font-ota"
+ load_fontloader_module "luatex-fonts-ota"
load_fontloader_module "luatex-fonts-otn" --> since 2014-01-07, replaces font-otn.lua
load_fontloader_module "font-otp" --> since 2013-04-23
load_fontloader_module "luatex-fonts-lua"
@@ -657,14 +657,19 @@ end
--[[doc--
- We create a callback for patching fonts on the fly, to be used by
- other packages.
- It initially contains the empty function that we are going to
+ We create callbacks for patching fonts on the fly, to be used by
+ other packages. In addition to the regular \identifier{patch_font}
+ callback there is an unsafe variant \identifier{patch_font_unsafe}
+ that will be invoked even if the target font lacks certain essential
+ tfmdata tables.
+
+ The callbacks initially contain the empty function that we are going to
override below.
--doc]]--
-create_callback("luaotfload.patch_font", "simple", dummy_function)
+create_callback("luaotfload.patch_font", "simple", dummy_function)
+create_callback("luaotfload.patch_font_unsafe", "simple", dummy_function)
--[[doc--
@@ -681,14 +686,16 @@ do
local read = fonts.definers.read
local patch = function (specification, size, id)
- local tfmdata = read (specification, size, id)
- if type (tfmdata) == "table" and tfmdata.shared then
+ local fontdata = read (specification, size, id)
+ if type (fontdata) == "table" and fontdata.shared then
--- We need to test for the “shared” field here
--- or else the fontspec capheight callback will
--- operate on tfm fonts.
- call_callback ("luaotfload.patch_font", tfmdata, specification)
+ call_callback ("luaotfload.patch_font", fontdata, specification)
+ else
+ call_callback ("luaotfload.patch_font_unsafe", fontdata, specification)
end
- return tfmdata
+ return fontdata
end
local mk_info = function (name)