summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElie Roux <elie.roux@telecom-bretagne.eu>2013-05-03 09:52:25 -0700
committerElie Roux <elie.roux@telecom-bretagne.eu>2013-05-03 09:52:25 -0700
commitf349a934661594c945ad118d85cfd3a7b4a296b8 (patch)
treee11e7e7f4093bdded4cfaccb71ecb4003c121265
parent8c5fb4b380191aefd6ddc0fcb738b24f740f4496 (diff)
parent0d5cb659dab620361bddc59d4f386fbbdc78b307 (diff)
downloadluaotfload-f349a934661594c945ad118d85cfd3a7b4a296b8.tar.gz
Merge pull request #38 from phi-gamma/master
workaround outdated packages (fontspec, unicode-math, microtype)
-rw-r--r--luaotfload-auxiliary.lua62
-rw-r--r--luaotfload.dtx24
2 files changed, 71 insertions, 15 deletions
diff --git a/luaotfload-auxiliary.lua b/luaotfload-auxiliary.lua
index 844c170..5ed7bb9 100644
--- a/luaotfload-auxiliary.lua
+++ b/luaotfload-auxiliary.lua
@@ -36,6 +36,68 @@ local stringbyte = string.byte
-----------------------------------------------------------------------
--[[doc--
+
+The font object (tfmdata) structure has changed since version 1.x, so
+in case other packages haven’t been updated we put fallbacks in place
+where they’d expect them. Specifically we have in mind:
+
+ · fontspec
+ · unicode-math
+ · microtype (most likely fixed till TL2013)
+
+--doc]]--
+
+--- fontobj -> fontobj
+local add_fontdata_fallbacks = function (fontdata)
+ if type(fontdata) == "table" then
+ local fontparameters = fontdata.parameters
+ local metadata
+ if not fontdata.shared then --- that would be a tfm
+ --- we can’t really catch everything that
+ --- goes wrong; for some reason, fontspec.lua
+ --- just assumes it always gets an otf object,
+ --- so its capheight callback, which does not
+ --- bother to do any checks, will access
+ --- fontdata.shared no matter what ...
+ fontdata.units = fontdata.units_per_em
+ else --- otf
+ metadata = fontdata.shared.rawdata.metadata
+ fontdata.units = fontparameters.units
+ local resources = fontdata.resources
+ fontdata.size = fontparameters.size
+ --- for legacy fontspec.lua and unicode-math.lua
+ fontdata.shared.otfdata = metadata
+ fontdata.shared.otfdata.metadata = metadata --- brr, that’s meta indeed
+ --- for microtype.lua
+ fontdata.shared.otfdata.luatex = {
+ unicodes = resources.unicodes,
+ features = resources.features,
+ }
+ end
+ end
+ return fontdata
+end
+
+luatexbase.add_to_callback(
+ "luaotfload.patch_font",
+ add_fontdata_fallbacks,
+ "luaotfload.fontdata_fallbacks")
+
+--[[doc--
+
+Additionally, the font registry is expected at fonts.identifiers, but
+in the meantime it has been migrated to fonts.hashes.identifiers.
+We’ll make luaotfload satisfy those assumptions. (Maybe it’d be more
+appropriate to use font.getfont() since Hans made it a harmless wrapper
+[1].)
+
+[1] http://www.ntg.nl/pipermail/ntg-context/2013/072166.html
+
+--doc]]--
+
+fonts.identifiers = fonts.hashes.identifiers
+
+--[[doc--
This sets two dimensions apparently relied upon by the unicode-math
package.
--doc]]--
diff --git a/luaotfload.dtx b/luaotfload.dtx
index fd71485..6daeece 100644
--- a/luaotfload.dtx
+++ b/luaotfload.dtx
@@ -1180,8 +1180,9 @@ local luaotfload = luaotfload
config = config or { }
config.luaotfload = config.luaotfload or { }
-config.luaotfload.resolver = config.luaotfload.resolver or "normal"
-config.luaotfload.definer = config.luaotfload.definer or "patch"
+config.luaotfload.resolver = config.luaotfload.resolver or "normal"
+config.luaotfload.definer = config.luaotfload.definer or "patch"
+config.luaotfload.loglevel = config.luaotfload.loglevel or 1
--luaotfload.prefer_merge = config.luaotfload.prefer_merge or true
luaotfload.module = {
@@ -1419,6 +1420,7 @@ tex.attribute[0] = 0
% \begin{macrocode}
loadmodule"merged.lua"
+---loadmodule"font-odv.lua" --- <= Devanagari support from Context
if fonts then
@@ -1518,20 +1520,9 @@ add_to_callback("find_vf_file",
loadmodule"lib-dir.lua" --- required by luaofload-database.lua
loadmodule"override.lua" --- “luat-ovr”
-logs.set_loglevel(config.luaotfload.loglevel or 2)
+logs.set_loglevel(config.luaotfload.loglevel)
% \end{macrocode}
-% \CONTEXT does not support ofm, these lines were added in order to make it
-% work. However they do not seem necessary so they are commented for now.
-%
-% \begin{macrocode}
--- if fonts and fonts.readers.tfm then
--- fonts.readers.ofm = fonts.readers.tfm
--- fonts.handlers.ofm = fonts.handlers.tfm --- empty anyways
--- fonts.formats.ofm = fonts.formats.tfm --- “type1”
--- --- fonts.readers.sequence[#fonts.readers.sequence+1] = "ofm"
---end
-% \end{macrocode}
% Now we load the modules written for \identifier{luaotfload}.
%
% \begin{macrocode}
@@ -1658,7 +1649,10 @@ local read_font_file = fonts.definers.read
--- spec -> size -> id -> tmfdata
local patch_defined_font = function (specification, size, id)
local tfmdata = read_font_file(specification, size, id)
- if type(tfmdata) == "table" then
+ if type(tfmdata) == "table" and tfmdata.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)
end
return tfmdata