From 7647a39d3d704888b105dfb000970b7bd60d7682 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Thu, 9 May 2013 21:58:45 +0200 Subject: tame fontspec compatibility hacks --- luaotfload-auxiliary.lua | 39 +++++++++++++++++++++++++++++---------- luaotfload.dtx | 9 +++++---- 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/luaotfload-auxiliary.lua b/luaotfload-auxiliary.lua index e93ea9d..c08f775 100644 --- a/luaotfload-auxiliary.lua +++ b/luaotfload-auxiliary.lua @@ -20,6 +20,7 @@ config.luaotfload = config.luaotfload or { } local aux = luaotfload.aux local log = luaotfload.log +local warning = luaotfload.log local identifiers = fonts.hashes.identifiers local fontid = font.id @@ -60,32 +61,50 @@ local add_fontdata_fallbacks = function (fontdata) --- 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 + fontdata.units = fontdata.units_per_em local resources = fontdata.resources --- the next line is a hack that fixes scaling of fonts with --- non-standard em-sizes (most ms fonts have 2048, others --- come with 256) - --- this is considered a bug in the font loader --fontdata.size = fontparameters.size * fontdata.units / 1000 --- 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 = { + pfminfo = { os2_capheight = metadata.pfminfo.os2_capheight }, + metadata = { ascent = metadata.ascent }, + } + --fontdata.shared.otfdata.metadata = metadata --- brr, that’s meta indeed + --- for microtype and fontspec + local fake_features = { } -- wrong: table.copy(resources.features) + setmetatable(fake_features, { __index = function (tab, idx) + warning("some package (probably fontspec) is outdated") + warning( + "attempt to index " .. + "tfmdata.shared.otfdata.luatex.features (%s)", + idx) + --os.exit(1) + return nil --- empty anyways + end}) fontdata.shared.otfdata.luatex = { unicodes = resources.unicodes, - features = resources.features, + features = fake_features, } end end return fontdata end -luatexbase.add_to_callback( - "luaotfload.patch_font", - add_fontdata_fallbacks, - "luaotfload.fontdata_fallbacks") +--if config.luaotfload.compatibility == true then +if true then + --- this will cause the output pdf to be garbled + --- in pdf.js + luatexbase.add_to_callback( + "luaotfload.patch_font", + add_fontdata_fallbacks, + "luaotfload.fontdata_fallbacks") +end --[[doc-- diff --git a/luaotfload.dtx b/luaotfload.dtx index 073ffa8..daaa48c 100644 --- a/luaotfload.dtx +++ b/luaotfload.dtx @@ -1224,11 +1224,12 @@ local luaotfload = luaotfload config = config or { } config.luaotfload = config.luaotfload or { } -------.luaotfload.resolver = config.luaotfload.resolver or "normal" -config.luaotfload.resolver = config.luaotfload.resolver or "cached" -config.luaotfload.definer = config.luaotfload.definer or "patch" +------.luaotfload.resolver = config.luaotfload.resolver or "normal" +config.luaotfload.resolver = config.luaotfload.resolver or "cached" +config.luaotfload.definer = config.luaotfload.definer or "patch" +config.luaotfload.compatibility = config.luaotfload.compatibility or false config.luaotfload.loglevel = config.luaotfload.loglevel or 1 -config.luaotfload.color_callback = config.luaotfload.color_callback or "pre_linebreak_filter" +config.luaotfload.color_callback = config.luaotfload.color_callback or "pre_linebreak_filter" --luaotfload.prefer_merge = config.luaotfload.prefer_merge or true luaotfload.module = { -- cgit v1.2.3